xref: /titanic_51/usr/src/lib/libxcurses2/h/curses.h (revision a31148363f598def767ac48c5d82e1572e44b935)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1996-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _CURSES_H
28 #define	_CURSES_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * curses.h
34  *
35  * XCurses Library
36  *
37  * Copyright 1990, 1995 by Mortice Kern Systems Inc.  All rights reserved.
38  *
39  */
40 
41 #include <sys/isa_defs.h>
42 #include <stdio.h>
43 #include <term.h>
44 #include <wchar.h>
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 #define	_XOPEN_CURSES
51 
52 #ifndef EOF
53 #define	EOF			(-1)
54 #endif
55 
56 #ifndef WEOF
57 #define	WEOF		((wint_t)(-1))
58 #endif
59 
60 #define	ERR			EOF
61 #define	OK			0
62 
63 #if !(defined(__cplusplus) && defined(_BOOL))
64 #ifndef _BOOL_DEFINED
65 typedef short	bool;
66 #define	_BOOL_DEFINED
67 #endif
68 #endif
69 
70 #define	TRUE    		1
71 #define	FALSE   		0
72 
73 typedef unsigned short	attr_t;
74 
75 /*
76  * These attributes and masks can be applied to an attr_t.
77  * These are ordered according to the <no_color_video> mask,
78  * which has been extended to include additional attributes.
79  */
80 #define	WA_NORMAL	0x0
81 #define	WA_STANDOUT	0x0001
82 #define	WA_UNDERLINE	0x0002
83 #define	WA_REVERSE	0x0004
84 #define	WA_BLINK	0x0008
85 #define	WA_DIM		0x0010
86 #define	WA_BOLD		0x0020
87 #define	WA_INVIS	0x0040
88 #define	WA_PROTECT	0x0080
89 #define	WA_ALTCHARSET	0x0100
90 #define	WA_HORIZONTAL	0x0200
91 #define	WA_LEFT		0x0400
92 #define	WA_LOW		0x0800
93 #define	WA_RIGHT	0x1000
94 #define	WA_TOP		0x2000
95 #define	WA_VERTICAL	0x4000
96 
97 #define	WA_SGR_MASK	0x01ff		/* Historical attribute set. */
98 #define	WA_SGR1_MASK	0x7e00		/* Extended attribute set. */
99 
100 /*
101  * Internal attribute used to support <ceol_standout_glitch>.
102  */
103 #define	WA_COOKIE	0x8000
104 
105 /*
106  * Color names.
107  */
108 #define	COLOR_BLACK	0
109 #define	COLOR_RED	1
110 #define	COLOR_GREEN	2
111 #define	COLOR_YELLOW	3
112 #define	COLOR_BLUE	4
113 #define	COLOR_MAGENTA	5
114 #define	COLOR_CYAN	6
115 #define	COLOR_WHITE	7
116 
117 /*
118  * A cchar_t details the attributes, color, and a string of wide characters
119  * composing a complex character (p12).  The wide character string consists
120  * of a spacing character (wcwidth() > 0) and zero or more non-spacing
121  * characters.  Xcurses (p17) states that the minimum number of non-spacing
122  * characters associated with a spacing character must be at least 5, if a
123  * limit is imposed.
124  */
125 #define	_M_CCHAR_MAX	6
126 
127 /*
128  * Opaque data type.
129  */
130 typedef struct {
131 	short	_f;			/* True if start of character. */
132 	short	_n;			/* Number of elements in wc[]. */
133 	short	_co;		/* Color pair number. */
134 	attr_t	_at;		/* Attribute flags. */
135 	wchar_t	_wc[_M_CCHAR_MAX];	/* Complex spacing character. */
136 } cchar_t;
137 
138 /*
139  * Opaque data type.
140  */
141 typedef struct window_t {
142 	cchar_t	_bg;		/* Background. */
143 	cchar_t	_fg;		/* Foreground, ignore character. */
144 	short	_cury, _curx;	/* Curent cursor position in window. */
145 	short	_begy, _begx;	/* Upper-left origin on screen. */
146 	short	_maxy, _maxx;	/* Window dimensions. */
147 	short	_top, _bottom;	/* Window's software scroll region. */
148 	short	_refy, _refx;	/* Pad origin of last refresh. */
149 	short	_sminy, _sminx;	/* T-L screen corner of last refresh. */
150 	short	_smaxy, _smaxx;	/* B-R screen corner of last refresh. */
151 	short	_vmin, _vtime;	/* wtimeout() control. */
152 	short	*_first, *_last;	/* Dirty region for each screen line. */
153 	unsigned short	_flags;		/* Internal flags for the window. */
154 	unsigned short	_scroll;	/* Internal for scroll optimization. */
155 	cchar_t	**_line;
156 	cchar_t	*_base;		/* Block of M*N screen cells. */
157 	struct window_t	*_parent;	/* Parent of sub-window. */
158 } WINDOW;
159 
160 /*
161  * Opaque data type.
162  */
163 typedef struct {
164 	int _kfd;		/* typeahead() file descriptor. */
165 	FILE *_if, *_of;	/* I/O file pointers. */
166 	TERMINAL *_term;	/* Associated terminfo entry. */
167 	WINDOW *_newscr;	/* New screen image built by wnoutrefresh(). */
168 	WINDOW *_curscr;	/* Current screen image after doupdate(). */
169 	mbstate_t _state;	/* Current multibyte state of _of. */
170 #if defined(_LP64)
171 	unsigned int	*_hash;	/* Hash values for curscr's screen lines. */
172 #else
173 	unsigned long	*_hash;	/* Hash values for curscr's screen lines. */
174 #endif /* defined(_LP64) */
175 	unsigned short _flags;	/* Assorted flags. */
176 	void *_decode;		/* Function key decode tree. */
177 	void *_in;		/* Wide I/O object. */
178 	struct {
179 		int _size;	/* Allocated size of the input stack. */
180 		int _count;	/* Number of entries on the input stack. */
181 		int *_stack;	/* Buffer used for the input stack. */
182 	} _unget;
183 	struct {
184 		WINDOW *_w;	/* Exists on if emulating soft label keys. */
185 		char *_labels[8];	/* Soft label key strings. */
186 		short _justify[8];	/* Justification for label. */
187 		char	*_saved[8];	/* exact representation of label */
188 	} _slk;
189 } SCREEN;
190 
191 
192 /*
193  * Backwards compatiblity with historical Curses applications.
194  */
195 #ifndef	_CHTYPE
196 #define	_CHTYPE
197 #if defined(_LP64)
198 typedef unsigned int	chtype;
199 #else
200 typedef unsigned long	chtype;
201 #endif
202 #endif
203 
204 /*
205  * These attributes and masks can be applied to a chtype.
206  * They are order according to the <no_color_video> mask.
207  */
208 #if defined(_LP64)
209 #define	A_NORMAL		0x00000000U
210 #define	A_ATTRIBUTES	0xffff0000U	/* Color/Attribute mask */
211 #define	A_CHARTEXT		0x0000ffffU	/* 16-bit character mask */
212 #define	A_STANDOUT		0x00010000U
213 #define	A_UNDERLINE		0x00020000U
214 #define	A_REVERSE		0x00040000U
215 #define	A_BLINK			0x00080000U
216 #define	A_DIM			0x00100000U
217 #define	A_BOLD			0x00200000U
218 #define	A_INVIS			0x00400000U
219 #define	A_PROTECT		0x00800000U
220 #define	A_ALTCHARSET	0x01000000U
221 #define	A_COLOR			0xfe000000U	/* Color mask */
222 #else	/* defined(_LP64) */
223 #define	A_NORMAL		0x00000000UL
224 #define	A_ATTRIBUTES	0xffff0000UL	/* Color/Attribute mask */
225 #define	A_CHARTEXT		0x0000ffffUL	/* 16-bit character mask */
226 #define	A_STANDOUT		0x00010000UL
227 #define	A_UNDERLINE		0x00020000UL
228 #define	A_REVERSE		0x00040000UL
229 #define	A_BLINK			0x00080000UL
230 #define	A_DIM			0x00100000UL
231 #define	A_BOLD			0x00200000UL
232 #define	A_INVIS			0x00400000UL
233 #define	A_PROTECT		0x00800000UL
234 #define	A_ALTCHARSET	0x01000000UL
235 #define	A_COLOR			0xfe000000UL	/* Color mask */
236 #endif	/* defined(_LP64) */
237 
238 /*
239  * Color atttribute support for chtype.
240  */
241 #define	__COLOR_SHIFT	26
242 
243 /*
244  * Characters constants used with a chtype.
245  * Mapping defined in Xcurses Section 6.2.12 (p260).
246  */
247 #define	ACS_VLINE	(A_ALTCHARSET | 'x')
248 #define	ACS_HLINE	(A_ALTCHARSET | 'q')
249 #define	ACS_ULCORNER	(A_ALTCHARSET | 'l')
250 #define	ACS_URCORNER	(A_ALTCHARSET | 'k')
251 #define	ACS_LLCORNER	(A_ALTCHARSET | 'm')
252 #define	ACS_LRCORNER	(A_ALTCHARSET | 'j')
253 #define	ACS_RTEE	(A_ALTCHARSET | 'u')
254 #define	ACS_LTEE	(A_ALTCHARSET | 't')
255 #define	ACS_BTEE	(A_ALTCHARSET | 'v')
256 #define	ACS_TTEE	(A_ALTCHARSET | 'w')
257 #define	ACS_PLUS	(A_ALTCHARSET | 'n')
258 #define	ACS_S1	(A_ALTCHARSET | 'o')
259 #define	ACS_S9	(A_ALTCHARSET | 's')
260 #define	ACS_DIAMOND	(A_ALTCHARSET | '`')
261 #define	ACS_CKBOARD	(A_ALTCHARSET | 'a')
262 #define	ACS_DEGREE	(A_ALTCHARSET | 'f')
263 #define	ACS_PLMINUS	(A_ALTCHARSET | 'g')
264 #define	ACS_BULLET	(A_ALTCHARSET | '~')
265 #define	ACS_LARROW	(A_ALTCHARSET | ',')
266 #define	ACS_RARROW	(A_ALTCHARSET | '+')
267 #define	ACS_DARROW	(A_ALTCHARSET | '.')
268 #define	ACS_UARROW	(A_ALTCHARSET | '-')
269 #define	ACS_BOARD	(A_ALTCHARSET | 'h')
270 #define	ACS_LANTERN	(A_ALTCHARSET | 'i')
271 #define	ACS_BLOCK	(A_ALTCHARSET | '0')
272 
273 /*
274  * Wide characters constants for a cchar_t.
275  */
276 extern const cchar_t __WACS_VLINE;
277 extern const cchar_t __WACS_HLINE;
278 extern const cchar_t __WACS_ULCORNER;
279 extern const cchar_t __WACS_URCORNER;
280 extern const cchar_t __WACS_LLCORNER;
281 extern const cchar_t __WACS_LRCORNER;
282 extern const cchar_t __WACS_RTEE;
283 extern const cchar_t __WACS_LTEE;
284 extern const cchar_t __WACS_BTEE;
285 extern const cchar_t __WACS_TTEE;
286 extern const cchar_t __WACS_PLUS;
287 extern const cchar_t __WACS_S1;
288 extern const cchar_t __WACS_S9;
289 extern const cchar_t __WACS_DIAMOND;
290 extern const cchar_t __WACS_CKBOARD;
291 extern const cchar_t __WACS_DEGREE;
292 extern const cchar_t __WACS_PLMINUS;
293 extern const cchar_t __WACS_BULLET;
294 extern const cchar_t __WACS_LARROW;
295 extern const cchar_t __WACS_RARROW;
296 extern const cchar_t __WACS_DARROW;
297 extern const cchar_t __WACS_UARROW;
298 extern const cchar_t __WACS_BOARD;
299 extern const cchar_t __WACS_LANTERN;
300 extern const cchar_t __WACS_BLOCK;
301 
302 #define	WACS_VLINE	&__WACS_VLINE
303 #define	WACS_HLINE	&__WACS_HLINE
304 #define	WACS_ULCORNER	&__WACS_ULCORNER
305 #define	WACS_URCORNER	&__WACS_URCORNER
306 #define	WACS_LLCORNER	&__WACS_LLCORNER
307 #define	WACS_LRCORNER	&__WACS_LRCORNER
308 #define	WACS_RTEE	&__WACS_RTEE
309 #define	WACS_LTEE	&__WACS_LTEE
310 #define	WACS_BTEE	&__WACS_BTEE
311 #define	WACS_TTEE	&__WACS_TTEE
312 #define	WACS_PLUS	&__WACS_PLUS
313 #define	WACS_S1		&__WACS_S1
314 #define	WACS_S9		&__WACS_S9
315 #define	WACS_DIAMOND	&__WACS_DIAMOND
316 #define	WACS_CKBOARD	&__WACS_CKBOARD
317 #define	WACS_DEGREE	&__WACS_DEGREE
318 #define	WACS_PLMINUS	&__WACS_PLMINUS
319 #define	WACS_BULLET	&__WACS_BULLET
320 #define	WACS_LARROW	&__WACS_LARROW
321 #define	WACS_RARROW	&__WACS_RARROW
322 #define	WACS_DARROW	&__WACS_DARROW
323 #define	WACS_UARROW	&__WACS_UARROW
324 #define	WACS_BOARD	&__WACS_BOARD
325 #define	WACS_LANTERN	&__WACS_LANTERN
326 #define	WACS_BLOCK	&__WACS_BLOCK
327 
328 
329 /*
330  * Internal macros.
331  */
332 #define	__m_getpary(w)		((w)->_parent == (WINDOW *) 0 ? -1 \
333 				: (w)->_begy - (w)->_parent->_begy)
334 #define	__m_getparx(w)		((w)->_parent == (WINDOW *) 0 ? -1 \
335 				: (w)->_begx - (w)->_parent->_begx)
336 
337 /*
338  * Global Window Macros
339  */
340 #define	getyx(w, y, x)	(y = (w)->_cury, x = (w)->_curx)
341 #define	getbegyx(w, y, x)	(y = (w)->_begy, x = (w)->_begx)
342 #define	getmaxyx(w, y, x)	(y = (w)->_maxy, x = (w)->_maxx)
343 #define	getparyx(w, y, x)	(y = __m_getpary(w), x = __m_getparx(w))
344 
345 /*
346  * Global variables
347  */
348 extern int LINES, COLS;
349 extern WINDOW *curscr, *stdscr;
350 extern int COLORS, COLOR_PAIRS;
351 
352 extern int addch(chtype);
353 extern int addchnstr(const chtype *, int);
354 extern int addchstr(const chtype *);
355 extern int addnstr(const char *, int);
356 extern int addnwstr(const wchar_t *, int);
357 extern int addstr(const char *);
358 extern int add_wch(const cchar_t *);
359 extern int add_wchnstr(const cchar_t *, int);
360 extern int add_wchstr(const cchar_t *);
361 extern int addwstr(const wchar_t *);
362 extern int attroff(int);
363 extern int attron(int);
364 extern int attrset(int);
365 extern int attr_get(attr_t *, short *, void *);
366 extern int attr_off(attr_t, void *);
367 extern int attr_on(attr_t, void *);
368 extern int attr_set(attr_t, short, void *);
369 extern int baudrate(void);
370 extern int beep(void);
371 extern int bkgd(chtype);
372 extern void	bkgdset(chtype);
373 extern int bkgrnd(const cchar_t *);
374 extern void bkgrndset(const cchar_t *);
375 extern int border(
376 	chtype, chtype, chtype, chtype,
377 	chtype, chtype, chtype, chtype);
378 extern int border_set(
379 	const cchar_t *, const cchar_t *,
380 	const cchar_t *, const cchar_t *,
381 	const cchar_t *, const cchar_t *,
382 	const cchar_t *, const cchar_t *);
383 extern int box(WINDOW *, chtype, chtype);
384 extern int box_set(WINDOW *, const cchar_t *, const cchar_t *);
385 extern bool can_change_color(void);
386 extern int cbreak(void);
387 extern int chgat(int, attr_t, short, const void *);
388 extern int clearok(WINDOW *, bool);
389 extern int clear(void);
390 extern int clrtobot(void);
391 extern int clrtoeol(void);
392 extern int color_content(short, short *, short *, short *);
393 extern int COLOR_PAIR(int);
394 extern int color_set(short, void *);
395 extern int copywin(const WINDOW *, WINDOW *,
396 	int, int, int, int, int, int, int);
397 extern int curs_set(int);
398 extern int def_prog_mode(void);
399 extern int def_shell_mode(void);
400 extern int delay_output(int);
401 extern int delch(void);
402 extern int deleteln(void);
403 extern void delscreen(SCREEN *);
404 extern int delwin(WINDOW *);
405 extern WINDOW *derwin(WINDOW *, int, int, int, int);
406 extern int doupdate(void);
407 extern WINDOW *dupwin(WINDOW *);
408 extern int echo(void);
409 extern int echochar(const chtype);
410 extern int echo_wchar(const cchar_t *);
411 extern int endwin(void);
412 extern char erasechar(void);
413 extern int erase(void);
414 extern int erasewchar(wchar_t *);
415 extern void filter(void);
416 extern int flash(void);
417 extern int flushinp(void);
418 extern chtype getbkgd(WINDOW *);
419 extern int getbkgrnd(cchar_t *);
420 extern int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
421 extern int getch(void);
422 extern int getnstr(char *, int);
423 extern int getn_wstr(wint_t *, int);
424 extern int getstr(char *);
425 extern int get_wch(wint_t *);
426 extern WINDOW *getwin(FILE *);
427 extern int get_wstr(wint_t *);
428 extern int halfdelay(int);
429 extern bool has_colors(void);
430 extern bool has_ic(void);
431 extern bool has_il(void);
432 extern int hline(chtype, int);
433 extern int hline_set(const cchar_t *, int);
434 extern void idcok(WINDOW *, bool);
435 extern int idlok(WINDOW *, bool);
436 extern void immedok(WINDOW *, bool);
437 extern chtype inch(void);
438 extern int inchnstr(chtype *, int);
439 extern int inchstr(chtype *);
440 extern WINDOW *initscr(void);
441 extern int init_color(short, short, short, short);
442 extern int init_pair(short, short, short);
443 extern int innstr(char *, int);
444 extern int innwstr(wchar_t *, int);
445 extern int insch(chtype);
446 extern int insdelln(int);
447 extern int insertln(void);
448 extern int insnstr(const char *, int);
449 extern int ins_nwstr(const wchar_t *, int);
450 extern int insstr(const char *);
451 extern int instr(char *);
452 extern int ins_wch(const cchar_t *);
453 extern int ins_wstr(const wchar_t *);
454 extern int intrflush(WINDOW *, bool);
455 extern int in_wch(cchar_t *);
456 extern int in_wchnstr(cchar_t *, int);
457 extern int in_wchstr(cchar_t *);
458 extern int inwstr(wchar_t *);
459 extern bool isendwin(void);
460 extern bool is_linetouched(WINDOW *, int);
461 extern bool is_wintouched(WINDOW *);
462 extern char *keyname(int);
463 extern char *key_name(wchar_t);
464 extern int keypad(WINDOW *, bool);
465 extern char killchar(void);
466 extern int killwchar(wchar_t *);
467 extern int leaveok(WINDOW *, bool);
468 extern char *longname(void);
469 extern int meta(WINDOW *, bool);
470 extern int move(int, int);
471 extern int mvaddch(int, int, chtype);
472 extern int mvaddchnstr(int, int, const chtype *, int);
473 extern int mvaddchstr(int, int, const chtype *);
474 extern int mvaddnstr(int, int, const char *, int);
475 extern int mvaddnwstr(int, int, const wchar_t *, int);
476 extern int mvaddstr(int, int, const char *);
477 extern int mvadd_wch(int, int, const cchar_t *);
478 extern int mvadd_wchnstr(int, int, const cchar_t *, int);
479 extern int mvadd_wchstr(int, int, const cchar_t *);
480 extern int mvaddwstr(int, int, const wchar_t *);
481 extern int mvchgat(int, int, int, attr_t, short, const void *);
482 extern int mvcur(int, int, int, int);
483 extern int mvdelch(int, int);
484 extern int mvderwin(WINDOW *, int, int);
485 extern int mvgetch(int, int);
486 extern int mvgetnstr(int, int, char *, int);
487 extern int mvgetn_wstr(int, int, wint_t *, int);
488 extern int mvgetstr(int, int, char *);
489 extern int mvget_wch(int, int, wint_t *);
490 extern int mvget_wstr(int, int, wint_t *);
491 extern int mvhline(int, int, chtype, int);
492 extern int mvhline_set(int, int, const cchar_t *, int);
493 extern chtype mvinch(int, int);
494 extern int mvinchnstr(int, int, chtype *, int);
495 extern int mvinchstr(int, int, chtype *);
496 extern int mvinnstr(int, int, char *, int);
497 extern int mvinnwstr(int, int, wchar_t *, int);
498 extern int mvinsch(int, int, chtype);
499 extern int mvinsnstr(int, int, const char *, int);
500 extern int mvins_nwstr(int, int, const wchar_t *, int);
501 extern int mvinsstr(int, int, const char *);
502 extern int mvinstr(int, int, char *);
503 extern int mvins_wch(int, int, const cchar_t *);
504 extern int mvins_wstr(int, int, const wchar_t *);
505 extern int mvin_wch(int, int, cchar_t *);
506 extern int mvin_wchnstr(int, int, cchar_t *, int);
507 extern int mvin_wchstr(int, int, cchar_t *);
508 extern int mvinwstr(int, int, wchar_t *);
509 extern int mvprintw(int, int, char *, ...);
510 extern int mvscanw(int, int, char *, ...);
511 extern int mvvline(int, int, chtype, int);
512 extern int mvvline_set(int, int, const cchar_t *, int);
513 extern int mvwaddch(WINDOW *, int, int, chtype);
514 extern int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
515 extern int mvwaddchstr(WINDOW *, int, int, const chtype *);
516 extern int mvwaddnstr(WINDOW *, int, int, const char *, int);
517 extern int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);
518 extern int mvwaddstr(WINDOW *, int, int, const char *);
519 extern int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
520 extern int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
521 extern int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
522 extern int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
523 extern int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);
524 extern int mvwdelch(WINDOW *, int, int);
525 extern int mvwgetch(WINDOW *, int, int);
526 extern int mvwgetnstr(WINDOW *, int, int, char *, int);
527 extern int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
528 extern int mvwgetstr(WINDOW *, int, int, char *);
529 extern int mvwget_wch(WINDOW *, int, int, wint_t *);
530 extern int mvwget_wstr(WINDOW *, int, int, wint_t *);
531 extern int mvwhline(WINDOW *, int, int, chtype, int);
532 extern int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
533 extern int mvwin(WINDOW *, int, int);
534 extern chtype mvwinch(WINDOW *, int, int);
535 extern int mvwinchnstr(WINDOW *, int, int, chtype *, int);
536 extern int mvwinchstr(WINDOW *, int, int, chtype *);
537 extern int mvwinnstr(WINDOW *, int, int, char *, int);
538 extern int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
539 extern int mvwinsch(WINDOW *, int, int, chtype);
540 extern int mvwinsnstr(WINDOW *, int, int, const char *, int);
541 extern int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
542 extern int mvwinsstr(WINDOW *, int, int, const char *);
543 extern int mvwinstr(WINDOW *, int, int, char *);
544 extern int mvwins_wch(WINDOW *, int, int, const cchar_t *);
545 extern int mvwins_wstr(WINDOW *, int, int, const wchar_t *);
546 extern int mvwin_wch(WINDOW *, int, int, cchar_t *);
547 extern int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
548 extern int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
549 extern int mvwinwstr(WINDOW *, int, int, wchar_t *);
550 extern int mvwprintw(WINDOW *, int, int, char *, ...);
551 extern int mvwscanw(WINDOW *, int, int, char *, ...);
552 extern int mvwvline(WINDOW *, int, int, chtype, int);
553 extern int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
554 extern int napms(int);
555 extern WINDOW *newpad(int, int);
556 extern SCREEN *newterm(char *, FILE *, FILE *);
557 extern WINDOW *newwin(int, int, int, int);
558 extern int nl(void);
559 extern int nocbreak(void);
560 extern int nodelay(WINDOW *, bool);
561 extern int noecho(void);
562 extern int nonl(void);
563 extern void noqiflush(void);
564 extern int noraw(void);
565 extern int notimeout(WINDOW *, bool);
566 extern int overlay(const WINDOW *, WINDOW *);
567 extern int overwrite(const WINDOW *, WINDOW *);
568 extern int pair_content(short, short *, short *);
569 extern int PAIR_NUMBER(int);
570 extern int pechochar(WINDOW *, chtype);
571 extern int pecho_wchar(WINDOW *, const cchar_t *);
572 extern int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
573 extern int prefresh(WINDOW *, int, int, int, int, int, int);
574 extern int printw(char *, ...);
575 extern int putwin(WINDOW *,  FILE *);
576 extern void qiflush(void);
577 extern int raw(void);
578 extern int redrawwin(WINDOW *);
579 extern int refresh(void);
580 extern int reset_prog_mode(void);
581 extern int reset_shell_mode(void);
582 extern int resetty(void);
583 extern int ripoffline(int, int (*)(WINDOW *, int));
584 extern int savetty(void);
585 extern int scanw(char *, ...);
586 extern int scr_dump(const char *);
587 extern int scr_init(const char *);
588 extern int scrl(int);
589 extern int scroll(WINDOW *);
590 extern int scrollok(WINDOW *, bool);
591 extern int scr_restore(const char *);
592 extern int scr_set(const char *);
593 extern int setcchar(cchar_t *, const wchar_t *, const attr_t,
594 	short, const void *);
595 extern int setscrreg(int, int);
596 extern SCREEN *set_term(SCREEN *);
597 extern int slk_attr_off(const attr_t, void *);
598 extern int slk_attroff(const chtype);
599 extern int slk_attr_on(const attr_t, void *);
600 extern int slk_attron(const chtype);
601 extern int slk_attr_set(const attr_t, short, void *);
602 extern int slk_attrset(const chtype);
603 extern int slk_clear(void);
604 extern int slk_color(short);
605 extern int slk_init(int);
606 extern char *slk_label(int);
607 extern int slk_noutrefresh(void);
608 extern int slk_refresh(void);
609 extern int slk_restore(void);
610 extern int slk_set(int, const char *, int);
611 extern int slk_touch(void);
612 extern int slk_wset(int, const wchar_t *, int);
613 extern int standend(void);
614 extern int standout(void);
615 extern int start_color(void);
616 extern WINDOW *subpad(WINDOW *, int, int, int, int);
617 extern WINDOW *subwin(WINDOW *, int, int, int, int);
618 extern int syncok(WINDOW *, bool);
619 extern chtype termattrs(void);
620 extern attr_t term_attrs(void);
621 extern char *termname(void);
622 extern void timeout(int);
623 extern int touchline(WINDOW *, int, int);
624 extern int touchwin(WINDOW *);
625 extern int typeahead(int);
626 extern int ungetch(int);
627 extern int unget_wch(const wchar_t);
628 extern int untouchwin(WINDOW *);
629 extern void use_env(bool);
630 extern int vid_attr(attr_t, short, void *);
631 extern int vidattr(chtype);
632 extern int vid_puts(attr_t, short, void *, int (*)(int));
633 extern int vidputs(chtype, int (*)(int));
634 extern int vline(chtype, int);
635 extern int vline_set(const cchar_t *, int);
636 extern int vwprintw(WINDOW *, char *, __va_list);
637 extern int vw_printw(WINDOW *, char *, __va_list);
638 extern int vwscanw(WINDOW *, char *, __va_list);
639 extern int vw_scanw(WINDOW *, char *, __va_list);
640 extern int waddch(WINDOW *, const chtype);
641 extern int waddchnstr(WINDOW *, const chtype *, int);
642 extern int waddchstr(WINDOW *, const chtype *);
643 extern int waddnstr(WINDOW *, const char *, int);
644 extern int waddnwstr(WINDOW *, const wchar_t *, int);
645 extern int waddstr(WINDOW *, const char *);
646 extern int wadd_wch(WINDOW *, const cchar_t *);
647 extern int wadd_wchnstr(WINDOW *, const cchar_t *, int);
648 extern int wadd_wchstr(WINDOW *, const cchar_t *);
649 extern int waddwstr(WINDOW *, const wchar_t *);
650 extern int wattroff(WINDOW *, int);
651 extern int wattron(WINDOW *, int);
652 extern int wattrset(WINDOW *, int);
653 extern int wattr_get(WINDOW *, attr_t *, short *, void *);
654 extern int wattr_off(WINDOW *, attr_t, void *);
655 extern int wattr_on(WINDOW *, attr_t, void *);
656 extern int wattr_set(WINDOW *, attr_t, short, void *);
657 extern int wbkgd(WINDOW *, chtype);
658 extern void	wbkgdset(WINDOW *, chtype);
659 extern int wbkgrnd(WINDOW *, const cchar_t *);
660 extern void wbkgrndset(WINDOW *, const cchar_t *);
661 extern int wborder(WINDOW *,
662 	chtype, chtype, chtype, chtype,
663 	chtype, chtype, chtype, chtype);
664 extern int wborder_set(WINDOW *,
665 	const cchar_t *, const cchar_t *,
666 	const cchar_t *, const cchar_t *,
667 	const cchar_t *, const cchar_t *,
668 	const cchar_t *, const cchar_t *);
669 extern int wchgat(WINDOW *, int, attr_t, short, const void *);
670 extern int wclear(WINDOW *);
671 extern int wclrtobot(WINDOW *);
672 extern int wclrtoeol(WINDOW *);
673 extern void wcursyncup(WINDOW *);
674 extern int wcolor_set(WINDOW *, short, void *);
675 extern int wdelch(WINDOW *);
676 extern int wdeleteln(WINDOW *);
677 extern int wechochar(WINDOW *, const chtype);
678 extern int wecho_wchar(WINDOW *, const cchar_t *);
679 extern int werase(WINDOW *);
680 extern int wgetbkgrnd(WINDOW *, cchar_t *);
681 extern int wgetch(WINDOW *);
682 extern int wgetnstr(WINDOW *, char *, int);
683 extern int wgetn_wstr(WINDOW *, wint_t *, int);
684 extern int wgetstr(WINDOW *, char *);
685 extern int wget_wch(WINDOW *, wint_t *);
686 extern int wget_wstr(WINDOW *, wint_t *);
687 extern int whline(WINDOW *, chtype, int);
688 extern int whline_set(WINDOW *, const cchar_t *, int);
689 extern chtype winch(WINDOW *);
690 extern int winchnstr(WINDOW *, chtype *, int);
691 extern int winchstr(WINDOW *, chtype *);
692 extern int winnstr(WINDOW *, char *, int);
693 extern int winnwstr(WINDOW *, wchar_t *, int);
694 extern int winsch(WINDOW *, chtype);
695 extern int winsdelln(WINDOW *, int);
696 extern int winsertln(WINDOW *);
697 extern int winsnstr(WINDOW *, const char *, int);
698 extern int wins_nwstr(WINDOW *, const wchar_t *, int);
699 extern int winsstr(WINDOW *, const char *);
700 extern int winstr(WINDOW *, char *);
701 extern int wins_wch(WINDOW *, const cchar_t *);
702 extern int wins_wstr(WINDOW *, const wchar_t *);
703 extern int win_wch(WINDOW *, cchar_t *);
704 extern int win_wchnstr(WINDOW *, cchar_t *, int);
705 extern int win_wchstr(WINDOW *, cchar_t *);
706 extern int winwstr(WINDOW *, wchar_t *);
707 extern int wmove(WINDOW *, int, int);
708 extern int wnoutrefresh(WINDOW *);
709 extern int wprintw(WINDOW *, char *, ...);
710 extern int wredrawln(WINDOW *, int, int);
711 extern int wrefresh(WINDOW *);
712 extern int wscanw(WINDOW *, char *, ...);
713 extern int wscrl(WINDOW *, int);
714 extern int wsetscrreg(WINDOW *, int, int);
715 extern int wstandend(WINDOW *);
716 extern int wstandout(WINDOW *);
717 extern void wsyncup(WINDOW *);
718 extern void wsyncdown(WINDOW *);
719 extern void wtimeout(WINDOW *, int);
720 extern int wtouchln(WINDOW *, int, int, int);
721 extern wchar_t *wunctrl(cchar_t *);
722 extern int wvline(WINDOW *, chtype, int);
723 extern int wvline_set(WINDOW *, const cchar_t *, int);
724 
725 #if !defined(__lint)
726 /*
727  * These macros can improve speed and size of an application.
728  */
729 extern WINDOW	*__w1;
730 extern chtype	__cht1;
731 extern chtype	__cht2;
732 extern cchar_t	*__pcht1;
733 extern cchar_t	*__pcht2;
734 
735 #define	addch(ch)	waddch(stdscr, ch)
736 #define	mvaddch(y, x, ch)	(move(y, x) ? ((ch), ERR) : addch(ch))
737 #define	mvwaddch(w, y, x, ch)	\
738 	(wmove(__w1 = (w), y, x) ? ((ch), ERR) : waddch(__w1, ch))
739 
740 #define	add_wch(cp)	wadd_wch(stdscr, cp)
741 #define	mvadd_wch(y, x, cp)	(move(y, x) ? ((cp), ERR) : add_wch(cp))
742 #define	mvwadd_wch(w, y, x, cp)	\
743 	(wmove(__w1 = (w), y, x) ? ((cp), ERR) : wadd_wch(__w1, cp))
744 
745 #define	addchnstr(chs, n)	waddchnstr(stdscr, chs, n)
746 #define	addchstr(chs)	waddchstr(stdscr, chs)
747 #define	mvaddchnstr(y, x, chs, n)	\
748 	(move(y, x) ? ((chs), (n), ERR) : addchnstr(chs, n))
749 
750 #define	mvaddchstr(y, x, chs)	\
751 	(move(y, x) ? ((chs), ERR) : addchstr(chs))
752 
753 #define	mvwaddchnstr(w, y, x, chs, n)	\
754 	(wmove(__w1 = (w), y, x) ? ((chs), (n), ERR) :\
755 	waddchnstr(__w1, chs, n))
756 
757 #define	mvwaddchstr(w, y, x, chs)	\
758 	(wmove(__w1 = (w), y, x) ? ((chs), ERR) : waddchstr(__w1, chs))
759 
760 #define	waddchstr(w, chs)	waddchnstr(w, chs, -1)
761 
762 #define	add_wchnstr(cp, n)	wadd_wchnstr(stdscr, cp, n)
763 #define	add_wchstr(cp)	wadd_wchstr(stdscr, cp)
764 #define	mvadd_wchnstr(y, x, cp, n)	\
765 	(move(y, x) ? ((cp), (n), ERR) : add_wchnstr(cp, n))
766 
767 #define	mvadd_wchstr(y, x, cp)	\
768 	(move(y, x) ? ((cp), ERR) : add_wchstr(cp))
769 
770 #define	mvwadd_wchnstr(w, y, x, cp, n)	\
771 	(wmove(__w1 = (w), y, x) ? ((cp), (n), ERR) :\
772 	wadd_wchnstr(__w1, cp, n))
773 
774 #define	mvwadd_wchstr(w, y, x, cp)	\
775 	(wmove(__w1 = (w), y, x) ? ((cp), ERR) :\
776 	wadd_wchstr(__w1, cp))
777 
778 #define	wadd_wchstr(w, cp)	wadd_wchnstr(w, cp, -1)
779 #define	addnstr(s, n)	waddnstr(stdscr, s, n)
780 #define	addstr(s)	waddstr(stdscr, s)
781 #define	mvaddnstr(y, x, s, n)	\
782 	(move(y, x) ? (s, n, ERR) : addnstr(s, n))
783 
784 #define	mvaddstr(y, x, s)	\
785 	(move(y, x) ? (s, ERR) : addstr(s))
786 
787 #define	mvwaddnstr(w, y, x, s, n)	\
788 	(wmove(__w1 = (w), y, x) ? (s, n, ERR) : waddnstr(__w1, s, n))
789 
790 #define	mvwaddstr(w, y, x, s)	\
791 	(wmove(__w1 = (w), y, x) ? (s, ERR) : waddstr(__w1, s))
792 
793 #define	waddstr(w, wcs)	waddnstr(w, wcs, -1)
794 #define	addnwstr(wcs, n)	waddnwstr(stdscr, wcs, n)
795 #define	addwstr(wcs)	waddwstr(stdscr, wcs)
796 #define	mvaddnwstr(y, x, wcs, n)	\
797 	(move(y, x) ? (wcs, n, ERR) : addnwstr(wcs, n))
798 
799 #define	mvaddwstr(y, x, wcs)	\
800 	(move(y, x) ? (wcs, ERR) : addwstr(wcs))
801 
802 #define	mvwaddnwstr(w, y, x, wcs, n)	\
803 	(wmove(__w1 = (w), y, x) ? (wcs, n, ERR) :\
804 	waddnwstr(__w1, wcs, n))
805 
806 #define	mvwaddwstr(w, y, x, wcs)	\
807 	(wmove(__w1 = (w), y, x) ? (wcs, ERR) : waddwstr(__w1, wcs))
808 
809 #define	waddwstr(w, wcs)	waddnwstr(w, wcs, -1)
810 #define	attr_get(a, c, o)	wattr_get(stdscr, a, c, o)
811 #define	attr_off(a, o)	wattr_off(stdscr, a, o)
812 #define	attr_on(a, o)	wattr_on(stdscr, a, o)
813 #define	attr_set(a, c, o)	wattr_set(stdscr, a, c, o)
814 
815 #define	COLOR_PAIR(n)	((chtype)(n) << __COLOR_SHIFT)
816 #define	PAIR_NUMBER(a)  (((chtype)(a) & A_COLOR) >> __COLOR_SHIFT)
817 
818 #define	bkgd(ch)	wbkgd(stdscr, ch)
819 #define	bkgdset(ch)	wbkgdset(stdscr, ch)
820 
821 #define	bkgrnd(b)	wbkgrnd(stdscr, b)
822 #define	bkgrndset(b)	wbkgrndset(stdscr, b)
823 #define	getbkgrnd(b)	wgetbkgrnd(stdscr, b)
824 #define	wgetbkgrnd(w, b)	(*(b) = (w)->_bg, OK)
825 
826 #define	border(ls, rs, ts, bs, tl, tr, bl, br)	\
827 	wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
828 
829 #define	border_set(ls, rs, ts, bs, tl, tr, bl, br)	\
830 	wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
831 
832 #define	box(w, v, h)	\
833 	wborder(w, __cht1 = (v), __cht1, __cht2 = (h), __cht2, 0, 0, 0, 0)
834 
835 #define	box_set(w, v, h)	\
836 	wborder_set(w, __pcht1 = (v), __pcht1, __pcht2 = (h), __pcht2,\
837 	0, 0, 0, 0)
838 
839 #define	can_change_color()	\
840 	(2 < max_colors && can_change && initialize_color != NULL)
841 
842 #define	has_colors()	(0 < max_colors)
843 
844 #define	chgat(n, a, co, p)	wchgat(stdscr, n, a, co, p)
845 #define	mvchgat(y, x, n, a, co, p)	\
846 	(move(y, x) ? (n, a, co, p, ERR) : chgat(n, a, co, p))
847 
848 #define	mvwchgat(w, y, x, n, a, co, p)	\
849 	(wmove(__w1 = (w), y, x) ? (n, a, co, p, ERR) :\
850 	wchgat(__w1, n, a, co, p))
851 
852 #define	clear()	wclear(stdscr)
853 #define	clrtobot()	wclrtobot(stdscr)
854 #define	clrtoeol()	wclrtoeol(stdscr)
855 #define	erase()	werase(stdscr)
856 #define	wclear(w)	\
857 	(clearok(__w1 = (w), 1) ? ERR : werase(__w1))
858 
859 #define	werase(w)	\
860 	(wmove(__w1 = (w), 0, 0) ? ERR : wclrtobot(__w1))
861 
862 #define	delch()	wdelch(stdscr)
863 #define	mvdelch(y, x)	(move(y, x) ? ERR : delch())
864 #define	mvwdelch(w, y, x)	\
865 	(wmove(__w1 = (w), y, x) ? ERR : wdelch(__w1))
866 
867 #define	deleteln()	wdeleteln(stdscr)
868 #define	insdelln(n)	winsdelln(stdscr, n)
869 #define	insertln()	winsertln(stdscr)
870 #define	wdeleteln(w)	winsdelln(w, -1)
871 #define	winsertln(w)	winsdelln(w, 1)
872 #define	refresh()	wrefresh(stdscr)
873 #define	echochar(ch)	wechochar(stdscr, ch)
874 #define	echo_wchar(cp)	wecho_wchar(stdscr, cp)
875 #define	wechochar(w, ch)	\
876 	(waddch(__w1 = (w), ch) ? (wrefresh(__w1), ERR) :\
877 	wrefresh(__w1))
878 
879 #define	wecho_wchar(w, cp)	\
880 	(wadd_wch(__w1 = (w), cp) ? (wrefresh(__w1), ERR) :\
881 	wrefresh(__w1))
882 
883 #define	getch()	wgetch(stdscr)
884 #define	mvgetch(y, x)	(move(y, x) ? ERR : getch())
885 #define	mvwgetch(w, y, x)	\
886 	(wmove(__w1 = (w), y, x) ? ERR : wgetch(__w1))
887 
888 #define	get_wch(wcp)	wget_wch(stdscr, wcp)
889 #define	mvget_wch(y, x, wcp)	\
890 	(move(y, x) ? (wcp, ERR) : get_wch(wcp))
891 
892 #define	mvwget_wch(w, y, x, wcp)	\
893 	(wmove(__w1 = (w), y, x) ? (wcp, ERR) : wget_wch(__w1, wcp))
894 
895 #define	getnstr(s, n)	wgetnstr(stdscr, s, n)
896 #define	getstr(s)	wgetstr(stdscr, s)
897 #define	mvgetnstr(y, x, s, n)	\
898 	(move(y, x) ? (s, n, ERR) : getnstr(s, n))
899 
900 #define	mvgetstr(y, x, s)	\
901 	(move(y, x) ? (s, ERR) : getstr(s))
902 
903 #define	mvwgetnstr(w, y, x, s, n)	\
904 	(wmove(__w1 = (w), y, x) ? (s, n, ERR) : wgetnstr(__w1, s, n))
905 
906 #define	mvwgetstr(w, y, x, s)	\
907 	(wmove(__w1 = (w), y, x) ? (s, ERR) : wgetstr(__w1, s))
908 
909 #define	wgetstr(w, s)	wgetnstr(w, s, -1)
910 #define	getn_wstr(wcs, n)	wgetn_wstr(stdscr, wcs, n)
911 #define	get_wstr(wcs)	wget_wstr(stdscr, wcs)
912 #define	mvgetn_wstr(y, x, wcs, n)	\
913 	(move(y, x) ? (wcs, n, ERR) : getn_wstr(wcs, n))
914 
915 #define	mvget_wstr(y, x, wcs)	\
916 	(move(y, x) ? (wcs, ERR) : get_wstr(wcs))
917 
918 #define	mvwgetn_wstr(w, y, x, wcs, n)	\
919 	(wmove(__w1 = (w), y, x) ? (wcs, n, ERR) :\
920 	wgetn_wstr(__w1, wcs, n))
921 
922 #define	mvwget_wstr(w, y, x, wcs)	\
923 	(wmove(__w1 = (w), y, x) ? (wcs, ERR) : wget_wstr(__w1, wcs))
924 
925 #define	wget_wstr(w, wcs)	wgetn_wstr(w, wcs, -1)
926 
927 #define	has_ic()	\
928 	(((insert_character != NULL || parm_ich != NULL) && \
929 	(delete_character != NULL || parm_dch != NULL)) || \
930 	(enter_insert_mode != NULL && exit_insert_mode))
931 
932 #define	has_il()	\
933 	(((insert_line != NULL || parm_insert_line != NULL) && \
934 	(delete_line != NULL || parm_delete_line != NULL)) || \
935 	change_scroll_region != NULL)
936 
937 #define	hline(ch, n)	whline(stdscr, ch, n)
938 #define	vline(ch, n)	wvline(stdscr, ch, n)
939 #define	mvhline(y, x, ch, n)	\
940 	(move(y, x) ? (ch, n, ERR) : hline(ch, n))
941 
942 #define	mvvline(y, x, ch, n)	\
943 	(move(y, x) ? (ch, n, ERR) : vline(ch, n))
944 
945 #define	mvwhline(w, y, x, ch, n)	\
946 	(wmove(__w1 = (w), y, x) ? (ch, n, ERR) : whline(__w1, ch, n))
947 
948 #define	mvwvline(w, y, x, ch, n)	\
949 	(wmove(__w1 = (w), y, x) ? (ch, n, ERR) : wvline(__w1, ch, n))
950 
951 #define	hline_set(cp, n)	whline_set(stdscr, cp, n)
952 #define	vline_set(cp, n)	wvline_set(stdscr, cp, n)
953 #define	mvhline_set(y, x, cp, n)	\
954 	(move(y, x) ? (cp, n, ERR) : hline_set(cp, n))
955 
956 #define	mvvline_set(y, x, cp, n)	\
957 	(move(y, x) ? (cp, n, ERR) : vline_set(cp, n))
958 
959 #define	mvwhline_set(w, y, x, cp, n)	\
960 	(wmove(__w1 = (w), y, x) ? (cp, n, ERR) : whline_set(__w1, cp, n))
961 
962 #define	mvwvline_set(w, y, x, cp, n)	\
963 	(wmove(__w1 = (w), y, x) ? (cp, n, ERR) : wvline_set(__w1, cp, n))
964 
965 #define	inch()	winch(stdscr)
966 #define	mvinch(y, x)	(move(y, x) ? ERR : inch())
967 #define	mvwinch(w, y, x)	\
968 	(wmove(__w1 = (w), y, x) ? ERR : winch(__w1))
969 
970 #define	in_wch(cp)	win_wch(stdscr, cp)
971 #define	mvin_wch(y, x, cp)	\
972 	(move(y, x) ? (cp, ERR) : in_wch(cp))
973 
974 #define	mvwin_wch(w, y, x, cp)	\
975 	(wmove(__w1 = (w), y, x) ? (cp, ERR) : win_wch(__w1, cp))
976 
977 #define	inchnstr(chs, n)	winchnstr(stdscr, chs, n)
978 #define	inchstr(chs)	winchstr(stdscr, chs)
979 #define	mvinchnstr(y, x, chs, n)	\
980 	(move(y, x) ? (chs, n, ERR) : inchnstr(chs, n))
981 
982 #define	mvinchstr(y, x, chs)	\
983 	(move(y, x) ? (chs, ERR) : inchstr(chs))
984 
985 #define	mvwinchnstr(w, y, x, chs, n)	\
986 	(wmove(__w1 = (w), y, x) ? (chs, n, ERR) : winchnstr(__w1, chs, n))
987 
988 #define	mvwinchstr(w, y, x, chs)	\
989 	(wmove(__w1 = (w), y, x) ? (chs, ERR) : winchstr(__w1, chs))
990 
991 #define	winchstr(w, chs)	winchnstr(w, chs, -1)
992 #define	in_wchnstr(cp, n)	win_wchnstr(stdscr, cp, n)
993 #define	in_wchstr(cp)	win_wchstr(stdscr, cp)
994 #define	mvin_wchnstr(y, x, cp, n)	\
995 	(move(y, x) ? (cp, n, ERR) : in_wchnstr(cp, n))
996 
997 #define	mvin_wchstr(y, x, cp)	\
998 	(move(y, x) ? (cp, ERR) : in_wchstr(cp))
999 
1000 #define	mvwin_wchnstr(w, y, x, cp, n)	\
1001 	(wmove(__w1 = (w), y, x) ? (cp, n, ERR) :\
1002 	win_wchnstr(__w1, cp, n))
1003 
1004 #define	mvwin_wchstr(w, y, x, cp)	\
1005 	(wmove(__w1 = (w), y, x) ? (cp, ERR) : win_wchstr(__w1, cp))
1006 
1007 #define	win_wchstr(w, cp)	win_wchnstr(w, cp, -1)
1008 #define	innstr(s, n)	winnstr(stdscr, s, n)
1009 #define	instr(s)	winstr(stdscr, s)
1010 #define	mvinnstr(y, x, s, n)	\
1011 	(move(y, x) ? (s, n, ERR) : innstr(s, n))
1012 
1013 #define	mvinstr(y, x, s)	\
1014 	(move(y, x) ? (s, ERR) : instr(s))
1015 
1016 #define	mvwinnstr(w, y, x, s, n)	\
1017 	(wmove(__w1 = (w), y, x) ? (s, n, ERR) : winnstr(__w1, s, n))
1018 
1019 #define	mvwinstr(w, y, x, s)	\
1020 	(wmove(__w1 = (w), y, x) ? (s, ERR) : winstr(__w1, s))
1021 
1022 #define	winstr(w, s)	(winnstr(w, s, -1), OK)
1023 #define	innwstr(wcs, n)	winnwstr(stdscr, wcs, n)
1024 #define	inwstr(wcs)	winwstr(stdscr, wcs)
1025 #define	mvinnwstr(y, x, wcs, n)	\
1026 	(move(y, x) ? (wcs, n, ERR) : innwstr(wcs, n))
1027 
1028 #define	mvinwstr(y, x, wcs)	\
1029 	(move(y, x) ? (wcs, ERR) : inwstr(wcs))
1030 
1031 #define	mvwinnwstr(w, y, x, wcs, n)	\
1032 	(wmove(__w1 = (w), y, x) ? (wcs, n, ERR) :\
1033 	winnwstr(__w1, wcs, n))
1034 
1035 #define	mvwinwstr(w, y, x, wcs)	\
1036 	(wmove(__w1 = (w), y, x) ? (wcs, ERR) : winwstr(__w1, wcs))
1037 
1038 #define	winwstr(w, wcs)	(winnwstr(w, wcs, -1), OK)
1039 #define	insch(ch)	winsch(stdscr, ch)
1040 #define	mvinsch(y, x, ch)	(move(y, x) ? (ch, ERR) : insch(ch))
1041 #define	mvwinsch(w, y, x, ch)	\
1042 	(wmove(__w1 = (w), y, x) ? (ch, ERR) : winsch(__w1, ch))
1043 
1044 #define	ins_wch(cp)	wins_wch(stdscr, cp)
1045 #define	mvins_wch(y, x, cp)	(move(y, x) ? (cp, ERR) : ins_wch(cp))
1046 #define	mvwins_wch(w, y, x, cp)	\
1047 	(wmove(__w1 = (w), y, x) ? (cp, ERR) : wins_wch(__w1, cp))
1048 
1049 #define	insnstr(s, n)	winsnstr(stdscr, s, n)
1050 #define	insstr(s)	winsstr(stdscr, s)
1051 #define	mvinsnstr(y, x, s, n)	(move(y, x) ? (s, n, ERR) : insnstr(s, n))
1052 #define	mvinsstr(y, x, s)	(move(y, x) ? (s, ERR) : insstr(s))
1053 #define	mvwinsnstr(w, y, x, s, n)	\
1054 	(wmove(__w1 = (w), y, x) ? (s, n, ERR) : winsnstr(__w1, s, n))
1055 
1056 #define	mvwinsstr(w, y, x, s)	\
1057 	(wmove(__w1 = (w), y, x) ? (s, ERR) : winsstr(__w1, s))
1058 
1059 #define	winsstr(w, s)	winsnstr(w, s, -1)
1060 #define	ins_nwstr(wcs, n)	wins_nwstr(stdscr, wcs, n)
1061 #define	ins_wstr(wcs)	wins_wstr(stdscr, wcs)
1062 #define	mvins_nwstr(y, x, wcs, n)	\
1063 	(move(y, x) ? (wcs, n, ERR) : ins_nwstr(wcs, n))
1064 
1065 #define	mvins_wstr(y, x, wcs)	(move(y, x) ? (wcs, ERR) : ins_wstr(wcs))
1066 #define	mvwins_nwstr(w, y, x, wcs, n)	\
1067 	(wmove(__w1 = (w), y, x) ? (wcs, n, ERR) : wins_nwstr(__w1, wcs, n))
1068 
1069 #define	mvwins_wstr(w, y, x, wcs)	\
1070 	(wmove(__w1 = (w), y, x) ? (wcs, ERR) : wins_wstr(__w1, wcs))
1071 
1072 #define	wins_wstr(w, wcs)	wins_nwstr(w, wcs, -1)
1073 #define	is_linetouched(w, y)	(0 <= (w)->_last[y])
1074 #define	move(y, x)	wmove(stdscr, y, x)
1075 #define	subpad(par, ny, nx, by, bx)	subwin(par, ny, nx, by, bx)
1076 #define	nodelay(w, bf)	(wtimeout(w, (bf) ? 0: -1), OK)
1077 #define	timeout(n)	wtimeout(stdscr, n)
1078 #define	qiflush()	((void) intrflush(NULL, 1))
1079 #define	noqiflush()	((void) intrflush(NULL, 0))
1080 #define	redrawwin(w)	wredrawln(__w1 = (w), 0, (__w1)->_maxy)
1081 #define	scrl(n)	wscrl(stdscr, n)
1082 #define	setscrreg(t, b)	wsetscrreg(stdscr, t, b)
1083 #define	standend()	wstandend(stdscr)
1084 #define	standout()	wstandout(stdscr)
1085 #define	touchline(w, y, n)	wtouchln(w, y, n, 1)
1086 #define	touchwin(w)	wtouchln(__w1 = (w), 0, __w1->_maxy, 1)
1087 #define	untouchwin(w)	wtouchln(__w1 = (w), 0, __w1->_maxy, 0)
1088 #define	termname()			(cur_term->_term)
1089 
1090 #endif	/* !defined(__lint) */
1091 
1092 /*
1093  * Special Keys
1094  *
1095  * Keypad layout
1096  *	A1	up	A3
1097  *     left	B2     right
1098  *	C1     down	C3
1099  *
1100  * Chossing negative values for KEY_ constants means that they can
1101  * be safely returned in either an int or long type.
1102  */
1103 #define	__KEY_BASE	(-2)
1104 #define	__KEY_MAX	__KEY_BASE
1105 
1106 #define	KEY_CODE_YES	(__KEY_BASE-1)		/* Special indicator. */
1107 #define	KEY_BREAK	(__KEY_BASE-2)		/* Break key (unreliable) */
1108 #define	KEY_DOWN	(__KEY_BASE-3)		/* The four arrow keys ... */
1109 #define	KEY_UP		(__KEY_BASE-4)
1110 #define	KEY_LEFT	(__KEY_BASE-5)
1111 #define	KEY_RIGHT	(__KEY_BASE-6)
1112 #define	KEY_HOME	(__KEY_BASE-7)		/* Move to upper-left corner. */
1113 #define	KEY_BACKSPACE	(__KEY_BASE-8)		/* Backspace */
1114 #define	KEY_F0		(__KEY_BASE-9)		/* Function keys.  Space for */
1115 #define	KEY_F(n)	(KEY_F0-(n))    	/* 64 keys is reserved. */
1116 #define	KEY_DL		(__KEY_BASE-73)		/* Delete line */
1117 #define	KEY_IL		(__KEY_BASE-74)		/* Insert line */
1118 #define	KEY_DC		(__KEY_BASE-75)		/* Delete character */
1119 #define	KEY_IC		(__KEY_BASE-76)		/* Ins char / enter ins mode */
1120 #define	KEY_EIC		(__KEY_BASE-77)		/* Exit insert char mode */
1121 #define	KEY_CLEAR	(__KEY_BASE-78)		/* Clear screen */
1122 #define	KEY_EOS		(__KEY_BASE-79)		/* Clear to end of screen */
1123 #define	KEY_EOL		(__KEY_BASE-80)		/* Clear to end of line */
1124 #define	KEY_SF		(__KEY_BASE-81)		/* Scroll 1 line forward */
1125 #define	KEY_SR		(__KEY_BASE-82)		/* Scroll 1 line backwards */
1126 #define	KEY_NPAGE	(__KEY_BASE-83)		/* Next page */
1127 #define	KEY_PPAGE	(__KEY_BASE-84)		/* Previous page */
1128 #define	KEY_STAB	(__KEY_BASE-85)		/* Set tab */
1129 #define	KEY_CTAB	(__KEY_BASE-86)		/* Clear tab */
1130 #define	KEY_CATAB	(__KEY_BASE-87)		/* Clear all tabs */
1131 #define	KEY_ENTER	(__KEY_BASE-88)		/* Enter or send */
1132 #define	KEY_SRESET	(__KEY_BASE-89)		/* Soft (partial) reset */
1133 #define	KEY_RESET	(__KEY_BASE-90)		/* Hard reset */
1134 #define	KEY_PRINT	(__KEY_BASE-91)		/* Print or copy */
1135 #define	KEY_LL		(__KEY_BASE-92)		/* Move to lower left corner. */
1136 #define	KEY_A1		(__KEY_BASE-93)		/* Upper left of keypad */
1137 #define	KEY_A3		(__KEY_BASE-94) 	/* Upper rght of keypad */
1138 #define	KEY_B2		(__KEY_BASE-95) 	/* Center of keypad */
1139 #define	KEY_C1		(__KEY_BASE-96) 	/* Lower left of keypad */
1140 #define	KEY_C3		(__KEY_BASE-97) 	/* Lower right of keypad */
1141 #define	KEY_BTAB	(__KEY_BASE-98) 	/* Back Tab */
1142 #define	KEY_BEG		(__KEY_BASE-99) 	/* Beginning */
1143 #define	KEY_CANCEL	(__KEY_BASE-100)
1144 #define	KEY_CLOSE	(__KEY_BASE-101)
1145 #define	KEY_COMMAND	(__KEY_BASE-102)
1146 #define	KEY_COPY	(__KEY_BASE-103)
1147 #define	KEY_CREATE	(__KEY_BASE-104)
1148 #define	KEY_END		(__KEY_BASE-105)
1149 #define	KEY_EXIT	(__KEY_BASE-106)
1150 #define	KEY_FIND	(__KEY_BASE-107)
1151 #define	KEY_HELP	(__KEY_BASE-108)
1152 #define	KEY_MARK	(__KEY_BASE-109)
1153 #define	KEY_MESSAGE	(__KEY_BASE-110)
1154 #define	KEY_MOUSE	(__KEY_BASE-111)	/* Mouse event occured */
1155 #define	KEY_MOVE	(__KEY_BASE-112)
1156 #define	KEY_NEXT	(__KEY_BASE-113)	/* Next object */
1157 #define	KEY_OPEN	(__KEY_BASE-114)
1158 #define	KEY_OPTIONS	(__KEY_BASE-115)
1159 #define	KEY_PREVIOUS	(__KEY_BASE-116)	/* Previous object */
1160 #define	KEY_REDO	(__KEY_BASE-117)
1161 #define	KEY_REFERENCE	(__KEY_BASE-118)
1162 #define	KEY_REFRESH	(__KEY_BASE-119)
1163 #define	KEY_REPLACE	(__KEY_BASE-120)
1164 #define	KEY_RESTART	(__KEY_BASE-121)
1165 #define	KEY_RESUME	(__KEY_BASE-122)
1166 #define	KEY_SAVE	(__KEY_BASE-123)
1167 #define	KEY_SBEG	(__KEY_BASE-124)	/* Shifted keys */
1168 #define	KEY_SCANCEL	(__KEY_BASE-125)
1169 #define	KEY_SCOMMAND	(__KEY_BASE-126)
1170 #define	KEY_SCOPY	(__KEY_BASE-127)
1171 #define	KEY_SCREATE	(__KEY_BASE-128)
1172 #define	KEY_SDC		(__KEY_BASE-129)
1173 #define	KEY_SDL		(__KEY_BASE-130)
1174 #define	KEY_SELECT	(__KEY_BASE-131)	/* Select */
1175 #define	KEY_SEND	(__KEY_BASE-132)	/* Shifted end key */
1176 #define	KEY_SEOL	(__KEY_BASE-133)
1177 #define	KEY_SEXIT	(__KEY_BASE-134)
1178 #define	KEY_SFIND	(__KEY_BASE-135)
1179 #define	KEY_SHELP	(__KEY_BASE-136)
1180 #define	KEY_SHOME	(__KEY_BASE-137)
1181 #define	KEY_SIC		(__KEY_BASE-138)
1182 #define	KEY_SLEFT	(__KEY_BASE-139)
1183 #define	KEY_SMESSAGE	(__KEY_BASE-140)
1184 #define	KEY_SMOVE	(__KEY_BASE-141)
1185 #define	KEY_SNEXT	(__KEY_BASE-142)
1186 #define	KEY_SOPTIONS	(__KEY_BASE-143)
1187 #define	KEY_SPREVIOUS	(__KEY_BASE-144)
1188 #define	KEY_SPRINT	(__KEY_BASE-145)
1189 #define	KEY_SREDO	(__KEY_BASE-146)
1190 #define	KEY_SREPLACE	(__KEY_BASE-147)
1191 #define	KEY_SRIGHT	(__KEY_BASE-148)
1192 #define	KEY_SRSUME	(__KEY_BASE-149)
1193 #define	KEY_SSAVE	(__KEY_BASE-150)
1194 #define	KEY_SSUSPEND	(__KEY_BASE-151)
1195 #define	KEY_SUNDO	(__KEY_BASE-152)
1196 #define	KEY_SUSPEND	(__KEY_BASE-153)
1197 #define	KEY_UNDO	(__KEY_BASE-154)
1198 
1199 #define	__KEY_MIN	(__KEY_BASE-155)
1200 
1201 #ifdef	__cplusplus
1202 }
1203 #endif
1204 
1205 #endif /* _CURSES_H */
1206