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
47extern "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
65typedef short	bool;
66#define	_BOOL_DEFINED
67#endif
68#endif
69
70#define	TRUE    		1
71#define	FALSE   		0
72
73typedef 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 */
130typedef 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 */
141typedef 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 */
163typedef 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)
198typedef unsigned int	chtype;
199#else
200typedef 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 */
276extern const cchar_t __WACS_VLINE;
277extern const cchar_t __WACS_HLINE;
278extern const cchar_t __WACS_ULCORNER;
279extern const cchar_t __WACS_URCORNER;
280extern const cchar_t __WACS_LLCORNER;
281extern const cchar_t __WACS_LRCORNER;
282extern const cchar_t __WACS_RTEE;
283extern const cchar_t __WACS_LTEE;
284extern const cchar_t __WACS_BTEE;
285extern const cchar_t __WACS_TTEE;
286extern const cchar_t __WACS_PLUS;
287extern const cchar_t __WACS_S1;
288extern const cchar_t __WACS_S9;
289extern const cchar_t __WACS_DIAMOND;
290extern const cchar_t __WACS_CKBOARD;
291extern const cchar_t __WACS_DEGREE;
292extern const cchar_t __WACS_PLMINUS;
293extern const cchar_t __WACS_BULLET;
294extern const cchar_t __WACS_LARROW;
295extern const cchar_t __WACS_RARROW;
296extern const cchar_t __WACS_DARROW;
297extern const cchar_t __WACS_UARROW;
298extern const cchar_t __WACS_BOARD;
299extern const cchar_t __WACS_LANTERN;
300extern 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 */
348extern int LINES, COLS;
349extern WINDOW *curscr, *stdscr;
350extern int COLORS, COLOR_PAIRS;
351
352extern int addch(chtype);
353extern int addchnstr(const chtype *, int);
354extern int addchstr(const chtype *);
355extern int addnstr(const char *, int);
356extern int addnwstr(const wchar_t *, int);
357extern int addstr(const char *);
358extern int add_wch(const cchar_t *);
359extern int add_wchnstr(const cchar_t *, int);
360extern int add_wchstr(const cchar_t *);
361extern int addwstr(const wchar_t *);
362extern int attroff(int);
363extern int attron(int);
364extern int attrset(int);
365extern int attr_get(attr_t *, short *, void *);
366extern int attr_off(attr_t, void *);
367extern int attr_on(attr_t, void *);
368extern int attr_set(attr_t, short, void *);
369extern int baudrate(void);
370extern int beep(void);
371extern int bkgd(chtype);
372extern void	bkgdset(chtype);
373extern int bkgrnd(const cchar_t *);
374extern void bkgrndset(const cchar_t *);
375extern int border(
376	chtype, chtype, chtype, chtype,
377	chtype, chtype, chtype, chtype);
378extern 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 *);
383extern int box(WINDOW *, chtype, chtype);
384extern int box_set(WINDOW *, const cchar_t *, const cchar_t *);
385extern bool can_change_color(void);
386extern int cbreak(void);
387extern int chgat(int, attr_t, short, const void *);
388extern int clearok(WINDOW *, bool);
389extern int clear(void);
390extern int clrtobot(void);
391extern int clrtoeol(void);
392extern int color_content(short, short *, short *, short *);
393extern int COLOR_PAIR(int);
394extern int color_set(short, void *);
395extern int copywin(const WINDOW *, WINDOW *,
396	int, int, int, int, int, int, int);
397extern int curs_set(int);
398extern int def_prog_mode(void);
399extern int def_shell_mode(void);
400extern int delay_output(int);
401extern int delch(void);
402extern int deleteln(void);
403extern void delscreen(SCREEN *);
404extern int delwin(WINDOW *);
405extern WINDOW *derwin(WINDOW *, int, int, int, int);
406extern int doupdate(void);
407extern WINDOW *dupwin(WINDOW *);
408extern int echo(void);
409extern int echochar(const chtype);
410extern int echo_wchar(const cchar_t *);
411extern int endwin(void);
412extern char erasechar(void);
413extern int erase(void);
414extern int erasewchar(wchar_t *);
415extern void filter(void);
416extern int flash(void);
417extern int flushinp(void);
418extern chtype getbkgd(WINDOW *);
419extern int getbkgrnd(cchar_t *);
420extern int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
421extern int getch(void);
422extern int getnstr(char *, int);
423extern int getn_wstr(wint_t *, int);
424extern int getstr(char *);
425extern int get_wch(wint_t *);
426extern WINDOW *getwin(FILE *);
427extern int get_wstr(wint_t *);
428extern int halfdelay(int);
429extern bool has_colors(void);
430extern bool has_ic(void);
431extern bool has_il(void);
432extern int hline(chtype, int);
433extern int hline_set(const cchar_t *, int);
434extern void idcok(WINDOW *, bool);
435extern int idlok(WINDOW *, bool);
436extern void immedok(WINDOW *, bool);
437extern chtype inch(void);
438extern int inchnstr(chtype *, int);
439extern int inchstr(chtype *);
440extern WINDOW *initscr(void);
441extern int init_color(short, short, short, short);
442extern int init_pair(short, short, short);
443extern int innstr(char *, int);
444extern int innwstr(wchar_t *, int);
445extern int insch(chtype);
446extern int insdelln(int);
447extern int insertln(void);
448extern int insnstr(const char *, int);
449extern int ins_nwstr(const wchar_t *, int);
450extern int insstr(const char *);
451extern int instr(char *);
452extern int ins_wch(const cchar_t *);
453extern int ins_wstr(const wchar_t *);
454extern int intrflush(WINDOW *, bool);
455extern int in_wch(cchar_t *);
456extern int in_wchnstr(cchar_t *, int);
457extern int in_wchstr(cchar_t *);
458extern int inwstr(wchar_t *);
459extern bool isendwin(void);
460extern bool is_linetouched(WINDOW *, int);
461extern bool is_wintouched(WINDOW *);
462extern char *keyname(int);
463extern char *key_name(wchar_t);
464extern int keypad(WINDOW *, bool);
465extern char killchar(void);
466extern int killwchar(wchar_t *);
467extern int leaveok(WINDOW *, bool);
468extern char *longname(void);
469extern int meta(WINDOW *, bool);
470extern int move(int, int);
471extern int mvaddch(int, int, chtype);
472extern int mvaddchnstr(int, int, const chtype *, int);
473extern int mvaddchstr(int, int, const chtype *);
474extern int mvaddnstr(int, int, const char *, int);
475extern int mvaddnwstr(int, int, const wchar_t *, int);
476extern int mvaddstr(int, int, const char *);
477extern int mvadd_wch(int, int, const cchar_t *);
478extern int mvadd_wchnstr(int, int, const cchar_t *, int);
479extern int mvadd_wchstr(int, int, const cchar_t *);
480extern int mvaddwstr(int, int, const wchar_t *);
481extern int mvchgat(int, int, int, attr_t, short, const void *);
482extern int mvcur(int, int, int, int);
483extern int mvdelch(int, int);
484extern int mvderwin(WINDOW *, int, int);
485extern int mvgetch(int, int);
486extern int mvgetnstr(int, int, char *, int);
487extern int mvgetn_wstr(int, int, wint_t *, int);
488extern int mvgetstr(int, int, char *);
489extern int mvget_wch(int, int, wint_t *);
490extern int mvget_wstr(int, int, wint_t *);
491extern int mvhline(int, int, chtype, int);
492extern int mvhline_set(int, int, const cchar_t *, int);
493extern chtype mvinch(int, int);
494extern int mvinchnstr(int, int, chtype *, int);
495extern int mvinchstr(int, int, chtype *);
496extern int mvinnstr(int, int, char *, int);
497extern int mvinnwstr(int, int, wchar_t *, int);
498extern int mvinsch(int, int, chtype);
499extern int mvinsnstr(int, int, const char *, int);
500extern int mvins_nwstr(int, int, const wchar_t *, int);
501extern int mvinsstr(int, int, const char *);
502extern int mvinstr(int, int, char *);
503extern int mvins_wch(int, int, const cchar_t *);
504extern int mvins_wstr(int, int, const wchar_t *);
505extern int mvin_wch(int, int, cchar_t *);
506extern int mvin_wchnstr(int, int, cchar_t *, int);
507extern int mvin_wchstr(int, int, cchar_t *);
508extern int mvinwstr(int, int, wchar_t *);
509extern int mvprintw(int, int, char *, ...);
510extern int mvscanw(int, int, char *, ...);
511extern int mvvline(int, int, chtype, int);
512extern int mvvline_set(int, int, const cchar_t *, int);
513extern int mvwaddch(WINDOW *, int, int, chtype);
514extern int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
515extern int mvwaddchstr(WINDOW *, int, int, const chtype *);
516extern int mvwaddnstr(WINDOW *, int, int, const char *, int);
517extern int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);
518extern int mvwaddstr(WINDOW *, int, int, const char *);
519extern int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
520extern int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
521extern int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
522extern int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
523extern int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);
524extern int mvwdelch(WINDOW *, int, int);
525extern int mvwgetch(WINDOW *, int, int);
526extern int mvwgetnstr(WINDOW *, int, int, char *, int);
527extern int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
528extern int mvwgetstr(WINDOW *, int, int, char *);
529extern int mvwget_wch(WINDOW *, int, int, wint_t *);
530extern int mvwget_wstr(WINDOW *, int, int, wint_t *);
531extern int mvwhline(WINDOW *, int, int, chtype, int);
532extern int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
533extern int mvwin(WINDOW *, int, int);
534extern chtype mvwinch(WINDOW *, int, int);
535extern int mvwinchnstr(WINDOW *, int, int, chtype *, int);
536extern int mvwinchstr(WINDOW *, int, int, chtype *);
537extern int mvwinnstr(WINDOW *, int, int, char *, int);
538extern int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
539extern int mvwinsch(WINDOW *, int, int, chtype);
540extern int mvwinsnstr(WINDOW *, int, int, const char *, int);
541extern int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
542extern int mvwinsstr(WINDOW *, int, int, const char *);
543extern int mvwinstr(WINDOW *, int, int, char *);
544extern int mvwins_wch(WINDOW *, int, int, const cchar_t *);
545extern int mvwins_wstr(WINDOW *, int, int, const wchar_t *);
546extern int mvwin_wch(WINDOW *, int, int, cchar_t *);
547extern int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
548extern int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
549extern int mvwinwstr(WINDOW *, int, int, wchar_t *);
550extern int mvwprintw(WINDOW *, int, int, char *, ...);
551extern int mvwscanw(WINDOW *, int, int, char *, ...);
552extern int mvwvline(WINDOW *, int, int, chtype, int);
553extern int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
554extern int napms(int);
555extern WINDOW *newpad(int, int);
556extern SCREEN *newterm(char *, FILE *, FILE *);
557extern WINDOW *newwin(int, int, int, int);
558extern int nl(void);
559extern int nocbreak(void);
560extern int nodelay(WINDOW *, bool);
561extern int noecho(void);
562extern int nonl(void);
563extern void noqiflush(void);
564extern int noraw(void);
565extern int notimeout(WINDOW *, bool);
566extern int overlay(const WINDOW *, WINDOW *);
567extern int overwrite(const WINDOW *, WINDOW *);
568extern int pair_content(short, short *, short *);
569extern int PAIR_NUMBER(int);
570extern int pechochar(WINDOW *, chtype);
571extern int pecho_wchar(WINDOW *, const cchar_t *);
572extern int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
573extern int prefresh(WINDOW *, int, int, int, int, int, int);
574extern int printw(char *, ...);
575extern int putwin(WINDOW *,  FILE *);
576extern void qiflush(void);
577extern int raw(void);
578extern int redrawwin(WINDOW *);
579extern int refresh(void);
580extern int reset_prog_mode(void);
581extern int reset_shell_mode(void);
582extern int resetty(void);
583extern int ripoffline(int, int (*)(WINDOW *, int));
584extern int savetty(void);
585extern int scanw(char *, ...);
586extern int scr_dump(const char *);
587extern int scr_init(const char *);
588extern int scrl(int);
589extern int scroll(WINDOW *);
590extern int scrollok(WINDOW *, bool);
591extern int scr_restore(const char *);
592extern int scr_set(const char *);
593extern int setcchar(cchar_t *, const wchar_t *, const attr_t,
594	short, const void *);
595extern int setscrreg(int, int);
596extern SCREEN *set_term(SCREEN *);
597extern int slk_attr_off(const attr_t, void *);
598extern int slk_attroff(const chtype);
599extern int slk_attr_on(const attr_t, void *);
600extern int slk_attron(const chtype);
601extern int slk_attr_set(const attr_t, short, void *);
602extern int slk_attrset(const chtype);
603extern int slk_clear(void);
604extern int slk_color(short);
605extern int slk_init(int);
606extern char *slk_label(int);
607extern int slk_noutrefresh(void);
608extern int slk_refresh(void);
609extern int slk_restore(void);
610extern int slk_set(int, const char *, int);
611extern int slk_touch(void);
612extern int slk_wset(int, const wchar_t *, int);
613extern int standend(void);
614extern int standout(void);
615extern int start_color(void);
616extern WINDOW *subpad(WINDOW *, int, int, int, int);
617extern WINDOW *subwin(WINDOW *, int, int, int, int);
618extern int syncok(WINDOW *, bool);
619extern chtype termattrs(void);
620extern attr_t term_attrs(void);
621extern char *termname(void);
622extern void timeout(int);
623extern int touchline(WINDOW *, int, int);
624extern int touchwin(WINDOW *);
625extern int typeahead(int);
626extern int ungetch(int);
627extern int unget_wch(const wchar_t);
628extern int untouchwin(WINDOW *);
629extern void use_env(bool);
630extern int vid_attr(attr_t, short, void *);
631extern int vidattr(chtype);
632extern int vid_puts(attr_t, short, void *, int (*)(int));
633extern int vidputs(chtype, int (*)(int));
634extern int vline(chtype, int);
635extern int vline_set(const cchar_t *, int);
636extern int vwprintw(WINDOW *, char *, __va_list);
637extern int vw_printw(WINDOW *, char *, __va_list);
638extern int vwscanw(WINDOW *, char *, __va_list);
639extern int vw_scanw(WINDOW *, char *, __va_list);
640extern int waddch(WINDOW *, const chtype);
641extern int waddchnstr(WINDOW *, const chtype *, int);
642extern int waddchstr(WINDOW *, const chtype *);
643extern int waddnstr(WINDOW *, const char *, int);
644extern int waddnwstr(WINDOW *, const wchar_t *, int);
645extern int waddstr(WINDOW *, const char *);
646extern int wadd_wch(WINDOW *, const cchar_t *);
647extern int wadd_wchnstr(WINDOW *, const cchar_t *, int);
648extern int wadd_wchstr(WINDOW *, const cchar_t *);
649extern int waddwstr(WINDOW *, const wchar_t *);
650extern int wattroff(WINDOW *, int);
651extern int wattron(WINDOW *, int);
652extern int wattrset(WINDOW *, int);
653extern int wattr_get(WINDOW *, attr_t *, short *, void *);
654extern int wattr_off(WINDOW *, attr_t, void *);
655extern int wattr_on(WINDOW *, attr_t, void *);
656extern int wattr_set(WINDOW *, attr_t, short, void *);
657extern int wbkgd(WINDOW *, chtype);
658extern void	wbkgdset(WINDOW *, chtype);
659extern int wbkgrnd(WINDOW *, const cchar_t *);
660extern void wbkgrndset(WINDOW *, const cchar_t *);
661extern int wborder(WINDOW *,
662	chtype, chtype, chtype, chtype,
663	chtype, chtype, chtype, chtype);
664extern 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 *);
669extern int wchgat(WINDOW *, int, attr_t, short, const void *);
670extern int wclear(WINDOW *);
671extern int wclrtobot(WINDOW *);
672extern int wclrtoeol(WINDOW *);
673extern void wcursyncup(WINDOW *);
674extern int wcolor_set(WINDOW *, short, void *);
675extern int wdelch(WINDOW *);
676extern int wdeleteln(WINDOW *);
677extern int wechochar(WINDOW *, const chtype);
678extern int wecho_wchar(WINDOW *, const cchar_t *);
679extern int werase(WINDOW *);
680extern int wgetbkgrnd(WINDOW *, cchar_t *);
681extern int wgetch(WINDOW *);
682extern int wgetnstr(WINDOW *, char *, int);
683extern int wgetn_wstr(WINDOW *, wint_t *, int);
684extern int wgetstr(WINDOW *, char *);
685extern int wget_wch(WINDOW *, wint_t *);
686extern int wget_wstr(WINDOW *, wint_t *);
687extern int whline(WINDOW *, chtype, int);
688extern int whline_set(WINDOW *, const cchar_t *, int);
689extern chtype winch(WINDOW *);
690extern int winchnstr(WINDOW *, chtype *, int);
691extern int winchstr(WINDOW *, chtype *);
692extern int winnstr(WINDOW *, char *, int);
693extern int winnwstr(WINDOW *, wchar_t *, int);
694extern int winsch(WINDOW *, chtype);
695extern int winsdelln(WINDOW *, int);
696extern int winsertln(WINDOW *);
697extern int winsnstr(WINDOW *, const char *, int);
698extern int wins_nwstr(WINDOW *, const wchar_t *, int);
699extern int winsstr(WINDOW *, const char *);
700extern int winstr(WINDOW *, char *);
701extern int wins_wch(WINDOW *, const cchar_t *);
702extern int wins_wstr(WINDOW *, const wchar_t *);
703extern int win_wch(WINDOW *, cchar_t *);
704extern int win_wchnstr(WINDOW *, cchar_t *, int);
705extern int win_wchstr(WINDOW *, cchar_t *);
706extern int winwstr(WINDOW *, wchar_t *);
707extern int wmove(WINDOW *, int, int);
708extern int wnoutrefresh(WINDOW *);
709extern int wprintw(WINDOW *, char *, ...);
710extern int wredrawln(WINDOW *, int, int);
711extern int wrefresh(WINDOW *);
712extern int wscanw(WINDOW *, char *, ...);
713extern int wscrl(WINDOW *, int);
714extern int wsetscrreg(WINDOW *, int, int);
715extern int wstandend(WINDOW *);
716extern int wstandout(WINDOW *);
717extern void wsyncup(WINDOW *);
718extern void wsyncdown(WINDOW *);
719extern void wtimeout(WINDOW *, int);
720extern int wtouchln(WINDOW *, int, int, int);
721extern wchar_t *wunctrl(cchar_t *);
722extern int wvline(WINDOW *, chtype, int);
723extern 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 */
729extern WINDOW	*__w1;
730extern chtype	__cht1;
731extern chtype	__cht2;
732extern cchar_t	*__pcht1;
733extern 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