You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

curses.h 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. #ifndef CURSES_H
  2. #define CURSES_H
  3. #include <stdint.h>
  4. #include <stdarg.h>
  5. /** @file
  6. *
  7. * MuCurses header file
  8. *
  9. */
  10. #undef ERR
  11. #define ERR (-1)
  12. #undef FALSE
  13. #define FALSE (0)
  14. #undef OK
  15. #define OK (0)
  16. #undef TRUE
  17. #define TRUE (1)
  18. typedef short bool;
  19. typedef uint32_t chtype;
  20. typedef uint32_t attr_t;
  21. /** Curses SCREEN object */
  22. typedef struct _curses_screen {
  23. void ( *init ) ( struct _curses_screen *scr );
  24. void ( *exit ) ( struct _curses_screen *scr );
  25. /**
  26. * Move cursor to position specified by x,y coords
  27. *
  28. * @v scr screen on which to operate
  29. * @v y Y position
  30. * @v x X position
  31. */
  32. void ( * movetoyx ) ( struct _curses_screen *scr,
  33. unsigned int y, unsigned int x );
  34. /**
  35. * Write character to current cursor position
  36. *
  37. * @v scr screen on which to operate
  38. * @v c character to be written
  39. */
  40. void ( * putc ) ( struct _curses_screen *scr, chtype c );
  41. /**
  42. * Pop a character from the keyboard input stream
  43. *
  44. * @v scr screen on which to operate
  45. * @ret c popped character
  46. */
  47. int ( * getc ) ( struct _curses_screen *scr );
  48. /**
  49. * Checks to see whether a character is waiting in the input stream
  50. *
  51. * @v scr screen on which to operate
  52. * @ret TRUE character waiting in stream
  53. * @ret FALSE no character waiting in stream
  54. */
  55. bool ( *peek ) ( struct _curses_screen *scr );
  56. } SCREEN;
  57. /** Curses Window struct */
  58. typedef struct _curses_window {
  59. /** screen with which window associates */
  60. SCREEN *scr;
  61. /** window attributes */
  62. attr_t attrs;
  63. /** window origin coordinates */
  64. unsigned int ori_x, ori_y;
  65. /** window cursor position */
  66. unsigned int curs_x, curs_y;
  67. /** window dimensions */
  68. unsigned int width, height;
  69. /** parent window */
  70. struct _curses_window *parent;
  71. /** windows that share the same parent as this one */
  72. //struct list_head siblings;
  73. /** windows der'd or sub'd from this one */
  74. //struct list_head children;
  75. } WINDOW;
  76. extern WINDOW _stdscr;
  77. extern SCREEN _curscr;
  78. extern unsigned short _COLS;
  79. extern unsigned short _LINES;
  80. extern unsigned int _COLOURS;
  81. extern unsigned int _COLOUR_PAIRS;
  82. #define stdscr ( &_stdscr )
  83. #define curscr ( &_curscr )
  84. #define COLS _COLS
  85. #define LINES _LINES
  86. #define COLORS _COLOURS
  87. #define COLOR_PAIRS _COLOUR_PAIRS
  88. #define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
  89. #define CPAIR_SHIFT 8
  90. #define ATTRS_SHIFT 16
  91. #define A_DEFAULT ( 1UL - 1UL )
  92. #define A_ALTCHARSET MUCURSES_BITS( 1UL, ATTRS_SHIFT + 0 )
  93. #define A_BLINK MUCURSES_BITS( 1UL, ATTRS_SHIFT + 1 )
  94. #define A_BOLD MUCURSES_BITS( 1UL, ATTRS_SHIFT + 2 )
  95. #define A_DIM MUCURSES_BITS( 1UL, ATTRS_SHIFT + 3 )
  96. #define A_INVIS MUCURSES_BITS( 1UL, ATTRS_SHIFT + 4 )
  97. #define A_PROTECT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 5 )
  98. #define A_REVERSE MUCURSES_BITS( 1UL, ATTRS_SHIFT + 6 )
  99. #define A_STANDOUT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 7 )
  100. #define A_UNDERLINE MUCURSES_BITS( 1UL, ATTRS_SHIFT + 8 )
  101. #define WA_ALTCHARSET A_ALTCHARSET
  102. #define WA_BLINK A_BLINK
  103. #define WA_BOLD A_BOLD
  104. #define WA_DIM A_DIM
  105. #define WA_INVIS A_INVIS
  106. #define WA_PROTECT A_PROTECT
  107. #define WA_REVERSE A_REVERSE
  108. #define WA_STANDOUT A_STANDOUT
  109. #define WA_UNDERLINE A_UNDERLINE
  110. #define WA_HORIZONTAL MUCURSES_BITS( 1UL, ATTRS_SHIFT + 9 )
  111. #define WA_VERTICAL MUCURSES_BITS( 1UL, ATTRS_SHIFT + 10 )
  112. #define WA_LEFT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 11 )
  113. #define WA_RIGHT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 12 )
  114. #define WA_LOW MUCURSES_BITS( 1UL, ATTRS_SHIFT + 13 )
  115. #define WA_TOP MUCURSES_BITS( 1UL, ATTRS_SHIFT + 14 )
  116. #define A_ATTRIBUTES ( MUCURSES_BITS( 1UL, ATTRS_SHIFT ) - 1UL )
  117. #define A_CHARTEXT ( MUCURSES_BITS( 1UL, 0 ) - 1UL )
  118. #define A_COLOUR MUCURSES_BITS( ( 1UL << 8 ) - 1UL, CPAIR_SHIFT )
  119. #define A_COLOR A_COLOUR
  120. #define ACS_ULCORNER '+'
  121. #define ACS_LLCORNER '+'
  122. #define ACS_URCORNER '+'
  123. #define ACS_LRCORNER '+'
  124. #define ACS_RTEE '+'
  125. #define ACS_LTEE '+'
  126. #define ACS_BTEE '+'
  127. #define ACS_TTEE '+'
  128. #define ACS_HLINE '-'
  129. #define ACS_VLINE '|'
  130. #define ACS_PLUS '+'
  131. #define ACS_S1 '-'
  132. #define ACS_S9 '_'
  133. #define ACS_DIAMOND '+'
  134. #define ACS_CKBOARD ':'
  135. #define ACS_DEGREE '\''
  136. #define ACS_PLMINUS '#'
  137. #define ACS_BULLET 'o'
  138. #define ACS_LARROW '<'
  139. #define ACS_RARROW '>'
  140. #define ACS_DARROW 'v'
  141. #define ACS_UARROW '^'
  142. #define ACS_BOARD '#'
  143. #define ACS_LANTERN '#'
  144. #define ACS_BLOCK '#'
  145. #define COLOUR_BLACK 0
  146. #define COLOUR_RED 1
  147. #define COLOUR_GREEN 2
  148. #define COLOUR_YELLOW 3
  149. #define COLOUR_BLUE 4
  150. #define COLOUR_MAGENTA 5
  151. #define COLOUR_CYAN 6
  152. #define COLOUR_WHITE 7
  153. #define COLOUR_FG 30
  154. #define COLOUR_BG 40
  155. #define COLOR_FG COLOUR_FG
  156. #define COLOR_BG COLOUR_BG
  157. #define COLOR_BLACK COLOUR_BLACK
  158. #define COLOR_BLUE COLOUR_BLUE
  159. #define COLOR_GREEN COLOUR_GREEN
  160. #define COLOR_CYAN COLOUR_CYAN
  161. #define COLOR_RED COLOUR_RED
  162. #define COLOR_MAGENTA COLOUR_MAGENTA
  163. #define COLOR_YELLOW COLOUR_YELLOW
  164. #define COLOR_WHITE COLOUR_WHITE
  165. /*
  166. * KEY code constants
  167. */
  168. #define KEY_BREAK 0401 /**< Break key */
  169. #define KEY_DOWN 0402 /**< down-arrow key */
  170. #define KEY_UP 0403 /**< up-arrow key */
  171. #define KEY_LEFT 0404 /**< left-arrow key */
  172. #define KEY_RIGHT 0405 /**< right-arrow key */
  173. #define KEY_HOME 0406 /**< home key */
  174. #define KEY_BACKSPACE 0407 /**< backspace key */
  175. #define KEY_F0 0410 /**< Function keys. Space for 64 */
  176. #define KEY_F(n) (KEY_F0+(n)) /**< Value of function key n */
  177. #define KEY_DL 0510 /**< delete-line key */
  178. #define KEY_IL 0511 /**< insert-line key */
  179. #define KEY_DC 0512 /**< delete-character key */
  180. #define KEY_IC 0513 /**< insert-character key */
  181. #define KEY_EIC 0514 /**< sent by rmir or smir in insert mode */
  182. #define KEY_CLEAR 0515 /**< clear-screen or erase key */
  183. #define KEY_EOS 0516 /**< clear-to-end-of-screen key */
  184. #define KEY_EOL 0517 /**< clear-to-end-of-line key */
  185. #define KEY_SF 0520 /**< scroll-forward key */
  186. #define KEY_SR 0521 /**< scroll-backward key */
  187. #define KEY_NPAGE 0522 /**< next-page key */
  188. #define KEY_PPAGE 0523 /**< previous-page key */
  189. #define KEY_STAB 0524 /**< set-tab key */
  190. #define KEY_CTAB 0525 /**< clear-tab key */
  191. #define KEY_CATAB 0526 /**< clear-all-tabs key */
  192. #define KEY_ENTER 0527 /**< enter/send key */
  193. #define KEY_PRINT 0532 /**< print key */
  194. #define KEY_LL 0533 /**< lower-left key (home down) */
  195. #define KEY_A1 0534 /**< upper left of keypad */
  196. #define KEY_A3 0535 /**< upper right of keypad */
  197. #define KEY_B2 0536 /**< center of keypad */
  198. #define KEY_C1 0537 /**< lower left of keypad */
  199. #define KEY_C3 0540 /**< lower right of keypad */
  200. #define KEY_BTAB 0541 /**< back-tab key */
  201. #define KEY_BEG 0542 /**< begin key */
  202. #define KEY_CANCEL 0543 /**< cancel key */
  203. #define KEY_CLOSE 0544 /**< close key */
  204. #define KEY_COMMAND 0545 /**< command key */
  205. #define KEY_COPY 0546 /**< copy key */
  206. #define KEY_CREATE 0547 /**< create key */
  207. #define KEY_END 0550 /**< end key */
  208. #define KEY_EXIT 0551 /**< exit key */
  209. #define KEY_FIND 0552 /**< find key */
  210. #define KEY_HELP 0553 /**< help key */
  211. #define KEY_MARK 0554 /**< mark key */
  212. #define KEY_MESSAGE 0555 /**< message key */
  213. #define KEY_MOVE 0556 /**< move key */
  214. #define KEY_NEXT 0557 /**< next key */
  215. #define KEY_OPEN 0560 /**< open key */
  216. #define KEY_OPTIONS 0561 /**< options key */
  217. #define KEY_PREVIOUS 0562 /**< previous key */
  218. #define KEY_REDO 0563 /**< redo key */
  219. #define KEY_REFERENCE 0564 /**< reference key */
  220. #define KEY_REFRESH 0565 /**< refresh key */
  221. #define KEY_REPLACE 0566 /**< replace key */
  222. #define KEY_RESTART 0567 /**< restart key */
  223. #define KEY_RESUME 0570 /**< resume key */
  224. #define KEY_SAVE 0571 /**< save key */
  225. #define KEY_SBEG 0572 /**< shifted begin key */
  226. #define KEY_SCANCEL 0573 /**< shifted cancel key */
  227. #define KEY_SCOMMAND 0574 /**< shifted command key */
  228. #define KEY_SCOPY 0575 /**< shifted copy key */
  229. #define KEY_SCREATE 0576 /**< shifted create key */
  230. #define KEY_SDC 0577 /**< shifted delete-character key */
  231. #define KEY_SDL 0600 /**< shifted delete-line key */
  232. #define KEY_SELECT 0601 /**< select key */
  233. #define KEY_SEND 0602 /**< shifted end key */
  234. #define KEY_SEOL 0603 /**< shifted clear-to-end-of-line key */
  235. #define KEY_SEXIT 0604 /**< shifted exit key */
  236. #define KEY_SFIND 0605 /**< shifted find key */
  237. #define KEY_SHELP 0606 /**< shifted help key */
  238. #define KEY_SHOME 0607 /**< shifted home key */
  239. #define KEY_SIC 0610 /**< shifted insert-character key */
  240. #define KEY_SLEFT 0611 /**< shifted left-arrow key */
  241. #define KEY_SMESSAGE 0612 /**< shifted message key */
  242. #define KEY_SMOVE 0613 /**< shifted move key */
  243. #define KEY_SNEXT 0614 /**< shifted next key */
  244. #define KEY_SOPTIONS 0615 /**< shifted options key */
  245. #define KEY_SPREVIOUS 0616 /**< shifted previous key */
  246. #define KEY_SPRINT 0617 /**< shifted print key */
  247. #define KEY_SREDO 0620 /**< shifted redo key */
  248. #define KEY_SREPLACE 0621 /**< shifted replace key */
  249. #define KEY_SRIGHT 0622 /**< shifted right-arrow key */
  250. #define KEY_SRSUME 0623 /**< shifted resume key */
  251. #define KEY_SSAVE 0624 /**< shifted save key */
  252. #define KEY_SSUSPEND 0625 /**< shifted suspend key */
  253. #define KEY_SUNDO 0626 /**< shifted undo key */
  254. #define KEY_SUSPEND 0627 /**< suspend key */
  255. #define KEY_UNDO 0630 /**< undo key */
  256. #define KEY_RESIZE 0632 /**< Terminal resize event */
  257. #define KEY_EVENT 0633 /**< We were interrupted by an event */
  258. #define KEY_MAX 0777 /* Maximum key value is 0633 */
  259. //extern int addch ( const chtype * );
  260. //extern int addchnstr ( const chtype *, int );
  261. //extern int addchstr ( const chtype * );
  262. //extern int addnstr ( const char *, int );
  263. //extern int addstr ( const char * );
  264. //extern int attroff ( int );
  265. //extern int attron ( int );
  266. //extern int attrset ( int );
  267. extern int attr_get ( attr_t *, short *, void * );
  268. extern int attr_off ( attr_t, void * );
  269. extern int attr_on ( attr_t, void * );
  270. extern int attr_set ( attr_t, short, void * );
  271. extern int baudrate ( void );
  272. extern int beep ( void );
  273. //extern void bkgdset ( chtype );
  274. /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
  275. chtype );*/
  276. extern int box ( WINDOW *, chtype, chtype );
  277. extern bool can_change_colour ( void );
  278. #define can_change_color() can_change_colour()
  279. extern int cbreak ( void );
  280. //extern int clrtobot ( void );
  281. //extern int clrtoeol ( void );
  282. extern int colour_content ( short, short *, short *, short * );
  283. #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
  284. //extern int colour_set ( short, void * );
  285. //#define color_set( cpno, opts ) colour_set( (cpno), (opts) )
  286. extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
  287. int, int, int, int );
  288. extern int curs_set ( int );
  289. extern int def_prog_mode ( void );
  290. extern int def_shell_mode ( void );
  291. extern int delay_output ( int );
  292. //extern int delch ( void );
  293. //extern int deleteln ( void );
  294. extern void delscreen ( SCREEN * );
  295. extern int delwin ( WINDOW * );
  296. extern WINDOW *derwin ( WINDOW *, int, int, int, int );
  297. //extern int doupdate ( void );
  298. extern WINDOW *dupwin ( WINDOW * );
  299. extern int echo ( void );
  300. extern int echochar ( const chtype );
  301. extern int endwin ( void );
  302. extern char erasechar ( void );
  303. //extern int erase ( void );
  304. extern void filter ( void );
  305. extern int flash ( void );
  306. extern int flushinp ( void );
  307. extern chtype getbkgd ( WINDOW * );
  308. //extern int getch ( void );
  309. //extern int getnstr ( char *, int );
  310. //extern int getstr ( char * );
  311. extern int halfdelay ( int );
  312. extern bool has_colors ( void );
  313. extern bool has_ic ( void );
  314. extern bool has_il ( void );
  315. //extern int hline ( chtype, int );
  316. extern void idcok ( WINDOW *, bool );
  317. extern int idlok ( WINDOW *, bool );
  318. //extern void immedok ( WINDOW *, bool );
  319. //extern chtype inch ( void );
  320. //extern int inchnstr ( chtype *, int );
  321. //extern int inchstr ( chtype * );
  322. extern WINDOW *initscr ( void );
  323. extern int init_colour ( short, short, short, short );
  324. #define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
  325. extern int init_pair ( short, short, short );
  326. //extern int innstr ( char *, int );
  327. //extern int insch ( chtype );
  328. //extern int insnstr ( const char *, int );
  329. //extern int insstr ( const char * );
  330. //extern int instr ( char * );
  331. extern int intrflush ( WINDOW *, bool );
  332. extern bool isendwin ( void );
  333. //extern bool is_linetouched ( WINDOW *, int );
  334. //extern bool is_wintouched ( WINDOW * );
  335. extern char *keyname ( int );
  336. extern int keypad ( WINDOW *, bool );
  337. extern char killchar ( void );
  338. extern int leaveok ( WINDOW *, bool );
  339. extern char *longname ( void );
  340. extern int meta ( WINDOW *, bool );
  341. //extern int move ( int, int );
  342. //extern int mvaddch ( int, int, const chtype );
  343. //extern int mvaddchnstr ( int, int, const chtype *, int );
  344. //extern int mvaddchstr ( int, int, const chtype * );
  345. //extern int mvaddnstr ( int, int, const char *, int );
  346. //extern int mvaddstr ( int, int, const char * );
  347. extern int mvcur ( int, int, int, int );
  348. //extern int mvdelch ( int, int );
  349. extern int mvderwin ( WINDOW *, int, int );
  350. //extern int mvgetch ( int, int );
  351. //extern int mvgetnstr ( int, int, char *, int );
  352. //extern int mvgetstr ( int, int, char * );
  353. //extern int mvhline ( int, int, chtype, int );
  354. //extern chtype mvinch ( int, int );
  355. //extern int mvinchnstr ( int, int, chtype *, int );
  356. //extern int mvinchstr ( int, int, chtype * );
  357. //extern int mvinnstr ( int, int, char *, int );
  358. //extern int mvinsch ( int, int, chtype );
  359. //extern int mvinsnstr ( int, int, const char *, int );
  360. //extern int mvinsstr ( int, int, const char * );
  361. //extern int mvinstr ( int, int, char * );
  362. //extern int mvprintw ( int, int, char *, ... );
  363. //extern int mvscanw ( int, int, char *, ... );
  364. //extern int mvvline ( int, int, chtype, int );
  365. //extern int mvwaddch ( WINDOW *, int, int, const chtype );
  366. //extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );
  367. //extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );
  368. //extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );
  369. //extern int mvwaddstr ( WINDOW *, int, int, const char * );
  370. //extern int mvwdelch ( WINDOW *, int, int );
  371. //extern int mvwgetch ( WINDOW *, int, int );
  372. //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
  373. //extern int mvwgetstr ( WINDOW *, int, int, char * );
  374. //extern int mvwhline ( WINDOW *, int, int, chtype, int );
  375. extern int mvwin ( WINDOW *, int, int );
  376. //extern chtype mvwinch ( WINDOW *, int, int );
  377. //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
  378. //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
  379. //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
  380. //extern int mvwinsch ( WINDOW *, int, int, chtype );
  381. //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
  382. //extern int mvwinsstr ( WINDOW *, int, int, const char * );
  383. //extern int mvwinstr ( WINDOW *, int, int, char * );
  384. //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
  385. //extern int mvwscanw ( WINDOW *, int, int, char *, ... );
  386. //extern int mvwvline ( WINDOW *, int, int, chtype, int );
  387. extern int napms ( int );
  388. //extern WINDOW *newpad ( int, int );
  389. extern WINDOW *newwin ( int, int, int, int );
  390. extern int nl ( void );
  391. extern int nocbreak ( void );
  392. extern int nodelay ( WINDOW *, bool );
  393. extern int noecho ( void );
  394. extern int nonl ( void );
  395. extern void noqiflush ( void );
  396. extern int noraw ( void );
  397. extern int notimeout ( WINDOW *, bool );
  398. extern int overlay ( const WINDOW *, WINDOW * );
  399. extern int overwrite ( const WINDOW *, WINDOW * );
  400. extern int pair_content ( short, short *, short * );
  401. extern int PAIR_NUMBER ( int );
  402. //extern int pechochar ( WINDOW *, chtype );
  403. //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
  404. //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
  405. extern int printw ( char *, ... );
  406. extern int putp ( const char * );
  407. extern void qiflush ( void );
  408. extern int raw ( void );
  409. //extern int redrawwin ( WINDOW * );
  410. //extern int refresh ( void );
  411. extern int reset_prog_mode ( void );
  412. extern int reset_shell_mode ( void );
  413. extern int resetty ( void );
  414. extern int ripoffline ( int, int (*) ( WINDOW *, int) );
  415. extern int savetty ( void );
  416. //extern int scanw ( char *, ... );
  417. //extern int scrl ( int );
  418. //extern int scroll ( WINDOW * );
  419. //extern int scrollok ( WINDOW *, bool );
  420. //extern int setscrreg ( int, int );
  421. extern SCREEN *set_term ( SCREEN * );
  422. extern int setupterm ( char *, int, int * );
  423. extern int slk_attr_off ( const attr_t, void * );
  424. extern int slk_attroff ( const chtype );
  425. extern int slk_attr_on ( const attr_t, void * );
  426. extern int slk_attron ( const chtype );
  427. extern int slk_attr_set ( const attr_t, short, void * );
  428. extern int slk_attrset ( const chtype );
  429. extern int slk_clear ( void );
  430. extern int slk_colour ( short );
  431. #define slk_color( c ) slk_colour( (c) )
  432. extern int slk_init ( int );
  433. extern char *slk_label ( int );
  434. extern int slk_noutrefresh ( void );
  435. //extern int slk_refresh ( void );
  436. extern int slk_restore ( void );
  437. extern int slk_set ( int, const char *, int );
  438. extern int slk_touch ( void );
  439. extern int standend ( void );
  440. extern int standout ( void );
  441. extern int start_colour ( void );
  442. #define start_color() start_colour()
  443. //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
  444. extern WINDOW *subwin ( WINDOW *, int, int, int, int );
  445. extern int syncok ( WINDOW *, bool );
  446. extern chtype termattrs ( void );
  447. extern attr_t term_attrs ( void );
  448. extern char *termname ( void );
  449. extern int tigetflag ( char * );
  450. extern int tigetnum ( char * );
  451. extern char *tigetstr ( char * );
  452. extern void timeout ( int );
  453. //extern int touchline ( WINDOW *, int, int );
  454. //extern int touchwin ( WINDOW * );
  455. extern char *tparm ( char *, long, long, long, long, long, long, long, long,
  456. long );
  457. extern int typeahead ( int );
  458. //extern int ungetch ( int );
  459. //extern int untouchwin ( WINDOW * );
  460. extern void use_env ( bool );
  461. extern int vid_attr ( attr_t, short, void * );
  462. extern int vidattr ( chtype );
  463. extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
  464. extern int vidputs ( chtype, int ( *) ( int) );
  465. //extern int vline ( chtype, int );
  466. //extern int vwprintw ( WINDOW *, const char *, va_list );
  467. extern int vw_printw ( WINDOW *, const char *, va_list );
  468. //extern int vwscanw ( WINDOW *, char *, va_list );
  469. //extern int vw_scanw ( WINDOW *, char *, va_list );
  470. extern int waddch ( WINDOW *, const chtype );
  471. extern int waddchnstr ( WINDOW *, const chtype *, int );
  472. //extern int waddchstr ( WINDOW *, const chtype * );
  473. extern int waddnstr ( WINDOW *, const char *, int );
  474. //extern int waddstr ( WINDOW *, const char * );
  475. extern int wattroff ( WINDOW *, int );
  476. extern int wattron ( WINDOW *, int );
  477. extern int wattrset ( WINDOW *, int );
  478. extern int wattr_get ( WINDOW *, attr_t *, short *, void * );
  479. extern int wattr_off ( WINDOW *, attr_t, void * );
  480. extern int wattr_on ( WINDOW *, attr_t, void * );
  481. extern int wattr_set ( WINDOW *, attr_t, short, void * );
  482. //extern void wbkgdset ( WINDOW *, chtype );
  483. extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
  484. chtype, chtype );
  485. extern int wclrtobot ( WINDOW * );
  486. extern int wclrtoeol ( WINDOW * );
  487. extern void wcursyncup ( WINDOW * );
  488. //extern int wcolor_set ( WINDOW *, short, void * );
  489. #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
  490. extern int wdelch ( WINDOW * );
  491. extern int wdeleteln ( WINDOW * );
  492. extern int wechochar ( WINDOW *, const chtype );
  493. extern int werase ( WINDOW * );
  494. extern int wgetch ( WINDOW * );
  495. extern int wgetnstr ( WINDOW *, char *, int );
  496. //extern int wgetstr ( WINDOW *, char * );
  497. extern int whline ( WINDOW *, chtype, int );
  498. //extern chtype winch ( WINDOW * );
  499. //extern int winchnstr ( WINDOW *, chtype *, int );
  500. //extern int winchstr ( WINDOW *, chtype * );
  501. //extern int winnstr ( WINDOW *, char *, int );
  502. //extern int winsch ( WINDOW *, chtype );
  503. //extern int winsnstr ( WINDOW *, const char *, int );
  504. //extern int winsstr ( WINDOW *, const char * );
  505. //extern int winstr ( WINDOW *, char * );
  506. extern int wmove ( WINDOW *, int, int );
  507. //extern int wnoutrefresh ( WINDOW * );
  508. extern int wprintw ( WINDOW *, const char *, ... );
  509. //extern int wredrawln ( WINDOW *, int, int );
  510. //extern int wrefresh ( WINDOW * );
  511. //extern int wscanw ( WINDOW *, char *, ... );
  512. //extern int wscrl ( WINDOW *, int );
  513. //extern int wsetscrreg ( WINDOW *, int, int );
  514. //extern int wstandend ( WINDOW * );
  515. //extern int wstandout ( WINDOW * );
  516. extern void wsyncup ( WINDOW * );
  517. extern void wsyncdown ( WINDOW * );
  518. extern void wtimeout ( WINDOW *, int );
  519. //extern int wtouchln ( WINDOW *, int, int, int );
  520. extern int wvline ( WINDOW *, chtype, int );
  521. /*
  522. * There is frankly a ridiculous amount of redundancy within the
  523. * curses API - ncurses decided to get around this by using #define
  524. * macros, but I've decided to be type-safe and implement them all as
  525. * static inlines instead...
  526. */
  527. static inline int addch ( const chtype ch ) {
  528. return waddch( stdscr, ch );
  529. }
  530. static inline int addchnstr ( const chtype *chstr, int n ) {
  531. return waddchnstr ( stdscr, chstr, n );
  532. }
  533. static inline int addchstr ( const chtype *chstr ) {
  534. return waddchnstr ( stdscr, chstr, -1 );
  535. }
  536. static inline int addnstr ( const char *str, int n ) {
  537. return waddnstr ( stdscr, str, n );
  538. }
  539. static inline int addstr ( const char *str ) {
  540. return waddnstr ( stdscr, str, -1 );
  541. }
  542. static inline int attroff ( int attrs ) {
  543. return wattroff ( stdscr, attrs );
  544. }
  545. static inline int attron ( int attrs ) {
  546. return wattron ( stdscr, attrs );
  547. }
  548. static inline int attrset ( int attrs ) {
  549. return wattrset ( stdscr, attrs );
  550. }
  551. static inline void bkgdset ( chtype ch ) {
  552. wattrset ( stdscr, ch );
  553. }
  554. static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
  555. chtype tl, chtype tr, chtype bl, chtype br ) {
  556. return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
  557. }
  558. static inline int clrtobot ( void ) {
  559. return wclrtobot( stdscr );
  560. }
  561. static inline int clrtoeol ( void ) {
  562. return wclrtoeol( stdscr );
  563. }
  564. static inline int delch ( void ) {
  565. return wdelch ( stdscr );
  566. }
  567. static inline int deleteln ( void ) {
  568. return wdeleteln( stdscr );
  569. }
  570. static inline int erase ( void ) {
  571. return werase ( stdscr );
  572. }
  573. static inline int getch ( void ) {
  574. return wgetch ( stdscr );
  575. }
  576. static inline int getnstr ( char *str, int n ) {
  577. return wgetnstr ( stdscr, str, n );
  578. }
  579. static inline int getstr ( char *str ) {
  580. return wgetnstr ( stdscr, str, -1 );
  581. }
  582. static inline int hline ( chtype ch, int n ) {
  583. return whline ( stdscr, ch, n );
  584. }
  585. static inline int move ( int y, int x ) {
  586. return wmove ( stdscr, y, x );
  587. }
  588. static inline int mvaddch ( int y, int x, const chtype ch ) {
  589. return ( wmove ( stdscr, y, x ) == OK
  590. ? waddch( stdscr, ch ) : ERR );
  591. }
  592. static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
  593. return ( wmove ( stdscr, y, x ) == OK
  594. ? waddchnstr ( stdscr, chstr, n ) : ERR );
  595. }
  596. static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
  597. return ( wmove ( stdscr, y, x ) == OK
  598. ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
  599. }
  600. static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
  601. return ( wmove ( stdscr, y, x ) == OK
  602. ? waddnstr ( stdscr, str, n ) : ERR );
  603. }
  604. static inline int mvaddstr ( int y, int x, const char *str ) {
  605. return ( wmove ( stdscr, y, x ) == OK
  606. ? waddnstr ( stdscr, str, -1 ) : ERR );
  607. }
  608. static inline int mvdelch ( int y, int x ) {
  609. return ( wmove ( stdscr, y, x ) == OK
  610. ? wdelch ( stdscr ) : ERR );
  611. }
  612. static inline int mvgetch ( int y, int x ) {
  613. return ( wmove ( stdscr, y, x ) == OK
  614. ? wgetch ( stdscr ) : ERR );
  615. }
  616. static inline int mvgetnstr ( int y, int x, char *str, int n ) {
  617. return ( wmove ( stdscr, y, x ) == OK
  618. ? wgetnstr ( stdscr, str, n ) : ERR );
  619. }
  620. static inline int mvgetstr ( int y, int x, char *str ) {
  621. return ( wmove ( stdscr, y, x ) == OK
  622. ? wgetnstr ( stdscr, str, -1 ) : ERR );
  623. }
  624. static inline int mvhline ( int y, int x, chtype ch, int n ) {
  625. return ( wmove ( stdscr, y, x ) == OK
  626. ? whline ( stdscr, ch, n ) : ERR );
  627. }
  628. // OK, so maybe a few I did with macros...
  629. #define mvprintw( y, x, fmt, ... ) \
  630. ( wmove(stdscr,(y),(x)) == OK \
  631. ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
  632. static inline int mvvline ( int y, int x, chtype ch, int n ) {
  633. return ( wmove ( stdscr, y, x ) == OK
  634. ? wvline ( stdscr, ch, n ) : ERR );
  635. }
  636. static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
  637. return ( wmove( win, y, x ) == OK
  638. ? waddch ( win, ch ) : ERR );
  639. }
  640. static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
  641. return ( wmove ( win, y, x ) == OK
  642. ? waddchnstr ( win, chstr, n ) : ERR );
  643. }
  644. static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
  645. return ( wmove ( win, y, x ) == OK
  646. ? waddchnstr ( win, chstr, -1 ) : ERR );
  647. }
  648. static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
  649. return ( wmove ( win, y, x ) == OK
  650. ? waddnstr ( win, str, n ) : ERR );
  651. }
  652. static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
  653. return ( wmove ( win, y, x ) == OK
  654. ? waddnstr ( win, str, -1 ) : ERR );
  655. }
  656. static inline int mvwdelch ( WINDOW *win, int y, int x ) {
  657. return ( wmove ( win, y, x ) == OK
  658. ? wdelch ( win ) : ERR );
  659. }
  660. static inline int mvwgetch ( WINDOW *win, int y, int x ) {
  661. return ( wmove ( win, y, x ) == OK
  662. ? wgetch ( win ) : ERR );
  663. }
  664. static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
  665. return ( wmove ( win, y, x ) == OK
  666. ? wgetnstr ( win, str, n ) : ERR );
  667. }
  668. static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
  669. return ( wmove ( win, y, x ) == OK
  670. ? wgetnstr ( win, str, -1 ) : ERR );
  671. }
  672. static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
  673. return ( wmove ( win, y, x ) == OK
  674. ? whline ( win, ch, n ) : ERR );
  675. }
  676. #define mvwprintw( win, y, x, fmt, ... ) \
  677. ( wmove((win),(y),(x)) == OK \
  678. ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
  679. static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
  680. return ( wmove ( win, y, x ) == OK
  681. ? wvline ( win, ch, n ) : ERR );
  682. }
  683. #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
  684. static inline int slk_refresh ( void ) {
  685. if ( slk_clear() == OK )
  686. return slk_restore();
  687. else
  688. return ERR;
  689. }
  690. #define standend() wstandend( stdscr )
  691. #define standout() wstandout( stdscr )
  692. static inline int vline ( chtype ch, int n ) {
  693. return wvline ( stdscr, ch, n );
  694. }
  695. // marked for removal
  696. static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
  697. return vw_printw ( win, fmt, varglist );
  698. }
  699. static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
  700. return waddchnstr ( win, chstr, -1 );
  701. }
  702. static inline int waddstr ( WINDOW *win, const char *str ) {
  703. return waddnstr ( win, str, -1 );
  704. }
  705. static inline int wbkgdset ( WINDOW *win, chtype ch ) {
  706. return wattrset( win, ch );
  707. }
  708. static inline int wgetstr ( WINDOW *win, char *str ) {
  709. return wgetnstr ( win, str, -1 );
  710. }
  711. static inline int wstandend ( WINDOW *win ) {
  712. return wattrset ( win, A_DEFAULT );
  713. }
  714. static inline int wstandout ( WINDOW *win ) {
  715. return wattrset ( win, A_STANDOUT );
  716. }
  717. #endif /* CURSES_H */