iPXE
curses.h
Go to the documentation of this file.
1 #ifndef CURSES_H
2 #define CURSES_H
3 
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include <stdarg.h>
7 #include <ipxe/console.h>
8 
9 /** @file
10  *
11  * MuCurses header file
12  *
13  */
14 
15 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
16 FILE_SECBOOT ( PERMITTED );
17 
18 #undef ERR
19 #define ERR (-1)
20 
21 #undef FALSE
22 #define FALSE (0)
23 
24 #undef OK
25 #define OK (0)
26 
27 #undef TRUE
28 #define TRUE (1)
29 
30 typedef uint32_t chtype;
31 typedef uint32_t attr_t;
32 
33 /** Curses SCREEN object */
34 typedef struct _curses_screen {
35  /** Current cursor position */
36  unsigned int curs_x, curs_y;
37  /** Current attribute */
39 
40  void ( *init ) ( struct _curses_screen *scr );
41  void ( *exit ) ( struct _curses_screen *scr );
42  /**
43  * Erase screen
44  *
45  * @v scr screen on which to operate
46  * @v attrs attributes
47  */
48  void ( * erase ) ( struct _curses_screen *scr, attr_t attrs );
49  /**
50  * Move cursor to position specified by x,y coords
51  *
52  * @v scr screen on which to operate
53  * @v y Y position
54  * @v x X position
55  */
56  void ( * movetoyx ) ( struct _curses_screen *scr,
57  unsigned int y, unsigned int x );
58  /**
59  * Write character to current cursor position
60  *
61  * @v scr screen on which to operate
62  * @v c character to be written
63  */
64  void ( * putc ) ( struct _curses_screen *scr, chtype c );
65  /**
66  * Pop a character from the keyboard input stream
67  *
68  * @v scr screen on which to operate
69  * @ret c popped character
70  */
71  int ( * getc ) ( struct _curses_screen *scr );
72  /**
73  * Checks to see whether a character is waiting in the input stream
74  *
75  * @v scr screen on which to operate
76  * @ret TRUE character waiting in stream
77  * @ret FALSE no character waiting in stream
78  */
79  bool ( *peek ) ( struct _curses_screen *scr );
80  /**
81  * Set cursor visibility
82  *
83  * @v scr screen on which to operate
84  * @v visibility cursor visibility
85  */
86  void ( * cursor ) ( struct _curses_screen *scr, int visibility );
87 } SCREEN;
88 
89 /** Curses Window struct */
90 typedef struct _curses_window {
91  /** screen with which window associates */
93  /** window attributes */
95  /** window origin coordinates */
96  unsigned int ori_x, ori_y;
97  /** window cursor position */
98  unsigned int curs_x, curs_y;
99  /** window dimensions */
100  unsigned int width, height;
101  /** parent window */
103  /** windows that share the same parent as this one */
104  //struct list_head siblings;
105  /** windows der'd or sub'd from this one */
106  //struct list_head children;
107 } WINDOW;
108 
109 extern WINDOW _stdscr;
110 
111 #define stdscr ( &_stdscr )
112 #define COLS console_width
113 #define LINES console_height
114 
115 #define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
116 #define CPAIR_SHIFT 8
117 #define ATTRS_SHIFT 16
118 
119 #define WA_DEFAULT ( 0x0000 << ATTRS_SHIFT )
120 #define WA_ALTCHARSET ( 0x0001 << ATTRS_SHIFT )
121 #define WA_BLINK ( 0x0002 << ATTRS_SHIFT )
122 #define WA_BOLD ( 0x0004 << ATTRS_SHIFT )
123 #define WA_DIM ( 0x0008 << ATTRS_SHIFT )
124 #define WA_INVIS ( 0x0010 << ATTRS_SHIFT )
125 #define WA_PROTECT ( 0x0020 << ATTRS_SHIFT )
126 #define WA_REVERSE ( 0x0040 << ATTRS_SHIFT )
127 #define WA_STANDOUT ( 0x0080 << ATTRS_SHIFT )
128 #define WA_UNDERLINE ( 0x0100 << ATTRS_SHIFT )
129 #define WA_HORIZONTAL ( 0x0200 << ATTRS_SHIFT )
130 #define WA_VERTICAL ( 0x0400 << ATTRS_SHIFT )
131 #define WA_LEFT ( 0x0800 << ATTRS_SHIFT )
132 #define WA_RIGHT ( 0x1000 << ATTRS_SHIFT )
133 #define WA_LOW ( 0x2000 << ATTRS_SHIFT )
134 #define WA_TOP ( 0x4000 << ATTRS_SHIFT )
135 
136 #define A_DEFAULT WA_DEFAULT
137 #define A_ALTCHARSET WA_ALTCHARSET
138 #define A_BLINK WA_BLINK
139 #define A_BOLD WA_BOLD
140 #define A_DIM WA_DIM
141 #define A_INVIS WA_INVIS
142 #define A_PROTECT WA_PROTECT
143 #define A_REVERSE WA_REVERSE
144 #define A_STANDOUT WA_STANDOUT
145 #define A_UNDERLINE WA_UNDERLINE
146 
147 #define A_ATTRIBUTES ( 0xffff << ATTRS_SHIFT )
148 #define A_CHARTEXT ( 0xff )
149 #define A_COLOUR ( 0xff << CPAIR_SHIFT )
150 #define A_COLOR A_COLOUR
151 
152 #define COLOUR_PAIR(n) ( (n) << CPAIR_SHIFT )
153 #define COLOR_PAIR(n) COLOUR_PAIR(n)
154 #define PAIR_NUMBER(attrs) ( ( (attrs) & A_COLOUR ) >> CPAIR_SHIFT )
155 
156 #define COLOUR_PAIRS 8 /* Arbitrary limit */
157 #define COLOR_PAIRS COLOUR_PAIRS
158 
159 #define ACS_ULCORNER '+'
160 #define ACS_LLCORNER '+'
161 #define ACS_URCORNER '+'
162 #define ACS_LRCORNER '+'
163 #define ACS_RTEE '+'
164 #define ACS_LTEE '+'
165 #define ACS_BTEE '+'
166 #define ACS_TTEE '+'
167 #define ACS_HLINE '-'
168 #define ACS_VLINE '|'
169 #define ACS_PLUS '+'
170 #define ACS_S1 '-'
171 #define ACS_S9 '_'
172 #define ACS_DIAMOND '+'
173 #define ACS_CKBOARD ':'
174 #define ACS_DEGREE '\''
175 #define ACS_PLMINUS '#'
176 #define ACS_BULLET 'o'
177 #define ACS_LARROW '<'
178 #define ACS_RARROW '>'
179 #define ACS_DARROW 'v'
180 #define ACS_UARROW '^'
181 #define ACS_BOARD '#'
182 #define ACS_LANTERN '#'
183 #define ACS_BLOCK '#'
184 
185 #define COLOUR_BLACK 0
186 #define COLOUR_RED 1
187 #define COLOUR_GREEN 2
188 #define COLOUR_YELLOW 3
189 #define COLOUR_BLUE 4
190 #define COLOUR_MAGENTA 5
191 #define COLOUR_CYAN 6
192 #define COLOUR_WHITE 7
193 #define COLOURS 7
194 
195 #define COLOUR_FG 30
196 #define COLOUR_BG 40
197 #define COLOR_FG COLOUR_FG
198 #define COLOR_BG COLOUR_BG
199 
200 #define COLOR_BLACK COLOUR_BLACK
201 #define COLOR_BLUE COLOUR_BLUE
202 #define COLOR_GREEN COLOUR_GREEN
203 #define COLOR_CYAN COLOUR_CYAN
204 #define COLOR_RED COLOUR_RED
205 #define COLOR_MAGENTA COLOUR_MAGENTA
206 #define COLOR_YELLOW COLOUR_YELLOW
207 #define COLOR_WHITE COLOUR_WHITE
208 #define COLORS COLOURS
209 
210 /*
211  * KEY code constants are define in ipxe/keys.h
212  */
213 #include <ipxe/keys.h>
214 
215 //extern int addch ( const chtype * );
216 //extern int addchnstr ( const chtype *, int );
217 //extern int addchstr ( const chtype * );
218 //extern int addnstr ( const char *, int );
219 //extern int addstr ( const char * );
220 //extern int attroff ( int );
221 //extern int attron ( int );
222 //extern int attrset ( int );
223 //extern int attr_get ( attr_t *, short *, void * );
224 //extern int attr_off ( attr_t, void * );
225 //extern int attr_on ( attr_t, void * );
226 //extern int attr_set ( attr_t, short, void * );
227 extern int baudrate ( void );
228 extern int beep ( void );
229 //extern void bkgdset ( chtype );
230 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
231  chtype );*/
232 extern int box ( WINDOW *, chtype, chtype ) __nonnull;
233 //extern bool can_change_colour ( void );
234 #define can_change_color() can_change_colour()
235 extern int cbreak ( void );
236 //extern int clrtobot ( void );
237 //extern int clrtoeol ( void );
238 extern int colour_content ( short, short *, short *, short * ) __nonnull;
239 #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
240 //extern int colour_set ( short, void * );
241 #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
242 extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
243  int, int, int, int );
244 extern int curs_set ( int );
245 extern int def_prog_mode ( void );
246 extern int def_shell_mode ( void );
247 extern int delay_output ( int );
248 //extern int delch ( void );
249 //extern int deleteln ( void );
250 extern void delscreen ( SCREEN * );
251 extern int delwin ( WINDOW * ) __nonnull;
252 extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
253 //extern int doupdate ( void );
254 extern WINDOW *dupwin ( WINDOW * ) __nonnull;
255 extern int echo ( void );
256 extern int echochar ( const chtype );
257 extern int endwin ( void );
258 extern char erasechar ( void );
259 extern int erase ( void );
260 extern void filter ( void );
261 extern int flash ( void );
262 extern int flushinp ( void );
263 extern __pure chtype getbkgd ( WINDOW * ) __nonnull;
264 //extern int getch ( void );
265 //extern int getnstr ( char *, int );
266 //extern int getstr ( char * );
267 extern int halfdelay ( int );
268 //extern bool has_colors ( void );
269 extern bool has_ic ( void );
270 extern bool has_il ( void );
271 //extern int hline ( chtype, int );
272 extern void idcok ( WINDOW *, bool );
273 extern int idlok ( WINDOW *, bool );
274 //extern void immedok ( WINDOW *, bool );
275 //extern chtype inch ( void );
276 //extern int inchnstr ( chtype *, int );
277 //extern int inchstr ( chtype * );
278 extern WINDOW *initscr ( void );
279 extern int init_colour ( short, short, short, short );
280 #define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
281 extern int init_pair ( short, short, short );
282 //extern int innstr ( char *, int );
283 //extern int insch ( chtype );
284 //extern int insnstr ( const char *, int );
285 //extern int insstr ( const char * );
286 //extern int instr ( char * );
287 extern int intrflush ( WINDOW *, bool );
288 extern bool isendwin ( void );
289 //extern bool is_linetouched ( WINDOW *, int );
290 //extern bool is_wintouched ( WINDOW * );
291 extern char *keyname ( int );
292 extern int keypad ( WINDOW *, bool );
293 extern char killchar ( void );
294 extern int leaveok ( WINDOW *, bool );
295 extern char *longname ( void );
296 extern int meta ( WINDOW *, bool );
297 //extern int move ( int, int );
298 //extern int mvaddch ( int, int, const chtype );
299 //extern int mvaddchnstr ( int, int, const chtype *, int );
300 //extern int mvaddchstr ( int, int, const chtype * );
301 //extern int mvaddnstr ( int, int, const char *, int );
302 //extern int mvaddstr ( int, int, const char * );
303 extern int mvcur ( int, int, int, int );
304 //extern int mvdelch ( int, int );
305 extern int mvderwin ( WINDOW *, int, int );
306 //extern int mvgetch ( int, int );
307 //extern int mvgetnstr ( int, int, char *, int );
308 //extern int mvgetstr ( int, int, char * );
309 //extern int mvhline ( int, int, chtype, int );
310 //extern chtype mvinch ( int, int );
311 //extern int mvinchnstr ( int, int, chtype *, int );
312 //extern int mvinchstr ( int, int, chtype * );
313 //extern int mvinnstr ( int, int, char *, int );
314 //extern int mvinsch ( int, int, chtype );
315 //extern int mvinsnstr ( int, int, const char *, int );
316 //extern int mvinsstr ( int, int, const char * );
317 //extern int mvinstr ( int, int, char * );
318 //extern int mvprintw ( int, int, char *, ... );
319 //extern int mvscanw ( int, int, char *, ... );
320 //extern int mvvline ( int, int, chtype, int );
321 //extern int mvwaddch ( WINDOW *, int, int, const chtype );
322 //extern int mvwaddchnstr ( WINDOW *, int, int, const chtype *, int );
323 //extern int mvwaddchstr ( WINDOW *, int, int, const chtype * );
324 //extern int mvwaddnstr ( WINDOW *, int, int, const char *, int );
325 //extern int mvwaddstr ( WINDOW *, int, int, const char * );
326 //extern int mvwdelch ( WINDOW *, int, int );
327 //extern int mvwgetch ( WINDOW *, int, int );
328 //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
329 //extern int mvwgetstr ( WINDOW *, int, int, char * );
330 //extern int mvwhline ( WINDOW *, int, int, chtype, int );
331 extern int mvwin ( WINDOW *, int, int ) __nonnull;
332 //extern chtype mvwinch ( WINDOW *, int, int );
333 //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
334 //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
335 //extern int mvwinnstr ( WINDOW *, int, int, char *, int );
336 //extern int mvwinsch ( WINDOW *, int, int, chtype );
337 //extern int mvwinsnstr ( WINDOW *, int, int, const char *, int );
338 //extern int mvwinsstr ( WINDOW *, int, int, const char * );
339 //extern int mvwinstr ( WINDOW *, int, int, char * );
340 //extern int mvwprintw ( WINDOW *, int, int, char *, ... );
341 //extern int mvwscanw ( WINDOW *, int, int, char *, ... );
342 //extern int mvwvline ( WINDOW *, int, int, chtype, int );
343 extern int napms ( int );
344 //extern WINDOW *newpad ( int, int );
345 extern WINDOW *newwin ( int, int, int, int );
346 extern int nl ( void );
347 extern int nocbreak ( void );
348 extern int nodelay ( WINDOW *, bool );
349 extern int noecho ( void );
350 extern int nonl ( void );
351 extern void noqiflush ( void );
352 extern int noraw ( void );
353 extern int notimeout ( WINDOW *, bool );
354 extern int overlay ( const WINDOW *, WINDOW * );
355 extern int overwrite ( const WINDOW *, WINDOW * );
356 extern int pair_content ( short, short *, short * ) __nonnull;
357 //extern int pechochar ( WINDOW *, chtype );
358 //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
359 //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
360 extern int printw ( char *, ... );
361 extern int putp ( const char * );
362 extern void qiflush ( void );
363 extern int raw ( void );
364 //extern int redrawwin ( WINDOW * );
365 //extern int refresh ( void );
366 extern int reset_prog_mode ( void );
367 extern int reset_shell_mode ( void );
368 extern int resetty ( void );
369 extern int ripoffline ( int, int (*) ( WINDOW *, int) );
370 extern int savetty ( void );
371 //extern int scanw ( char *, ... );
372 //extern int scrl ( int );
373 //extern int scroll ( WINDOW * );
374 //extern int scrollok ( WINDOW *, bool );
375 //extern int setscrreg ( int, int );
376 extern SCREEN *set_term ( SCREEN * );
377 extern int setupterm ( char *, int, int * );
378 extern int slk_attr_off ( const attr_t, void * );
379 extern int slk_attroff ( const chtype );
380 extern int slk_attr_on ( const attr_t, void * );
381 extern int slk_attron ( const chtype );
382 extern int slk_attr_set ( const attr_t, short, void * );
383 extern int slk_attrset ( const chtype );
384 extern int slk_clear ( void );
385 extern int slk_colour ( short );
386 #define slk_color( c ) slk_colour( (c) )
387 extern int slk_init ( int );
388 extern char *slk_label ( int );
389 extern int slk_noutrefresh ( void );
390 //extern int slk_refresh ( void );
391 extern int slk_restore ( void );
392 extern int slk_set ( int, const char *, int ) __nonnull;
393 extern int slk_touch ( void );
394 extern int standend ( void );
395 extern int standout ( void );
396 //extern int start_colour ( void );
397 #define start_color() start_colour()
398 //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
399 extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull;
400 extern int syncok ( WINDOW *, bool );
401 extern chtype termattrs ( void );
402 extern attr_t term_attrs ( void );
403 extern char *termname ( void );
404 extern int tigetflag ( char * );
405 extern int tigetnum ( char * );
406 extern char *tigetstr ( char * );
407 extern void timeout ( int );
408 //extern int touchline ( WINDOW *, int, int );
409 //extern int touchwin ( WINDOW * );
410 extern char *tparm ( char *, long, long, long, long, long, long, long, long,
411  long );
412 extern int typeahead ( int );
413 //extern int ungetch ( int );
414 //extern int untouchwin ( WINDOW * );
415 extern void use_env ( bool );
416 extern int vid_attr ( attr_t, short, void * );
417 extern int vidattr ( chtype );
418 extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
419 extern int vidputs ( chtype, int ( *) ( int) );
420 //extern int vline ( chtype, int );
421 //extern int vwprintw ( WINDOW *, const char *, va_list );
422 extern int vw_printw ( WINDOW *, const char *, va_list ) __nonnull;
423 //extern int vwscanw ( WINDOW *, char *, va_list );
424 //extern int vw_scanw ( WINDOW *, char *, va_list );
425 extern int waddch ( WINDOW *, const chtype ) __nonnull;
426 extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
427 //extern int waddchstr ( WINDOW *, const chtype * );
428 extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
429 //extern int waddstr ( WINDOW *, const char * );
430 extern int wattroff ( WINDOW *, int ) __nonnull;
431 extern int wattron ( WINDOW *, int ) __nonnull;
432 extern int wattrset ( WINDOW *, int ) __nonnull;
433 extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
434  __attribute__ (( nonnull (1, 2, 3)));
435 extern int wattr_off ( WINDOW *, attr_t, void * )
436  __attribute__ (( nonnull (1)));
437 extern int wattr_on ( WINDOW *, attr_t, void * )
438  __attribute__ (( nonnull (1)));
439 extern int wattr_set ( WINDOW *, attr_t, short, void * )
440  __attribute__ (( nonnull (1)));
441 //extern void wbkgdset ( WINDOW *, chtype );
442 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
444 extern int wclrtobot ( WINDOW * ) __nonnull;
445 extern int wclrtoeol ( WINDOW * ) __nonnull;
446 extern void wcursyncup ( WINDOW * );
447 extern int wcolour_set ( WINDOW *, short, void * )
448  __attribute__ (( nonnull (1)));
449 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
450 extern int wdelch ( WINDOW * ) __nonnull;
451 extern int wdeleteln ( WINDOW * ) __nonnull;
452 extern int wechochar ( WINDOW *, const chtype );
453 extern int werase ( WINDOW * ) __nonnull;
454 extern int wgetch ( WINDOW * );
455 extern int wgetnstr ( WINDOW *, char *, int );
456 //extern int wgetstr ( WINDOW *, char * );
457 extern int whline ( WINDOW *, chtype, int ) __nonnull;
458 //extern chtype winch ( WINDOW * );
459 //extern int winchnstr ( WINDOW *, chtype *, int );
460 //extern int winchstr ( WINDOW *, chtype * );
461 //extern int winnstr ( WINDOW *, char *, int );
462 //extern int winsch ( WINDOW *, chtype );
463 //extern int winsnstr ( WINDOW *, const char *, int );
464 //extern int winsstr ( WINDOW *, const char * );
465 //extern int winstr ( WINDOW *, char * );
466 extern int wmove ( WINDOW *, int, int );
467 //extern int wnoutrefresh ( WINDOW * );
468 extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
469 //extern int wredrawln ( WINDOW *, int, int );
470 //extern int wrefresh ( WINDOW * );
471 //extern int wscanw ( WINDOW *, char *, ... );
472 //extern int wscrl ( WINDOW *, int );
473 //extern int wsetscrreg ( WINDOW *, int, int );
474 //extern int wstandend ( WINDOW * );
475 //extern int wstandout ( WINDOW * );
476 extern void wsyncup ( WINDOW * );
477 extern void wsyncdown ( WINDOW * );
478 extern void wtimeout ( WINDOW *, int );
479 //extern int wtouchln ( WINDOW *, int, int, int );
480 extern int wvline ( WINDOW *, chtype, int ) __nonnull;
481 
482 /*
483  * There is frankly a ridiculous amount of redundancy within the
484  * curses API - ncurses decided to get around this by using #define
485  * macros, but I've decided to be type-safe and implement them all as
486  * static inlines instead...
487  */
488 
489 static inline int addch ( const chtype ch ) {
490  return waddch( stdscr, ch );
491 }
492 
493 static inline int addchnstr ( const chtype *chstr, int n ) {
494  return waddchnstr ( stdscr, chstr, n );
495 }
496 
497 static inline int addchstr ( const chtype *chstr ) {
498  return waddchnstr ( stdscr, chstr, -1 );
499 }
500 
501 static inline int addnstr ( const char *str, int n ) {
502  return waddnstr ( stdscr, str, n );
503 }
504 
505 static inline int addstr ( const char *str ) {
506  return waddnstr ( stdscr, str, -1 );
507 }
508 
509 static inline int attroff ( int attrs ) {
510  return wattroff ( stdscr, attrs );
511 }
512 
513 static inline int attron ( int attrs ) {
514  return wattron ( stdscr, attrs );
515 }
516 
517 static inline int attrset ( int attrs ) {
518  return wattrset ( stdscr, attrs );
519 }
520 
521 static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
522  return wattr_get ( stdscr, attrs, pair, opts );
523 }
524 
525 static inline int attr_off ( attr_t attrs, void *opts ) {
526  return wattr_off ( stdscr, attrs, opts );
527 }
528 
529 static inline int attr_on ( attr_t attrs, void *opts ) {
530  return wattr_on ( stdscr, attrs, opts );
531 }
532 
533 static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
534  return wattr_set ( stdscr, attrs, cpair, opts );
535 }
536 
537 static inline void bkgdset ( chtype ch ) {
538  wattrset ( stdscr, ch );
539 }
540 
541 static inline int border ( chtype ls, chtype rs, chtype ts, chtype bs,
542  chtype tl, chtype tr, chtype bl, chtype br ) {
543  return wborder ( stdscr, ls, rs, ts, bs, tl, tr, bl, br );
544 }
545 
546 static inline bool can_change_colour ( void ) {
547  return FALSE;
548 }
549 
550 static inline int clrtobot ( void ) {
551  return wclrtobot( stdscr );
552 }
553 
554 static inline int clrtoeol ( void ) {
555  return wclrtoeol( stdscr );
556 }
557 
558 static inline int colour_set ( short colour_pair_number, void *opts ) {
559  return wcolour_set ( stdscr, colour_pair_number, opts );
560 }
561 
562 static inline int delch ( void ) {
563  return wdelch ( stdscr );
564 }
565 
566 static inline int deleteln ( void ) {
567  return wdeleteln( stdscr );
568 }
569 
570 static inline int getch ( void ) {
571  return wgetch ( stdscr );
572 }
573 
574 static inline int getnstr ( char *str, int n ) {
575  return wgetnstr ( stdscr, str, n );
576 }
577 
578 static inline int getstr ( char *str ) {
579  return wgetnstr ( stdscr, str, -1 );
580 }
581 
582 static inline bool has_colors ( void ) {
583  return TRUE;
584 }
585 
586 static inline int has_key ( int kc __unused ) {
587  return TRUE;
588 }
589 
590 static inline int hline ( chtype ch, int n ) {
591  return whline ( stdscr, ch, n );
592 }
593 
594 static inline int move ( int y, int x ) {
595  return wmove ( stdscr, y, x );
596 }
597 
598 static inline int mvaddch ( int y, int x, const chtype ch ) {
599  return ( wmove ( stdscr, y, x ) == OK
600  ? waddch( stdscr, ch ) : ERR );
601 }
602 
603 static inline int mvaddchnstr ( int y, int x, const chtype *chstr, int n ) {
604  return ( wmove ( stdscr, y, x ) == OK
605  ? waddchnstr ( stdscr, chstr, n ) : ERR );
606 }
607 
608 static inline int mvaddchstr ( int y, int x, const chtype *chstr ) {
609  return ( wmove ( stdscr, y, x ) == OK
610  ? waddchnstr ( stdscr, chstr, -1 ) : ERR );
611 }
612 
613 static inline int mvaddnstr ( int y, int x, const char *str, int n ) {
614  return ( wmove ( stdscr, y, x ) == OK
615  ? waddnstr ( stdscr, str, n ) : ERR );
616 }
617 
618 static inline int mvaddstr ( int y, int x, const char *str ) {
619  return ( wmove ( stdscr, y, x ) == OK
620  ? waddnstr ( stdscr, str, -1 ) : ERR );
621 }
622 
623 static inline int mvdelch ( int y, int x ) {
624  return ( wmove ( stdscr, y, x ) == OK
625  ? wdelch ( stdscr ) : ERR );
626 }
627 
628 static inline int mvgetch ( int y, int x ) {
629  return ( wmove ( stdscr, y, x ) == OK
630  ? wgetch ( stdscr ) : ERR );
631 }
632 
633 static inline int mvgetnstr ( int y, int x, char *str, int n ) {
634  return ( wmove ( stdscr, y, x ) == OK
635  ? wgetnstr ( stdscr, str, n ) : ERR );
636 }
637 
638 static inline int mvgetstr ( int y, int x, char *str ) {
639  return ( wmove ( stdscr, y, x ) == OK
640  ? wgetnstr ( stdscr, str, -1 ) : ERR );
641 }
642 
643 static inline int mvhline ( int y, int x, chtype ch, int n ) {
644  return ( wmove ( stdscr, y, x ) == OK
645  ? whline ( stdscr, ch, n ) : ERR );
646 }
647 
648 // OK, so maybe a few I did with macros...
649 #define mvprintw( y, x, fmt, ... ) \
650  ( wmove(stdscr,(y),(x)) == OK \
651  ? wprintw( stdscr,(fmt), ## __VA_ARGS__ ) : ERR )
652 
653 static inline int mvvline ( int y, int x, chtype ch, int n ) {
654  return ( wmove ( stdscr, y, x ) == OK
655  ? wvline ( stdscr, ch, n ) : ERR );
656 }
657 
658 static inline int mvwaddch ( WINDOW *win, int y, int x, const chtype ch ) {
659  return ( wmove( win, y, x ) == OK
660  ? waddch ( win, ch ) : ERR );
661 }
662 
663 static inline int mvwaddchnstr ( WINDOW *win, int y, int x, const chtype *chstr, int n ) {
664  return ( wmove ( win, y, x ) == OK
665  ? waddchnstr ( win, chstr, n ) : ERR );
666 }
667 
668 static inline int mvwaddchstr ( WINDOW *win, int y, int x, const chtype *chstr ) {
669  return ( wmove ( win, y, x ) == OK
670  ? waddchnstr ( win, chstr, -1 ) : ERR );
671 }
672 
673 static inline int mvwaddnstr ( WINDOW *win, int y, int x, const char *str, int n ) {
674  return ( wmove ( win, y, x ) == OK
675  ? waddnstr ( win, str, n ) : ERR );
676 }
677 
678 static inline int mvwaddstr ( WINDOW *win, int y, int x, const char *str ) {
679  return ( wmove ( win, y, x ) == OK
680  ? waddnstr ( win, str, -1 ) : ERR );
681 }
682 
683 static inline int mvwdelch ( WINDOW *win, int y, int x ) {
684  return ( wmove ( win, y, x ) == OK
685  ? wdelch ( win ) : ERR );
686 }
687 
688 static inline int mvwgetch ( WINDOW *win, int y, int x ) {
689  return ( wmove ( win, y, x ) == OK
690  ? wgetch ( win ) : ERR );
691 }
692 
693 static inline int mvwgetnstr ( WINDOW *win, int y, int x, char *str, int n ) {
694  return ( wmove ( win, y, x ) == OK
695  ? wgetnstr ( win, str, n ) : ERR );
696 }
697 
698 static inline int mvwgetstr ( WINDOW *win, int y, int x, char *str ) {
699  return ( wmove ( win, y, x ) == OK
700  ? wgetnstr ( win, str, -1 ) : ERR );
701 }
702 
703 static inline int mvwhline ( WINDOW *win, int y, int x, chtype ch, int n ) {
704  return ( wmove ( win, y, x ) == OK
705  ? whline ( win, ch, n ) : ERR );
706 }
707 
708 #define mvwprintw( win, y, x, fmt, ... ) \
709  ( wmove((win),(y),(x)) == OK \
710  ? wprintw((win),(fmt), ## __VA_ARGS__) : ERR )
711 
712 static inline int mvwvline ( WINDOW *win, int y, int x, chtype ch, int n ) {
713  return ( wmove ( win, y, x ) == OK
714  ? wvline ( win, ch, n ) : ERR );
715 }
716 
717 #define printw( fmt, ... ) wprintw(stdscr,(fmt), ## __VA_ARGS__ )
718 
719 static inline int slk_refresh ( void ) {
720  if ( slk_clear() == OK )
721  return slk_restore();
722  else
723  return ERR;
724 }
725 
726 #define standend() wstandend( stdscr )
727 #define standout() wstandout( stdscr )
728 
729 static inline int start_colour ( void ) {
730  return OK;
731 }
732 
733 static inline int vline ( chtype ch, int n ) {
734  return wvline ( stdscr, ch, n );
735 }
736 
737 // marked for removal
738 static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
739  return vw_printw ( win, fmt, varglist );
740 }
741 
742 static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
743  return waddchnstr ( win, chstr, -1 );
744 }
745 
746 static inline int waddstr ( WINDOW *win, const char *str ) {
747  return waddnstr ( win, str, -1 );
748 }
749 
750 static inline int wbkgdset ( WINDOW *win, chtype ch ) {
751  return wattrset( win, ch );
752 }
753 
754 static inline int wgetstr ( WINDOW *win, char *str ) {
755  return wgetnstr ( win, str, -1 );
756 }
757 
758 static inline int wstandend ( WINDOW *win ) {
759  return wattrset ( win, A_DEFAULT );
760 }
761 
762 static inline int wstandout ( WINDOW *win ) {
763  return wattrset ( win, A_STANDOUT );
764 }
765 
766 #endif /* CURSES_H */
int vid_attr(attr_t, short, void *)
static int mvaddchstr(int y, int x, const chtype *chstr)
Definition: curses.h:608
#define __attribute__(x)
Definition: compiler.h:10
int overlay(const WINDOW *, WINDOW *)
int slk_attr_on(const attr_t, void *)
int reset_shell_mode(void)
int mvwin(WINDOW *, int, int) __nonnull
Move window origin to specified coordinates.
Definition: windows.c:94
FILE_SECBOOT(PERMITTED)
#define __pure
Declare a function as pure - i.e.
Definition: compiler.h:578
int beep(void)
Audible signal.
Definition: alert.c:17
int wvline(WINDOW *, chtype, int) __nonnull
Create a vertical line in a window.
Definition: edging.c:102
int slk_colour(short)
Set soft label colour pair.
Definition: slk.c:223
static int wgetstr(WINDOW *win, char *str)
Definition: curses.h:754
static int attrset(int attrs)
Definition: curses.h:517
WINDOW * subwin(WINDOW *, int, int, int, int) __nonnull
Create a new sub-window.
Definition: windows.c:140
static int attr_off(attr_t attrs, void *opts)
Definition: curses.h:525
int wcolour_set(WINDOW *, short, void *)
Curses SCREEN object.
Definition: curses.h:34
static int delch(void)
Definition: curses.h:562
int def_prog_mode(void)
int wattr_on(WINDOW *, attr_t, void *)
static int mvaddchnstr(int y, int x, const chtype *chstr, int n)
Definition: curses.h:603
void idcok(WINDOW *, bool)
int syncok(WINDOW *, bool)
static int slk_refresh(void)
Definition: curses.h:719
Curses Window struct.
Definition: curses.h:90
static int getch(void)
Definition: curses.h:570
int reset_prog_mode(void)
void qiflush(void)
bool has_il(void)
static int addch(const chtype ch)
Definition: curses.h:489
char erasechar(void)
int wgetnstr(WINDOW *, char *, int)
Read at most n characters from the FIFO into a window.
Definition: kb.c:88
void noqiflush(void)
int slk_touch(void)
static int mvwgetch(WINDOW *win, int y, int x)
Definition: curses.h:688
static int attroff(int attrs)
Definition: curses.h:509
static int mvaddnstr(int y, int x, const char *str, int n)
Definition: curses.h:613
int nocbreak(void)
WINDOW _stdscr
Definition: mucurses.c:21
int wmove(WINDOW *, int, int)
Move a window's cursor to the specified position.
Definition: mucurses.c:136
#define A_DEFAULT
Definition: curses.h:136
int init_pair(short, short, short)
Initialise colour pair.
Definition: colour.c:37
static unsigned int x
Definition: pixbuf.h:63
unsigned int curs_y
Definition: curses.h:98
int wprintw(WINDOW *, const char *,...) __nonnull
Print formatted output to a window.
Definition: print.c:79
static int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
Definition: curses.h:541
static int vline(chtype ch, int n)
Definition: curses.h:733
void(* exit)(struct _curses_screen *scr)
Definition: curses.h:41
int setupterm(char *, int, int *)
static int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
Definition: curses.h:738
static int mvvline(int y, int x, chtype ch, int n)
Definition: curses.h:653
void(* cursor)(struct _curses_screen *scr, int visibility)
Set cursor visibility.
Definition: curses.h:86
uint8_t bl
Definition: registers.h:78
int idlok(WINDOW *, bool)
int wborder(WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype) __nonnull
Draw borders from single-byte characters and renditions around a window.
Definition: edging.c:43
unsigned int height
Definition: curses.h:100
static int wstandout(WINDOW *win)
Definition: curses.h:762
int endwin(void)
Finalise console environment.
Definition: wininit.c:32
void wcursyncup(WINDOW *)
static int mvgetch(int y, int x)
Definition: curses.h:628
static int mvwgetstr(WINDOW *win, int y, int x, char *str)
Definition: curses.h:698
WINDOW * dupwin(WINDOW *) __nonnull
Create a duplicate of the specified window.
Definition: windows.c:71
#define standend()
Definition: curses.h:726
unsigned int width
window dimensions
Definition: curses.h:100
int echochar(const chtype)
int intrflush(WINDOW *, bool)
uint8_t ch
Definition: registers.h:83
char * keyname(int)
static int mvaddch(int y, int x, const chtype ch)
Definition: curses.h:598
static int deleteln(void)
Definition: curses.h:566
static int waddstr(WINDOW *win, const char *str)
Definition: curses.h:746
uint32_t attr_t
Definition: curses.h:31
#define ERR
Definition: curses.h:19
int wclrtoeol(WINDOW *) __nonnull
Clear a window to the end of the current line.
Definition: clear.c:38
#define __nonnull
Declare a function's pointer parameters as non-null - i.e.
Definition: compiler.h:592
int wattrset(WINDOW *, int) __nonnull
Set attributes in a window.
Definition: winattrs.c:53
int slk_set(int, const char *, int) __nonnull
Configure specified soft key.
Definition: slk.c:352
static int wstandend(WINDOW *win)
Definition: curses.h:758
static void bkgdset(chtype ch)
Definition: curses.h:537
static int hline(chtype ch, int n)
Definition: curses.h:590
int cbreak(void)
#define A_STANDOUT
Definition: curses.h:144
int typeahead(int)
int napms(int)
static int mvdelch(int y, int x)
Definition: curses.h:623
static int mvgetstr(int y, int x, char *str)
Definition: curses.h:638
WINDOW * initscr(void)
Initialise console environment.
Definition: wininit.c:18
int wattr_off(WINDOW *, attr_t, void *)
static int mvwdelch(WINDOW *win, int y, int x)
Definition: curses.h:683
int colour_content(short, short *, short *, short *) __nonnull
Identify the RGB components of a given colour value.
Definition: colour.c:23
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
int nonl(void)
bool has_ic(void)
bool(* peek)(struct _curses_screen *scr)
Checks to see whether a character is waiting in the input stream.
Definition: curses.h:79
void(* init)(struct _curses_screen *scr)
Definition: curses.h:40
char * termname(void)
static int attr_set(attr_t attrs, short cpair, void *opts)
Definition: curses.h:533
#define FALSE
Definition: curses.h:22
int waddch(WINDOW *, const chtype) __nonnull
Add a single-byte character and rendition to a window and advance the cursor.
Definition: print.c:24
int wattr_get(WINDOW *, attr_t *, short *, void *)
int vid_puts(attr_t, short, void *, int(*)(int))
static int mvwaddstr(WINDOW *win, int y, int x, const char *str)
Definition: curses.h:678
int notimeout(WINDOW *, bool)
#define bool
Definition: stdbool.h:7
int keypad(WINDOW *, bool)
User interaction.
int meta(WINDOW *, bool)
int noecho(void)
Definition: kb.c:141
#define stdscr
Definition: curses.h:111
static int waddchstr(WINDOW *win, const chtype *chstr)
Definition: curses.h:742
int wattroff(WINDOW *, int) __nonnull
Turn off attributes in a window.
Definition: winattrs.c:29
int def_shell_mode(void)
static int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n)
Definition: curses.h:693
int halfdelay(int)
int putp(const char *)
static int colour_set(short colour_pair_number, void *opts)
Definition: curses.h:558
int wclrtobot(WINDOW *) __nonnull
Clear a window to the bottom from current cursor position.
Definition: clear.c:20
static int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
Definition: curses.h:658
int wechochar(WINDOW *, const chtype)
SCREEN * scr
screen with which window associates
Definition: curses.h:92
int mvcur(int, int, int, int)
attr_t attrs
window attributes
Definition: curses.h:94
static int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n)
Definition: curses.h:673
int slk_clear(void)
Clear the soft function key labels from the screen.
Definition: slk.c:209
static int clrtoeol(void)
Definition: curses.h:554
int curs_set(int)
Set cursor visibility.
Definition: mucurses.c:154
int waddchnstr(WINDOW *, const chtype *, int) __nonnull
Add string of single-byte characters and renditions to a window.
Definition: print_nadv.c:21
static int addstr(const char *str)
Definition: curses.h:505
char * tigetstr(char *)
char * tparm(char *, long, long, long, long, long, long, long, long, long)
int nodelay(WINDOW *, bool)
int baudrate(void)
int init_colour(short, short, short, short)
int vw_printw(WINDOW *, const char *, va_list) __nonnull
Print formatted output in a window.
Definition: print.c:62
int raw(void)
static int attr_get(attr_t *attrs, short *pair, void *opts)
Definition: curses.h:521
int pair_content(short, short *, short *) __nonnull
Get colours of colour pair.
Definition: colour.c:56
#define printw(fmt,...)
Definition: curses.h:717
int vidputs(chtype, int(*)(int))
static int start_colour(void)
Definition: curses.h:729
unsigned int curs_x
Current cursor position.
Definition: curses.h:36
unsigned int uint32_t
Definition: stdint.h:12
int tigetflag(char *)
void(* erase)(struct _curses_screen *scr, attr_t attrs)
Erase screen.
Definition: curses.h:48
__pure chtype getbkgd(WINDOW *) __nonnull
Get the background rendition attributes for a window.
Definition: winattrs.c:18
int(* getc)(struct _curses_screen *scr)
Pop a character from the keyboard input stream.
Definition: curses.h:71
void use_env(bool)
static int getnstr(char *str, int n)
Definition: curses.h:574
void(* movetoyx)(struct _curses_screen *scr, unsigned int y, unsigned int x)
Move cursor to position specified by x,y coords.
Definition: curses.h:56
struct _curses_window * parent
parent window
Definition: curses.h:102
static int mvgetnstr(int y, int x, char *str, int n)
Definition: curses.h:633
int slk_attrset(const chtype)
Set soft function key attributes.
Definition: slk.c:154
#define standout()
Definition: curses.h:727
#define OK
Definition: curses.h:25
static bool has_colors(void)
Definition: curses.h:582
attr_t attrs
Current attribute.
Definition: curses.h:38
SCREEN * set_term(SCREEN *)
int flushinp(void)
int werase(WINDOW *) __nonnull
Completely clear a window.
Definition: clear.c:87
int waddnstr(WINDOW *, const char *, int) __nonnull
Add string of single-byte characters to a window.
Definition: print.c:37
WINDOW * newwin(int, int, int, int)
Create new WINDOW.
Definition: windows.c:114
static int mvhline(int y, int x, chtype ch, int n)
Definition: curses.h:643
int slk_restore(void)
Restore soft function key labels to the screen.
Definition: slk.c:307
unsigned int curs_y
Definition: curses.h:36
static int getstr(char *str)
Definition: curses.h:578
int leaveok(WINDOW *, bool)
char * slk_label(int)
Return the label for the specified soft key.
Definition: slk.c:295
static int mvwaddchstr(WINDOW *win, int y, int x, const chtype *chstr)
Definition: curses.h:668
int whline(WINDOW *, chtype, int) __nonnull
Create a horizontal line in a window.
Definition: edging.c:82
static int mvwhline(WINDOW *win, int y, int x, chtype ch, int n)
Definition: curses.h:703
__builtin_va_list va_list
Definition: stdarg.h:7
struct _curses_window WINDOW
Curses Window struct.
int ripoffline(int, int(*)(WINDOW *, int))
static int attr_on(attr_t attrs, void *opts)
Definition: curses.h:529
Key definitions.
int vidattr(chtype)
int wgetch(WINDOW *)
Pop a character from the FIFO into a window.
Definition: kb.c:55
void wsyncup(WINDOW *)
char * longname(void)
static unsigned int unsigned int y
Definition: pixbuf.h:63
chtype termattrs(void)
static int move(int y, int x)
Definition: curses.h:594
int flash(void)
void(* putc)(struct _curses_screen *scr, chtype c)
Write character to current cursor position.
Definition: curses.h:64
int erase(void)
Completely clear the screen.
Definition: clear.c:98
static bool can_change_colour(void)
Definition: curses.h:546
char killchar(void)
static int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *chstr, int n)
Definition: curses.h:663
int ssize_t const char * fmt
Definition: vsprintf.h:73
static union @447 opts
"cert<xxx>" option list
uint32_t chtype
Definition: curses.h:30
static int wbkgdset(WINDOW *win, chtype ch)
Definition: curses.h:750
static int has_key(int kc __unused)
Definition: curses.h:586
static int addchstr(const chtype *chstr)
Definition: curses.h:497
void timeout(int)
static int addnstr(const char *str, int n)
Definition: curses.h:501
int wattron(WINDOW *, int) __nonnull
Turn on attributes in a window.
Definition: winattrs.c:41
void delscreen(SCREEN *)
static int clrtobot(void)
Definition: curses.h:550
int box(WINDOW *, chtype, chtype) __nonnull
Draw borders from single-byte characters and renditions around a window.
Definition: edging.c:22
int nl(void)
int wdelch(WINDOW *) __nonnull
Delete character under the cursor in a window.
Definition: clear.c:56
int noraw(void)
int slk_attr_set(const attr_t, short, void *)
int slk_noutrefresh(void)
int delwin(WINDOW *) __nonnull
Delete a window.
Definition: windows.c:20
int slk_init(int)
Initialise the soft function keys.
Definition: slk.c:241
int overwrite(const WINDOW *, WINDOW *)
bool isendwin(void)
int echo(void)
Definition: kb.c:133
unsigned int curs_x
window cursor position
Definition: curses.h:98
WINDOW * derwin(WINDOW *, int, int, int, int) __nonnull
Create a new derived window.
Definition: windows.c:48
int wdeleteln(WINDOW *) __nonnull
Delete line under a window's cursor.
Definition: clear.c:69
static int addchnstr(const chtype *chstr, int n)
Definition: curses.h:493
unsigned int ori_x
window origin coordinates
Definition: curses.h:96
struct _curses_screen SCREEN
Curses SCREEN object.
void wtimeout(WINDOW *, int)
int slk_attroff(const chtype)
Turn off soft function key attributes.
Definition: slk.c:128
int slk_attron(const chtype)
Turn on soft function key attributes.
Definition: slk.c:141
int slk_attr_off(const attr_t, void *)
static int mvaddstr(int y, int x, const char *str)
Definition: curses.h:618
int tigetnum(char *)
void filter(void)
#define TRUE
Definition: curses.h:28
static int attron(int attrs)
Definition: curses.h:513
static int mvwvline(WINDOW *win, int y, int x, chtype ch, int n)
Definition: curses.h:712
attr_t term_attrs(void)
int wattr_set(WINDOW *, attr_t, short, void *)
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int resetty(void)
int mvderwin(WINDOW *, int, int)
#define inline
Definition: compiler.h:624
unsigned int ori_y
Definition: curses.h:96
int savetty(void)
int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int)
int delay_output(int)
void wsyncdown(WINDOW *)