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