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.

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