curses.h學習筆記

----------------------------------------------------------------------
curses定義的全局變量

    WINDOW *stdscr;        // 默認的標準窗口

    WINDOW *curscr;        // 當前窗口

    WINDOW *newscr;      // 新創建窗口

  int LINES;                      // 當前終端的行數

    int COLS;                       // 當前終端的列數

    int TABSIZE;                  // 製表符長度

----------------------------------------------------------------------    

curses宏定義:

    #define      TRUE    1

    #define      FALSE   0

    #define      ERR(-1)

    #define      OK(0)
    字符屬性
        #define      NCURSES_ATTR_SHIFT  8

        #define      NCURSES_BITS(mask,shift)((mask) <<((shift) + NCURSES_ATTR_SHIFT))

        #define      A_NORMAL  0L                                                            // 關閉所有特殊屬性,普通模式

        #define      A_ATTRIBUTES  NCURSES_BITS(~(1UL - 1UL),0)  // 打開全部特殊屬性

        #define      A_STANDOUT    NCURSES_BITS(1UL,8)                  // 高亮突出顯示

        #define      A_UNDERLINE   NCURSES_BITS(1UL,9)                  // 下劃線

        #define      A_REVERSE NCURSES_BITS(1UL,10)                        // 反色突出顯示

        #define      A_BLINK      NCURSES_BITS(1UL,11)                        // 閃爍

        #define      A_DIM   NCURSES_BITS(1UL,12)                               // 半亮突出顯示

        #define      A_BOLDNCURSES_BITS(1UL,13)                                // 加粗
    特殊符號
        ACS_ULCORNER    ┌  ACS_LLCORNER    └ ACS_URCORNER    ┐ ACS_LRCORNER    ┘
        ACS_LTEE        ├  ACS_RTEE        ┤  ACS_BTEE        ┴ ACS_TTEE        ┬
        ACS_HLINE       ─  ACS_VLINE       │  ACS_PLUS        ┼ ACS_S1          
        ACS_S9            ACS_DIAMOND ◆ ACS_CKBOARD ▒ ACS_DEGREE °
        ACS_PLMINUS ±      ACS_BULLET  ·     ACS_UARROW  ^   ACS_BOARD       #
        ACS_LANTERN ␋ ACS_BLOCK       #   ACS_S3            ACS_S7          
        ACS_LEQUAL  ≤ ACS_GEQUAL  ≥  ACS_PI          π      ACS_NEQUAL ≠
        ACS_STERLING    £   ACS_BSSB        ┌  ACS_SSBB        └  ACS_BBSS        ┐
        ACS_SBBS        ┘  ACS_SBSS        ┤  ACS_SSSB        ├ ACS_SSBS        ┴
        ACS_BSSS        ┬  ACS_BSBS        ─  ACS_SBSB        │  ACS_SSSS        ┼
    字符顏色
        #define COLOR_BLACK 0

        #define COLOR_RED       1

        #define COLOR_GREEN 2

        #define COLOR_YELLOW    3

        #define COLOR_BLUE      4

        #define COLOR_MAGENTA   5

        #define COLOR_CYAN      6

        #define COLOR_WHITE 7
    鼠標事件
        #define    BUTTON1_RELEASED         000000000001L       按鈕 1 鬆開
        #define    BUTTON1_PRESSED          000000000002L       按鈕 1 按下
        #define    BUTTON1_CLICKED          000000000004L       按鈕 1 單擊
        #define    BUTTON1_DOUBLE_CLICKED   000000000010L       按鈕 1 雙擊
        #define    BUTTON1_TRIPLE_CLICKED   000000000020L       按鈕 1 三擊
        #define    BUTTON1_RESERVED_EVENT   000000000040L       按鈕 1 保留
        #define    BUTTON2_RELEASED         000000000100L       按鈕 2 鬆開
        #define    BUTTON2_PRESSED          000000000200L       按鈕 2 按下
        #define    BUTTON2_CLICKED          000000000400L       按鈕 2 單擊
        #define    BUTTON2_DOUBLE_CLICKED   000000001000L       按鈕 2 雙擊 
        #define    BUTTON2_TRIPLE_CLICKED   000000002000L       按鈕 2 三擊
        #define    BUTTON2_RESERVED_EVENT   000000004000L       按鈕 2 保留
        #define    BUTTON3_RELEASED         000000010000L       按鈕 3 鬆開
        #define    BUTTON3_PRESSED          000000020000L       按鈕 3 按下
        #define    BUTTON3_CLICKED          000000040000L       按鈕 3 單擊
        #define    BUTTON3_DOUBLE_CLICKED   000000100000L       按鈕 3 雙擊
        #define    BUTTON3_TRIPLE_CLICKED   000000200000L       按鈕 3 三擊
        #define    BUTTON3_RESERVED_EVENT   000000400000L       按鈕 3 保留
        #define    BUTTON4_RELEASED         000001000000L       按鈕 4 鬆開
        #define    BUTTON4_PRESSED          000002000000L       按鈕 4 按下
        #define    BUTTON4_CLICKED          000004000000L       按鈕 4 單擊
        #define    BUTTON4_DOUBLE_CLICKED   000010000000L       按鈕 4 雙擊
        #define    BUTTON4_TRIPLE_CLICKED   000020000000L       按鈕 4 三擊
        #define    BUTTON4_RESERVED_EVENT   000040000000L       按鈕 4 保留
        #define    BUTTON_CTRL              000100000000L       同時 CTRL 鍵也被按下
        #define    BUTTON_SHIFT             000200000000L       同時 SHIFT 鍵也被按下
        #define    BUTTON_ALT               000400000000L       同時 ALT 鍵也被按下
        #define    ALL_MOUSE_EVENTS         000777777777L       接收所有的鼠標消息
        #define    REPORT_MOUSE_POSITION    001000000000L       報告鼠標位置
    鍵盤:
        #define KEY_CODE_YES    0400        /* A wchar_t contains a key code */
        #define KEY_MIN             0401        /* Minimum curses key */
        #define KEY_BREAK           0401        /* Break key(unreliable) */
        #define KEY_SRESET          0530        /* Soft(partial) reset(unreliable) */
        #define KEY_RESET       0531        /* Reset or hard reset(unreliable) */
        #define KEY_DOWN        0402        /* down-arrow key */
        #define KEY_UP          0403        /* up-arrow key */
        #define KEY_LEFT        0404        /* left-arrow key */
        #define KEY_RIGHT       0405        /* right-arrow key */
        #define KEY_HOME        0406        /* home key */
        #define KEY_BACKSPACE   0407        /* backspace key */
        #define KEY_F0          0410        /* Function keys.  Space for 64 */
        #define KEY_F(n)        (KEY_F0+(n))    /* Value of function key n */
        #define KEY_DL          0510        /* delete-line key */
        #define KEY_IL          0511        /* insert-line key */
        #define KEY_DC          0512        /* delete-character key */
        #define KEY_IC          0513        /* insert-character key */
        #define KEY_EIC         0514        /* sent by rmir or smir in insert mode */
        #define KEY_CLEAR       0515        /* clear-screen or erase key */
        #define KEY_EOS         0516        /* clear-to-end-of-screen key */
        #define KEY_EOL         0517        /* clear-to-end-of-line key */
        #define KEY_SF          0520        /* scroll-forward key */
        #define KEY_SR          0521        /* scroll-backward key */
        #define KEY_NPAGE       0522        /* next-page key */
        #define KEY_PPAGE       0523        /* previous-page key */
        #define KEY_STAB        0524        /* set-tab key */
        #define KEY_CTAB        0525        /* clear-tab key */
        #define KEY_CATAB       0526        /* clear-all-tabs key */
        #define KEY_ENTER       0527        /* enter/send key */
        #define KEY_PRINT       0532        /* print key */
        #define KEY_LL          0533        /* lower-left key(home down) */
        #define KEY_A1          0534        /* upper left of keypad */
        #define KEY_A3          0535        /* upper right of keypad */
        #define KEY_B2          0536        /* center of keypad */
        #define KEY_C1          0537        /* lower left of keypad */
        #define KEY_C3          0540        /* lower right of keypad */
        #define KEY_BTAB        0541        /* back-tab key */
        #define KEY_BEG         0542        /* begin key */
        #define KEY_CANCEL      0543        /* cancel key */
        #define KEY_CLOSE       0544        /* close key */
        #define KEY_COMMAND 0545        /* command key */
        #define KEY_COPY        0546        /* copy key */
        #define KEY_CREATE      0547        /* create key */
        #define KEY_END         0550        /* end key */
        #define KEY_EXIT            0551        /* exit key */
        #define KEY_FIND        0552        /* find key */
        #define KEY_HELP        0553        /* help key */
        #define KEY_MARK        0554        /* mark key */
        #define KEY_MESSAGE 0555        /* message key */
        #define KEY_MOVE        0556        /* move key */
        #define KEY_NEXT        0557        /* next key */
        #define KEY_OPEN        0560        /* open key */
        #define KEY_OPTIONS 0561        /* options key */
        #define KEY_PREVIOUS    0562        /* previous key */
        #define KEY_REDO        0563        /* redo key */
        #define KEY_REFERENCE   0564        /* reference key */
        #define KEY_REFRESH 0565        /* refresh key */
        #define KEY_REPLACE     0566        /* replace key */
        #define KEY_RESTART     0567        /* restart key */
        #define KEY_RESUME      0570        /* resume key */
        #define KEY_SAVE        0571        /* save key */
        #define KEY_SBEG        0572        /* shifted begin key */
        #define KEY_SCANCEL 0573        /* shifted cancel key */
        #define KEY_SCOMMAND    0574        /* shifted command key */
        #define KEY_SCOPY       0575        /* shifted copy key */
        #define KEY_SCREATE     0576        /* shifted create key */
        #define KEY_SDC         0577        /* shifted delete-character key */
        #define KEY_SDL         0600        /* shifted delete-line key */
        #define KEY_SELECT      0601        /* select key */
        #define KEY_SEND        0602        /* shifted end key */
        #define KEY_SEOL        0603        /* shifted clear-to-end-of-line key */
        #define KEY_SEXIT       0604        /* shifted exit key */
        #define KEY_SFIND       0605        /* shifted find key */
        #define KEY_SHELP       0606        /* shifted help key */
        #define KEY_SHOME       0607        /* shifted home key */
        #define KEY_SIC         0610        /* shifted insert-character key */
        #define KEY_SLEFT       0611        /* shifted left-arrow key */
        #define KEY_SMESSAGE    0612        /* shifted message key */
        #define KEY_SMOVE       0613        /* shifted move key */
        #define KEY_SNEXT       0614        /* shifted next key */
        #define KEY_SOPTIONS    0615        /* shifted options key */
        #define KEY_SPREVIOUS   0616        /* shifted previous key */
        #define KEY_SPRINT      0617        /* shifted print key */
        #define KEY_SREDO       0620        /* shifted redo key */
        #define KEY_SREPLACE    0621        /* shifted replace key */
        #define KEY_SRIGHT      0622        /* shifted right-arrow key */
        #define KEY_SRSUME      0623        /* shifted resume key */
        #define KEY_SSAVE       0624        /* shifted save key */
        #define KEY_SSUSPEND    0625        /* shifted suspend key */
        #define KEY_SUNDO       0626        /* shifted undo key */
        #define KEY_SUSPEND 0627        /* suspend key */
        #define KEY_UNDO        0630        /* undo key */
        #define KEY_MOUSE       0631        /* Mouse event has occurred */
        #define KEY_RESIZE      0632        /* Terminal resize event */
        #define KEY_EVENT       0633        /* We were interrupted by an event */
        #define KEY_MAX         0777        /* Maximum key value is 0633 */
