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
15FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
16FILE_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
32
33/** Curses SCREEN object */
34typedef 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 );
88
89/** Curses Window struct */
90typedef 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;
108
109extern 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 * );
227extern int baudrate ( void );
228extern int beep ( void );
229//extern void bkgdset ( chtype );
230/*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
231 chtype );*/
232extern int box ( WINDOW *, chtype, chtype ) __nonnull;
233//extern bool can_change_colour ( void );
234#define can_change_color() can_change_colour()
235extern int cbreak ( void );
236//extern int clrtobot ( void );
237//extern int clrtoeol ( void );
238extern 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) )
242extern int copywin ( const WINDOW *, WINDOW *, int, int, int,
243 int, int, int, int );
244extern int curs_set ( int );
245extern int def_prog_mode ( void );
246extern int def_shell_mode ( void );
247extern int delay_output ( int );
248//extern int delch ( void );
249//extern int deleteln ( void );
250extern void delscreen ( SCREEN * );
251extern int delwin ( WINDOW * ) __nonnull;
252extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
253//extern int doupdate ( void );
254extern WINDOW *dupwin ( WINDOW * ) __nonnull;
255extern int echo ( void );
256extern int echochar ( const chtype );
257extern int endwin ( void );
258extern char erasechar ( void );
259extern int erase ( void );
260extern void filter ( void );
261extern int flash ( void );
262extern int flushinp ( void );
264//extern int getch ( void );
265//extern int getnstr ( char *, int );
266//extern int getstr ( char * );
267extern int halfdelay ( int );
268//extern bool has_colors ( void );
269extern bool has_ic ( void );
270extern bool has_il ( void );
271//extern int hline ( chtype, int );
272extern void idcok ( WINDOW *, bool );
273extern 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 * );
278extern WINDOW *initscr ( void );
279extern int init_colour ( short, short, short, short );
280#define init_color ( c, r, g, b ) init_colour ( (c), (r), (g), (b) )
281extern 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 * );
287extern int intrflush ( WINDOW *, bool );
288extern bool isendwin ( void );
289//extern bool is_linetouched ( WINDOW *, int );
290//extern bool is_wintouched ( WINDOW * );
291extern char *keyname ( int );
292extern int keypad ( WINDOW *, bool );
293extern char killchar ( void );
294extern int leaveok ( WINDOW *, bool );
295extern char *longname ( void );
296extern 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 * );
303extern int mvcur ( int, int, int, int );
304//extern int mvdelch ( int, int );
305extern 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 );
331extern 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 );
343extern int napms ( int );
344//extern WINDOW *newpad ( int, int );
345extern WINDOW *newwin ( int, int, int, int );
346extern int nl ( void );
347extern int nocbreak ( void );
348extern int nodelay ( WINDOW *, bool );
349extern int noecho ( void );
350extern int nonl ( void );
351extern void noqiflush ( void );
352extern int noraw ( void );
353extern int notimeout ( WINDOW *, bool );
354extern int overlay ( const WINDOW *, WINDOW * );
355extern int overwrite ( const WINDOW *, WINDOW * );
356extern 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 );
360extern int printw ( char *, ... );
361extern int putp ( const char * );
362extern void qiflush ( void );
363extern int raw ( void );
364//extern int redrawwin ( WINDOW * );
365//extern int refresh ( void );
366extern int reset_prog_mode ( void );
367extern int reset_shell_mode ( void );
368extern int resetty ( void );
369extern int ripoffline ( int, int (*) ( WINDOW *, int) );
370extern 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 );
376extern SCREEN *set_term ( SCREEN * );
377extern int setupterm ( char *, int, int * );
378extern int slk_attr_off ( const attr_t, void * );
379extern int slk_attroff ( const chtype );
380extern int slk_attr_on ( const attr_t, void * );
381extern int slk_attron ( const chtype );
382extern int slk_attr_set ( const attr_t, short, void * );
383extern int slk_attrset ( const chtype );
384extern int slk_clear ( void );
385extern int slk_colour ( short );
386#define slk_color( c ) slk_colour( (c) )
387extern int slk_init ( int );
388extern char *slk_label ( int );
389extern int slk_noutrefresh ( void );
390//extern int slk_refresh ( void );
391extern int slk_restore ( void );
392extern int slk_set ( int, const char *, int ) __nonnull;
393extern int slk_touch ( void );
394extern int standend ( void );
395extern int standout ( void );
396//extern int start_colour ( void );
397#define start_color() start_colour()
398//extern WINDOW *subpad ( WINDOW *, int, int, int, int );
399extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull;
400extern int syncok ( WINDOW *, bool );
401extern chtype termattrs ( void );
402extern attr_t term_attrs ( void );
403extern char *termname ( void );
404extern int tigetflag ( char * );
405extern int tigetnum ( char * );
406extern char *tigetstr ( char * );
407extern void timeout ( int );
408//extern int touchline ( WINDOW *, int, int );
409//extern int touchwin ( WINDOW * );
410extern char *tparm ( char *, long, long, long, long, long, long, long, long,
411 long );
412extern int typeahead ( int );
413//extern int ungetch ( int );
414//extern int untouchwin ( WINDOW * );
415extern void use_env ( bool );
416extern int vid_attr ( attr_t, short, void * );
417extern int vidattr ( chtype );
418extern int vid_puts ( attr_t, short, void *, int ( *) ( int) );
419extern int vidputs ( chtype, int ( *) ( int) );
420//extern int vline ( chtype, int );
421//extern int vwprintw ( WINDOW *, const char *, va_list );
422extern 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 );
425extern int waddch ( WINDOW *, const chtype ) __nonnull;
426extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
427//extern int waddchstr ( WINDOW *, const chtype * );
428extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
429//extern int waddstr ( WINDOW *, const char * );
430extern int wattroff ( WINDOW *, int ) __nonnull;
431extern int wattron ( WINDOW *, int ) __nonnull;
432extern int wattrset ( WINDOW *, int ) __nonnull;
433extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
434 __attribute__ (( nonnull (1, 2, 3)));
435extern int wattr_off ( WINDOW *, attr_t, void * )
436 __attribute__ (( nonnull (1)));
437extern int wattr_on ( WINDOW *, attr_t, void * )
438 __attribute__ (( nonnull (1)));
439extern int wattr_set ( WINDOW *, attr_t, short, void * )
440 __attribute__ (( nonnull (1)));
441//extern void wbkgdset ( WINDOW *, chtype );
442extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
444extern int wclrtobot ( WINDOW * ) __nonnull;
445extern int wclrtoeol ( WINDOW * ) __nonnull;
446extern void wcursyncup ( WINDOW * );
447extern int wcolour_set ( WINDOW *, short, void * )
448 __attribute__ (( nonnull (1)));
449#define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
450extern int wdelch ( WINDOW * ) __nonnull;
451extern int wdeleteln ( WINDOW * ) __nonnull;
452extern int wechochar ( WINDOW *, const chtype );
453extern int werase ( WINDOW * ) __nonnull;
454extern int wgetch ( WINDOW * );
455extern int wgetnstr ( WINDOW *, char *, int );
456//extern int wgetstr ( WINDOW *, char * );
457extern 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 * );
466extern int wmove ( WINDOW *, int, int );
467//extern int wnoutrefresh ( WINDOW * );
468extern 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 * );
476extern void wsyncup ( WINDOW * );
477extern void wsyncdown ( WINDOW * );
478extern void wtimeout ( WINDOW *, int );
479//extern int wtouchln ( WINDOW *, int, int, int );
480extern 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
489static inline int addch ( const chtype ch ) {
490 return waddch( stdscr, ch );
491}
492
493static inline int addchnstr ( const chtype *chstr, int n ) {
494 return waddchnstr ( stdscr, chstr, n );
495}
496
497static inline int addchstr ( const chtype *chstr ) {
498 return waddchnstr ( stdscr, chstr, -1 );
499}
500
501static inline int addnstr ( const char *str, int n ) {
502 return waddnstr ( stdscr, str, n );
503}
504
505static inline int addstr ( const char *str ) {
506 return waddnstr ( stdscr, str, -1 );
507}
508
509static inline int attroff ( int attrs ) {
510 return wattroff ( stdscr, attrs );
511}
512
513static inline int attron ( int attrs ) {
514 return wattron ( stdscr, attrs );
515}
516
517static inline int attrset ( int attrs ) {
518 return wattrset ( stdscr, attrs );
519}
520
521static inline int attr_get ( attr_t *attrs, short *pair, void *opts ) {
522 return wattr_get ( stdscr, attrs, pair, opts );
523}
524
525static inline int attr_off ( attr_t attrs, void *opts ) {
526 return wattr_off ( stdscr, attrs, opts );
527}
528
529static inline int attr_on ( attr_t attrs, void *opts ) {
530 return wattr_on ( stdscr, attrs, opts );
531}
532
533static inline int attr_set ( attr_t attrs, short cpair, void *opts ) {
534 return wattr_set ( stdscr, attrs, cpair, opts );
535}
536
537static inline void bkgdset ( chtype ch ) {
538 wattrset ( stdscr, ch );
539}
540
541static 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
546static inline bool can_change_colour ( void ) {
547 return FALSE;
548}
549
550static inline int clrtobot ( void ) {
551 return wclrtobot( stdscr );
552}
553
554static inline int clrtoeol ( void ) {
555 return wclrtoeol( stdscr );
556}
557
558static inline int colour_set ( short colour_pair_number, void *opts ) {
559 return wcolour_set ( stdscr, colour_pair_number, opts );
560}
561
562static inline int delch ( void ) {
563 return wdelch ( stdscr );
564}
565
566static inline int deleteln ( void ) {
567 return wdeleteln( stdscr );
568}
569
570static inline int getch ( void ) {
571 return wgetch ( stdscr );
572}
573
574static inline int getnstr ( char *str, int n ) {
575 return wgetnstr ( stdscr, str, n );
576}
577
578static inline int getstr ( char *str ) {
579 return wgetnstr ( stdscr, str, -1 );
580}
581
582static inline bool has_colors ( void ) {
583 return TRUE;
584}
585
586static inline int has_key ( int kc __unused ) {
587 return TRUE;
588}
589
590static inline int hline ( chtype ch, int n ) {
591 return whline ( stdscr, ch, n );
592}
593
594static inline int move ( int y, int x ) {
595 return wmove ( stdscr, y, x );
596}
597
598static inline int mvaddch ( int y, int x, const chtype ch ) {
599 return ( wmove ( stdscr, y, x ) == OK
600 ? waddch( stdscr, ch ) : ERR );
601}
602
603static 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
608static 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
613static 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
618static 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
623static inline int mvdelch ( int y, int x ) {
624 return ( wmove ( stdscr, y, x ) == OK
625 ? wdelch ( stdscr ) : ERR );
626}
627
628static inline int mvgetch ( int y, int x ) {
629 return ( wmove ( stdscr, y, x ) == OK
630 ? wgetch ( stdscr ) : ERR );
631}
632
633static 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
638static inline int mvgetstr ( int y, int x, char *str ) {
639 return ( wmove ( stdscr, y, x ) == OK
640 ? wgetnstr ( stdscr, str, -1 ) : ERR );
641}
642
643static 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
653static 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
658static 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
663static 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
668static 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
673static 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
678static 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
683static inline int mvwdelch ( WINDOW *win, int y, int x ) {
684 return ( wmove ( win, y, x ) == OK
685 ? wdelch ( win ) : ERR );
686}
687
688static inline int mvwgetch ( WINDOW *win, int y, int x ) {
689 return ( wmove ( win, y, x ) == OK
690 ? wgetch ( win ) : ERR );
691}
692
693static 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
698static 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
703static 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
712static 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
719static 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
729static inline int start_colour ( void ) {
730 return OK;
731}
732
733static inline int vline ( chtype ch, int n ) {
734 return wvline ( stdscr, ch, n );
735}
736
737// marked for removal
738static inline int vwprintw ( WINDOW *win, const char *fmt, va_list varglist ) {
739 return vw_printw ( win, fmt, varglist );
740}
741
742static inline int waddchstr ( WINDOW *win, const chtype *chstr ) {
743 return waddchnstr ( win, chstr, -1 );
744}
745
746static inline int waddstr ( WINDOW *win, const char *str ) {
747 return waddnstr ( win, str, -1 );
748}
749
750static inline int wbkgdset ( WINDOW *win, chtype ch ) {
751 return wattrset( win, ch );
752}
753
754static inline int wgetstr ( WINDOW *win, char *str ) {
755 return wgetnstr ( win, str, -1 );
756}
757
758static inline int wstandend ( WINDOW *win ) {
759 return wattrset ( win, A_DEFAULT );
760}
761
762static inline int wstandout ( WINDOW *win ) {
763 return wattrset ( win, A_STANDOUT );
764}
765
766#endif /* CURSES_H */
unsigned int uint32_t
Definition stdint.h:12
static union @024010030001061367220137227263210031030210157031 opts
"cert<xxx>" option list
int wdelch(WINDOW *win)
Delete character under the cursor in a window.
Definition clear.c:56
static int attr_get(attr_t *attrs, short *pair, void *opts)
Definition curses.h:521
int overwrite(const WINDOW *, WINDOW *)
static int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n)
Definition curses.h:693
int delay_output(int)
#define standend()
Definition curses.h:726
static int attrset(int attrs)
Definition curses.h:517
#define printw(fmt,...)
Definition curses.h:717
int wdeleteln(WINDOW *) __nonnull
Delete line under a window's cursor.
Definition clear.c:69
static void bkgdset(chtype ch)
Definition curses.h:537
uint32_t attr_t
Definition curses.h:31
static int mvdelch(int y, int x)
Definition curses.h:623
int echo(void)
Definition kb.c:133
int waddch(WINDOW *, const chtype) __nonnull
Add a single-byte character and rendition to a window and advance the cursor.
Definition print.c:24
uint32_t chtype
Definition curses.h:30
static int attr_set(attr_t attrs, short cpair, void *opts)
Definition curses.h:533
int wprintw(WINDOW *, const char *,...) __nonnull
Print formatted output to a window.
Definition print.c:79
int erase(void)
Completely clear the screen.
Definition clear.c:98
int tigetnum(char *)
static int getnstr(char *str, int n)
Definition curses.h:574
static int waddchstr(WINDOW *win, const chtype *chstr)
Definition curses.h:742
static int delch(void)
Definition curses.h:562
static int mvaddch(int y, int x, const chtype ch)
Definition curses.h:598
static int mvwhline(WINDOW *win, int y, int x, chtype ch, int n)
Definition curses.h:703
WINDOW * derwin(WINDOW *, int, int, int, int) __nonnull
Create a new derived window.
Definition windows.c:48
int wattr_get(WINDOW *, attr_t *, short *, void *)
#define standout()
Definition curses.h:727
static int mvwaddchstr(WINDOW *win, int y, int x, const chtype *chstr)
Definition curses.h:668
static int mvgetnstr(int y, int x, char *str, int n)
Definition curses.h:633
int wcolour_set(WINDOW *, short, void *)
static int mvvline(int y, int x, chtype ch, int n)
Definition curses.h:653
int wattroff(WINDOW *, int) __nonnull
Turn off attributes in a window.
Definition winattrs.c:29
bool has_il(void)
char * keyname(int)
int mvwin(WINDOW *, int, int) __nonnull
Move window origin to specified coordinates.
Definition windows.c:94
bool has_ic(void)
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 mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n)
Definition curses.h:673
static int mvwgetch(WINDOW *win, int y, int x)
Definition curses.h:688
int waddnstr(WINDOW *, const char *, int) __nonnull
Add string of single-byte characters to a window.
Definition print.c:37
attr_t term_attrs(void)
void timeout(int)
int nocbreak(void)
#define A_STANDOUT
Definition curses.h:144
int init_colour(short, short, short, short)
void wtimeout(WINDOW *, int)
static int mvaddstr(int y, int x, const char *str)
Definition curses.h:618
int baudrate(void)
int nonl(void)
static int start_colour(void)
Definition curses.h:729
WINDOW * initscr(void)
Initialise console environment.
Definition wininit.c:18
chtype termattrs(void)
int tigetflag(char *)
static bool has_colors(void)
Definition curses.h:582
static int getch(void)
Definition curses.h:570
static int mvwgetstr(WINDOW *win, int y, int x, char *str)
Definition curses.h:698
int vw_printw(WINDOW *, const char *, va_list) __nonnull
Print formatted output in a window.
Definition print.c:62
WINDOW * dupwin(WINDOW *) __nonnull
Create a duplicate of the specified window.
Definition windows.c:71
int slk_touch(void)
int reset_prog_mode(void)
int intrflush(WINDOW *, bool)
int noraw(void)
int flash(void)
int savetty(void)
static int clrtobot(void)
Definition curses.h:550
static int addchnstr(const chtype *chstr, int n)
Definition curses.h:493
static int vline(chtype ch, int n)
Definition curses.h:733
int putp(const char *)
struct _curses_screen SCREEN
Curses SCREEN object.
int overlay(const WINDOW *, WINDOW *)
int slk_clear(void)
Clear the soft function key labels from the screen.
Definition slk.c:209
#define stdscr
Definition curses.h:111
int wattr_off(WINDOW *, attr_t, void *)
int colour_content(short, short *, short *, short *) __nonnull
Identify the RGB components of a given colour value.
Definition colour.c:23
int slk_init(int)
Initialise the soft function keys.
Definition slk.c:241
int init_pair(short, short, short)
Initialise colour pair.
Definition colour.c:37
int keypad(WINDOW *, bool)
int wattr_on(WINDOW *, attr_t, void *)
int ripoffline(int, int(*)(WINDOW *, int))
int wattrset(WINDOW *, int) __nonnull
Set attributes in a window.
Definition winattrs.c:53
static int mvhline(int y, int x, chtype ch, int n)
Definition curses.h:643
static int addch(const chtype ch)
Definition curses.h:489
static int hline(chtype ch, int n)
Definition curses.h:590
int slk_attr_off(const attr_t, void *)
char * slk_label(int)
Return the label for the specified soft key.
Definition slk.c:295
static int move(int y, int x)
Definition curses.h:594
static int deleteln(void)
Definition curses.h:566
static int wstandout(WINDOW *win)
Definition curses.h:762
#define ERR
Definition curses.h:19
char erasechar(void)
int setupterm(char *, int, int *)
int slk_noutrefresh(void)
int noecho(void)
Definition kb.c:141
int wmove(WINDOW *, int, int)
Move a window's cursor to the specified position.
Definition mucurses.c:136
static int addstr(const char *str)
Definition curses.h:505
char * longname(void)
static int mvaddnstr(int y, int x, const char *str, int n)
Definition curses.h:613
int wattron(WINDOW *, int) __nonnull
Turn on attributes in a window.
Definition winattrs.c:41
int slk_colour(short)
Set soft label colour pair.
Definition slk.c:223
int slk_attr_on(const attr_t, void *)
int pair_content(short, short *, short *) __nonnull
Get colours of colour pair.
Definition colour.c:56
int napms(int)
int wgetch(WINDOW *)
Pop a character from the FIFO into a window.
Definition kb.c:55
static int attr_on(attr_t attrs, void *opts)
Definition curses.h:529
int notimeout(WINDOW *, bool)
void delscreen(SCREEN *)
static int mvwdelch(WINDOW *win, int y, int x)
Definition curses.h:683
int wclrtoeol(WINDOW *) __nonnull
Clear a window to the end of the current line.
Definition clear.c:38
static int wstandend(WINDOW *win)
Definition curses.h:758
bool isendwin(void)
SCREEN * set_term(SCREEN *)
int nl(void)
char * termname(void)
#define A_DEFAULT
Definition curses.h:136
static int mvwvline(WINDOW *win, int y, int x, chtype ch, int n)
Definition curses.h:712
int slk_attr_set(const attr_t, short, void *)
int def_shell_mode(void)
int def_prog_mode(void)
int endwin(void)
Finalise console environment.
Definition wininit.c:32
int slk_set(int, const char *, int) __nonnull
Configure specified soft key.
Definition slk.c:352
int wattr_set(WINDOW *, attr_t, short, void *)
int whline(WINDOW *, chtype, int) __nonnull
Create a horizontal line in a window.
Definition edging.c:82
char * tigetstr(char *)
int wechochar(WINDOW *, const chtype)
int wvline(WINDOW *, chtype, int) __nonnull
Create a vertical line in a window.
Definition edging.c:102
static int mvaddchstr(int y, int x, const chtype *chstr)
Definition curses.h:608
static int addchstr(const chtype *chstr)
Definition curses.h:497
void qiflush(void)
int beep(void)
Audible signal.
Definition alert.c:17
int typeahead(int)
int vid_attr(attr_t, short, void *)
int nodelay(WINDOW *, bool)
static int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
Definition curses.h:738
int echochar(const chtype)
void idcok(WINDOW *, bool)
#define OK
Definition curses.h:25
int cbreak(void)
static int colour_set(short colour_pair_number, void *opts)
Definition curses.h:558
int vidattr(chtype)
char * tparm(char *, long, long, long, long, long, long, long, long, long)
static int attr_off(attr_t attrs, void *opts)
Definition curses.h:525
void wsyncdown(WINDOW *)
int wclrtobot(WINDOW *) __nonnull
Clear a window to the bottom from current cursor position.
Definition clear.c:20
static int wgetstr(WINDOW *win, char *str)
Definition curses.h:754
__pure chtype getbkgd(WINDOW *) __nonnull
Get the background rendition attributes for a window.
Definition winattrs.c:18
int vid_puts(attr_t, short, void *, int(*)(int))
int flushinp(void)
WINDOW * newwin(int, int, int, int)
Create new WINDOW.
Definition windows.c:114
void noqiflush(void)
WINDOW * subwin(WINDOW *, int, int, int, int) __nonnull
Create a new sub-window.
Definition windows.c:140
int vidputs(chtype, int(*)(int))
int delwin(WINDOW *) __nonnull
Delete a window.
Definition windows.c:20
int mvderwin(WINDOW *, int, int)
static int mvwaddstr(WINDOW *win, int y, int x, const char *str)
Definition curses.h:678
int resetty(void)
int leaveok(WINDOW *, bool)
int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int)
int wdelch(WINDOW *) __nonnull
Delete character under the cursor in a window.
Definition clear.c:56
static int clrtoeol(void)
Definition curses.h:554
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
int halfdelay(int)
static int mvgetch(int y, int x)
Definition curses.h:628
void filter(void)
Receive packet filter.
Definition pxe_api.h:11
int werase(WINDOW *) __nonnull
Completely clear a window.
Definition clear.c:87
static int mvaddchnstr(int y, int x, const chtype *chstr, int n)
Definition curses.h:603
int syncok(WINDOW *, bool)
static int waddstr(WINDOW *win, const char *str)
Definition curses.h:746
static int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *chstr, int n)
Definition curses.h:663
void wsyncup(WINDOW *)
int slk_restore(void)
Restore soft function key labels to the screen.
Definition slk.c:307
int slk_attron(const chtype)
Turn on soft function key attributes.
Definition slk.c:141
static int addnstr(const char *str, int n)
Definition curses.h:501
static int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
Definition curses.h:658
int wgetnstr(WINDOW *, char *, int)
Read at most n characters from the FIFO into a window.
Definition kb.c:88
static bool can_change_colour(void)
Definition curses.h:546
char killchar(void)
static int attroff(int attrs)
Definition curses.h:509
int reset_shell_mode(void)
static int getstr(char *str)
Definition curses.h:578
static int wbkgdset(WINDOW *win, chtype ch)
Definition curses.h:750
int waddchnstr(WINDOW *, const chtype *, int) __nonnull
Add string of single-byte characters and renditions to a window.
Definition print_nadv.c:21
int mvcur(int, int, int, int)
struct _curses_window WINDOW
Curses Window struct.
int curs_set(int)
Set cursor visibility.
Definition mucurses.c:154
static int mvgetstr(int y, int x, char *str)
Definition curses.h:638
int slk_attrset(const chtype)
Set soft function key attributes.
Definition slk.c:154
static int slk_refresh(void)
Definition curses.h:719
int slk_attroff(const chtype)
Turn off soft function key attributes.
Definition slk.c:128
int box(WINDOW *, chtype, chtype) __nonnull
Draw borders from single-byte characters and renditions around a window.
Definition edging.c:22
static int has_key(int kc __unused)
Definition curses.h:586
int idlok(WINDOW *, bool)
int raw(void)
Raw version number.
Definition CIB_PRM.h:0
void wcursyncup(WINDOW *)
void use_env(bool)
static int attron(int attrs)
Definition curses.h:513
int wvline(WINDOW *win, chtype ch, int n)
Create a vertical line in a window.
Definition edging.c:102
int whline(WINDOW *win, chtype ch, int n)
Create a horizontal line in a window.
Definition edging.c:82
uint8_t meta
Metadata flags.
Definition ena.h:3
#define inline
Definition compiler.h:624
#define __nonnull
Declare a function's pointer parameters as non-null - i.e.
Definition compiler.h:592
#define __pure
Declare a function as pure - i.e.
Definition compiler.h:578
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
User interaction.
int wgetch(WINDOW *win)
Pop a character from the FIFO into a window.
Definition kb.c:55
int wgetnstr(WINDOW *win, char *str, int n)
Read at most n characters from the FIFO into a window.
Definition kb.c:88
Key definitions.
int wmove(WINDOW *win, int y, int x) __nonnull
Move a window's cursor to the specified position.
Definition mucurses.c:136
WINDOW _stdscr
Definition mucurses.c:21
static unsigned int unsigned int y
Definition pixbuf.h:63
static unsigned int x
Definition pixbuf.h:63
int waddch(WINDOW *win, const chtype ch)
Add a single-byte character and rendition to a window and advance the cursor.
Definition print.c:24
int waddnstr(WINDOW *win, const char *str, int n)
Add string of single-byte characters to a window.
Definition print.c:37
int waddchnstr(WINDOW *win, const chtype *chstr, int n)
Add string of single-byte characters and renditions to a window.
Definition print_nadv.c:21
uint8_t bl
Definition registers.h:0
uint8_t ch
Definition registers.h:1
__builtin_va_list va_list
Definition stdarg.h:7
#define bool
Definition stdbool.h:7
Curses SCREEN object.
Definition curses.h:34
void(* init)(struct _curses_screen *scr)
Definition curses.h:40
void(* putc)(struct _curses_screen *scr, chtype c)
Write character to current cursor position.
Definition curses.h:64
void(* erase)(struct _curses_screen *scr, attr_t attrs)
Erase screen.
Definition curses.h:48
attr_t attrs
Current attribute.
Definition curses.h:38
void(* cursor)(struct _curses_screen *scr, int visibility)
Set cursor visibility.
Definition curses.h:86
unsigned int curs_x
Current cursor position.
Definition curses.h:36
int(* getc)(struct _curses_screen *scr)
Pop a character from the keyboard input stream.
Definition curses.h:71
bool(* peek)(struct _curses_screen *scr)
Checks to see whether a character is waiting in the input stream.
Definition curses.h:79
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
void(* exit)(struct _curses_screen *scr)
Definition curses.h:41
unsigned int curs_y
Definition curses.h:36
Curses Window struct.
Definition curses.h:90
unsigned int ori_x
window origin coordinates
Definition curses.h:96
unsigned int curs_x
window cursor position
Definition curses.h:98
unsigned int width
window dimensions
Definition curses.h:100
unsigned int height
Definition curses.h:100
unsigned int ori_y
Definition curses.h:96
unsigned int curs_y
Definition curses.h:98
struct _curses_window * parent
parent window
Definition curses.h:102
attr_t attrs
window attributes
Definition curses.h:94
SCREEN * scr
screen with which window associates
Definition curses.h:92
#define TRUE
Definition tlan.h:46
#define FALSE
Definition tlan.h:45
int ssize_t const char * fmt
Definition vsprintf.h:73