panic() cleanup.
[minix.git] / include / curses.h
blobaf1b0b3290ce40edada49e1b7ed393121324a1ff
1 /* curses.h - defines macros and prototypes for curses */
3 #ifndef _CURSES_H
4 #define _CURSES_H
6 #include <termios.h>
7 #include <stdarg.h>
8 #include <stdio.h>
10 typedef int bool;
12 #ifndef TRUE
13 #define TRUE 1
14 #endif
15 #ifndef FALSE
16 #define FALSE 0
17 #endif
18 #ifndef ERR
19 #define ERR (-1) /* general error flag */
20 #endif
21 #ifndef OK
22 #define OK 0 /* general OK flag */
23 #endif
25 /* Macros. */
26 #define box(win,vc,hc) wbox(win,0,0,0,0,vc,hc)
27 #define addch(ch) waddch(stdscr,ch)
28 #define mvaddch(y,x,ch) (wmove(stdscr,y,x)==ERR?ERR:waddch(stdscr,ch))
29 #define mvwaddch(win,y,x,ch) (wmove(win,y,x)==ERR?ERR:waddch(win,ch))
30 #define getch() wgetch(stdscr)
31 #define mvgetch(y,x) (wmove(stdscr,y,x)==ERR?ERR:wgetch(stdscr))
32 #define mvwgetch(win,y,x) (wmove(win,y,x)==ERR?ERR:wgetch(win))
33 #define addstr(str) waddstr(stdscr,str)
34 #define mvaddstr(y,x,str) (wmove(stdscr,y,x)==ERR?ERR:waddstr(stdscr,str))
35 #define mvwaddstr(win,y,x,str) (wmove(win,y,x)==ERR?ERR:waddstr(win,str))
36 #define getstr(str) wgetstr(stdscr,str)
37 #define mvgetstr(y,x,str) (wmove(stdscr,y,x)==ERR?ERR:wgetstr(stdscr,str))
38 #define mvwgetstr(win,y,x,str) (wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
39 #define move(y,x) wmove(stdscr,y,x)
40 #define clear() wclear(stdscr)
41 #define erase() werase(stdscr)
42 #define clrtobot() wclrtobot(stdscr)
43 #define mvclrtobot(y,x) (wmove(stdscr,y,x)==ERR?ERR:wclrtobot(stdscr))
44 #define mvwclrtobot(win,y,x) (wmove(win,y,x)==ERR?ERR:wclrtobot(win))
45 #define clrtoeol() wclrtoeol(stdscr)
46 #define mvclrtoeol(y,x) (wmove(stdscr,y,x)==ERR?ERR:wclrtoeol(stdscr))
47 #define mvwclrtoeol(win,y,x) (wmove(win,y,x)==ERR?ERR:wclrtoeol(win))
48 #define insertln() winsertln(stdscr)
49 #define mvinsertln(y,x) (wmove(stdscr,y,x)==ERR?ERR:winsertln(stdscr))
50 #define mvwinsertln(win,y,x) (wmove(win,y,x)==ERR?ERR:winsertln(win))
51 #define deleteln() wdeleteln(stdscr)
52 #define mvdeleteln(y,x) (wmove(stdscr,y,x)==ERR?ERR:wdeleteln(stdscr))
53 #define mvwdeleteln(win,y,x) (wmove(win,y,x)==ERR?ERR:wdeleteln(win))
54 #define refresh() wrefresh(stdscr)
55 #define inch() winch(stdscr)
56 #define insch(ch) winsch(stdscr,ch)
57 #define mvinsch(y,x,ch) (wmove(stdscr,y,x)==ERR?ERR:winsch(stdscr,ch))
58 #define mvwinsch(win,y,x,ch) (wmove(win,y,x)==ERR?ERR:winsch(win,ch))
59 #define delch() wdelch(stdscr)
60 #define mvdelch(y,x) (wmove(stdscr,y,x)==ERR?ERR:wdelch(stdscr))
61 #define mvwdelch(win,y,x) (wmove(win,y,x)==ERR?ERR:wdelch(win))
62 #define standout() wstandout(stdscr)
63 #define wstandout(win) ((win)->_attrs |= A_STANDOUT)
64 #define standend() wstandend(stdscr)
65 #define wstandend(win) ((win)->_attrs &= ~A_STANDOUT)
66 #define attrset(attrs) wattrset(stdscr, attrs)
67 #define wattrset(win, attrs) ((win)->_attrs = (attrs))
68 #define attron(attrs) wattron(stdscr, attrs)
69 #define wattron(win, attrs) ((win)->_attrs |= (attrs))
70 #define attroff(attrs) wattroff(stdscr,attrs)
71 #define wattroff(win, attrs) ((win)->_attrs &= ~(attrs))
72 #define resetty() tcsetattr(1, TCSANOW, &_orig_tty)
73 #define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
75 /* Video attribute definitions. */
76 #define A_BLINK 0x0100
77 #define A_BLANK 0
78 #define A_BOLD 0x0200
79 #define A_DIM 0
80 #define A_PROTECT 0
81 #define A_REVERSE 0x0400
82 #define A_STANDOUT 0x0800
83 #define A_UNDERLINE 0x1000
84 #define A_ALTCHARSET 0x2000
86 /* Type declarations. */
87 typedef struct {
88 int _cury; /* current pseudo-cursor */
89 int _curx;
90 int _maxy; /* max coordinates */
91 int _maxx;
92 int _begy; /* origin on screen */
93 int _begx;
94 int _flags; /* window properties */
95 int _attrs; /* attributes of written characters */
96 int _tabsize; /* tab character size */
97 bool _clear; /* causes clear at next refresh */
98 bool _leave; /* leaves cursor as it happens */
99 bool _scroll; /* allows window scrolling */
100 bool _nodelay; /* input character wait flag */
101 bool _keypad; /* flags keypad key mode active */
102 int **_line; /* pointer to line pointer array */
103 int *_minchng; /* First changed character in line */
104 int *_maxchng; /* Last changed character in line */
105 int _regtop; /* Top/bottom of scrolling region */
106 int _regbottom;
107 } WINDOW;
109 /* External variables */
110 extern int LINES; /* terminal height */
111 extern int COLS; /* terminal width */
112 extern bool NONL; /* \n causes CR too ? */
113 extern WINDOW *curscr; /* the current screen image */
114 extern WINDOW *stdscr; /* the default screen window */
115 extern struct termios _orig_tty, _tty;
117 extern unsigned int ACS_ULCORNER; /* terminal dependent block grafic */
118 extern unsigned int ACS_LLCORNER; /* charcters. Forget IBM, we are */
119 extern unsigned int ACS_URCORNER; /* independent of their charset. :-) */
120 extern unsigned int ACS_LRCORNER;
121 extern unsigned int ACS_RTEE;
122 extern unsigned int ACS_LTEE;
123 extern unsigned int ACS_BTEE;
124 extern unsigned int ACS_TTEE;
125 extern unsigned int ACS_HLINE;
126 extern unsigned int ACS_VLINE;
127 extern unsigned int ACS_PLUS;
128 extern unsigned int ACS_S1;
129 extern unsigned int ACS_S9;
130 extern unsigned int ACS_DIAMOND;
131 extern unsigned int ACS_CKBOARD;
132 extern unsigned int ACS_DEGREE;
133 extern unsigned int ACS_PLMINUS;
134 extern unsigned int ACS_BULLET;
135 extern unsigned int ACS_LARROW;
136 extern unsigned int ACS_RARROW;
137 extern unsigned int ACS_DARROW;
138 extern unsigned int ACS_UARROW;
139 extern unsigned int ACS_BOARD;
140 extern unsigned int ACS_LANTERN;
141 extern unsigned int ACS_BLOCK;
143 _PROTOTYPE( char *unctrl, (int _c) );
144 _PROTOTYPE( int baudrate, (void));
145 _PROTOTYPE( void beep, (void));
146 _PROTOTYPE( void cbreak, (void));
147 _PROTOTYPE( void clearok, (WINDOW *_win, bool _flag) );
148 _PROTOTYPE( void clrscr, (void));
149 _PROTOTYPE( void curs_set, (int _visibility) );
150 _PROTOTYPE( void delwin, (WINDOW *_win) );
151 _PROTOTYPE( void doupdate, (void));
152 _PROTOTYPE( void echo, (void));
153 _PROTOTYPE( int endwin, (void));
154 _PROTOTYPE( int erasechar, (void));
155 _PROTOTYPE( void fatal, (char *_s) );
156 _PROTOTYPE( int fixterm, (void));
157 _PROTOTYPE( void flash, (void));
158 _PROTOTYPE( void gettmode, (void));
159 _PROTOTYPE( void idlok, (WINDOW *_win, bool _flag) );
160 _PROTOTYPE( WINDOW *initscr, (void));
161 _PROTOTYPE( void keypad, (WINDOW *_win, bool _flag) );
162 _PROTOTYPE( int killchar, (void));
163 _PROTOTYPE( void leaveok, (WINDOW *_win, bool _flag) );
164 _PROTOTYPE( char *longname, (void));
165 _PROTOTYPE( void meta, (WINDOW *_win, bool _flag) );
166 _PROTOTYPE( int mvcur, (int _oldy, int _oldx, int _newy, int _newx) );
167 _PROTOTYPE( int mvinch, (int _y, int _x) );
168 _PROTOTYPE( int mvprintw, (int _y, int _x, const char *_fmt, ...) );
169 _PROTOTYPE( int mvscanw, (int _y, int _x, const char *_fmt, ...) );
170 _PROTOTYPE( int mvwin, (WINDOW *_win, int _begy, int _begx) );
171 _PROTOTYPE( int mvwinch, (WINDOW *_win, int _y, int _x) );
172 _PROTOTYPE( int mvwprintw, (WINDOW *_win, int _y, int _x, const char *_fmt,
173 ...) );
174 _PROTOTYPE( int mvwscanw, (WINDOW *_win, int _y, int _x, const char *_fmt,
175 ...) );
176 _PROTOTYPE( WINDOW *newwin, (int _num_lines, int _num_cols, int _y, int _x));
177 _PROTOTYPE( void nl, (void));
178 _PROTOTYPE( void nocbreak, (void));
179 _PROTOTYPE( void nodelay, (WINDOW *_win, bool _flag) );
180 _PROTOTYPE( void noecho, (void));
181 _PROTOTYPE( void nonl, (void));
182 _PROTOTYPE( void noraw, (void));
183 _PROTOTYPE( void outc, (int _c) );
184 _PROTOTYPE( void overlay, (WINDOW *_win1, WINDOW *_win2) );
185 _PROTOTYPE( void overwrite, (WINDOW *_win1, WINDOW *_win2) );
186 _PROTOTYPE( void poscur, (int _r, int _c) );
187 _PROTOTYPE( int printw, (const char *_fmt, ...) );
188 _PROTOTYPE( void raw, (void));
189 _PROTOTYPE( int resetterm, (void));
190 _PROTOTYPE( int saveoldterm, (void));
191 _PROTOTYPE( int saveterm, (void));
192 _PROTOTYPE( int savetty, (void));
193 _PROTOTYPE( int scanw, (const char *_fmt, ...) );
194 _PROTOTYPE( void scroll, (WINDOW *_win) );
195 _PROTOTYPE( void scrollok, (WINDOW *_win, bool _flag) );
196 _PROTOTYPE( int setscrreg, (int _top, int _bottom) );
197 _PROTOTYPE( int setterm, (char *_type) );
198 _PROTOTYPE( int setupterm, (void));
199 _PROTOTYPE( WINDOW *subwin, (WINDOW *_orig, int _nlines, int _ncols, int _y,
200 int _x));
201 _PROTOTYPE( int tabsize, (int _ts) );
202 _PROTOTYPE( void touchwin, (WINDOW *_win) );
203 _PROTOTYPE( int waddch, (WINDOW *_win, int _c) );
204 _PROTOTYPE( int waddstr, (WINDOW *_win, char *_str) );
205 _PROTOTYPE( int wbox, (WINDOW *_win, int _ymin, int _xmin, int _ymax,
206 int _xmax, unsigned int _v, unsigned int _h) );
207 _PROTOTYPE( void wclear, (WINDOW *_win) );
208 _PROTOTYPE( int wclrtobot, (WINDOW *_win) );
209 _PROTOTYPE( int wclrtoeol, (WINDOW *_win) );
210 _PROTOTYPE( int wdelch, (WINDOW *_win) );
211 _PROTOTYPE( int wdeleteln, (WINDOW *_win) );
212 _PROTOTYPE( void werase, (WINDOW *_win) );
213 _PROTOTYPE( int wgetch, (WINDOW *_win) );
214 _PROTOTYPE( int wgetstr, (WINDOW *_win, char *_str) );
215 _PROTOTYPE( int winch, (WINDOW *_win) );
216 _PROTOTYPE( int winsch, (WINDOW *_win, int _c) );
217 _PROTOTYPE( int winsertln, (WINDOW *_win) );
218 _PROTOTYPE( int wmove, (WINDOW *_win, int _y, int _x) );
219 _PROTOTYPE( void wnoutrefresh, (WINDOW *_win) );
220 _PROTOTYPE( int wprintw, (WINDOW *_win, const char *_fmt, ...));
221 _PROTOTYPE( void wrefresh, (WINDOW *_win) );
222 _PROTOTYPE( int wscanw, (WINDOW *_win, const char *_fmt, ...));
223 _PROTOTYPE( int wsetscrreg, (WINDOW *_win, int _top, int _bottom) );
224 _PROTOTYPE( int wtabsize, (WINDOW *_win, int _ts) );
226 #endif /* _CURSES_H */