25 typedef uint32_t bool;
26 typedef uint32_t chtype;
27 typedef chtype attr_t;
29 /** Curses SCREEN object */
30 typedef struct _curses_screen {
32 * Move cursor to position specified by x,y coords
34 * @v scr screen on which to operate
38 void ( * movetoyx ) ( struct _curses_screen *scr,
39 unsigned int y, unsigned int x );
41 * Write character to current cursor position
43 * @v scr screen on which to operate
44 * @v c character to be written
46 void ( * putc ) ( struct _curses_screen *scr, chtype c );
50 * @v scr screen on which to operate
53 int ( * getc ) ( struct _curses_screen *scr );
56 /** Curses Window struct */
57 typedef struct _curses_window {
58 /** screen with which window associates */
60 /** window attributes */
62 /** window origin coordinates */
63 unsigned int ori_x, ori_y;
64 /** window cursor position */
65 unsigned int curs_x, curs_y;
66 /** window dimensions */
67 unsigned int width, height;
70 extern WINDOW _stdscr;
71 #define stdscr ( &_stdscr )
73 #define MUCURSES_ATTR_SHIFT 16
74 #define MUCURSES_BITS( mask, shift ) (( mask ) << (( shift ) + MUCURSES_ATTR_SHIFT ))
76 #define A_DEFAULT ( 1UL - 1UL )
77 #define A_ALTCHARSET MUCURSES_BITS( 1UL, 0 )
78 #define A_BLINK MUCURSES_BITS( 1UL, 1 )
79 #define A_BOLD MUCURSES_BITS( 1UL, 2 )
80 #define A_DIM MUCURSES_BITS( 1UL, 3 )
81 #define A_INVIS MUCURSES_BITS( 1UL, 4 )
82 #define A_PROTECT MUCURSES_BITS( 1UL, 5 )
83 #define A_REVERSE MUCURSES_BITS( 1UL, 6 )
84 #define A_STANDOUT MUCURSES_BITS( 1UL, 7 )
85 #define A_UNDERLINE MUCURSES_BITS( 1UL, 8 )
87 #define WA_ALTCHARSET A_ALTCHARSET
88 #define WA_BLINK A_BLINK
89 #define WA_BOLD A_BOLD
91 #define WA_INVIS A_INVIS
92 #define WA_PROTECT A_PROTECT
93 #define WA_REVERSE A_REVERSE
94 #define WA_STANDOUT A_STANDOUT
95 #define WA_UNDERLINE A_UNDERLINE
96 #define WA_HORIZONTAL MUCURSES_BITS( 1UL, 9 )
97 #define WA_VERTICAL MUCURSES_BITS( 1UL, 10 )
98 #define WA_LEFT MUCURSES_BITS( 1UL, 11 )
99 #define WA_RIGHT MUCURSES_BITS( 1UL, 12 )
100 #define WA_LOW MUCURSES_BITS( 1UL, 13 )
101 #define WA_TOP MUCURSES_BITS( 1UL, 14 )
103 #define A_ATTRIBUTES MUCURSES_BITS( ~( 1UL - 1UL ), 0 )
104 #define A_CHARTEXT ( MUCURSES_BITS( 1UL, 0 ) - 1UL )
105 #define A_COLOR MUCURSES_BITS( ( 1UL << 8 ) - 1UL, 0 )
107 #define ACS_ULCORNER '+'
108 #define ACS_LLCORNER '+'
109 #define ACS_URCORNER '+'
110 #define ACS_LRCORNER '+'
115 #define ACS_HLINE '-'
116 #define ACS_VLINE '|'
120 #define ACS_DIAMOND '+'
121 #define ACS_CKBOARD ':'
122 #define ACS_DEGREE '\''
123 #define ACS_PLMINUS '#'
124 #define ACS_BULLET 'o'
125 #define ACS_LARROW '<'
126 #define ACS_RARROW '>'
127 #define ACS_DARROW 'v'
128 #define ACS_UARROW '^'
129 #define ACS_BOARD '#'
130 #define ACS_LANTERN '#'
131 #define ACS_BLOCK '#'
133 #define COLOUR_BLACK 0
134 #define COLOUR_BLUE 1
135 #define COLOUR_GREEN 2
136 #define COLOUR_CYAN 3
138 #define COLOUR_MAGENTA 5
139 #define COLOUR_YELLOW 6
140 #define COLOUR_WHITE 7
142 #define COLOR_BLACK COLOUR_BLACK
143 #define COLOR_BLUE COLOUR_BLUE
144 #define COLOR_GREEN COLOUR_GREEN
145 #define COLOR_CYAN COLOUR_CYAN
146 #define COLOR_RED COLOUR_RED
147 #define COLOR_MAGENTA COLOUR_MAGENTA
148 #define COLOR_YELLOW COLOUR_YELLOW
149 #define COLOR_WHITE COLOUR_WHITE
154 #define KEY_BREAK 0401 /**< Break key */
155 #define KEY_DOWN 0402 /**< down-arrow key */
156 #define KEY_UP 0403 /**< up-arrow key */
157 #define KEY_LEFT 0404 /**< left-arrow key */
158 #define KEY_RIGHT 0405 /**< right-arrow key */
159 #define KEY_HOME 0406 /**< home key */
160 #define KEY_BACKSPACE 0407 /**< backspace key */
161 #define KEY_F0 0410 /**< Function keys. Space for 64 */
162 #define KEY_F(n) (KEY_F0+(n)) /**< Value of function key n */
163 #define KEY_DL 0510 /**< delete-line key */
164 #define KEY_IL 0511 /**< insert-line key */
165 #define KEY_DC 0512 /**< delete-character key */
166 #define KEY_IC 0513 /**< insert-character key */
167 #define KEY_EIC 0514 /**< sent by rmir or smir in insert mode */
168 #define KEY_CLEAR 0515 /**< clear-screen or erase key */
169 #define KEY_EOS 0516 /**< clear-to-end-of-screen key */
170 #define KEY_EOL 0517 /**< clear-to-end-of-line key */
171 #define KEY_SF 0520 /**< scroll-forward key */
172 #define KEY_SR 0521 /**< scroll-backward key */
173 #define KEY_NPAGE 0522 /**< next-page key */
174 #define KEY_PPAGE 0523 /**< previous-page key */
175 #define KEY_STAB 0524 /**< set-tab key */
176 #define KEY_CTAB 0525 /**< clear-tab key */
177 #define KEY_CATAB 0526 /**< clear-all-tabs key */
178 #define KEY_ENTER 0527 /**< enter/send key */
179 #define KEY_PRINT 0532 /**< print key */
180 #define KEY_LL 0533 /**< lower-left key (home down) */
181 #define KEY_A1 0534 /**< upper left of keypad */
182 #define KEY_A3 0535 /**< upper right of keypad */
183 #define KEY_B2 0536 /**< center of keypad */
184 #define KEY_C1 0537 /**< lower left of keypad */
185 #define KEY_C3 0540 /**< lower right of keypad */
186 #define KEY_BTAB 0541 /**< back-tab key */
187 #define KEY_BEG 0542 /**< begin key */
188 #define KEY_CANCEL 0543 /**< cancel key */
189 #define KEY_CLOSE 0544 /**< close key */
190 #define KEY_COMMAND 0545 /**< command key */
191 #define KEY_COPY 0546 /**< copy key */
192 #define KEY_CREATE 0547 /**< create key */
193 #define KEY_END 0550 /**< end key */
194 #define KEY_EXIT 0551 /**< exit key */
195 #define KEY_FIND 0552 /**< find key */
196 #define KEY_HELP 0553 /**< help key */
197 #define KEY_MARK 0554 /**< mark key */
198 #define KEY_MESSAGE 0555 /**< message key */
199 #define KEY_MOVE 0556 /**< move key */
200 #define KEY_NEXT 0557 /**< next key */
201 #define KEY_OPEN 0560 /**< open key */
202 #define KEY_OPTIONS 0561 /**< options key */
203 #define KEY_PREVIOUS 0562 /**< previous key */
204 #define KEY_REDO 0563 /**< redo key */
205 #define KEY_REFERENCE 0564 /**< reference key */
206 #define KEY_REFRESH 0565 /**< refresh key */
207 #define KEY_REPLACE 0566 /**< replace key */
208 #define KEY_RESTART 0567 /**< restart key */
209 #define KEY_RESUME 0570 /**< resume key */
210 #define KEY_SAVE 0571 /**< save key */
211 #define KEY_SBEG 0572 /**< shifted begin key */
212 #define KEY_SCANCEL 0573 /**< shifted cancel key */
213 #define KEY_SCOMMAND 0574 /**< shifted command key */
214 #define KEY_SCOPY 0575 /**< shifted copy key */
215 #define KEY_SCREATE 0576 /**< shifted create key */
216 #define KEY_SDC 0577 /**< shifted delete-character key */
217 #define KEY_SDL 0600 /**< shifted delete-line key */
218 #define KEY_SELECT 0601 /**< select key */
219 #define KEY_SEND 0602 /**< shifted end key */
220 #define KEY_SEOL 0603 /**< shifted clear-to-end-of-line key */
221 #define KEY_SEXIT 0604 /**< shifted exit key */
222 #define KEY_SFIND 0605 /**< shifted find key */
223 #define KEY_SHELP 0606 /**< shifted help key */
224 #define KEY_SHOME 0607 /**< shifted home key */
225 #define KEY_SIC 0610 /**< shifted insert-character key */
226 #define KEY_SLEFT 0611 /**< shifted left-arrow key */
227 #define KEY_SMESSAGE 0612 /**< shifted message key */
228 #define KEY_SMOVE 0613 /**< shifted move key */
229 #define KEY_SNEXT 0614 /**< shifted next key */
230 #define KEY_SOPTIONS 0615 /**< shifted options key */
231 #define KEY_SPREVIOUS 0616 /**< shifted previous key */
232 #define KEY_SPRINT 0617 /**< shifted print key */
233 #define KEY_SREDO 0620 /**< shifted redo key */
234 #define KEY_SREPLACE 0621 /**< shifted replace key */
235 #define KEY_SRIGHT 0622 /**< shifted right-arrow key */
236 #define KEY_SRSUME 0623 /**< shifted resume key */
237 #define KEY_SSAVE 0624 /**< shifted save key */
238 #define KEY_SSUSPEND 0625 /**< shifted suspend key */
239 #define KEY_SUNDO 0626 /**< shifted undo key */
240 #define KEY_SUSPEND 0627 /**< suspend key */
241 #define KEY_UNDO 0630 /**< undo key */
242 #define KEY_RESIZE 0632 /**< Terminal resize event */
243 #define KEY_EVENT 0633 /**< We were interrupted by an event */
245 #define KEY_MAX 0777 /* Maximum key value is 0633 */
247 /*extern int addch ( const chtype * );*/
248 /*extern int addchnstr ( const chtype *, int );*/
249 /*extern int addchstr ( const chtype * );*/
250 /*extern int addnstr ( const char *, int );*/
251 /*extern int addstr ( const char * );*/
252 /*extern int attroff ( int );*/
253 /*extern int attron ( int );*/
254 /*extern int attrset ( int );*/
255 extern int attr_get ( attr_t *, short *, void * );
256 extern int attr_off ( attr_t, void * );
257 extern int attr_on ( attr_t, void * );
258 extern int attr_set ( attr_t, short, void * );
259 extern int baudrate ( void );
260 extern int beep ( void );
261 /*extern int bkgd ( chtype );*/
262 /*extern void bkgdset ( chtype );*/
263 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
265 extern int box ( WINDOW *, chtype, chtype );
266 extern bool can_change_colour ( void );
267 #define can_change_color() can_change_colour()
268 extern int cbreak ( void );
269 extern int chgat ( int, attr_t, short, const void * );
270 extern int clearok ( WINDOW *, bool );
271 extern int clear ( void );
272 extern int clrtobot ( void );
273 extern int clrtoeol ( void );
274 extern int colour_content ( short, short *, short *, short * );
275 #define color_content( col, r, g, b ) colour_content( (col), (r), (g), (b) )
276 extern int colour_set ( short, void * );
277 #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
278 extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
279 int, int, int, int );
280 extern int curs_set ( int );
281 extern int def_prog_mode ( void );
282 extern int def_shell_mode ( void );
283 extern int delay_output ( int );
284 extern int delch ( void );
285 extern int deleteln ( void );
286 extern void delscreen ( SCREEN * );
287 extern int delwin ( WINDOW * );
288 extern WINDOW *derwin ( WINDOW *, int, int, int, int );
289 extern int doupdate ( void );
290 extern WINDOW *dupwin ( WINDOW * );
291 extern int echo ( void );
292 extern int echochar ( const chtype );
293 extern int endwin ( void );
294 extern char erasechar ( void );
295 extern int erase ( void );
296 extern void filter ( void );
297 extern int flash ( void );
298 extern int flushinp ( void );
299 extern chtype getbkgd ( WINDOW * );
300 extern int getch ( void );
301 extern int getnstr ( char *, int );
302 extern int getstr ( char * );
303 extern int halfdelay ( int );
304 extern bool has_colors ( void );
305 extern bool has_ic ( void );
306 extern bool has_il ( void );
307 extern int hline ( chtype, int );
308 extern void idcok ( WINDOW *, bool );
309 extern int idlok ( WINDOW *, bool );
310 extern void immedok ( WINDOW *, bool );
311 extern chtype inch ( void );
312 extern int inchnstr ( chtype *, int );
313 extern int inchstr ( chtype * );
314 extern WINDOW *initscr ( void );
315 extern int init_color ( short, short, short, short );
316 extern int init_pair ( short, short, short );
317 extern int innstr ( char *, int );
318 extern int insch ( chtype );
319 extern int insdelln ( int );
320 extern int insertln ( void );
321 extern int insnstr ( const char *, int );
322 extern int insstr ( const char * );
323 extern int instr ( char * );
324 extern int intrflush ( WINDOW *, bool );
325 extern bool isendwin ( void );
326 extern bool is_linetouched ( WINDOW *, int );
327 extern bool is_wintouched ( WINDOW * );
328 extern char *keyname ( int );
329 extern int keypad ( WINDOW *, bool );
330 extern char killchar ( void );
331 extern int leaveok ( WINDOW *, bool );
332 extern char *longname ( void );
333 extern int meta ( WINDOW *, bool );
334 /*extern int move ( int, int );*/
335 /*extern int mvaddch ( int, int, const chtype );*/
336 /*extern int mvaddchnstr ( int, int, const chtype *, int );*/
337 /*extern int mvaddchstr ( int, int, const chtype * );*/
338 /*extern int mvaddnstr ( int, int, const char *, int );*/
339 /*extern int mvaddstr ( int, int, const char * );*/
340 extern int mvchgat ( int, int, int, attr_t, short, const void * );
341 extern int mvcur ( int, int, int, int );
342 extern int mvdelch ( int, int );
343 extern int mvderwin ( WINDOW *, int, int );
344 extern int mvgetch ( int, int );
345 extern int mvgetnstr ( int, int, char *, int );
346 extern int mvgetstr ( int, int, char * );
347 extern int mvhline ( int, int, chtype, int );
348 extern chtype mvinch ( int, int );
349 extern int mvinchnstr ( int, int, chtype *, int );
350 extern int mvinchstr ( int, int, chtype * );
351 extern int mvinnstr ( int, int, char *, int );
352 extern int mvinsch ( int, int, chtype );
353 extern int mvinsnstr ( int, int, const char *, int );
354 extern int mvinsstr ( int, int, const char * );
355 extern int mvinstr ( int, int, char * );
356 extern int mvprintw ( int, int, char *, ... );
357 extern int mvscanw ( int, int, char *, ... );
358 extern int mvvline ( int, int, chtype, int );
359 /*extern int mvwaddch ( WINDOW *, int, int, const chtype );*/
360 /*extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );*/
361 /*extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );*/
362 /*extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );*/
363 /*extern int mvwaddstr ( WINDOW *, int, int, const char * );*/
364 extern int mvwchgat ( WINDOW *, int, int, int, attr_t, short, const void * );
365 extern int mvwdelch ( WINDOW *, int, int );
366 extern int mvwgetch ( WINDOW *, int, int );
367 extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
368 extern int mvwgetstr ( WINDOW *, int, int, char * );
369 extern int mvwhline ( WINDOW *, int, int, chtype, int );
370 extern int mvwin ( WINDOW *, int, int );
371 extern chtype mvwinch ( WINDOW *, int, int );
372 extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
373 extern int mvwinchstr ( WINDOW *, int, int, chtype * );
374 extern int mvwinnstr ( WINDOW *, int, int, char *, int );
375 extern int mvwinsch ( WINDOW *, int, int, chtype );
376 extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
377 extern int mvwinsstr ( WINDOW *, int, int, const char * );
378 extern int mvwinstr ( WINDOW *, int, int, char * );
379 extern int mvwprintw ( WINDOW *, int, int, char *, ... );
380 extern int mvwscanw ( WINDOW *, int, int, char *, ... );
381 extern int mvwvline ( WINDOW *, int, int, chtype, int );
382 extern int napms ( int );
383 extern WINDOW *newpad ( int, int );
384 extern WINDOW *newwin ( int, int, int, int );
385 extern int nl ( void );
386 extern int nocbreak ( void );
387 extern int nodelay ( WINDOW *, bool );
388 extern int noecho ( void );
389 extern int nonl ( void );
390 extern void noqiflush ( void );
391 extern int noraw ( void );
392 extern int notimeout ( WINDOW *, bool );
393 extern int overlay ( const WINDOW *, WINDOW * );
394 extern int overwrite ( const WINDOW *, WINDOW * );
395 extern int pair_content ( short, short *, short * );
396 extern int PAIR_NUMBER ( int );
397 extern int pechochar ( WINDOW *, chtype );
398 extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
399 extern int prefresh ( WINDOW *, int, int, int, int, int, int );
400 extern int printw ( char *, ... );
401 extern int putp ( const char * );
402 extern void qiflush ( void );
403 extern int raw ( void );
404 extern int redrawwin ( WINDOW * );
405 extern int refresh ( void );
406 extern int reset_prog_mode ( void );
407 extern int reset_shell_mode ( void );
408 extern int resetty ( void );
409 extern int ripoffline ( int, int ( *) ( WINDOW *, int) );
410 extern int savetty ( void );
411 extern int scanw ( char *, ... );
412 extern int scr_dump ( const char * );
413 extern int scr_init ( const char * );
414 extern int scrl ( int );
415 extern int scroll ( WINDOW * );
416 extern int scrollok ( WINDOW *, bool );
417 extern int scr_restore ( const char * );
418 extern int scr_set ( const char * );
419 extern int setscrreg ( int, int );
420 extern SCREEN *set_term ( SCREEN * );
421 extern int setupterm ( char *, int, int * );
422 extern int slk_attr_off ( const attr_t, void * );
423 extern int slk_attroff ( const chtype );
424 extern int slk_attr_on ( const attr_t, void * );
425 extern int slk_attron ( const chtype );
426 extern int slk_attr_set ( const attr_t, short, void * );
427 extern int slk_attrset ( const chtype );
428 extern int slk_clear ( void );
429 extern int slk_color ( short );
430 extern int slk_init ( int );
431 extern char *slk_label ( int );
432 extern int slk_noutrefresh ( void );
433 extern int slk_refresh ( void );
434 extern int slk_restore ( void );
435 extern int slk_set ( int, const char *, int );
436 extern int slk_touch ( void );
437 extern int standend ( void );
438 extern int standout ( void );
439 extern int start_color ( void );
440 extern WINDOW *subpad ( WINDOW *, int, int, int, int );
441 extern WINDOW *subwin ( WINDOW *, int, int, int, int );
442 extern int syncok ( WINDOW *, bool );
443 extern chtype termattrs ( void );
444 extern attr_t term_attrs ( void );
445 extern char *termname ( void );
446 extern int tigetflag ( char * );
447 extern int tigetnum ( char * );
448 extern char *tigetstr ( char * );
449 extern void timeout ( int );
450 extern int touchline ( WINDOW *, int, int );
451 extern int touchwin ( WINDOW * );
452 extern char *tparm ( char *, long, long, long, long, long, long, long, long,
454 extern int typeahead ( int );
455 extern int ungetch ( int );
456 extern int untouchwin ( WINDOW * );
457 extern void use_env ( bool );
458 extern int vid_attr ( attr_t, short, void * );
459 extern int vidattr ( chtype );
460 extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
461 extern int vidputs ( chtype, int ( *) ( int) );
462 extern int vline ( chtype, int );
463 extern int vwprintw ( WINDOW *, char *, va_list * );
464 extern int vw_printw ( WINDOW *, char *, va_list * );
465 extern int vwscanw ( WINDOW *, char *, va_list * );
466 extern int vw_scanw ( WINDOW *, char *, va_list * );
467 extern int waddch ( WINDOW *, const chtype );
468 extern int waddchnstr ( WINDOW *, const chtype *, int );
469 /*extern int waddchstr ( WINDOW *, const chtype * );*/
470 extern int waddnstr ( WINDOW *, const char *, int );
471 /*extern int waddstr ( WINDOW *, const char * );*/
472 extern int wattroff ( WINDOW *, int );
473 extern int wattron ( WINDOW *, int );
474 extern int wattrset ( WINDOW *, int );
475 extern int wattr_get ( WINDOW *, attr_t *, short *, void * );
476 extern int wattr_off ( WINDOW *, attr_t, void * );
477 extern int wattr_on ( WINDOW *, attr_t, void * );
478 extern int wattr_set ( WINDOW *, attr_t, short, void * );
479 extern int wbkgd ( WINDOW *, chtype );
480 /*extern void wbkgdset ( WINDOW *, chtype );*/
481 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
483 extern int wchgat ( WINDOW *, int, attr_t, short, const void * );
484 extern int wclear ( WINDOW * );
485 extern int wclrtobot ( WINDOW * );
486 extern int wclrtoeol ( WINDOW * );
487 extern void wcursyncup ( WINDOW * );
488 extern int wcolor_set ( WINDOW *, short, void * );
489 extern int wdelch ( WINDOW * );
490 extern int wdeleteln ( WINDOW * );
491 extern int wechochar ( WINDOW *, const chtype );
492 extern int werase ( WINDOW * );
493 extern int wgetch ( WINDOW * );
494 extern int wgetnstr ( WINDOW *, char *, int );
495 extern int wgetstr ( WINDOW *, char * );
496 extern int whline ( WINDOW *, chtype, int );
497 extern chtype winch ( WINDOW * );
498 extern int winchnstr ( WINDOW *, chtype *, int );
499 extern int winchstr ( WINDOW *, chtype * );
500 extern int winnstr ( WINDOW *, char *, int );
501 extern int winsch ( WINDOW *, chtype );
502 extern int winsdelln ( WINDOW *, int );
503 extern int winsertln ( WINDOW * );
504 extern int winsnstr ( WINDOW *, const char *, int );
505 extern int winsstr ( WINDOW *, const char * );
506 extern int winstr ( WINDOW *, char * );
507 extern int wmove ( WINDOW *, int, int );
508 extern int wnoutrefresh ( WINDOW * );
509 extern int wprintw ( WINDOW *, char *, ... );
510 extern int wredrawln ( WINDOW *, int, int );
511 extern int wrefresh ( WINDOW * );
512 extern int wscanw ( WINDOW *, char *, ... );
513 extern int wscrl ( WINDOW *, int );
514 extern int wsetscrreg ( WINDOW *, int, int );
515 extern int wstandend ( WINDOW * );
516 extern int wstandout ( WINDOW * );
517 extern void wsyncup ( WINDOW * );
518 extern void wsyncdown ( WINDOW * );
519 extern void wtimeout ( WINDOW *, int );
520 extern int wtouchln ( WINDOW *, int, int, int );
521 extern int wvline ( WINDOW *, chtype, int );
523 #define COLOUR_PAIR(n) MUCURSES_BITS( (n), -8 )
524 #define COLOR_PAIR(n) COLOUR_PAIR(n)
531 * Add a single-byte character and rendition to stdscr and advance the
534 * @v ch character to be added at cursor
535 * @ret rc return status code
537 static inline int addch ( const chtype ch ) {
538 return waddch( stdscr, ch );
542 * Add string of single-byte characters and renditions to stdscr
544 * @v *chstr pointer to first chtype in "string"
545 * @v n number of chars from chstr to render
546 * @ret rc return status code
548 static inline int addchnstr ( const chtype *chstr, int n ) {
549 return waddchnstr ( stdscr, chstr, n );
553 * Add string of single-byte characters and renditions to stdscr
555 * @v *chstr pointer to first chtype in "string"
556 * @ret rc return status code
558 static inline int addchstr ( const chtype *chstr ) {
559 return waddchnstr ( stdscr, chstr, -1 );
563 * Add string of single-byte characters to stdscr
565 * @v *str standard c-style string
566 * @v n max number of chars from string to render
567 * @ret rc return status code
569 static inline int addnstr ( const char *str, int n ) {
570 return waddnstr ( stdscr, str, n );
574 * Add string of single-byte characters to stdscr
576 * @v *str standard c-style string
577 * @ret rc return status code
579 static inline int addstr ( const char *str ) {
580 return waddnstr ( stdscr, str, -1 );
584 * Turn off attributes
586 * @v win subject window
587 * @v attrs attributes to enable
588 * @ret rc return status code
590 static inline int attroff ( int attrs ) {
591 return wattroff ( stdscr, attrs );
597 * @v win subject window
598 * @v attrs attributes to enable
599 * @ret rc return status code
601 static inline int attron ( int attrs ) {
602 return wattron ( stdscr, attrs );
608 * @v win subject window
609 * @v attrs attributes to enable
610 * @ret rc return status code
612 static inline int attrset ( int attrs ) {
613 return wattrset ( stdscr, attrs );
617 * Set background rendition attributes for stdscr and apply to
620 * @v ch chtype containing rendition attributes
621 * @ret rc return status code
623 static inline int bkgd ( chtype ch ) {
624 return wbkgd ( stdscr, ch );
628 * Set background rendition attributes for stdscr
630 static inline void bkgdset ( chtype ch ) {
631 wattrset ( stdscr, ch );
635 * Draw borders from single-byte characters and renditions around
642 * @v tl top left corner
643 * @v tr top right corner
644 * @v bl bottom left corner
645 * @v br bottom right corner
646 * @ret rc return status code
648 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
649 chtype tl, chtype tr, chtype bl, chtype br ) {
650 return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
654 * Move stdscr cursor to the specified position
658 * @ret rc return status code
660 static inline int move ( int y, int x ) {
661 return wmove ( stdscr, y, x );
665 * Add a single-byte character and rendition to stdscr at the
666 * specified position and advance the cursor
670 * @v ch character to be added at cursor
671 * @ret rc return status code
673 static inline int mvaddch ( int y, int x, const chtype ch ) {
674 return ( wmove ( stdscr, y, x ) == ERR
675 ? ERR : waddch( stdscr, ch ) );
679 * Add string of single-byte characters and renditions to stdscr at
680 * the specified position
684 * @v *chstr pointer to first chtype in "string"
685 * @v n max number of chars from chstr to render
686 * @ret rc return status code
688 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
689 return ( wmove ( stdscr, y, x ) == ERR
690 ? ERR : waddchnstr ( stdscr, chstr, n ) );
694 * Add string of single-byte characters and renditions to stdscr at
695 * the specified position
699 * @v *chstr pointer to first chtype in "string"
700 * @ret rc return status code
702 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
703 return ( wmove ( stdscr, y, x ) == ERR
704 ? ERR : waddchnstr ( stdscr, chstr, -1 ) );
708 * Add string of single-byte characters to stdscr at the specified
713 * @v *str standard c-style string
714 * @v n max number of chars from string to render
715 * @ret rc return status code
717 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
718 return ( wmove ( stdscr, y, x ) == ERR
719 ? ERR : waddnstr ( stdscr, str, n ) );
723 * Add string of single-byte characters to stdscr at the specified
728 * @v *str standard c-style string
729 * @ret rc return status code
731 static inline int mvaddstr ( int y, int x, const char *str ) {
732 return ( wmove ( stdscr, y, x ) == ERR
733 ? ERR : waddnstr ( stdscr, str, -1 ) );
737 * Add a single-byte character and rendition to a window at the
738 * specified position and advance the cursor
740 * @v *win subject window
743 * @v ch character to be added at cursor
744 * @ret rc return status code
746 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
747 return ( wmove( win, y, x ) == ERR
748 ? ERR : waddch ( win, ch ) );
752 * Add string of single-byte characters and renditions to a window at
753 * the specified position
755 * @v *win subject window
758 * @v *chstr pointer to first chtype in "string"
759 * @v n max number of chars from chstr to render
760 * @ret rc return status code
762 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
763 return ( wmove ( win, y, x ) == ERR
764 ? ERR : waddchnstr ( win, chstr, n ) );
768 * Add string of single-byte characters and renditions to a window at
769 * the specified position
771 * @v *win subject window
774 * @v *chstr pointer to first chtype in "string"
775 * @ret rc return status code
777 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
778 return ( wmove ( win, y, x ) == ERR
779 ? ERR : waddchnstr ( win, chstr, -1 ) );
783 * Add string of single-byte characters to a window at the specified
786 * @v *win window to be rendered in
789 * @v *str standard c-style string
790 * @v n max number of chars from string to render
791 * @ret rc return status code
793 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
794 return ( wmove ( win, y, x ) == ERR
795 ? ERR : waddnstr ( win, str, n ) );
799 * Add string of single-byte characters to a window at the specified
802 * @v *win window to be rendered in
805 * @v *str standard c-style string
806 * @ret rc return status code
808 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
809 return ( wmove ( win, y, x ) == ERR
810 ? ERR : waddnstr ( win, str, -1 ) );
814 * Add string of single-byte characters and renditions to a window
816 * @v *win subject window
817 * @v *chstr pointer to first chtype in "string"
818 * @ret rc return status code
820 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
821 return waddchnstr ( win, chstr, -1 );
825 * Add string of single-byte characters to a window
827 * @v *win window to be rendered in
828 * @v *str standard c-style string
829 * @ret rc return status code
831 static inline int waddstr ( WINDOW *win, const char *str ) {
832 return waddnstr ( win, str, -1 );
836 * Set background rendition attributes for a window and apply to
839 * @v *win window to be operated on
840 * @v ch chtype containing rendition attributes
841 * @ret rc return status code
843 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
844 return wattrset( win, ch );
847 #endif /* CURSES_H */