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));