----------------------------------------------------------------------
curses數據類型

     typedef unsigned long chtype;

     typedef unsigned char bool;

     typedef chtypeattr_t;     // int 類型
----------------------------------------------------------------------
初始化
    WINDOW  *   initscr     (void);                             /*開啓curses模式*/
    int             endwin      (void);                             /*離開curses模式*/
    bool            isendwin    (void); 
    SCREEN      *   newterm (char *type, FILE *outfd, FILE *infd);  /*建立新的屏幕*/
    SCREEN      *   set_term    (SCREEN *new);                      /*將new屏幕作爲當前工作的屏幕*/
    void            delscreen   (SCREEN* sp);                       /*釋放sp所佔有的資源*/
-----------------------------------------------------------------------
窗口管理函數:
    WINDOW  *   newwin      (int nlines, int ncols,
                                    int begin_y,int begin_x);           /*新建一個窗口,若所有參數爲0,則大小同窗口*/
    int             delwin      (WINDOW *win);                      /*刪除窗口win,若存在子窗口,則要先刪除子窗口*/
    int             mvwin       (WINDOW *win, int y, int x);            /* 把窗口移動到y,x的位置,若超出屏幕,則出錯*/
    WINDOW *   subwin      (WINDOW *orig, int nlines,          /*返回一個位於 origwin 窗口中間的子窗口。如果用戶改變這兩*/
                                    int ncols,int begin_y, int begin_x);    /*個窗口中的一個,則這種改變將會同時反映到這兩個窗口上*/
    WINDOW  *   derwin      (WINDOW *orig, int nlines,          /*函數與 subwin(.)相同,只不過這裏的 begin_x 和 begin_y 是*/
                                    int ncols,int begin_y, int begin_x);    /*相對於 origwin 的,而不是相對於屏幕的。*/
    int             mvderwin    (WINDOW *win, int par_y, int par_x);    /*(*)   此函數將把 win 移到父窗口內。*/
    WINDOW  *   dupwin      (WINDOW *win);                      /*函數複製窗口 win。*/
    void            wsyncup (WINDOW *win);
    int             syncok      (WINDOW *win, bool bf);
    void            wcursyncup  (WINDOW *win);
    void            wsyncdown   (WINDOW *win);
