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