xref: /aosp_15_r20/external/coreboot/payloads/libpayload/curses/PDCurses/demos/tui.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /*
2  * 'textual user interface'
3  *
4  * $Id: tui.h,v 1.11 2008/07/14 12:35:23 wmcbrine Exp $
5  *
6  * Author : P.J. Kunst <[email protected]>
7  * Date   : 25-02-93
8  */
9 
10 #ifndef _TUI_H_
11 #define _TUI_H_
12 
13 #include <curses.h>
14 
15 #ifdef A_COLOR
16 #define A_ATTR  (A_ATTRIBUTES ^ A_COLOR)  /* A_BLINK, A_REVERSE, A_BOLD */
17 #else
18 #define A_ATTR  (A_ATTRIBUTES)            /* standard UNIX attributes */
19 #endif
20 
21 #define MAXSTRLEN  256
22 #define KEY_ESC    0x1b     /* Escape */
23 
24 typedef void (*FUNC)(void);
25 
26 typedef struct
27 {
28     char *name; /* item label */
29     FUNC  func; /* (pointer to) function */
30     char *desc; /* function description */
31 } menu;
32 
33 /* ANSI C function prototypes: */
34 
35 void    clsbody(void);
36 int     bodylen(void);
37 WINDOW *bodywin(void);
38 
39 void    rmerror(void);
40 void    rmstatus(void);
41 
42 void    titlemsg(char *msg);
43 void    bodymsg(char *msg);
44 void    errormsg(char *msg);
45 void    statusmsg(char *msg);
46 
47 bool    keypressed(void);
48 int     getkey(void);
49 int     waitforkey(void);
50 
51 void    DoExit(void);
52 void    startmenu(menu *mp, char *title);
53 void    domenu(menu *mp);
54 
55 int     weditstr(WINDOW *win, char *buf, int field);
56 WINDOW *winputbox(WINDOW *win, int nlines, int ncols);
57 int     getstrings(char *desc[], char *buf[], int field);
58 
59 #define editstr(s,f)           (weditstr(stdscr,s,f))
60 #define mveditstr(y,x,s,f)     (move(y,x)==ERR?ERR:editstr(s,f))
61 #define mvweditstr(w,y,x,s,f)  (wmove(w,y,x)==ERR?ERR:weditstr(w,s,f))
62 
63 #define inputbox(l,c)          (winputbox(stdscr,l,c))
64 #define mvinputbox(y,x,l,c)    (move(y,x)==ERR?w:inputbox(l,c))
65 #define mvwinputbox(w,y,x,l,c) (wmove(w,y,x)==ERR?w:winputbox(w,l,c))
66 
67 #endif
68