----------------------------------------------------------------------------------------
窗口拷貝
    int overlay     (const WINDOW *srcwin, WINDOW *dstwin);             /*將把 srcwin中的所有非空格文本拷貝到 dstwin中。*/
    int overwrite   (const WINDOW *srcwin, WINDOW *dstwin);             /*將把 srcwin中的所有文本拷貝到 dstwin 中。*/
    int copywin (const WINDOW *srcwin, WINDOW *dstwin, int sminrow,     /*拷貝時要選擇,拷貝的區域*/
                        int smincol, int dminrow, int dmincol, int dmaxrow,
                        int dmaxcol, int overlay);
--------------------------------------------------------------------------------------
單字符顯示函數
    int addch       (const chtype ch);                          /* 這些函數都用於在光標後顯示單個字符,   */
    int waddch      (WINDOW *win, const chtype ch);             /* 其中w代表windows,即需要指定窗口,   */
    int mvaddch (int y, int x, const chtype ch);                    /*mv則是先將光標定位到y,x,然後在顯     */
    int mvwaddch    (WINDOW *win, int y, int x, const chtype ch);   /*示字符,echochar則相當於先調用addch() */
    int echochar    (const chtype ch);                          /*,然後再調用refresh()。     */
    int wechochar   (WINDOW *win, const chtype ch);
