1 /* curses.h */
2 /* header for windows implementation of curses library */
3 
4 #ifndef CURSES_H
5 #define CURSES_H	/* define prevents multiple includes */
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 #include <stdio.h>
12 
13 #ifndef INCLUDED_STDARG_H
14 #include <stdarg.h>
15 #define INCLUDED_STDARG_H
16 #endif
17 
18 
19 #define NCURSES_VERSION_MAJOR 5
20 #define NCURSES_VERSION_MINOR 0
21 
22 /* we truncate screen to no larger than this */
23 #define CUR_MAXLINES 80
24 #define CUR_MAXCOLS 200
25 
26 #define CHTYPE unsigned long
27 #ifdef	CHTYPE
28 	typedef	CHTYPE chtype;
29 #else
30 	typedef unsigned long chtype;
31 #endif /* CHTYPE */
32 
33 extern CHTYPE *acs_map;
34 
35 #define ERR (-1)
36 
37 struct tag_window
38 {
39 	short      _cury, _curx;   /* current coordinates */
40 	short      _maxy, _maxx;   /* max coordinates */
41 	short      _begy, _begx;   /* (0,0) screen coordinates */
42 	int        _ylines;        /* major axis size of _y */
43 	int        _ycols;         /* minor axis size of _y */
44 	char      *_yarr;          /* [_ylines][_ycols] array */
45 	int        _num;           /* window number */
46 	int        _scroll;        /* scroll allowed */
47 	int        _boxed;		   /* a box surrounds the window */
48 	int        _mincy;         /* mimimum changed y (for refresh) */
49 	int        _maxcy;         /* mimimum changed y (for refresh) */
50 	struct tag_window * _parent;	/* parent window if a sub window */
51 };
52 
53 typedef struct tag_window WINDOW;
54 typedef	char bool;
55 
56 extern	int	LINES, COLS;
57 extern	WINDOW	*stdscr, *curscr;
58 
59 /* routine prototypes */
60 
61 int box(WINDOW *wp, chtype x, chtype y);
62 int cbreak();
63 int clearok(WINDOW *wp, int okay);
64 int crmode();
65 int curs_set(int mode);
66 int delwin(WINDOW *wp);
67 int doupdate(void);
68 int echo();
69 int endwin();
70 int has_key(int ch);
71 WINDOW  *initscr();
72 int keypad(WINDOW *wp, int bf);
73 int mvwaddch(WINDOW *wp, int y, int x, chtype ch);
74 int mvwaddnstr(WINDOW *wp, int y, int x, char *cp, int n);
75 int mvwaddstr(WINDOW *wp, int y, int x, char *cp);
76 int mvwgetnstr(WINDOW *wp, int y, int x, char *cp, int n);
77 int mvwgetstr(WINDOW *wp, int y, int x, char *cp);
78 int mvwprintw(WINDOW *wp, int x, int y, ...);
79 WINDOW  *newwin(int nlines, int ncols, int begy, int begx);
80 int nocbreak();
81 int nocrmode();
82 int noecho();
83 int redrawwin(WINDOW *wp);
84 int scrollok(WINDOW *wp, int okay);
85 WINDOW  *subwin(WINDOW *wp, int nlines, int ncols, int begy, int begx);
86 int touchwin(WINDOW *wp);
87 int vwprintw(WINDOW *wp, char *fmt, va_list ap);
88 int waddch(WINDOW *wp, chtype ch);
89 int waddnstr(WINDOW *wp, const char *cp, int n);
90 int waddstr(WINDOW *wp, const char *cp);
91 int wborder(WINDOW *wp, chtype ls, chtype rs, chtype ts, chtype bs
92 	, chtype tl, chtype tr, chtype bl, chtype br);
93 int wclrtoeol(WINDOW *wp);
94 int werase(WINDOW *wp);
95 int wgetch(WINDOW *wp);
96 int wgetnstr(WINDOW *wp, char *cp, int n);
97 int wgetstr(WINDOW *wp, char *cp);
98 int wmove(WINDOW *wp, int x, int y);
99 int wnoutrefresh(WINDOW *wp);
100 int wprintw(WINDOW *wp, ...);
101 int wrefresh(WINDOW *wp);
102 /* win32 specific routines */
103 void wtitle(const char * title);
104 
105 /*
106  * Standard alternate character set.  The current ACS world is evolving,
107  * so we support only a widely available subset: the line drawing characters
108  * from the VT100, plus a few from the Teletype 5410v1.  Eventually there
109  * may be support of more sophisticated ACS line drawing, such as that
110  * in the Teletype 5410, the HP line drawing set, and the like.  There may
111  * be support for some non line oriented characters as well.
112  *
113  * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
114  * is the right, b is the bottom, and l is the left.  t, r, b, and l might
115  * be B (blank), S (single), D (double), or T (thick).  The subset defined
116  * here only uses B and S.
117  */
118 
119 #define ACS_BSSB	(acs_map['l'])
120 #define ACS_SSBB	(acs_map['m'])
121 #define ACS_BBSS	(acs_map['k'])
122 #define ACS_SBBS	(acs_map['j'])
123 #define ACS_SBSS	(acs_map['u'])
124 #define ACS_SSSB	(acs_map['t'])
125 #define ACS_SSBS	(acs_map['v'])
126 #define ACS_BSSS	(acs_map['w'])
127 #define ACS_BSBS	(acs_map['q'])
128 #define ACS_SBSB	(acs_map['x'])
129 #define ACS_SSSS	(acs_map['n'])
130 
131 /*
132  * Human readable names for the most commonly used characters.
133  * "Upper", "right", etc. are chosen to be consistent with the vt100 manual.
134  */
135 
136 #define ACS_ULCORNER	ACS_BSSB
137 #define ACS_LLCORNER	ACS_SSBB
138 #define ACS_URCORNER	ACS_BBSS
139 #define ACS_LRCORNER	ACS_SBBS
140 #define ACS_RTEE	ACS_SBSS
141 #define ACS_LTEE	ACS_SSSB
142 #define ACS_BTEE	ACS_SSBS
143 #define ACS_TTEE	ACS_BSSS
144 #define ACS_HLINE	ACS_BSBS
145 #define ACS_VLINE	ACS_SBSB
146 #define ACS_PLUS	ACS_SSSS
147 #define ACS_S1		(acs_map['o'])	/* scan line 1 */
148 #define ACS_S9		(acs_map['s'])	/* scan line 9 */
149 #define ACS_DIAMOND	(acs_map['`'])	/* diamond */
150 #define ACS_CKBOARD	(acs_map['a'])	/* checker board (stipple) */
151 #define ACS_DEGREE	(acs_map['f'])	/* degree symbol */
152 #define ACS_PLMINUS	(acs_map['g'])	/* plus/minus */
153 #define ACS_BULLET	(acs_map['~'])	/* bullet */
154 	/* Teletype 5410v1 symbols */
155 #define ACS_LARROW	(acs_map[','])	/* arrow pointing left */
156 #define ACS_RARROW	(acs_map['+'])	/* arrow pointing right */
157 #define ACS_DARROW	(acs_map['.'])	/* arrow pointing down */
158 #define ACS_UARROW	(acs_map['-'])	/* arrow pointing up */
159 #define ACS_BOARD	(acs_map['h'])	/* board of squares */
160 #define ACS_LANTERN	(acs_map['i'])	/* lantern symbol */
161 #define ACS_BLOCK	(acs_map['0'])	/* solid square block */
162 
163 /* Funny "characters" enabled for various special function keys for input */
164 /* This list is created from caps and curses.ed. Do not edit it! */
165 #define KEY_MIN		0401		/* Minimum curses key */
166 #define KEY_BREAK	0401		/* break key (unreliable) */
167 #define KEY_DOWN	0402		/* Sent by terminal down arrow key */
168 #define KEY_UP		0403		/* Sent by terminal up arrow key */
169 #define KEY_LEFT	0404		/* Sent by terminal left arrow key */
170 #define KEY_RIGHT	0405		/* Sent by terminal right arrow key */
171 #define KEY_HOME	0406		/* Sent by home key. */
172 #define KEY_BACKSPACE	0407		/* Sent by backspace key */
173 #define KEY_F0		0410		/* function key f0. */
174 #define KEY_F(n)	(KEY_F0+(n))	/* Space for 64 function keys is reserved. */
175 #define KEY_DL		0510		/* Sent by delete line key. */
176 #define KEY_IL		0511		/* Sent by insert line. */
177 #define KEY_DC		0512		/* Sent by delete character key. */
178 #define KEY_IC		0513		/* Sent by ins char/enter ins mode key. */
179 #define KEY_EIC		0514		/* Sent by rmir or smir in insert mode. */
180 #define KEY_CLEAR	0515		/* Sent by clear screen or erase key. */
181 #define KEY_EOS		0516		/* Sent by clear-to-end-of-screen key. */
182 #define KEY_EOL		0517		/* Sent by clear-to-end-of-line key. */
183 #define KEY_SF		0520		/* Sent by scroll-forward/down key */
184 #define KEY_SR		0521		/* Sent by scroll-backward/up key */
185 #define KEY_NPAGE	0522		/* Sent by next-page key */
186 #define KEY_PPAGE	0523		/* Sent by previous-page key */
187 #define KEY_STAB	0524		/* Sent by set-tab key */
188 #define KEY_CTAB	0525		/* Sent by clear-tab key */
189 #define KEY_CATAB	0526		/* Sent by clear-all-tabs key. */
190 #define KEY_ENTER	0527		/* Enter/send (unreliable) */
191 #define KEY_SRESET	0530		/* soft (partial) reset (unreliable) */
192 #define KEY_RESET	0531		/* reset or hard reset (unreliable) */
193 #define KEY_PRINT	0532		/* print or copy */
194 #define KEY_LL		0533		/* Sent by home-down key */
195 					/* The keypad is arranged like this: */
196 					/*    a1    up    a3   */
197 					/*   left   b2  right  */
198 					/*    c1   down   c3   */
199 #define KEY_A1		0534		/* Upper left of keypad */
200 #define KEY_A3		0535		/* Upper right of keypad */
201 #define KEY_B2		0536		/* Center of keypad */
202 #define KEY_C1		0537		/* Lower left of keypad */
203 #define KEY_C3		0540		/* Lower right of keypad */
204 #define KEY_BTAB	0541		/* Back tab key */
205 #define KEY_BEG		0542		/* beg(inning) key */
206 #define KEY_CANCEL	0543		/* cancel key */
207 #define KEY_CLOSE	0544		/* close key */
208 #define KEY_COMMAND	0545		/* cmd (command) key */
209 #define KEY_COPY	0546		/* copy key */
210 #define KEY_CREATE	0547		/* create key */
211 #define KEY_END		0550		/* end key */
212 #define KEY_EXIT	0551		/* exit key */
213 #define KEY_FIND	0552		/* find key */
214 #define KEY_HELP	0553		/* help key */
215 #define KEY_MARK	0554		/* mark key */
216 #define KEY_MESSAGE	0555		/* message key */
217 #define KEY_MOVE	0556		/* move key */
218 #define KEY_NEXT	0557		/* next object key */
219 #define KEY_OPEN	0560		/* open key */
220 #define KEY_OPTIONS	0561		/* options key */
221 #define KEY_PREVIOUS	0562		/* previous object key */
222 #define KEY_REDO	0563		/* redo key */
223 #define KEY_REFERENCE	0564		/* ref(erence) key */
224 #define KEY_REFRESH	0565		/* refresh key */
225 #define KEY_REPLACE	0566		/* replace key */
226 #define KEY_RESTART	0567		/* restart key */
227 #define KEY_RESUME	0570		/* resume key */
228 #define KEY_SAVE	0571		/* save key */
229 #define KEY_SBEG	0572		/* shifted beginning key */
230 #define KEY_SCANCEL	0573		/* shifted cancel key */
231 #define KEY_SCOMMAND	0574		/* shifted command key */
232 #define KEY_SCOPY	0575		/* shifted copy key */
233 #define KEY_SCREATE	0576		/* shifted create key */
234 #define KEY_SDC		0577		/* shifted delete char key */
235 #define KEY_SDL		0600		/* shifted delete line key */
236 #define KEY_SELECT	0601		/* select key */
237 #define KEY_SEND	0602		/* shifted end key */
238 #define KEY_SEOL	0603		/* shifted clear line key */
239 #define KEY_SEXIT	0604		/* shifted exit key */
240 #define KEY_SFIND	0605		/* shifted find key */
241 #define KEY_SHELP	0606		/* shifted help key */
242 #define KEY_SHOME	0607		/* shifted home key */
243 #define KEY_SIC		0610		/* shifted input key */
244 #define KEY_SLEFT	0611		/* shifted left arrow key */
245 #define KEY_SMESSAGE	0612		/* shifted message key */
246 #define KEY_SMOVE	0613		/* shifted move key */
247 #define KEY_SNEXT	0614		/* shifted next key */
248 #define KEY_SOPTIONS	0615		/* shifted options key */
249 #define KEY_SPREVIOUS	0616		/* shifted prev key */
250 #define KEY_SPRINT	0617		/* shifted print key */
251 #define KEY_SREDO	0620		/* shifted redo key */
252 #define KEY_SREPLACE	0621		/* shifted replace key */
253 #define KEY_SRIGHT	0622		/* shifted right arrow */
254 #define KEY_SRSUME	0623		/* shifted resume key */
255 #define KEY_SSAVE	0624		/* shifted save key */
256 #define KEY_SSUSPEND	0625		/* shifted suspend key */
257 #define KEY_SUNDO	0626		/* shifted undo key */
258 #define KEY_SUSPEND	0627		/* suspend key */
259 #define KEY_UNDO	0630		/* undo key */
260 #define KEY_MOUSE	0631		/* Mouse event has occured */
261 #define KEY_MAX		0777		/* Maximum curses key */
262 
263 /* Various video attributes */
264 #define A_STANDOUT	000000200000L
265 #define	_STANDOUT	A_STANDOUT    /* for compatability with old curses */
266 #define A_UNDERLINE	000000400000L
267 #define A_REVERSE	000001000000L
268 #define A_BLINK		000002000000L
269 #define A_DIM		000004000000L
270 #define A_BOLD		000010000000L
271 #define A_ALTCHARSET	000100000000L
272 
273 /* The next two are subject to change so don't depend on them */
274 #define A_INVIS		000020000000L
275 #define A_PROTECT	000040000000L
276 
277 #define A_NORMAL	000000000000L
278 #define A_ATTRIBUTES	037777600000L	/* 0xFFFF0000 */
279 #define A_CHARTEXT	000000177777L	/* 0x0000FFFF */
280 #define A_COLOR		017600000000L
281 
282 #define COLOR_PAIR(n)	((n) << 25)
283 #define PAIR_NUMBER(n)	(((n) & A_COLOR) >> 25)
284 
285 /* definition of 8 basic color	*/
286 #define COLOR_BLACK	0
287 #define COLOR_RED	1
288 #define COLOR_GREEN	2
289 #define COLOR_YELLOW	3
290 #define COLOR_BLUE	4
291 #define COLOR_MAGENTA	5
292 #define COLOR_CYAN	6
293 #define COLOR_WHITE	7
294 
295 #ifdef CURSES_MOUSE
296 /* mouse related macros: don't change these definitions or bit-masks. */
297 /* they are interdependent (used by _map_button() in tgetch()	      */
298 #define BUTTON_RELEASED            0
299 #define BUTTON_PRESSED             1
300 #define BUTTON_CLICKED             2
301 #define BUTTON_DOUBLE_CLICKED      3
302 #define BUTTON_TRIPLE_CLICKED      4
303 
304 #define MOUSE_X_POS                (Mouse_status.x)
305 #define MOUSE_Y_POS                (Mouse_status.y)
306 #define A_BUTTON_CHANGED           (Mouse_status.changes & 7)
307 #define MOUSE_MOVED                (Mouse_status.changes & 8)
308 #define MOUSE_POS_REPORT	   (Mouse_status.changes & 16)
309 #define BUTTON_CHANGED(x)          (Mouse_status.changes & (1 << ((x) - 1)))
310 #define BUTTON_STATUS(x)           (Mouse_status.button[(x)-1])
311 
312 /* definition of mouse bit-masks	*/
313 #define	BUTTON1_RELEASED	000000000001L
314 #define	BUTTON1_PRESSED		000000000002L
315 #define	BUTTON1_CLICKED		000000000004L
316 #define	BUTTON1_DOUBLE_CLICKED	000000000010L
317 #define	BUTTON1_TRIPLE_CLICKED	000000000020L
318 #define	BUTTON2_RELEASED	000000000040L
319 #define	BUTTON2_PRESSED		000000000100L
320 #define	BUTTON2_CLICKED		000000000200L
321 #define	BUTTON2_DOUBLE_CLICKED	000000000400L
322 #define	BUTTON2_TRIPLE_CLICKED	000000001000L
323 #define	BUTTON3_RELEASED	000000002000L
324 #define	BUTTON3_PRESSED		000000004000L
325 #define	BUTTON3_CLICKED		000000010000L
326 #define	BUTTON3_DOUBLE_CLICKED	000000020000L
327 #define	BUTTON3_TRIPLE_CLICKED	000000040000L
328 #define ALL_MOUSE_EVENTS	000000077777L
329 #define REPORT_MOUSE_POSITION	000000100000L
330 #endif	/* CURSES_MOUSE */
331 
332 #ifdef __cplusplus
333 }
334 #endif
335 
336 #endif /* CURSES_H */
337