UNIX curses GwanHwang Dept CSIE National Taiwan Normal

  • Slides: 18
Download presentation
UNIX 螢幕導向程式的發 展利器 - curses Gwan-Hwang Dept. CSIE National Taiwan Normal University 2009. 11.

UNIX 螢幕導向程式的發 展利器 - curses Gwan-Hwang Dept. CSIE National Taiwan Normal University 2009. 11. 24

如何編譯(compile) l 編輯好程式, 在 UNIX 提示符號下鍵入: % /usr/5 bin/cc [file. c] -lcurses ^^^^^^^ 引進

如何編譯(compile) l 編輯好程式, 在 UNIX 提示符號下鍵入: % /usr/5 bin/cc [file. c] -lcurses ^^^^^^^ 引進 curses. h 這個 library 或 % /usr/5 bin/cc [file. c] -lcurses -ltermlib

將平常較常用的一些設定放在一 個叫 initial()的函式內 void initial() { initscr(); cbreak(); nonl(); noecho(); intrflush(stdscr, FALSE); keypad(stdscr, TRUE);

將平常較常用的一些設定放在一 個叫 initial()的函式內 void initial() { initscr(); cbreak(); nonl(); noecho(); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); refresh(); }

如何利用方向鍵 l curses 將一些如方向鍵等特殊控制字元, 以 KEY_ 為開頭定義在 curses. h l l l l KEY_UP

如何利用方向鍵 l curses 將一些如方向鍵等特殊控制字元, 以 KEY_ 為開頭定義在 curses. h l l l l KEY_UP 0403 ↑ KEY_DOWN 0402 ↓ KEY_LEFT 0404 ← KEY_RIGHT 0405 → KEY_HOME 0406 Home key KEY_BACKSPACE 0407 backspace KEY_F 0 0410 Function keys. KEY_F(n) (KEY_F 0+(n)) Formula for f. KEY_NPAGE 0522 Next page KEY_PPAGE 0523 Previous page [TAB] /t [ENTER] /r [ESC] 27 [BACKSPACE] 127

視窗的建立 l 視窗的建立, 以 newwin() 這個函式來完成. 同 時, 需宣告此視窗為 WINDOW結構變數. l WINDOW *newwin(lines, colums,

視窗的建立 l 視窗的建立, 以 newwin() 這個函式來完成. 同 時, 需宣告此視窗為 WINDOW結構變數. l WINDOW *newwin(lines, colums, start_y, start_x); WINDOW *win; win=newwin(10, 20, 0, 0);

介紹一些較重要的函式 l l l l wmove(win, y, x) touchwin(win) wrefresh(win) mvwaddstr(win, y, x, str)

介紹一些較重要的函式 l l l l wmove(win, y, x) touchwin(win) wrefresh(win) mvwaddstr(win, y, x, str) wattron(attr) delwin(win) subwin(win, ny, nx, y, x)

視窗的捲動 l l scrollok(win, TRUE); 開啟 scrollok(win, FALSE); 關閉

視窗的捲動 l l scrollok(win, TRUE); 開啟 scrollok(win, FALSE); 關閉