--------------------------------------------------------------------------------------
字符串輸出函數
    int addstr      (const char *str);                      /* 這些函數用來在光標後顯示字符串,w,*/
    int addnstr     (const char *str, int n);               /* mv,前綴與上面的意思相同,參數中的n  */
    int waddstr     (WINDOW *win, const char *str);     /* 表示最多輸出的字符個數,當值爲-1時   */
    int waddnstr    (WINDOW *win, const char *str, int n);  /*則全部輸出。*/
    int mvaddstr    (int y, int x, const char *str);
    int mvaddnstr   (int y, int x, const char *str, int n);
    int mvwaddstr   (WINDOW *win, int y, int x, const char *str);
    int mvwaddnstr  (WINDOW *win, int y, int x, const char *str, int n);
--------------------------------------------------------------------------------------
緩存字符串輸出函數
    int addchstr        (const chtype *chstr);                      /* 這些函數在輸出時並不顯示在 */
    int addchnstr       (const chtype *chstr, int n);               /* 物理屏幕上,而是存儲在虛擬 */
    int waddchstr       (WINDOW *win, const chtype *chstr);     /*屏幕裏,物理窗口的光標位置  */  
    int waddchnstr      (WINDOW *win, const chtype *chstr, int n);  /* 不變,如輸出長度超過窗口的 */
    int mvaddchstr      (int y, int x, const chtype *chstr);            /* 寬度,則會被截斷。 */
    int mvaddchnstr (int y, int x, const chtype *chstr, int n);
    int mvwaddchstr (WINDOW *win, int y, int x, const chtype *chstr);
    int mvwaddchnstr    (WINDOW *win, int y, int x, const chtype *chstr, int n);
--------------------------------------------------------------------------------------
格式化輸出函數
    int printw      (const char *fmt, ...);                             /*類似於printf(),前綴的意義與上面相同*/
    int wprintw     (WINDOW *win, const char *fmt, ...);
    int mvprintw    (int y, int x, const char *fmt, ...);
    int mvwprintw   (WINDOW *win, int y, int x, const char  *fmt,...);
    int vwprintw    (WINDOW  *win,  const char *fmt, va_list varglist); /* 類似於vprintf().*/
    int vw_printw   (WINDOW *win, const char *fmt,  va_list  varglist);
--------------------------------------------------------------------------------------
插入式單字符顯示
    int insch       (chtype ch);                    /* 這些函數把字符 ch 插入到光標的左邊,    */
    int winsch      (WINDOW *win, chtype ch);   /*光標後面的所有字符則向右移動一個位置。*/
    int mvinsch (int y, int x, chtype ch);      /*在這一行最右端的字符可能會丟失。    */
    int mvwinsch    (WINDOW *win, int y, int x, chtype ch);   
