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