您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

curses.h 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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 ) __nonnull;
  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 * ) __nonnull;
  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 * ) __nonnull;
  212. extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
  213. //extern int doupdate ( void );
  214. extern WINDOW *dupwin ( WINDOW * ) __nonnull;
  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 __pure chtype getbkgd ( WINDOW * ) __nonnull;
  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 ) __nonnull;
  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 * ) __nonnull;
  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 ) __nonnull;
  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 ) __nonnull;
  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 ) __nonnull;
  383. //extern int vwscanw ( WINDOW *, char *, va_list );
  384. //extern int vw_scanw ( WINDOW *, char *, va_list );
  385. extern int waddch ( WINDOW *, const chtype ) __nonnull;
  386. extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
  387. //extern int waddchstr ( WINDOW *, const chtype * );
  388. extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
  389. //extern int waddstr ( WINDOW *, const char * );
  390. extern int wattroff ( WINDOW *, int ) __nonnull;
  391. extern int wattron ( WINDOW *, int ) __nonnull;
  392. extern int wattrset ( WINDOW *, int ) __nonnull;
  393. extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
  394. __attribute__ (( nonnull (1, 2, 3)));
  395. extern int wattr_off ( WINDOW *, attr_t, void * )
  396. __attribute__ (( nonnull (1)));
  397. extern int wattr_on ( WINDOW *, attr_t, void * )
  398. __attribute__ (( nonnull (1)));
  399. extern int wattr_set ( WINDOW *, attr_t, short, void * )
  400. __attribute__ (( nonnull (1)));
  401. //extern void wbkgdset ( WINDOW *, chtype );
  402. extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
  403. chtype, chtype ) __nonnull;
  404. extern int wclrtobot ( WINDOW * ) __nonnull;
  405. extern int wclrtoeol ( WINDOW * ) __nonnull;
  406. extern void wcursyncup ( WINDOW * );
  407. extern int wcolour_set ( WINDOW *, short, void * ) __nonnull;
  408. #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
  409. extern int wdelch ( WINDOW * ) __nonnull;
  410. extern int wdeleteln ( WINDOW * ) __nonnull;
  411. extern int wechochar ( WINDOW *, const chtype );
  412. extern int werase ( WINDOW * ) __nonnull;
  413. extern int wgetch ( WINDOW * );
  414. extern int wgetnstr ( WINDOW *, char *, int );
  415. //extern int wgetstr ( WINDOW *, char * );
  416. extern int whline ( WINDOW *, chtype, int ) __nonnull;
  417. //extern chtype winch ( WINDOW * );
  418. //extern int winchnstr ( WINDOW *, chtype *, int );
  419. //extern int winchstr ( WINDOW *, chtype * );
  420. //extern int winnstr ( WINDOW *, char *, int );
  421. //extern int winsch ( WINDOW *, chtype );
  422. //extern int winsnstr ( WINDOW *, const char *, int );
  423. //extern int winsstr ( WINDOW *, const char * );
  424. //extern int winstr ( WINDOW *, char * );
  425. extern int wmove ( WINDOW *, int, int );
  426. //extern int wnoutrefresh ( WINDOW * );
  427. extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
  428. //extern int wredrawln ( WINDOW *, int, int );
  429. //extern int wrefresh ( WINDOW * );
  430. //extern int wscanw ( WINDOW *, char *, ... );
  431. //extern int wscrl ( WINDOW *, int );
  432. //extern int wsetscrreg ( WINDOW *, int, int );
  433. //extern int wstandend ( WINDOW * );
  434. //extern int wstandout ( WINDOW * );
  435. extern void wsyncup ( WINDOW * );
  436. extern void wsyncdown ( WINDOW * );
  437. extern void wtimeout ( WINDOW *, int );
  438. //extern int wtouchln ( WINDOW *, int, int, int );
  439. extern int wvline ( WINDOW *, chtype, int ) __nonnull;
  440. /*
  441. * There is frankly a ridiculous amount of redundancy within the
  442. * curses API - ncurses decided to get around this by using #define
  443. * macros, but I've decided to be type-safe and implement them all as
  444. * static inlines instead...
  445. */
  446. static inline int addch ( const chtype ch ) {
  447. return waddch( stdscr, ch );
  448. }
  449. static inline int addchnstr ( const chtype *chstr, int n ) {
  450. return waddchnstr ( stdscr, chstr, n );
  451. }
  452. static inline int addchstr ( const chtype *chstr ) {
  453. return waddchnstr ( stdscr, chstr, -1 );
  454. }
  455. static inline int addnstr ( const char *str, int n ) {
  456. return waddnstr ( stdscr, str, n );
  457. }
  458. static inline int addstr ( const char *str ) {
  459. return waddnstr ( stdscr, str, -1 );
  460. }
  461. static inline int attroff ( int attrs ) {
  462. return wattroff ( stdscr, attrs );
  463. }
  464. static inline int attron ( int attrs ) {
  465. return wattron ( stdscr, attrs );
  466. }
  467. static inline int attrset ( int attrs ) {
  468. return wattrset ( stdscr, attrs );
  469. }
  470. static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
  471. return wattr_get ( stdscr, attrs, pair, opts );
  472. }
  473. static inline int attr_off ( attr_t attrs, void *opts ) {
  474. return wattr_off ( stdscr, attrs, opts );
  475. }
  476. static inline int attr_on ( attr_t attrs, void *opts ) {
  477. return wattr_on ( stdscr, attrs, opts );
  478. }
  479. static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
  480. return wattr_set ( stdscr, attrs, cpair, opts );
  481. }
  482. static inline void bkgdset ( chtype ch ) {
  483. wattrset ( stdscr, ch );
  484. }
  485. static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
  486. chtype tl, chtype tr, chtype bl, chtype br ) {
  487. return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
  488. }
  489. static inline bool can_change_colour ( void ) {
  490. return FALSE;
  491. }
  492. static inline int clrtobot ( void ) {
  493. return wclrtobot( stdscr );
  494. }
  495. static inline int clrtoeol ( void ) {
  496. return wclrtoeol( stdscr );
  497. }
  498. static inline int colour_set ( short colour_pair_number, void *opts ) {
  499. return wcolour_set ( stdscr, colour_pair_number, opts );
  500. }
  501. static inline int delch ( void ) {
  502. return wdelch ( stdscr );
  503. }
  504. static inline int deleteln ( void ) {
  505. return wdeleteln( stdscr );
  506. }
  507. static inline int erase ( void ) {
  508. return werase ( stdscr );
  509. }
  510. static inline int getch ( void ) {
  511. return wgetch ( stdscr );
  512. }
  513. static inline int getnstr ( char *str, int n ) {
  514. return wgetnstr ( stdscr, str, n );
  515. }
  516. static inline int getstr ( char *str ) {
  517. return wgetnstr ( stdscr, str, -1 );
  518. }
  519. static inline bool has_colors ( void ) {
  520. return TRUE;
  521. }
  522. static inline int has_key ( int kc __unused ) {
  523. return TRUE;
  524. }
  525. static inline int hline ( chtype ch, int n ) {
  526. return whline ( stdscr, ch, n );
  527. }
  528. static inline int move ( int y, int x ) {
  529. return wmove ( stdscr, y, x );
  530. }
  531. static inline int mvaddch ( int y, int x, const chtype ch ) {
  532. return ( wmove ( stdscr, y, x ) == OK
  533. ? waddch( stdscr, ch ) : ERR );
  534. }
  535. static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
  536. return ( wmove ( stdscr, y, x ) == OK
  537. ? waddchnstr ( stdscr, chstr, n ) : ERR );
  538. }
  539. static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
  540. return ( wmove ( stdscr, y, x ) == OK
  541. ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
  542. }
  543. static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
  544. return ( wmove ( stdscr, y, x ) == OK
  545. ? waddnstr ( stdscr, str, n ) : ERR );
  546. }
  547. static inline int mvaddstr ( int y, int x, const char *str ) {
  548. return ( wmove ( stdscr, y, x ) == OK
  549. ? waddnstr ( stdscr, str, -1 ) : ERR );
  550. }
  551. static inline int mvdelch ( int y, int x ) {
  552. return ( wmove ( stdscr, y, x ) == OK
  553. ? wdelch ( stdscr ) : ERR );
  554. }
  555. static inline int mvgetch ( int y, int x ) {
  556. return ( wmove ( stdscr, y, x ) == OK
  557. ? wgetch ( stdscr ) : ERR );
  558. }
  559. static inline int mvgetnstr ( int y, int x, char *str, int n ) {
  560. return ( wmove ( stdscr, y, x ) == OK
  561. ? wgetnstr ( stdscr, str, n ) : ERR );
  562. }
  563. static inline int mvgetstr ( int y, int x, char *str ) {
  564. return ( wmove ( stdscr, y, x ) == OK
  565. ? wgetnstr ( stdscr, str, -1 ) : ERR );
  566. }
  567. static inline int mvhline ( int y, int x, chtype ch, int n ) {
  568. return ( wmove ( stdscr, y, x ) == OK
  569. ? whline ( stdscr, ch, n ) : ERR );
  570. }
  571. // OK, so maybe a few I did with macros...
  572. #define mvprintw( y, x, fmt, ... ) \
  573. ( wmove(stdscr,(y),(x)) == OK \
  574. ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
  575. static inline int mvvline ( int y, int x, chtype ch, int n ) {
  576. return ( wmove ( stdscr, y, x ) == OK
  577. ? wvline ( stdscr, ch, n ) : ERR );
  578. }
  579. static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
  580. return ( wmove( win, y, x ) == OK
  581. ? waddch ( win, ch ) : ERR );
  582. }
  583. static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
  584. return ( wmove ( win, y, x ) == OK
  585. ? waddchnstr ( win, chstr, n ) : ERR );
  586. }
  587. static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
  588. return ( wmove ( win, y, x ) == OK
  589. ? waddchnstr ( win, chstr, -1 ) : ERR );
  590. }
  591. static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
  592. return ( wmove ( win, y, x ) == OK
  593. ? waddnstr ( win, str, n ) : ERR );
  594. }
  595. static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
  596. return ( wmove ( win, y, x ) == OK
  597. ? waddnstr ( win, str, -1 ) : ERR );
  598. }
  599. static inline int mvwdelch ( WINDOW *win, int y, int x ) {
  600. return ( wmove ( win, y, x ) == OK
  601. ? wdelch ( win ) : ERR );
  602. }
  603. static inline int mvwgetch ( WINDOW *win, int y, int x ) {
  604. return ( wmove ( win, y, x ) == OK
  605. ? wgetch ( win ) : ERR );
  606. }
  607. static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
  608. return ( wmove ( win, y, x ) == OK
  609. ? wgetnstr ( win, str, n ) : ERR );
  610. }
  611. static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
  612. return ( wmove ( win, y, x ) == OK
  613. ? wgetnstr ( win, str, -1 ) : ERR );
  614. }
  615. static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
  616. return ( wmove ( win, y, x ) == OK
  617. ? whline ( win, ch, n ) : ERR );
  618. }
  619. #define mvwprintw( win, y, x, fmt, ... ) \
  620. ( wmove((win),(y),(x)) == OK \
  621. ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
  622. static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
  623. return ( wmove ( win, y, x ) == OK
  624. ? wvline ( win, ch, n ) : ERR );
  625. }
  626. #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
  627. static inline int slk_refresh ( void ) {
  628. if ( slk_clear() == OK )
  629. return slk_restore();
  630. else
  631. return ERR;
  632. }
  633. #define standend() wstandend( stdscr )
  634. #define standout() wstandout( stdscr )
  635. static inline int start_colour ( void ) {
  636. return OK;
  637. }
  638. static inline int vline ( chtype ch, int n ) {
  639. return wvline ( stdscr, ch, n );
  640. }
  641. // marked for removal
  642. static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
  643. return vw_printw ( win, fmt, varglist );
  644. }
  645. static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
  646. return waddchnstr ( win, chstr, -1 );
  647. }
  648. static inline int waddstr ( WINDOW *win, const char *str ) {
  649. return waddnstr ( win, str, -1 );
  650. }
  651. static inline int wbkgdset ( WINDOW *win, chtype ch ) {
  652. return wattrset( win, ch );
  653. }
  654. static inline int wgetstr ( WINDOW *win, char *str ) {
  655. return wgetnstr ( win, str, -1 );
  656. }
  657. static inline int wstandend ( WINDOW *win ) {
  658. return wattrset ( win, A_DEFAULT );
  659. }
  660. static inline int wstandout ( WINDOW *win ) {
  661. return wattrset ( win, A_STANDOUT );
  662. }
  663. #endif /* CURSES_H */