----------------------------------------------------------------------------------------
清除部分或全部屏幕(詳見curs_clear(3))
    int erase       (void);         /*對當前窗口寫空字符*/
    int werase      (WINDOW *win);
    int clear       (void);
    int wclear      (WINDOW *win);
    int clrtobot        (void);         /*從當前光標位置開始清屏,一直到底部*/
    int wclrtobot   (WINDOW *win);
    int clrtoeol        (void);         /*從光標位置刪除當前行*/
    int wclrtoeol   (WINDOW *win);
---------------------------------------------------------------------------------------
鼠標函數
    int              getmouse       (MEVENT *event);                        /*讀取鼠標消息*/
    int              ungetmouse (MEVENT *event);                        /*鼠標消息重新放回消息隊列中*/
    mmask_t  mousemask  (mmask_t newmask, mmask_t *oldmask);    /*標誌鼠標事件*/
    bool          wenclose      (const WINDOW *win, int y, int x);          /*檢測給定的屏幕座標是否在指定窗口上面*/
    bool          mouse_trafo   (int* pY, int* pX, bool to_screen);                 
    bool          wmouse_trafo  (const WINDOW* win, int* pY, int* pX,bool to_screen);/*將一個給定的窗口相關的座標轉換爲屏幕座標*/
    int             mouseinterval   (int erval);                                /*設置一次鼠標單擊的最小時間間隔*/
---------------------------------------------------------------------------------------
字符串插入函數
    int insstr      (const char *str);                      /*這些函數將在當前光標的左邊插入 str(字符的個數不能*/
    int insnstr     (const char *str, int n);               /*超過一行的限度)。在光標右邊的字符將右移,如果到達*/
    int winsstr     (WINDOW *win, const char *str);     /*行尾,則字符將丟失,光標位置不變。y 和 x 是指在插入*/
    int winsnstr    (WINDOW *win, const char *str, int n);  /*str以前先要把光標移動到的座標,n 是要插入的字符的數目*/
    int mvinsstr    (int y, int x, const char *str);            /*(如果 n 爲 0 則插入整個字符串)。*/
    int mvinsnstr   (int y, int x, const char *str, int n);
    int mvwinsstr   (WINDOW *win, int y, int x, const char *str);
    int mvwinsnstr  (WINDOW *win, int y, int x, const char *str, int n);
-----------------------------------------------------------------------------------------
字符刪除函數
    int delch       (void);         /*刪除光標左邊的字符,並把光標右邊餘下的字符向左移動一個位置。*/
    int wdelch      (WINDOW *win);
    int mvdelch (int y, int x);
    int mvwdelch    (WINDOW *win, int y, int x);
------------------------------------------------------------------------------------------
行操作函數
    int deleteln        (void);         /*刪除光標下面一行,最後一行將會被清除*/
    int wdeleteln   (WINDOW *win);
    int insdelln        (int n);            /*正向插入一行,負向刪除一行*/
    int winsdelln   (WINDOW *win, int n);
    int insertln        (void);         /*插入一行*/
    int winsertln   (WINDOW *win);
------------------------------------------------------------------------------------
畫方框或直線 (詳見curs_border(3) )
    int border      (chtype ls, chtype rs, chtype ts, chtype bs,        /*這些函數在窗口的邊界(或者 win 的邊界)*/
                        chtype tl, chtype tr, chtype bl, chtype br);    /*畫上方框*/
    int wborder (WINDOW *win, chtype ls, chtype rs,         /*ls左邊rs右邊ts上邊bs下邊tl左上角tr右上角*/
                        chtype ts, chtype bs, chtype tl, chtype tr, /*bl左下角br右下角*/
                        chtype bl, chtype br);
    int box         (WINDOW *win, chtype verch, chtype horch);
    int hline       (chtype ch, int n);                             /*畫水平線*/
    int whline      (WINDOW *win, chtype ch, int n);
    int vline       (chtype ch, int n);                             /*畫垂直線*/
    int wvline      (WINDOW *win, chtype ch, int n);
                        mvhline(int y, int x, chtype ch, int n);
                        mvwhline(WINDOW *, int y, int x, chtype ch, int n);
    int mvvline     (int y, int x, chtype ch, int n);
    int mvwvline    (WINDOW *, int y, int x, chtype ch, int n);
