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 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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. FILE_LICENCE ( GPL2_OR_LATER );
  11. #undef ERR
  12. #define ERR (-1)
  13. #undef FALSE
  14. #define FALSE (0)
  15. #undef OK
  16. #define OK (0)
  17. #undef TRUE
  18. #define TRUE (1)
  19. typedef int bool;
  20. typedef uint32_t chtype;
  21. typedef uint32_t attr_t;
  22. /** Curses SCREEN object */
  23. typedef struct _curses_screen {
  24. /** Current cursor position */
  25. unsigned int curs_x, curs_y;
  26. /** Current attribute */
  27. attr_t attrs;
  28. void ( *init ) ( struct _curses_screen *scr );
  29. void ( *exit ) ( struct _curses_screen *scr );
  30. /**
  31. * Move cursor to position specified by x,y coords
  32. *
  33. * @v scr screen on which to operate
  34. * @v y Y position
  35. * @v x X position
  36. */
  37. void ( * movetoyx ) ( struct _curses_screen *scr,
  38. unsigned int y, unsigned int x );
  39. /**
  40. * Write character to current cursor position
  41. *
  42. * @v scr screen on which to operate
  43. * @v c character to be written
  44. */
  45. void ( * putc ) ( struct _curses_screen *scr, chtype c );
  46. /**
  47. * Pop a character from the keyboard input stream
  48. *
  49. * @v scr screen on which to operate
  50. * @ret c popped character
  51. */
  52. int ( * getc ) ( struct _curses_screen *scr );
  53. /**
  54. * Checks to see whether a character is waiting in the input stream
  55. *
  56. * @v scr screen on which to operate
  57. * @ret TRUE character waiting in stream
  58. * @ret FALSE no character waiting in stream
  59. */
  60. bool ( *peek ) ( struct _curses_screen *scr );
  61. } SCREEN;
  62. /** Curses Window struct */
  63. typedef struct _curses_window {
  64. /** screen with which window associates */
  65. SCREEN *scr;
  66. /** window attributes */
  67. attr_t attrs;
  68. /** window origin coordinates */
  69. unsigned int ori_x, ori_y;
  70. /** window cursor position */
  71. unsigned int curs_x, curs_y;
  72. /** window dimensions */
  73. unsigned int width, height;
  74. /** parent window */
  75. struct _curses_window *parent;
  76. /** windows that share the same parent as this one */
  77. //struct list_head siblings;
  78. /** windows der'd or sub'd from this one */
  79. //struct list_head children;
  80. } WINDOW;
  81. extern WINDOW _stdscr;
  82. extern unsigned short _COLS;
  83. extern unsigned short _LINES;
  84. #define stdscr ( &_stdscr )
  85. #define COLS _COLS
  86. #define LINES _LINES
  87. #define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
  88. #define CPAIR_SHIFT 8
  89. #define ATTRS_SHIFT 16
  90. #define WA_DEFAULT ( 0x0000 << ATTRS_SHIFT )
  91. #define WA_ALTCHARSET ( 0x0001 << ATTRS_SHIFT )
  92. #define WA_BLINK ( 0x0002 << ATTRS_SHIFT )
  93. #define WA_BOLD ( 0x0004 << ATTRS_SHIFT )
  94. #define WA_DIM ( 0x0008 << ATTRS_SHIFT )
  95. #define WA_INVIS ( 0x0010 << ATTRS_SHIFT )
  96. #define WA_PROTECT ( 0x0020 << ATTRS_SHIFT )
  97. #define WA_REVERSE ( 0x0040 << ATTRS_SHIFT )
  98. #define WA_STANDOUT ( 0x0080 << ATTRS_SHIFT )
  99. #define WA_UNDERLINE ( 0x0100 << ATTRS_SHIFT )
  100. #define WA_HORIZONTAL ( 0x0200 << ATTRS_SHIFT )
  101. #define WA_VERTICAL ( 0x0400 << ATTRS_SHIFT )
  102. #define WA_LEFT ( 0x0800 << ATTRS_SHIFT )
  103. #define WA_RIGHT ( 0x1000 << ATTRS_SHIFT )
  104. #define WA_LOW ( 0x2000 << ATTRS_SHIFT )
  105. #define WA_TOP ( 0x4000 << ATTRS_SHIFT )
  106. #define A_DEFAULT WA_DEFAULT
  107. #define A_ALTCHARSET WA_ALTCHARSET
  108. #define A_BLINK WA_BLINK
  109. #define A_BOLD WA_BOLD
  110. #define A_DIM WA_DIM
  111. #define A_INVIS WA_INVIS
  112. #define A_PROTECT WA_PROTECT
  113. #define A_REVERSE WA_REVERSE
  114. #define A_STANDOUT WA_STANDOUT
  115. #define A_UNDERLINE WA_UNDERLINE
  116. #define A_ATTRIBUTES ( 0xffff << ATTRS_SHIFT )
  117. #define A_CHARTEXT ( 0xff )
  118. #define A_COLOUR ( 0xff << CPAIR_SHIFT )
  119. #define A_COLOR A_COLOUR
  120. #define COLOUR_PAIR(n) ( (n) << CPAIR_SHIFT )
  121. #define COLOR_PAIR(n) COLOUR_PAIR(n)
  122. #define PAIR_NUMBER(attrs) ( ( (attrs) & A_COLOUR ) >> CPAIR_SHIFT )
  123. #define COLOUR_PAIRS 8 /* Arbitrary limit */
  124. #define COLOR_PAIRS COLOUR_PAIRS
  125. #define ACS_ULCORNER '+'
  126. #define ACS_LLCORNER '+'
  127. #define ACS_URCORNER '+'
  128. #define ACS_LRCORNER '+'
  129. #define ACS_RTEE '+'
  130. #define ACS_LTEE '+'
  131. #define ACS_BTEE '+'
  132. #define ACS_TTEE '+'
  133. #define ACS_HLINE '-'
  134. #define ACS_VLINE '|'
  135. #define ACS_PLUS '+'
  136. #define ACS_S1 '-'
  137. #define ACS_S9 '_'
  138. #define ACS_DIAMOND '+'
  139. #define ACS_CKBOARD ':'
  140. #define ACS_DEGREE '\''
  141. #define ACS_PLMINUS '#'
  142. #define ACS_BULLET 'o'
  143. #define ACS_LARROW '<'
  144. #define ACS_RARROW '>'
  145. #define ACS_DARROW 'v'
  146. #define ACS_UARROW '^'
  147. #define ACS_BOARD '#'
  148. #define ACS_LANTERN '#'
  149. #define ACS_BLOCK '#'
  150. #define COLOUR_BLACK 0
  151. #define COLOUR_RED 1
  152. #define COLOUR_GREEN 2
  153. #define COLOUR_YELLOW 3
  154. #define COLOUR_BLUE 4
  155. #define COLOUR_MAGENTA 5
  156. #define COLOUR_CYAN 6
  157. #define COLOUR_WHITE 7
  158. #define COLOURS 7
  159. #define COLOUR_FG 30
  160. #define COLOUR_BG 40
  161. #define COLOR_FG COLOUR_FG
  162. #define COLOR_BG COLOUR_BG
  163. #define COLOR_BLACK COLOUR_BLACK
  164. #define COLOR_BLUE COLOUR_BLUE
  165. #define COLOR_GREEN COLOUR_GREEN
  166. #define COLOR_CYAN COLOUR_CYAN
  167. #define COLOR_RED COLOUR_RED
  168. #define COLOR_MAGENTA COLOUR_MAGENTA
  169. #define COLOR_YELLOW COLOUR_YELLOW
  170. #define COLOR_WHITE COLOUR_WHITE
  171. #define COLORS COLOURS
  172. /*
  173. * KEY code constants are define in ipxe/keys.h
  174. */
  175. #include <ipxe/keys.h>
  176. //extern int addch ( const chtype * );
  177. //extern int addchnstr ( const chtype *, int );
  178. //extern int addchstr ( const chtype * );
  179. //extern int addnstr ( const char *, int );
  180. //extern int addstr ( const char * );
  181. //extern int attroff ( int );
  182. //extern int attron ( int );
  183. //extern int attrset ( int );
  184. //extern int attr_get ( attr_t *, short *, void * );
  185. //extern int attr_off ( attr_t, void * );
  186. //extern int attr_on ( attr_t, void * );
  187. //extern int attr_set ( attr_t, short, void * );
  188. extern int baudrate ( void );
  189. extern int beep ( void );
  190. //extern void bkgdset ( chtype );
  191. /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
  192. chtype );*/
  193. extern int box ( WINDOW *, chtype, chtype ) __nonnull;
  194. //extern bool can_change_colour ( void );
  195. #define can_change_color() can_change_colour()
  196. extern int cbreak ( void );
  197. //extern int clrtobot ( void );
  198. //extern int clrtoeol ( void );
  199. extern int colour_content ( short, short *, short *, short * ) __nonnull;
  200. #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
  201. //extern int colour_set ( short, void * );
  202. #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
  203. extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
  204. int, int, int, int );
  205. extern int curs_set ( int );
  206. extern int def_prog_mode ( void );
  207. extern int def_shell_mode ( void );
  208. extern int delay_output ( int );
  209. //extern int delch ( void );
  210. //extern int deleteln ( void );
  211. extern void delscreen ( SCREEN * );
  212. extern int delwin ( WINDOW * ) __nonnull;
  213. extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
  214. //extern int doupdate ( void );
  215. extern WINDOW *dupwin ( WINDOW * ) __nonnull;
  216. extern int echo ( void );
  217. extern int echochar ( const chtype );
  218. extern int endwin ( void );
  219. extern char erasechar ( void );
  220. //extern int erase ( void );
  221. extern void filter ( void );
  222. extern int flash ( void );
  223. extern int flushinp ( void );
  224. extern __pure chtype getbkgd ( WINDOW * ) __nonnull;
  225. //extern int getch ( void );
  226. //extern int getnstr ( char *, int );
  227. //extern int getstr ( char * );
  228. extern int halfdelay ( int );
  229. //extern bool has_colors ( void );
  230. extern bool has_ic ( void );
  231. extern bool has_il ( void );
  232. //extern int hline ( chtype, int );
  233. extern void idcok ( WINDOW *, bool );
  234. extern int idlok ( WINDOW *, bool );
  235. //extern void immedok ( WINDOW *, bool );
  236. //extern chtype inch ( void );
  237. //extern int inchnstr ( chtype *, int );
  238. //extern int inchstr ( chtype * );
  239. extern WINDOW *initscr ( void );
  240. extern int init_colour ( short, short, short, short );
  241. #define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
  242. extern int init_pair ( short, short, short );
  243. //extern int innstr ( char *, int );
  244. //extern int insch ( chtype );
  245. //extern int insnstr ( const char *, int );
  246. //extern int insstr ( const char * );
  247. //extern int instr ( char * );
  248. extern int intrflush ( WINDOW *, bool );
  249. extern bool isendwin ( void );
  250. //extern bool is_linetouched ( WINDOW *, int );
  251. //extern bool is_wintouched ( WINDOW * );
  252. extern char *keyname ( int );
  253. extern int keypad ( WINDOW *, bool );
  254. extern char killchar ( void );
  255. extern int leaveok ( WINDOW *, bool );
  256. extern char *longname ( void );
  257. extern int meta ( WINDOW *, bool );
  258. //extern int move ( int, int );
  259. //extern int mvaddch ( int, int, const chtype );
  260. //extern int mvaddchnstr ( int, int, const chtype *, int );
  261. //extern int mvaddchstr ( int, int, const chtype * );
  262. //extern int mvaddnstr ( int, int, const char *, int );
  263. //extern int mvaddstr ( int, int, const char * );
  264. extern int mvcur ( int, int, int, int );
  265. //extern int mvdelch ( int, int );
  266. extern int mvderwin ( WINDOW *, int, int );
  267. //extern int mvgetch ( int, int );
  268. //extern int mvgetnstr ( int, int, char *, int );
  269. //extern int mvgetstr ( int, int, char * );
  270. //extern int mvhline ( int, int, chtype, int );
  271. //extern chtype mvinch ( int, int );
  272. //extern int mvinchnstr ( int, int, chtype *, int );
  273. //extern int mvinchstr ( int, int, chtype * );
  274. //extern int mvinnstr ( int, int, char *, int );
  275. //extern int mvinsch ( int, int, chtype );
  276. //extern int mvinsnstr ( int, int, const char *, int );
  277. //extern int mvinsstr ( int, int, const char * );
  278. //extern int mvinstr ( int, int, char * );
  279. //extern int mvprintw ( int, int, char *, ... );
  280. //extern int mvscanw ( int, int, char *, ... );
  281. //extern int mvvline ( int, int, chtype, int );
  282. //extern int mvwaddch ( WINDOW *, int, int, const chtype );
  283. //extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );
  284. //extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );
  285. //extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );
  286. //extern int mvwaddstr ( WINDOW *, int, int, const char * );
  287. //extern int mvwdelch ( WINDOW *, int, int );
  288. //extern int mvwgetch ( WINDOW *, int, int );
  289. //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
  290. //extern int mvwgetstr ( WINDOW *, int, int, char * );
  291. //extern int mvwhline ( WINDOW *, int, int, chtype, int );
  292. extern int mvwin ( WINDOW *, int, int ) __nonnull;
  293. //extern chtype mvwinch ( WINDOW *, int, int );
  294. //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
  295. //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
  296. //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
  297. //extern int mvwinsch ( WINDOW *, int, int, chtype );
  298. //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
  299. //extern int mvwinsstr ( WINDOW *, int, int, const char * );
  300. //extern int mvwinstr ( WINDOW *, int, int, char * );
  301. //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
  302. //extern int mvwscanw ( WINDOW *, int, int, char *, ... );
  303. //extern int mvwvline ( WINDOW *, int, int, chtype, int );
  304. extern int napms ( int );
  305. //extern WINDOW *newpad ( int, int );
  306. extern WINDOW *newwin ( int, int, int, int );
  307. extern int nl ( void );
  308. extern int nocbreak ( void );
  309. extern int nodelay ( WINDOW *, bool );
  310. extern int noecho ( void );
  311. extern int nonl ( void );
  312. extern void noqiflush ( void );
  313. extern int noraw ( void );
  314. extern int notimeout ( WINDOW *, bool );
  315. extern int overlay ( const WINDOW *, WINDOW * );
  316. extern int overwrite ( const WINDOW *, WINDOW * );
  317. extern int pair_content ( short, short *, short * ) __nonnull;
  318. //extern int pechochar ( WINDOW *, chtype );
  319. //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
  320. //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
  321. extern int printw ( char *, ... );
  322. extern int putp ( const char * );
  323. extern void qiflush ( void );
  324. extern int raw ( void );
  325. //extern int redrawwin ( WINDOW * );
  326. //extern int refresh ( void );
  327. extern int reset_prog_mode ( void );
  328. extern int reset_shell_mode ( void );
  329. extern int resetty ( void );
  330. extern int ripoffline ( int, int (*) ( WINDOW *, int) );
  331. extern int savetty ( void );
  332. //extern int scanw ( char *, ... );
  333. //extern int scrl ( int );
  334. //extern int scroll ( WINDOW * );
  335. //extern int scrollok ( WINDOW *, bool );
  336. //extern int setscrreg ( int, int );
  337. extern SCREEN *set_term ( SCREEN * );
  338. extern int setupterm ( char *, int, int * );
  339. extern int slk_attr_off ( const attr_t, void * );
  340. extern int slk_attroff ( const chtype );
  341. extern int slk_attr_on ( const attr_t, void * );
  342. extern int slk_attron ( const chtype );
  343. extern int slk_attr_set ( const attr_t, short, void * );
  344. extern int slk_attrset ( const chtype );
  345. extern int slk_clear ( void );
  346. extern int slk_colour ( short );
  347. #define slk_color( c ) slk_colour( (c) )
  348. extern int slk_init ( int );
  349. extern char *slk_label ( int );
  350. extern int slk_noutrefresh ( void );
  351. //extern int slk_refresh ( void );
  352. extern int slk_restore ( void );
  353. extern int slk_set ( int, const char *, int ) __nonnull;
  354. extern int slk_touch ( void );
  355. extern int standend ( void );
  356. extern int standout ( void );
  357. //extern int start_colour ( void );
  358. #define start_color() start_colour()
  359. //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
  360. extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull;
  361. extern int syncok ( WINDOW *, bool );
  362. extern chtype termattrs ( void );
  363. extern attr_t term_attrs ( void );
  364. extern char *termname ( void );
  365. extern int tigetflag ( char * );
  366. extern int tigetnum ( char * );
  367. extern char *tigetstr ( char * );
  368. extern void timeout ( int );
  369. //extern int touchline ( WINDOW *, int, int );
  370. //extern int touchwin ( WINDOW * );
  371. extern char *tparm ( char *, long, long, long, long, long, long, long, long,
  372. long );
  373. extern int typeahead ( int );
  374. //extern int ungetch ( int );
  375. //extern int untouchwin ( WINDOW * );
  376. extern void use_env ( bool );
  377. extern int vid_attr ( attr_t, short, void * );
  378. extern int vidattr ( chtype );
  379. extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
  380. extern int vidputs ( chtype, int ( *) ( int) );
  381. //extern int vline ( chtype, int );
  382. //extern int vwprintw ( WINDOW *, const char *, va_list );
  383. extern int vw_printw ( WINDOW *, const char *, va_list ) __nonnull;
  384. //extern int vwscanw ( WINDOW *, char *, va_list );
  385. //extern int vw_scanw ( WINDOW *, char *, va_list );
  386. extern int waddch ( WINDOW *, const chtype ) __nonnull;
  387. extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
  388. //extern int waddchstr ( WINDOW *, const chtype * );
  389. extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
  390. //extern int waddstr ( WINDOW *, const char * );
  391. extern int wattroff ( WINDOW *, int ) __nonnull;
  392. extern int wattron ( WINDOW *, int ) __nonnull;
  393. extern int wattrset ( WINDOW *, int ) __nonnull;
  394. extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
  395. __attribute__ (( nonnull (1, 2, 3)));
  396. extern int wattr_off ( WINDOW *, attr_t, void * )
  397. __attribute__ (( nonnull (1)));
  398. extern int wattr_on ( WINDOW *, attr_t, void * )
  399. __attribute__ (( nonnull (1)));
  400. extern int wattr_set ( WINDOW *, attr_t, short, void * )
  401. __attribute__ (( nonnull (1)));
  402. //extern void wbkgdset ( WINDOW *, chtype );
  403. extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
  404. chtype, chtype ) __nonnull;
  405. extern int wclrtobot ( WINDOW * ) __nonnull;
  406. extern int wclrtoeol ( WINDOW * ) __nonnull;
  407. extern void wcursyncup ( WINDOW * );
  408. extern int wcolour_set ( WINDOW *, short, void * ) __nonnull;
  409. #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
  410. extern int wdelch ( WINDOW * ) __nonnull;
  411. extern int wdeleteln ( WINDOW * ) __nonnull;
  412. extern int wechochar ( WINDOW *, const chtype );
  413. extern int werase ( WINDOW * ) __nonnull;
  414. extern int wgetch ( WINDOW * );
  415. extern int wgetnstr ( WINDOW *, char *, int );
  416. //extern int wgetstr ( WINDOW *, char * );
  417. extern int whline ( WINDOW *, chtype, int ) __nonnull;
  418. //extern chtype winch ( WINDOW * );
  419. //extern int winchnstr ( WINDOW *, chtype *, int );
  420. //extern int winchstr ( WINDOW *, chtype * );
  421. //extern int winnstr ( WINDOW *, char *, int );
  422. //extern int winsch ( WINDOW *, chtype );
  423. //extern int winsnstr ( WINDOW *, const char *, int );
  424. //extern int winsstr ( WINDOW *, const char * );
  425. //extern int winstr ( WINDOW *, char * );
  426. extern int wmove ( WINDOW *, int, int );
  427. //extern int wnoutrefresh ( WINDOW * );
  428. extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
  429. //extern int wredrawln ( WINDOW *, int, int );
  430. //extern int wrefresh ( WINDOW * );
  431. //extern int wscanw ( WINDOW *, char *, ... );
  432. //extern int wscrl ( WINDOW *, int );
  433. //extern int wsetscrreg ( WINDOW *, int, int );
  434. //extern int wstandend ( WINDOW * );
  435. //extern int wstandout ( WINDOW * );
  436. extern void wsyncup ( WINDOW * );
  437. extern void wsyncdown ( WINDOW * );
  438. extern void wtimeout ( WINDOW *, int );
  439. //extern int wtouchln ( WINDOW *, int, int, int );
  440. extern int wvline ( WINDOW *, chtype, int ) __nonnull;
  441. /*
  442. * There is frankly a ridiculous amount of redundancy within the
  443. * curses API - ncurses decided to get around this by using #define
  444. * macros, but I've decided to be type-safe and implement them all as
  445. * static inlines instead...
  446. */
  447. static inline int addch ( const chtype ch ) {
  448. return waddch( stdscr, ch );
  449. }
  450. static inline int addchnstr ( const chtype *chstr, int n ) {
  451. return waddchnstr ( stdscr, chstr, n );
  452. }
  453. static inline int addchstr ( const chtype *chstr ) {
  454. return waddchnstr ( stdscr, chstr, -1 );
  455. }
  456. static inline int addnstr ( const char *str, int n ) {
  457. return waddnstr ( stdscr, str, n );
  458. }
  459. static inline int addstr ( const char *str ) {
  460. return waddnstr ( stdscr, str, -1 );
  461. }
  462. static inline int attroff ( int attrs ) {
  463. return wattroff ( stdscr, attrs );
  464. }
  465. static inline int attron ( int attrs ) {
  466. return wattron ( stdscr, attrs );
  467. }
  468. static inline int attrset ( int attrs ) {
  469. return wattrset ( stdscr, attrs );
  470. }
  471. static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
  472. return wattr_get ( stdscr, attrs, pair, opts );
  473. }
  474. static inline int attr_off ( attr_t attrs, void *opts ) {
  475. return wattr_off ( stdscr, attrs, opts );
  476. }
  477. static inline int attr_on ( attr_t attrs, void *opts ) {
  478. return wattr_on ( stdscr, attrs, opts );
  479. }
  480. static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
  481. return wattr_set ( stdscr, attrs, cpair, opts );
  482. }
  483. static inline void bkgdset ( chtype ch ) {
  484. wattrset ( stdscr, ch );
  485. }
  486. static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
  487. chtype tl, chtype tr, chtype bl, chtype br ) {
  488. return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
  489. }
  490. static inline bool can_change_colour ( void ) {
  491. return FALSE;
  492. }
  493. static inline int clrtobot ( void ) {
  494. return wclrtobot( stdscr );
  495. }
  496. static inline int clrtoeol ( void ) {
  497. return wclrtoeol( stdscr );
  498. }
  499. static inline int colour_set ( short colour_pair_number, void *opts ) {
  500. return wcolour_set ( stdscr, colour_pair_number, opts );
  501. }
  502. static inline int delch ( void ) {
  503. return wdelch ( stdscr );
  504. }
  505. static inline int deleteln ( void ) {
  506. return wdeleteln( stdscr );
  507. }
  508. static inline int erase ( void ) {
  509. return werase ( stdscr );
  510. }
  511. static inline int getch ( void ) {
  512. return wgetch ( stdscr );
  513. }
  514. static inline int getnstr ( char *str, int n ) {
  515. return wgetnstr ( stdscr, str, n );
  516. }
  517. static inline int getstr ( char *str ) {
  518. return wgetnstr ( stdscr, str, -1 );
  519. }
  520. static inline bool has_colors ( void ) {
  521. return TRUE;
  522. }
  523. static inline int has_key ( int kc __unused ) {
  524. return TRUE;
  525. }
  526. static inline int hline ( chtype ch, int n ) {
  527. return whline ( stdscr, ch, n );
  528. }
  529. static inline int move ( int y, int x ) {
  530. return wmove ( stdscr, y, x );
  531. }
  532. static inline int mvaddch ( int y, int x, const chtype ch ) {
  533. return ( wmove ( stdscr, y, x ) == OK
  534. ? waddch( stdscr, ch ) : ERR );
  535. }
  536. static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
  537. return ( wmove ( stdscr, y, x ) == OK
  538. ? waddchnstr ( stdscr, chstr, n ) : ERR );
  539. }
  540. static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
  541. return ( wmove ( stdscr, y, x ) == OK
  542. ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
  543. }
  544. static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
  545. return ( wmove ( stdscr, y, x ) == OK
  546. ? waddnstr ( stdscr, str, n ) : ERR );
  547. }
  548. static inline int mvaddstr ( int y, int x, const char *str ) {
  549. return ( wmove ( stdscr, y, x ) == OK
  550. ? waddnstr ( stdscr, str, -1 ) : ERR );
  551. }
  552. static inline int mvdelch ( int y, int x ) {
  553. return ( wmove ( stdscr, y, x ) == OK
  554. ? wdelch ( stdscr ) : ERR );
  555. }
  556. static inline int mvgetch ( int y, int x ) {
  557. return ( wmove ( stdscr, y, x ) == OK
  558. ? wgetch ( stdscr ) : ERR );
  559. }
  560. static inline int mvgetnstr ( int y, int x, char *str, int n ) {
  561. return ( wmove ( stdscr, y, x ) == OK
  562. ? wgetnstr ( stdscr, str, n ) : ERR );
  563. }
  564. static inline int mvgetstr ( int y, int x, char *str ) {
  565. return ( wmove ( stdscr, y, x ) == OK
  566. ? wgetnstr ( stdscr, str, -1 ) : ERR );
  567. }
  568. static inline int mvhline ( int y, int x, chtype ch, int n ) {
  569. return ( wmove ( stdscr, y, x ) == OK
  570. ? whline ( stdscr, ch, n ) : ERR );
  571. }
  572. // OK, so maybe a few I did with macros...
  573. #define mvprintw( y, x, fmt, ... ) \
  574. ( wmove(stdscr,(y),(x)) == OK \
  575. ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
  576. static inline int mvvline ( int y, int x, chtype ch, int n ) {
  577. return ( wmove ( stdscr, y, x ) == OK
  578. ? wvline ( stdscr, ch, n ) : ERR );
  579. }
  580. static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
  581. return ( wmove( win, y, x ) == OK
  582. ? waddch ( win, ch ) : ERR );
  583. }
  584. static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
  585. return ( wmove ( win, y, x ) == OK
  586. ? waddchnstr ( win, chstr, n ) : ERR );
  587. }
  588. static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
  589. return ( wmove ( win, y, x ) == OK
  590. ? waddchnstr ( win, chstr, -1 ) : ERR );
  591. }
  592. static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
  593. return ( wmove ( win, y, x ) == OK
  594. ? waddnstr ( win, str, n ) : ERR );
  595. }
  596. static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
  597. return ( wmove ( win, y, x ) == OK
  598. ? waddnstr ( win, str, -1 ) : ERR );
  599. }
  600. static inline int mvwdelch ( WINDOW *win, int y, int x ) {
  601. return ( wmove ( win, y, x ) == OK
  602. ? wdelch ( win ) : ERR );
  603. }
  604. static inline int mvwgetch ( WINDOW *win, int y, int x ) {
  605. return ( wmove ( win, y, x ) == OK
  606. ? wgetch ( win ) : ERR );
  607. }
  608. static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
  609. return ( wmove ( win, y, x ) == OK
  610. ? wgetnstr ( win, str, n ) : ERR );
  611. }
  612. static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
  613. return ( wmove ( win, y, x ) == OK
  614. ? wgetnstr ( win, str, -1 ) : ERR );
  615. }
  616. static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
  617. return ( wmove ( win, y, x ) == OK
  618. ? whline ( win, ch, n ) : ERR );
  619. }
  620. #define mvwprintw( win, y, x, fmt, ... ) \
  621. ( wmove((win),(y),(x)) == OK \
  622. ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
  623. static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
  624. return ( wmove ( win, y, x ) == OK
  625. ? wvline ( win, ch, n ) : ERR );
  626. }
  627. #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
  628. static inline int slk_refresh ( void ) {
  629. if ( slk_clear() == OK )
  630. return slk_restore();
  631. else
  632. return ERR;
  633. }
  634. #define standend() wstandend( stdscr )
  635. #define standout() wstandout( stdscr )
  636. static inline int start_colour ( void ) {
  637. return OK;
  638. }
  639. static inline int vline ( chtype ch, int n ) {
  640. return wvline ( stdscr, ch, n );
  641. }
  642. // marked for removal
  643. static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
  644. return vw_printw ( win, fmt, varglist );
  645. }
  646. static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
  647. return waddchnstr ( win, chstr, -1 );
  648. }
  649. static inline int waddstr ( WINDOW *win, const char *str ) {
  650. return waddnstr ( win, str, -1 );
  651. }
  652. static inline int wbkgdset ( WINDOW *win, chtype ch ) {
  653. return wattrset( win, ch );
  654. }
  655. static inline int wgetstr ( WINDOW *win, char *str ) {
  656. return wgetnstr ( win, str, -1 );
  657. }
  658. static inline int wstandend ( WINDOW *win ) {
  659. return wattrset ( win, A_DEFAULT );
  660. }
  661. static inline int wstandout ( WINDOW *win ) {
  662. return wattrset ( win, A_STANDOUT );
  663. }
  664. #endif /* CURSES_H */