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