----------------------------------------------------------------------------------------
背景屬性設置
    void    bkgdset     (chtype ch);                    /* 函數設置窗口或者屏幕的背景字符和屬性。 */
    void    wbkgdset    (WINDOW *win, chtype ch);   /* ch 的屬性將和窗口中所有非空格的字符的屬性進行 OR */
    int     bkgd        (chtype ch);                    /*  操作。背景是窗口的一部分,將不會隨着滾動、*/
    int     wbkgd       (WINDOW *win, chtype ch);   /*輸入或輸出而改變*/
    chtype  getbkgd     (WINDOW *win);
-----------------------------------------------------------------------------------------
單字符輸入函數(詳見curs_getch(3) )
    int getch       (void);                     /* getch()將從終端讀取輸入,讀取的方式取決於是否設置了延遲模式。*/
    int wgetch      (WINDOW *win);              /* 如果設置了延遲模式,則 getch()將一直等待,直到用戶按下一個鍵   */
    int mvgetch (int y, int x);                 /* 爲止;如果沒有設置延遲模式,則它將返回輸入緩衝區中的數據,如   */
    int mvwgetch    (WINDOW *win, int y, int x);    /* 果輸入緩衝區爲空,則它將返回 ERR。*/
    int ungetch     (int ch);                       /* 這個函數將把字符 ch 送回輸入緩衝區。*/
    int has_key     (int ch);
-------------------------------------------------------------------------------------------
字符串輸入函數
    int getstr      (char *str);
    int getnstr     (char *str, int n);
    int wgetstr     (WINDOW *win, char *str);
    int wgetnstr    (WINDOW *win, char *str, int n);
    int mvgetstr    (int y, int x, char *str);
    int mvwgetstr   (WINDOW *win, int y, int x, char *str);
    int mvgetnstr   (int y, int x, char *str, int n);
    int mvwgetnstr  (WINDOW *, int y, int x, char *str, int n);
--------------------------------------------------------------------------------------------
格式化輸入函數
    int scanw       (char *fmt, ...);
    int wscanw      (WINDOW *win, char *fmt, ...);
    int mvscanw (int y, int x, char *fmt, ...);
    int mvwscanw    (WINDOW *win, int y, int x, char *fmt, ...);
    int vw_scanw    (WINDOW *win, char *fmt, va_list varglist);
    int vwscanw (WINDOW *win, char *fmt, va_list varglist);
----------------------------------------------------------------------------------------------
輸出選項
    int     clearok     (WINDOW *win, bool bf); /*下一次調用 wrefresh()時是否將會清除屏幕,並完全地把它重新畫一遍*/         
    int     idlok       (WINDOW *win, bool bf); /*爲窗口使能或者關閉終端的 insert/delete 特徵,針對行*/
    void    idcok       (WINDOW *win, bool bf); /*爲窗口使能或者關閉終端的 insert/delete 特徵,針對字符*/
    void    immedok (WINDOW *win, bool bf); /*(默認否)是否對窗口 win 的每一次改變都將導致物理屏幕的一次刷新。*/
    int     leaveok     (WINDOW *win, bool bf); /*不使用光標的程序可以把 leaveok(.)設置爲 TRUE*/
    int     setscrreg   (int top, int bot);                            
    int     wsetscrreg  (WINDOW *win, int top, int bot); 
    int     scrollok        (WINDOW *win, bool bf);
    int     nl          (void);                 /*打開平移,這樣在回車時就會平移到新的一行,在輸出時就會走行*/
    int     nonl        (void);                 /*關上平移之後,ncurses 做光標移動操作時速度就會快一些*/
------------------------------------------------------------------------------------------------
滾動屏幕
    int scroll  (WINDOW *win);
    int scrl        (int n);
    int wscrl   (WINDOW *win, int n);
