25 typedef uint32_t bool;
26 typedef uint32_t chtype;
27 typedef chtype attr_t;
29 /** Curses SCREEN object */
30 typedef struct _curses_screen {
32 * Move cursor to position specified by x,y coords
34 * @v scr screen on which to operate
38 void ( * movetoyx ) ( struct _curses_screen *scr,
39 unsigned int y, unsigned int x );
41 * Write character to current cursor position
43 * @v scr screen on which to operate
44 * @v c character to be written
46 void ( * putc ) ( struct _curses_screen *scr, chtype c );
50 * @v scr screen on which to operate
53 int ( * getc ) ( struct _curses_screen *scr );
56 /** Curses Window struct */
57 typedef struct _curses_window {
58 /** screen with which window associates */
60 /** window attributes */
62 /** window origin coordinates */
63 unsigned int ori_x, ori_y;
64 /** window cursor position */
65 unsigned int curs_x, curs_y;
66 /** window dimensions */
67 unsigned int width, height;
68 /** parent/child ptrs */
69 struct _curses_window *parent, *child;
72 extern WINDOW _stdscr;
73 extern SCREEN _curscr;
74 extern unsigned short _COLS;
75 extern unsigned short _LINES;
76 extern unsigned short _COLOURS;
77 extern unsigned int *_COLOUR_PAIRS;
79 #define stdscr ( &_stdscr )
80 #define curscr ( &_curscr )
83 #define COLORS _COLOURS
84 #define COLOR_PAIRS COLOUR_PAIRS
86 #define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
88 #define ATTRS_SHIFT 16
90 #define A_DEFAULT ( 1UL - 1UL )
91 #define A_ALTCHARSET MUCURSES_BITS( 1UL, ATTRS_SHIFT + 0 )
92 #define A_BLINK MUCURSES_BITS( 1UL, ATTRS_SHIFT + 1 )
93 #define A_BOLD MUCURSES_BITS( 1UL, ATTRS_SHIFT + 2 )
94 #define A_DIM MUCURSES_BITS( 1UL, ATTRS_SHIFT + 3 )
95 #define A_INVIS MUCURSES_BITS( 1UL, ATTRS_SHIFT + 4 )
96 #define A_PROTECT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 5 )
97 #define A_REVERSE MUCURSES_BITS( 1UL, ATTRS_SHIFT + 6 )
98 #define A_STANDOUT MUCURSES_BITS( 1UL, ATTRS_SHIFT + 7 )
99 #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
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 )
117 #define A_ATTRIBUTES ( MUCURSES_BITS( 1UL, ATTRS_SHIFT ) - 1UL )
118 #define A_CHARTEXT ( MUCURSES_BITS( 1UL, 0 ) - 1UL )
119 #define A_COLOR MUCURSES_BITS( ( 1UL << 8 ) - 1UL, CPAIR_SHIFT )
121 #define ACS_ULCORNER '+'
122 #define ACS_LLCORNER '+'
123 #define ACS_URCORNER '+'
124 #define ACS_LRCORNER '+'
129 #define ACS_HLINE '-'
130 #define ACS_VLINE '|'
134 #define ACS_DIAMOND '+'
135 #define ACS_CKBOARD ':'
136 #define ACS_DEGREE '\''
137 #define ACS_PLMINUS '#'
138 #define ACS_BULLET 'o'
139 #define ACS_LARROW '<'
140 #define ACS_RARROW '>'
141 #define ACS_DARROW 'v'
142 #define ACS_UARROW '^'
143 #define ACS_BOARD '#'
144 #define ACS_LANTERN '#'
145 #define ACS_BLOCK '#'
147 #define COLOUR_BLACK 0
148 #define COLOUR_BLUE 1
149 #define COLOUR_GREEN 2
150 #define COLOUR_CYAN 3
152 #define COLOUR_MAGENTA 5
153 #define COLOUR_YELLOW 6
154 #define COLOUR_WHITE 7
156 #define COLOR_BLACK COLOUR_BLACK
157 #define COLOR_BLUE COLOUR_BLUE
158 #define COLOR_GREEN COLOUR_GREEN
159 #define COLOR_CYAN COLOUR_CYAN
160 #define COLOR_RED COLOUR_RED
161 #define COLOR_MAGENTA COLOUR_MAGENTA
162 #define COLOR_YELLOW COLOUR_YELLOW
163 #define COLOR_WHITE COLOUR_WHITE
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 */
259 #define KEY_MAX 0777 /* Maximum key value is 0633 */
261 /*extern int addch ( const chtype * );*/
262 /*extern int addchnstr ( const chtype *, int );*/
263 /*extern int addchstr ( const chtype * );*/
264 /*extern int addnstr ( const char *, int );*/
265 /*extern int addstr ( const char * );*/
266 /*extern int attroff ( int );*/
267 /*extern int attron ( int );*/
268 /*extern int attrset ( int );*/
269 extern int attr_get ( attr_t *, short *, void * );
270 extern int attr_off ( attr_t, void * );
271 extern int attr_on ( attr_t, void * );
272 extern int attr_set ( attr_t, short, void * );
273 extern int baudrate ( void );
274 extern int beep ( void );
275 /*extern void bkgdset ( chtype );*/
276 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
278 extern int box ( WINDOW *, chtype, chtype );
279 extern bool can_change_colour ( void );
280 #define can_change_color() can_change_colour()
281 extern int cbreak ( void );
282 /*extern int clrtobot ( void );*/
283 /*extern int clrtoeol ( void );*/
284 extern int colour_content ( short, short *, short *, short * );
285 #define color_content( col, r, g, b ) colour_content( (col), (r), (g), (b) )
286 /*extern int colour_set ( short, void * );*/
287 /*#define color_set( cpno, opts ) colour_set( (cpno), (opts) )*/
288 extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
289 int, int, int, int );
290 extern int curs_set ( int );
291 extern int def_prog_mode ( void );
292 extern int def_shell_mode ( void );
293 extern int delay_output ( int );
294 /*extern int delch ( void );*/
295 /*extern int deleteln ( void );*/
296 extern void delscreen ( SCREEN * );
297 extern int delwin ( WINDOW * );
298 extern WINDOW *derwin ( WINDOW *, int, int, int, int );
299 /*extern int doupdate ( void );*/
300 extern WINDOW *dupwin ( WINDOW * );
301 extern int echo ( void );
302 extern int echochar ( const chtype );
303 extern int endwin ( void );
304 extern char erasechar ( void );
305 extern int erase ( void );
306 extern void filter ( void );
307 extern int flash ( void );
308 extern int flushinp ( void );
309 extern chtype getbkgd ( WINDOW * );
310 extern int getch ( void );
311 extern int getnstr ( char *, int );
312 extern int getstr ( char * );
313 extern int halfdelay ( int );
314 extern bool has_colors ( void );
315 extern bool has_ic ( void );
316 extern bool has_il ( void );
317 //extern int hline ( chtype, int );
318 extern void idcok ( WINDOW *, bool );
319 extern int idlok ( WINDOW *, bool );
320 extern void immedok ( WINDOW *, bool );
321 /*extern chtype inch ( void );*/
322 /*extern int inchnstr ( chtype *, int );*/
323 /*extern int inchstr ( chtype * );*/
324 extern WINDOW *initscr ( void );
325 extern int init_color ( short, short, short, short );
326 extern int init_pair ( short, short, short );
327 //extern int innstr ( char *, int );
328 //extern int insch ( chtype );
329 //extern int insnstr ( const char *, int );
330 //extern int insstr ( const char * );
331 //extern int instr ( char * );
332 extern int intrflush ( WINDOW *, bool );
333 extern bool isendwin ( void );
334 extern bool is_linetouched ( WINDOW *, int );
335 extern bool is_wintouched ( WINDOW * );
336 extern char *keyname ( int );
337 extern int keypad ( WINDOW *, bool );
338 extern char killchar ( void );
339 extern int leaveok ( WINDOW *, bool );
340 extern char *longname ( void );
341 extern int meta ( WINDOW *, bool );
342 /*extern int move ( int, int );*/
343 /*extern int mvaddch ( int, int, const chtype );*/
344 /*extern int mvaddchnstr ( int, int, const chtype *, int );*/
345 /*extern int mvaddchstr ( int, int, const chtype * );*/
346 /*extern int mvaddnstr ( int, int, const char *, int );*/
347 /*extern int mvaddstr ( int, int, const char * );*/
348 extern int mvcur ( int, int, int, int );
349 /*extern int mvdelch ( int, int );*/
350 extern int mvderwin ( WINDOW *, int, int );
351 extern int mvgetch ( int, int );
352 extern int mvgetnstr ( int, int, char *, int );
353 extern int mvgetstr ( int, int, char * );
354 //extern int mvhline ( int, int, chtype, int );
355 //extern chtype mvinch ( int, int );
356 /*extern int mvinchnstr ( int, int, chtype *, int );*/
357 /*extern int mvinchstr ( int, int, chtype * );*/
358 /*extern int mvinnstr ( int, int, char *, int );*/
359 //extern int mvinsch ( int, int, chtype );
360 //extern int mvinsnstr ( int, int, const char *, int );
361 //extern int mvinsstr ( int, int, const char * );
362 //extern int mvinstr ( int, int, char * );
363 //extern int mvprintw ( int, int, char *, ... );
364 extern int mvscanw ( int, int, char *, ... );
365 //extern int mvvline ( int, int, chtype, int );
366 /*extern int mvwaddch ( WINDOW *, int, int, const chtype );*/
367 /*extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );*/
368 /*extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );*/
369 /*extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );*/
370 /*extern int mvwaddstr ( WINDOW *, int, int, const char * );*/
371 /*extern int mvwdelch ( WINDOW *, int, int );*/
372 extern int mvwgetch ( WINDOW *, int, int );
373 extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
374 extern int mvwgetstr ( WINDOW *, int, int, char * );
375 //extern int mvwhline ( WINDOW *, int, int, chtype, int );
376 extern int mvwin ( WINDOW *, int, int );
377 //extern chtype mvwinch ( WINDOW *, int, int );
378 //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
379 //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
380 //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
381 //extern int mvwinsch ( WINDOW *, int, int, chtype );
382 //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
383 //extern int mvwinsstr ( WINDOW *, int, int, const char * );
384 //extern int mvwinstr ( WINDOW *, int, int, char * );
385 //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
386 extern int mvwscanw ( WINDOW *, int, int, char *, ... );
387 //extern int mvwvline ( WINDOW *, int, int, chtype, int );
388 extern int napms ( int );
389 extern WINDOW *newpad ( int, int );
390 extern WINDOW *newwin ( int, int, int, int );
391 extern int nl ( void );
392 extern int nocbreak ( void );
393 extern int nodelay ( WINDOW *, bool );
394 extern int noecho ( void );
395 extern int nonl ( void );
396 extern void noqiflush ( void );
397 extern int noraw ( void );
398 extern int notimeout ( WINDOW *, bool );
399 extern int overlay ( const WINDOW *, WINDOW * );
400 extern int overwrite ( const WINDOW *, WINDOW * );
401 extern int pair_content ( short, short *, short * );
402 extern int PAIR_NUMBER ( int );
403 extern int pechochar ( WINDOW *, chtype );
404 extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
405 extern int prefresh ( WINDOW *, int, int, int, int, int, int );
406 extern int printw ( char *, ... );
407 extern int putp ( const char * );
408 extern void qiflush ( void );
409 extern int raw ( void );
410 /*extern int redrawwin ( WINDOW * );*/
411 /*extern int refresh ( void );*/
412 extern int reset_prog_mode ( void );
413 extern int reset_shell_mode ( void );
414 extern int resetty ( void );
415 extern int ripoffline ( int, int ( *) ( WINDOW *, int) );
416 extern int savetty ( void );
417 extern int scanw ( char *, ... );
418 extern int scrl ( int );
419 extern int scroll ( WINDOW * );
420 extern int scrollok ( WINDOW *, bool );
421 extern int setscrreg ( int, int );
422 extern SCREEN *set_term ( SCREEN * );
423 extern int setupterm ( char *, int, int * );
424 extern int slk_attr_off ( const attr_t, void * );
425 extern int slk_attroff ( const chtype );
426 extern int slk_attr_on ( const attr_t, void * );
427 extern int slk_attron ( const chtype );
428 extern int slk_attr_set ( const attr_t, short, void * );
429 extern int slk_attrset ( const chtype );
430 extern int slk_clear ( void );
431 extern int slk_color ( short );
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_color ( void );
442 extern WINDOW *subpad ( WINDOW *, int, int, int, int );
443 extern WINDOW *subwin ( WINDOW *, int, int, int, int );
444 extern int syncok ( WINDOW *, bool );
445 extern chtype termattrs ( void );
446 extern attr_t term_attrs ( void );
447 extern char *termname ( void );
448 extern int tigetflag ( char * );
449 extern int tigetnum ( char * );
450 extern char *tigetstr ( char * );
451 extern void timeout ( int );
452 extern int touchline ( WINDOW *, int, int );
453 extern int touchwin ( WINDOW * );
454 extern char *tparm ( char *, long, long, long, long, long, long, long, long,
456 extern int typeahead ( int );
457 extern int ungetch ( int );
458 extern int untouchwin ( WINDOW * );
459 extern void use_env ( bool );
460 extern int vid_attr ( attr_t, short, void * );
461 extern int vidattr ( chtype );
462 extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
463 extern int vidputs ( chtype, int ( *) ( int) );
464 //extern int vline ( chtype, int );
465 //extern int vwprintw ( WINDOW *, const char *, va_list );
466 extern int vw_printw ( WINDOW *, const char *, va_list );
467 extern int vwscanw ( WINDOW *, char *, va_list );
468 extern int vw_scanw ( WINDOW *, char *, va_list );
469 extern int waddch ( WINDOW *, const chtype );
470 extern int waddchnstr ( WINDOW *, const chtype *, int );
471 /*extern int waddchstr ( WINDOW *, const chtype * );*/
472 extern int waddnstr ( WINDOW *, const char *, int );
473 /*extern int waddstr ( WINDOW *, const char * );*/
474 extern int wattroff ( WINDOW *, int );
475 extern int wattron ( WINDOW *, int );
476 extern int wattrset ( WINDOW *, int );
477 extern int wattr_get ( WINDOW *, attr_t *, short *, void * );
478 extern int wattr_off ( WINDOW *, attr_t, void * );
479 extern int wattr_on ( WINDOW *, attr_t, void * );
480 extern int wattr_set ( WINDOW *, attr_t, short, void * );
481 /*extern void wbkgdset ( WINDOW *, chtype );*/
482 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
484 extern int wclrtobot ( WINDOW * );
485 extern int wclrtoeol ( WINDOW * );
486 extern void wcursyncup ( WINDOW * );
487 /*extern int wcolor_set ( WINDOW *, short, void * );*/
488 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
489 extern int wdelch ( WINDOW * );
490 extern int wdeleteln ( WINDOW * );
491 extern int wechochar ( WINDOW *, const chtype );
492 extern int werase ( WINDOW * );
493 extern int wgetch ( WINDOW * );
494 extern int wgetnstr ( WINDOW *, char *, int );
495 extern int wgetstr ( WINDOW *, char * );
496 extern int whline ( WINDOW *, chtype, int );
497 //extern chtype winch ( WINDOW * );
498 //extern int winchnstr ( WINDOW *, chtype *, int );
499 //extern int winchstr ( WINDOW *, chtype * );
500 //extern int winnstr ( WINDOW *, char *, int );
501 //extern int winsch ( WINDOW *, chtype );
502 //extern int winsnstr ( WINDOW *, const char *, int );
503 //extern int winsstr ( WINDOW *, const char * );
504 //extern int winstr ( WINDOW *, char * );
505 extern int wmove ( WINDOW *, int, int );
506 extern int wnoutrefresh ( WINDOW * );
507 extern int wprintw ( WINDOW *, const char *, ... );
508 /*extern int wredrawln ( WINDOW *, int, int );*/
509 /*extern int wrefresh ( WINDOW * );*/
510 extern int wscanw ( WINDOW *, char *, ... );
511 /*extern int wscrl ( WINDOW *, int );*/
512 extern int wsetscrreg ( WINDOW *, int, int );
513 extern int wstandend ( WINDOW * );
514 extern int wstandout ( WINDOW * );
515 extern void wsyncup ( WINDOW * );
516 extern void wsyncdown ( WINDOW * );
517 extern void wtimeout ( WINDOW *, int );
518 extern int wtouchln ( WINDOW *, int, int, int );
519 extern int wvline ( WINDOW *, chtype, int );
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...
528 static inline int addch ( const chtype ch ) {
529 return waddch( stdscr, ch );
532 static inline int addchnstr ( const chtype *chstr, int n ) {
533 return waddchnstr ( stdscr, chstr, n );
536 static inline int addchstr ( const chtype *chstr ) {
537 return waddchnstr ( stdscr, chstr, -1 );
540 static inline int addnstr ( const char *str, int n ) {
541 return waddnstr ( stdscr, str, n );
544 static inline int addstr ( const char *str ) {
545 return waddnstr ( stdscr, str, -1 );
548 static inline int attroff ( int attrs ) {
549 return wattroff ( stdscr, attrs );
552 static inline int attron ( int attrs ) {
553 return wattron ( stdscr, attrs );
556 static inline int attrset ( int attrs ) {
557 return wattrset ( stdscr, attrs );
560 static inline void bkgdset ( chtype ch ) {
561 wattrset ( stdscr, ch );
564 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
565 chtype tl, chtype tr, chtype bl, chtype br ) {
566 return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
569 static inline int clrtobot ( void ) {
570 return wclrtobot( stdscr );
573 static inline int clrtoeol ( void ) {
574 return wclrtoeol( stdscr );
577 static inline int delch ( void ) {
578 return wdelch ( stdscr );
581 static inline int deleteln ( void ) {
582 return wdeleteln( stdscr );
585 static inline int hline ( chtype ch, int n ) {
586 return whline ( stdscr, ch, n );
589 static inline int move ( int y, int x ) {
590 return wmove ( stdscr, y, x );
593 static inline int mvaddch ( int y, int x, const chtype ch ) {
594 return ( wmove ( stdscr, y, x ) == OK
595 ? waddch( stdscr, ch ) : ERR );
598 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
599 return ( wmove ( stdscr, y, x ) == OK
600 ? waddchnstr ( stdscr, chstr, n ) : ERR );
603 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
604 return ( wmove ( stdscr, y, x ) == OK
605 ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
608 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
609 return ( wmove ( stdscr, y, x ) == OK
610 ? waddnstr ( stdscr, str, n ) : ERR );
613 static inline int mvaddstr ( int y, int x, const char *str ) {
614 return ( wmove ( stdscr, y, x ) == OK
615 ? waddnstr ( stdscr, str, -1 ) : ERR );
618 static inline int mvdelch ( int y, int x ) {
619 return ( wmove ( stdscr, y, x ) == OK
620 ? wdelch ( stdscr ) : ERR );
623 static inline int mvhline ( int y, int x, chtype ch, int n ) {
624 return ( wmove ( stdscr, y, x ) == OK
625 ? whline ( stdscr, ch, n ) : ERR );
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 )
633 static inline int mvvline ( int y, int x, chtype ch, int n ) {
634 return ( wmove ( stdscr, y, x ) == OK
635 ? wvline ( stdscr, ch, n ) : ERR );
638 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
639 return ( wmove( win, y, x ) == OK
640 ? waddch ( win, ch ) : ERR );
643 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
644 return ( wmove ( win, y, x ) == OK
645 ? waddchnstr ( win, chstr, n ) : ERR );
648 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
649 return ( wmove ( win, y, x ) == OK
650 ? waddchnstr ( win, chstr, -1 ) : ERR );
653 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
654 return ( wmove ( win, y, x ) == OK
655 ? waddnstr ( win, str, n ) : ERR );
658 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
659 return ( wmove ( win, y, x ) == OK
660 ? waddnstr ( win, str, -1 ) : ERR );
663 static inline int mvwdelch ( WINDOW *win, int y, int x ) {
664 return ( wmove ( win, y, x ) == OK
665 ? wdelch ( win ) : ERR );
668 static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
669 return ( wmove ( win, y, x ) == OK
670 ? whline ( win, ch, n ) : ERR );
673 #define mvwprintw( win, y, x, fmt, ... ) \
674 ( wmove((win),(y),(x)) == OK \
675 ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
677 static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
678 return ( wmove ( win, y, x ) == OK
679 ? wvline ( win, ch, n ) : ERR );
682 #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
684 static inline int vline ( chtype ch, int n ) {
685 return wvline ( stdscr, ch, n );
688 // marked for removal
689 static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
690 return vw_printw ( win, fmt, varglist );
693 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
694 return waddchnstr ( win, chstr, -1 );
697 static inline int waddstr ( WINDOW *win, const char *str ) {
698 return waddnstr ( win, str, -1 );
701 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
702 return wattrset( win, ch );
705 #endif /* CURSES_H */