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_BREAK 0401 /**< Break key */
198 #define KEY_DOWN 0402 /**< down-arrow key */
199 #define KEY_UP 0403 /**< up-arrow key */
200 #define KEY_LEFT 0404 /**< left-arrow key */
201 #define KEY_RIGHT 0405 /**< right-arrow key */
202 #define KEY_HOME 0406 /**< home key */
203 #define KEY_BACKSPACE 0407 /**< backspace key */
204 #define KEY_F0 0410 /**< Function keys. Space for 64 */
205 #define KEY_F(n) (KEY_F0+(n)) /**< Value of function key n */
206 #define KEY_DL 0510 /**< delete-line key */
207 #define KEY_IL 0511 /**< insert-line key */
208 #define KEY_DC 0512 /**< delete-character key */
209 #define KEY_IC 0513 /**< insert-character key */
210 #define KEY_EIC 0514 /**< sent by rmir or smir in insert mode */
211 #define KEY_CLEAR 0515 /**< clear-screen or erase key */
212 #define KEY_EOS 0516 /**< clear-to-end-of-screen key */
213 #define KEY_EOL 0517 /**< clear-to-end-of-line key */
214 #define KEY_SF 0520 /**< scroll-forward key */
215 #define KEY_SR 0521 /**< scroll-backward key */
216 #define KEY_NPAGE 0522 /**< next-page key */
217 #define KEY_PPAGE 0523 /**< previous-page key */
218 #define KEY_STAB 0524 /**< set-tab key */
219 #define KEY_CTAB 0525 /**< clear-tab key */
220 #define KEY_CATAB 0526 /**< clear-all-tabs key */
221 #define KEY_ENTER 0527 /**< enter/send key */
222 #define KEY_PRINT 0532 /**< print key */
223 #define KEY_LL 0533 /**< lower-left key (home down) */
224 #define KEY_A1 0534 /**< upper left of keypad */
225 #define KEY_A3 0535 /**< upper right of keypad */
226 #define KEY_B2 0536 /**< center of keypad */
227 #define KEY_C1 0537 /**< lower left of keypad */
228 #define KEY_C3 0540 /**< lower right of keypad */
229 #define KEY_BTAB 0541 /**< back-tab key */
230 #define KEY_BEG 0542 /**< begin key */
231 #define KEY_CANCEL 0543 /**< cancel key */
232 #define KEY_CLOSE 0544 /**< close key */
233 #define KEY_COMMAND 0545 /**< command key */
234 #define KEY_COPY 0546 /**< copy key */
235 #define KEY_CREATE 0547 /**< create key */
236 #define KEY_END 0550 /**< end key */
237 #define KEY_EXIT 0551 /**< exit key */
238 #define KEY_FIND 0552 /**< find key */
239 #define KEY_HELP 0553 /**< help key */
240 #define KEY_MARK 0554 /**< mark key */
241 #define KEY_MESSAGE 0555 /**< message key */
242 #define KEY_MOVE 0556 /**< move key */
243 #define KEY_NEXT 0557 /**< next key */
244 #define KEY_OPEN 0560 /**< open key */
245 #define KEY_OPTIONS 0561 /**< options key */
246 #define KEY_PREVIOUS 0562 /**< previous key */
247 #define KEY_REDO 0563 /**< redo key */
248 #define KEY_REFERENCE 0564 /**< reference key */
249 #define KEY_REFRESH 0565 /**< refresh key */
250 #define KEY_REPLACE 0566 /**< replace key */
251 #define KEY_RESTART 0567 /**< restart key */
252 #define KEY_RESUME 0570 /**< resume key */
253 #define KEY_SAVE 0571 /**< save key */
254 #define KEY_SBEG 0572 /**< shifted begin key */
255 #define KEY_SCANCEL 0573 /**< shifted cancel key */
256 #define KEY_SCOMMAND 0574 /**< shifted command key */
257 #define KEY_SCOPY 0575 /**< shifted copy key */
258 #define KEY_SCREATE 0576 /**< shifted create key */
259 #define KEY_SDC 0577 /**< shifted delete-character key */
260 #define KEY_SDL 0600 /**< shifted delete-line key */
261 #define KEY_SELECT 0601 /**< select key */
262 #define KEY_SEND 0602 /**< shifted end key */
263 #define KEY_SEOL 0603 /**< shifted clear-to-end-of-line key */
264 #define KEY_SEXIT 0604 /**< shifted exit key */
265 #define KEY_SFIND 0605 /**< shifted find key */
266 #define KEY_SHELP 0606 /**< shifted help key */
267 #define KEY_SHOME 0607 /**< shifted home key */
268 #define KEY_SIC 0610 /**< shifted insert-character key */
269 #define KEY_SLEFT 0611 /**< shifted left-arrow key */
270 #define KEY_SMESSAGE 0612 /**< shifted message key */
271 #define KEY_SMOVE 0613 /**< shifted move key */
272 #define KEY_SNEXT 0614 /**< shifted next key */
273 #define KEY_SOPTIONS 0615 /**< shifted options key */
274 #define KEY_SPREVIOUS 0616 /**< shifted previous key */
275 #define KEY_SPRINT 0617 /**< shifted print key */
276 #define KEY_SREDO 0620 /**< shifted redo key */
277 #define KEY_SREPLACE 0621 /**< shifted replace key */
278 #define KEY_SRIGHT 0622 /**< shifted right-arrow key */
279 #define KEY_SRSUME 0623 /**< shifted resume key */
280 #define KEY_SSAVE 0624 /**< shifted save key */
281 #define KEY_SSUSPEND 0625 /**< shifted suspend key */
282 #define KEY_SUNDO 0626 /**< shifted undo key */
283 #define KEY_SUSPEND 0627 /**< suspend key */
284 #define KEY_UNDO 0630 /**< undo key */
285 #define KEY_RESIZE 0632 /**< Terminal resize event */
286 #define KEY_EVENT 0633 /**< We were interrupted by an event */
288 #define KEY_MAX 0777 /* Maximum key value is 0633 */
290 //extern int addch ( const chtype * );
291 //extern int addchnstr ( const chtype *, int );
292 //extern int addchstr ( const chtype * );
293 //extern int addnstr ( const char *, int );
294 //extern int addstr ( const char * );
295 //extern int attroff ( int );
296 //extern int attron ( int );
297 //extern int attrset ( int );
298 //extern int attr_get ( attr_t *, short *, void * );
299 //extern int attr_off ( attr_t, void * );
300 //extern int attr_on ( attr_t, void * );
301 //extern int attr_set ( attr_t, short, void * );
302 extern int baudrate ( void );
303 extern int beep ( void );
304 //extern void bkgdset ( chtype );
305 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
307 extern int box ( WINDOW *, chtype, chtype );
308 //extern bool can_change_colour ( void );
309 #define can_change_color() can_change_colour()
310 extern int cbreak ( void );
311 //extern int clrtobot ( void );
312 //extern int clrtoeol ( void );
313 extern int colour_content ( short, short *, short *, short * );
314 #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
315 //extern int colour_set ( short, void * );
316 #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
317 extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
318 int, int, int, int );
319 extern int curs_set ( int );
320 extern int def_prog_mode ( void );
321 extern int def_shell_mode ( void );
322 extern int delay_output ( int );
323 //extern int delch ( void );
324 //extern int deleteln ( void );
325 extern void delscreen ( SCREEN * );
326 extern int delwin ( WINDOW * );
327 extern WINDOW *derwin ( WINDOW *, int, int, int, int );
328 //extern int doupdate ( void );
329 extern WINDOW *dupwin ( WINDOW * );
330 extern int echo ( void );
331 extern int echochar ( const chtype );
332 extern int endwin ( void );
333 extern char erasechar ( void );
334 //extern int erase ( void );
335 extern void filter ( void );
336 extern int flash ( void );
337 extern int flushinp ( void );
338 extern chtype getbkgd ( WINDOW * );
339 //extern int getch ( void );
340 //extern int getnstr ( char *, int );
341 //extern int getstr ( char * );
342 extern int halfdelay ( int );
343 //extern bool has_colors ( void );
344 extern bool has_ic ( void );
345 extern bool has_il ( void );
346 //extern int hline ( chtype, int );
347 extern void idcok ( WINDOW *, bool );
348 extern int idlok ( WINDOW *, bool );
349 //extern void immedok ( WINDOW *, bool );
350 //extern chtype inch ( void );
351 //extern int inchnstr ( chtype *, int );
352 //extern int inchstr ( chtype * );
353 extern WINDOW *initscr ( void );
354 extern int init_colour ( short, short, short, short );
355 #define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
356 extern int init_pair ( short, short, short );
357 //extern int innstr ( char *, int );
358 //extern int insch ( chtype );
359 //extern int insnstr ( const char *, int );
360 //extern int insstr ( const char * );
361 //extern int instr ( char * );
362 extern int intrflush ( WINDOW *, bool );
363 extern bool isendwin ( void );
364 //extern bool is_linetouched ( WINDOW *, int );
365 //extern bool is_wintouched ( WINDOW * );
366 extern char *keyname ( int );
367 extern int keypad ( WINDOW *, bool );
368 extern char killchar ( void );
369 extern int leaveok ( WINDOW *, bool );
370 extern char *longname ( void );
371 extern int meta ( WINDOW *, bool );
372 //extern int move ( int, int );
373 //extern int mvaddch ( int, int, const chtype );
374 //extern int mvaddchnstr ( int, int, const chtype *, int );
375 //extern int mvaddchstr ( int, int, const chtype * );
376 //extern int mvaddnstr ( int, int, const char *, int );
377 //extern int mvaddstr ( int, int, const char * );
378 extern int mvcur ( int, int, int, int );
379 //extern int mvdelch ( int, int );
380 extern int mvderwin ( WINDOW *, int, int );
381 //extern int mvgetch ( int, int );
382 //extern int mvgetnstr ( int, int, char *, int );
383 //extern int mvgetstr ( int, int, char * );
384 //extern int mvhline ( int, int, chtype, int );
385 //extern chtype mvinch ( int, int );
386 //extern int mvinchnstr ( int, int, chtype *, int );
387 //extern int mvinchstr ( int, int, chtype * );
388 //extern int mvinnstr ( int, int, char *, int );
389 //extern int mvinsch ( int, int, chtype );
390 //extern int mvinsnstr ( int, int, const char *, int );
391 //extern int mvinsstr ( int, int, const char * );
392 //extern int mvinstr ( int, int, char * );
393 //extern int mvprintw ( int, int, char *, ... );
394 //extern int mvscanw ( int, int, char *, ... );
395 //extern int mvvline ( int, int, chtype, int );
396 //extern int mvwaddch ( WINDOW *, int, int, const chtype );
397 //extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );
398 //extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );
399 //extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );
400 //extern int mvwaddstr ( WINDOW *, int, int, const char * );
401 //extern int mvwdelch ( WINDOW *, int, int );
402 //extern int mvwgetch ( WINDOW *, int, int );
403 //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
404 //extern int mvwgetstr ( WINDOW *, int, int, char * );
405 //extern int mvwhline ( WINDOW *, int, int, chtype, int );
406 extern int mvwin ( WINDOW *, int, int );
407 //extern chtype mvwinch ( WINDOW *, int, int );
408 //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
409 //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
410 //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
411 //extern int mvwinsch ( WINDOW *, int, int, chtype );
412 //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
413 //extern int mvwinsstr ( WINDOW *, int, int, const char * );
414 //extern int mvwinstr ( WINDOW *, int, int, char * );
415 //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
416 //extern int mvwscanw ( WINDOW *, int, int, char *, ... );
417 //extern int mvwvline ( WINDOW *, int, int, chtype, int );
418 extern int napms ( int );
419 //extern WINDOW *newpad ( int, int );
420 extern WINDOW *newwin ( int, int, int, int );
421 extern int nl ( void );
422 extern int nocbreak ( void );
423 extern int nodelay ( WINDOW *, bool );
424 extern int noecho ( void );
425 extern int nonl ( void );
426 extern void noqiflush ( void );
427 extern int noraw ( void );
428 extern int notimeout ( WINDOW *, bool );
429 extern int overlay ( const WINDOW *, WINDOW * );
430 extern int overwrite ( const WINDOW *, WINDOW * );
431 extern int pair_content ( short, short *, short * );
432 //extern int pechochar ( WINDOW *, chtype );
433 //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
434 //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
435 extern int printw ( char *, ... );
436 extern int putp ( const char * );
437 extern void qiflush ( void );
438 extern int raw ( void );
439 //extern int redrawwin ( WINDOW * );
440 //extern int refresh ( void );
441 extern int reset_prog_mode ( void );
442 extern int reset_shell_mode ( void );
443 extern int resetty ( void );
444 extern int ripoffline ( int, int (*) ( WINDOW *, int) );
445 extern int savetty ( void );
446 //extern int scanw ( char *, ... );
447 //extern int scrl ( int );
448 //extern int scroll ( WINDOW * );
449 //extern int scrollok ( WINDOW *, bool );
450 //extern int setscrreg ( int, int );
451 extern SCREEN *set_term ( SCREEN * );
452 extern int setupterm ( char *, int, int * );
453 extern int slk_attr_off ( const attr_t, void * );
454 extern int slk_attroff ( const chtype );
455 extern int slk_attr_on ( const attr_t, void * );
456 extern int slk_attron ( const chtype );
457 extern int slk_attr_set ( const attr_t, short, void * );
458 extern int slk_attrset ( const chtype );
459 extern int slk_clear ( void );
460 extern int slk_colour ( short );
461 #define slk_color( c ) slk_colour( (c) )
462 extern int slk_init ( int );
463 extern char *slk_label ( int );
464 extern int slk_noutrefresh ( void );
465 //extern int slk_refresh ( void );
466 extern int slk_restore ( void );
467 extern int slk_set ( int, const char *, int );
468 extern int slk_touch ( void );
469 extern int standend ( void );
470 extern int standout ( void );
471 //extern int start_colour ( void );
472 #define start_color() start_colour()
473 //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
474 extern WINDOW *subwin ( WINDOW *, int, int, int, int );
475 extern int syncok ( WINDOW *, bool );
476 extern chtype termattrs ( void );
477 extern attr_t term_attrs ( void );
478 extern char *termname ( void );
479 extern int tigetflag ( char * );
480 extern int tigetnum ( char * );
481 extern char *tigetstr ( char * );
482 extern void timeout ( int );
483 //extern int touchline ( WINDOW *, int, int );
484 //extern int touchwin ( WINDOW * );
485 extern char *tparm ( char *, long, long, long, long, long, long, long, long,
487 extern int typeahead ( int );
488 //extern int ungetch ( int );
489 //extern int untouchwin ( WINDOW * );
490 extern void use_env ( bool );
491 extern int vid_attr ( attr_t, short, void * );
492 extern int vidattr ( chtype );
493 extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
494 extern int vidputs ( chtype, int ( *) ( int) );
495 //extern int vline ( chtype, int );
496 //extern int vwprintw ( WINDOW *, const char *, va_list );
497 extern int vw_printw ( WINDOW *, const char *, va_list );
498 //extern int vwscanw ( WINDOW *, char *, va_list );
499 //extern int vw_scanw ( WINDOW *, char *, va_list );
500 extern int waddch ( WINDOW *, const chtype );
501 extern int waddchnstr ( WINDOW *, const chtype *, int );
502 //extern int waddchstr ( WINDOW *, const chtype * );
503 extern int waddnstr ( WINDOW *, const char *, int );
504 //extern int waddstr ( WINDOW *, const char * );
505 extern int wattroff ( WINDOW *, int );
506 extern int wattron ( WINDOW *, int );
507 extern int wattrset ( WINDOW *, int );
508 extern int wattr_get ( WINDOW *, attr_t *, short *, void * );
509 extern int wattr_off ( WINDOW *, attr_t, void * );
510 extern int wattr_on ( WINDOW *, attr_t, void * );
511 extern int wattr_set ( WINDOW *, attr_t, short, void * );
512 //extern void wbkgdset ( WINDOW *, chtype );
513 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
515 extern int wclrtobot ( WINDOW * );
516 extern int wclrtoeol ( WINDOW * );
517 extern void wcursyncup ( WINDOW * );
518 extern int wcolour_set ( WINDOW *, short, void * );
519 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
520 extern int wdelch ( WINDOW * );
521 extern int wdeleteln ( WINDOW * );
522 extern int wechochar ( WINDOW *, const chtype );
523 extern int werase ( WINDOW * );
524 extern int wgetch ( WINDOW * );
525 extern int wgetnstr ( WINDOW *, char *, int );
526 //extern int wgetstr ( WINDOW *, char * );
527 extern int whline ( WINDOW *, chtype, int );
528 //extern chtype winch ( WINDOW * );
529 //extern int winchnstr ( WINDOW *, chtype *, int );
530 //extern int winchstr ( WINDOW *, chtype * );
531 //extern int winnstr ( WINDOW *, char *, int );
532 //extern int winsch ( WINDOW *, chtype );
533 //extern int winsnstr ( WINDOW *, const char *, int );
534 //extern int winsstr ( WINDOW *, const char * );
535 //extern int winstr ( WINDOW *, char * );
536 extern int wmove ( WINDOW *, int, int );
537 //extern int wnoutrefresh ( WINDOW * );
538 extern int wprintw ( WINDOW *, const char *, ... );
539 //extern int wredrawln ( WINDOW *, int, int );
540 //extern int wrefresh ( WINDOW * );
541 //extern int wscanw ( WINDOW *, char *, ... );
542 //extern int wscrl ( WINDOW *, int );
543 //extern int wsetscrreg ( WINDOW *, int, int );
544 //extern int wstandend ( WINDOW * );
545 //extern int wstandout ( WINDOW * );
546 extern void wsyncup ( WINDOW * );
547 extern void wsyncdown ( WINDOW * );
548 extern void wtimeout ( WINDOW *, int );
549 //extern int wtouchln ( WINDOW *, int, int, int );
550 extern int wvline ( WINDOW *, chtype, int );
553 * There is frankly a ridiculous amount of redundancy within the
554 * curses API - ncurses decided to get around this by using #define
555 * macros, but I've decided to be type-safe and implement them all as
556 * static inlines instead...
559 static inline int addch ( const chtype ch ) {
560 return waddch( stdscr, ch );
563 static inline int addchnstr ( const chtype *chstr, int n ) {
564 return waddchnstr ( stdscr, chstr, n );
567 static inline int addchstr ( const chtype *chstr ) {
568 return waddchnstr ( stdscr, chstr, -1 );
571 static inline int addnstr ( const char *str, int n ) {
572 return waddnstr ( stdscr, str, n );
575 static inline int addstr ( const char *str ) {
576 return waddnstr ( stdscr, str, -1 );
579 static inline int attroff ( int attrs ) {
580 return wattroff ( stdscr, attrs );
583 static inline int attron ( int attrs ) {
584 return wattron ( stdscr, attrs );
587 static inline int attrset ( int attrs ) {
588 return wattrset ( stdscr, attrs );
591 static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
592 return wattr_get ( stdscr, attrs, pair, opts );
595 static inline int attr_off ( attr_t attrs, void *opts ) {
596 return wattr_off ( stdscr, attrs, opts );
599 static inline int attr_on ( attr_t attrs, void *opts ) {
600 return wattr_on ( stdscr, attrs, opts );
603 static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
604 return wattr_set ( stdscr, attrs, cpair, opts );
607 static inline void bkgdset ( chtype ch ) {
608 wattrset ( stdscr, ch );
611 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
612 chtype tl, chtype tr, chtype bl, chtype br ) {
613 return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
616 static inline bool can_change_colour ( void ) {
620 static inline int clrtobot ( void ) {
621 return wclrtobot( stdscr );
624 static inline int clrtoeol ( void ) {
625 return wclrtoeol( stdscr );
628 static inline int colour_set ( short colour_pair_number, void *opts ) {
629 return wcolour_set ( stdscr, colour_pair_number, opts );
632 static inline int delch ( void ) {
633 return wdelch ( stdscr );
636 static inline int deleteln ( void ) {
637 return wdeleteln( stdscr );
640 static inline int erase ( void ) {
641 return werase ( stdscr );
644 static inline int getch ( void ) {
645 return wgetch ( stdscr );
648 static inline int getnstr ( char *str, int n ) {
649 return wgetnstr ( stdscr, str, n );
652 static inline int getstr ( char *str ) {
653 return wgetnstr ( stdscr, str, -1 );
656 static inline bool has_colors ( void ) {
660 static inline int hline ( chtype ch, int n ) {
661 return whline ( stdscr, ch, n );
664 static inline int move ( int y, int x ) {
665 return wmove ( stdscr, y, x );
668 static inline int mvaddch ( int y, int x, const chtype ch ) {
669 return ( wmove ( stdscr, y, x ) == OK
670 ? waddch( stdscr, ch ) : ERR );
673 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
674 return ( wmove ( stdscr, y, x ) == OK
675 ? waddchnstr ( stdscr, chstr, n ) : ERR );
678 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
679 return ( wmove ( stdscr, y, x ) == OK
680 ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
683 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
684 return ( wmove ( stdscr, y, x ) == OK
685 ? waddnstr ( stdscr, str, n ) : ERR );
688 static inline int mvaddstr ( int y, int x, const char *str ) {
689 return ( wmove ( stdscr, y, x ) == OK
690 ? waddnstr ( stdscr, str, -1 ) : ERR );
693 static inline int mvdelch ( int y, int x ) {
694 return ( wmove ( stdscr, y, x ) == OK
695 ? wdelch ( stdscr ) : ERR );
698 static inline int mvgetch ( int y, int x ) {
699 return ( wmove ( stdscr, y, x ) == OK
700 ? wgetch ( stdscr ) : ERR );
703 static inline int mvgetnstr ( int y, int x, char *str, int n ) {
704 return ( wmove ( stdscr, y, x ) == OK
705 ? wgetnstr ( stdscr, str, n ) : ERR );
708 static inline int mvgetstr ( int y, int x, char *str ) {
709 return ( wmove ( stdscr, y, x ) == OK
710 ? wgetnstr ( stdscr, str, -1 ) : ERR );
713 static inline int mvhline ( int y, int x, chtype ch, int n ) {
714 return ( wmove ( stdscr, y, x ) == OK
715 ? whline ( stdscr, ch, n ) : ERR );
718 // OK, so maybe a few I did with macros...
719 #define mvprintw( y, x, fmt, ... ) \
720 ( wmove(stdscr,(y),(x)) == OK \
721 ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
723 static inline int mvvline ( int y, int x, chtype ch, int n ) {
724 return ( wmove ( stdscr, y, x ) == OK
725 ? wvline ( stdscr, ch, n ) : ERR );
728 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
729 return ( wmove( win, y, x ) == OK
730 ? waddch ( win, ch ) : ERR );
733 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
734 return ( wmove ( win, y, x ) == OK
735 ? waddchnstr ( win, chstr, n ) : ERR );
738 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
739 return ( wmove ( win, y, x ) == OK
740 ? waddchnstr ( win, chstr, -1 ) : ERR );
743 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
744 return ( wmove ( win, y, x ) == OK
745 ? waddnstr ( win, str, n ) : ERR );
748 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
749 return ( wmove ( win, y, x ) == OK
750 ? waddnstr ( win, str, -1 ) : ERR );
753 static inline int mvwdelch ( WINDOW *win, int y, int x ) {
754 return ( wmove ( win, y, x ) == OK
755 ? wdelch ( win ) : ERR );
758 static inline int mvwgetch ( WINDOW *win, int y, int x ) {
759 return ( wmove ( win, y, x ) == OK
760 ? wgetch ( win ) : ERR );
763 static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
764 return ( wmove ( win, y, x ) == OK
765 ? wgetnstr ( win, str, n ) : ERR );
768 static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
769 return ( wmove ( win, y, x ) == OK
770 ? wgetnstr ( win, str, -1 ) : ERR );
773 static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
774 return ( wmove ( win, y, x ) == OK
775 ? whline ( win, ch, n ) : ERR );
778 #define mvwprintw( win, y, x, fmt, ... ) \
779 ( wmove((win),(y),(x)) == OK \
780 ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
782 static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
783 return ( wmove ( win, y, x ) == OK
784 ? wvline ( win, ch, n ) : ERR );
787 #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
789 static inline int slk_refresh ( void ) {
790 if ( slk_clear() == OK )
791 return slk_restore();
796 #define standend() wstandend( stdscr )
797 #define standout() wstandout( stdscr )
799 static inline int start_colour ( void ) {
803 static inline int vline ( chtype ch, int n ) {
804 return wvline ( stdscr, ch, n );
807 // marked for removal
808 static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
809 return vw_printw ( win, fmt, varglist );
812 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
813 return waddchnstr ( win, chstr, -1 );
816 static inline int waddstr ( WINDOW *win, const char *str ) {
817 return waddnstr ( win, str, -1 );
820 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
821 return wattrset( win, ch );
824 static inline int wgetstr ( WINDOW *win, char *str ) {
825 return wgetnstr ( win, str, -1 );
828 static inline int wstandend ( WINDOW *win ) {
829 return wattrset ( win, A_DEFAULT );
832 static inline int wstandout ( WINDOW *win ) {
833 return wattrset ( win, A_STANDOUT );
836 #endif /* CURSES_H */