-----------------------------------------------------------------------------------------------
輸入選項
    int     cbreak      (void);                 /*CBREAK 模式打開,程序就可以立刻使用讀取的輸入信息*/
    int     nocbreak    (void);                 /* CBREAK 關閉,則輸入將被緩存起來,直到產生新的一行*/
    int     echo        (void);                 /*開啓輸入回顯*/
    int     noecho      (void);                 /*關閉輸入回顯*/
    int     halfdelay   (int tenths);               /*與 cbreak()相似,但它要延遲 t 秒鐘。*/
    int     intrflush       (WINDOW *win, bool bf); /*TRUE在終端上按下任意中斷鍵時,所有的輸出將會刷新到 tty 驅動程序隊列中。*/
    int     keypad      (WINDOW *win, bool bf); /*開啓鍵盤映射*/
    int     meta        (WINDOW *win, bool bf); /*bf 爲TRUE,從 getch()返回的鍵代碼將是完整的 8 位(最高位將不會被去掉)*/
    int     nodelay     (WINDOW *win, bool bf); /*設置終端爲非阻塞模式。若無輸入則getch()返回ERR,若爲FALSE
                                                    ,則等待直到用戶按鍵。*/
    int     raw         (void);                 /*把 RAW 模式打開,與 CBREAK 相同,它們的區別在於 RAW 模式不處理特殊字符。*/
    int     noraw       (void);                 /*把 RAW 模式關閉*/
    void    noqiflush   (void);
    void    qiflush     (void);
    int     notimeout   (WINDOW *win, bool bf); /*爲TRUE,則getch()將使用一個特殊的定時器(一秒鐘長)。到時間以。*/
                                                /*後再對以Esc等鍵打頭的輸入序列進行解釋*/
    void    timeout     (int delay);                /*如果 t 是正數,則讀操作將被阻塞 t 毫秒;如果 t 爲零,則不發生任何阻塞*/
    void    wtimeout    (WINDOW *win, int delay);   /*;如果 t 是負數,則程序將阻塞,直到有輸入爲止*/
    int     typeahead   (int fd);                   /*如果 fd 是-1,則不檢查超前鍵擊,否則 ncurses 將使用文件描述符 fd 來進行這些檢查*/
---------------------------------------------------------------------------
終端屬性 (curs_termattrs(3))
    int         baudrate    (void);     /*函數返回終端的顯示速度,以 bps 爲單位。*/
    char        erasechar   (void);     /*返回當前刪除的字符。*/
    int         erasewchar  (wchar_t *ch);
    bool        has_ic      (void);     /*如果終端具有插入/刪除字符的能力,則返回TRUE*/
    bool        has_il      (void);     /*如果終端具有插入/刪除行的能力,將返回TRUE*/
    char        killchar        (void);     /*返回當前殺死的字符。*/
    int         killwchar   (wchar_t *ch);
    char    *   longname    (void);     /*返回的指針允許用戶訪問當前終端的描述符。*/
    attr_t      term_attrs  (void);
    chtype      termattrs   (void);
    char    *   termname    (void);     /*返回環境變量$TERM的值,截取前14個字符*/
------------------------------------------------------------------------------
更新終端
    int     refresh         (void);                     /*把窗口映像拷貝到終端*/
    int     wrefresh        (WINDOW *win);              /*把窗口映像拷貝到 win,並使它看起來象原來的樣子*/
    int     wnoutrefresh    (WINDOW *win);              /*只拷貝到窗口 win,終端上將不進行任何輸出,但是虛擬屏幕實際上發生改變*/
    int     doupdate        (void);                     /*輸出到終端上。*/
    int     redrawwin       (WINDOW *win);                          /*1.如果在往屏幕上輸出新內容時需要清除一些行或者*/
    int     wredrawln       (WINDOW *win, int beg_line, int num_lines); /*2.整個屏幕,可以使用這兩個函數。*/
    int     touchwin        (WINDOW *win);                                              
    int     touchline       (WINDOW *win, int start, int count);
    int     untouchwin      (WINDOW *win);
    int     wtouchln        (WINDOW *win, int y, int n, int changed);
    bool    is_linetouched  (WINDOW *win, int line);                /*檢查自從上次調用 refresh()以來,第 line 行是否已被按掀過。*/
    bool    is_wintouched   (WINDOW *win);                      /*檢查自從上次調用 refresh()以來,窗口 win 是否已被按掀過。*/
-----------------------------------------------------------------------------------------------
字符屬性:顏色,下劃線,加粗等
    int     start_color             (void);                     /*初始化*/
    int     init_pair                   (short pair, short f, short b); /*初始化顏色對*/
    int     init_color              (short color, short r, short g, short b);
    bool    has_colors              (void);                     /*測試顯示器是否支持顯示色彩*/
    bool    can_change_color        (void);
    int     color_content           (short  color, short *r, short *g, short*b);
    int     pair_content                (short pair, short *f, short *b);
    int     use_default_colors      (void);
    int     assume_default_colors   (int fg, int bg);
----------------------------------------------------------------------------------------
得到光標位置
    void    getyx   (WINDOW *win, int y, int x);        /*返回當前光標位置*/
    void    getparyx    (WINDOW *win, int y, int x);    /*若果win是子窗口,將把該窗口對應父窗口的座標存儲在y和x則y和x都將爲-1。*/
    void    getbegyx    (WINDOW *win, int y, int x);    /*得到窗口的其實座標*/
    void    getmaxyx    (WINDOW *win, int y, int x);    /*得到窗口的最大座標*/
----------------------------------------------------------------------------------------
光標和屏幕座標
    int     move                (int y, int x);     /*移動光標*/
    int     wmove               (WINDOW *win, int y, int x);
    int     def_prog_mode       (void);
    int     def_shell_mode      (void);
    int     reset_prog_mode (void);
    int     reset_shell_mode    (void);
    int     resetty             (void);
    int     savetty             (void);
    void    getsyx              (int y, int x);     /*把虛擬屏幕光標存放在 y 和 x 中*/
    void    setsyx              (int y, int x);     /*設置虛擬座標,*/
    int     ripoffline          (int line, int(*init)(WINDOW *, int));
    int     curs_set                (int visibility);   /*光標置爲可見或者不可見,如果終端有這個功能*/
    int     napms               (int ms);
-----------------------------------------------------------------------------------------
小鍵盤
    WINDOW  *   newpad          (int nlines, int ncols);
    WINDOW  *   subpad          (WINDOW *orig, int nlines, int ncols,
                                        int begin_y, int begin_x);
    int             prefresh        (WINDOW *pad, int pminrow, int pmincol,
                                        int sminrow, int smincol, int smaxrow, int smaxcol);
    int             pnoutrefresh    (WINDOW *pad, int pminrow, int pmincol,
                                        int sminrow, int smincol, int smaxrow, int smaxcol);
    int             pechochar       (WINDOW *pad, chtype ch);
    int             pecho_wchar (WINDOW *pad, const cchar_t *wch);
--------------------------------------------------------------------------------------------
軟標籤
    int         slk_init            (int fmt);
    int         slk_set         (int labnum, const char *label, int fmt);
    int         slk_refresh     (void);
    int         slk_noutrefresh (void);
    char    *   slk_label       (int labnum);
    int         slk_clear       (void);
    int         slk_restore     (void);
    int         slk_touch       (void);
    int         slk_attron      (const chtype attrs);
    int         slk_attroff     (const chtype attrs);
    int         slk_attrset     (const chtype attrs);
    int         slk_attr_on     (attr_t attrs, void* opts);
    int         slk_attr_off        (const attr_t attrs, void * opts);
    int         slk_attr_set        (const attr_t attrs,
                                    short color_pair_number, void* opts);
    attr_t      slk_attr            (void);
    int         slk_color       (short color_pair_number);
-----------------------------------------------------------------------------------
實用工具:
    char        *   unctrl      (chtype c);
    char        *   wunctrl     (cchar_t *c);
    char        *   keyname (int c);
    char        *   key_name    (wchar_t w);
    void            filter      (void);
    void            nofilter        (void);
    void            use_env     (bool f);
    int             putwin      (WINDOW *win, FILE *filep);/*將窗口轉存到文件*/
    WINDOW  *   getwin      (FILE *filep);/*從文件讀取窗口*/
    int             delay_output    (int ms);
    int             flushinp        (void);
-----------------------------------------------------------------------------------
XXX
    int             beep        (void);
    int             flash       (void);
    char        *   unctrl      (chtype c);
    char        *   wunctrl     (cchar_t *c);
    char        *   keyname (int c);
    char        *   key_name    (wchar_t w);
    void            filter      (void);
    void            nofilter        (void);
    void            use_env     (bool f);
    int             putwin      (WINDOW *win, FILE *filep);
    WINDOW  *   getwin      (FILE *filep);
    int             delay_output    (int ms);
    int             flushinp        (void);
----------------------------------------------------------------------------------
低級訪問
    int     def_prog_mode       (void);
    int     def_shell_mode      (void);
    int     reset_prog_mode (void);
    int     reset_shell_mode    (void);
    int     resetty             (void);
    int     savetty             (void);
    void    getsyx              (int y, int x);
    void    setsyx              (int y, int x);
    int     ripoffline          (int line, int(*init)(WINDOW *, int));
    int     curs_set                (int visibility);
    int     napms               (int ms);
-----------------------------------------------------------------------------------------
屏幕轉儲
    int scr_dump    (const char *filename); /*保存屏幕*/
    int scr_restore (const char *filename); /*讀取屏幕*/
    int scr_init        (const char *filename);
    int scr_set     (const char *filename);
------------------------------------------------------------------------------------------
Termcap 模擬(#include <term.h>)
    int         tgetent (char *bp, const char *name);
    int         tgetflag    (char *id);
    int         tgetnum (char *id);
    char    *   tgetstr (char *id, char **area);
    char    *   tgoto   (const char *cap, int col, int row);
    int         tputs   (const char *str, int affcnt, int(*putc)(int));
-----------------------------------------------------------------------------------------
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章