1/* $MirOS: src/lib/libncurses/src/include/curses.h.in,v 1.4 2013/10/31 20:06:35 tg Exp $ */
2/****************************************************************************
3 * Copyright © 2013                                                         *
4 *	Thorsten “mirabilos” Glaser <tg@mirbsd.org>                         *
5 * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
6 *                                                                          *
7 * Permission is hereby granted, free of charge, to any person obtaining a  *
8 * copy of this software and associated documentation files (the            *
9 * "Software"), to deal in the Software without restriction, including      *
10 * without limitation the rights to use, copy, modify, merge, publish,      *
11 * distribute, distribute with modifications, sublicense, and/or sell       *
12 * copies of the Software, and to permit persons to whom the Software is    *
13 * furnished to do so, subject to the following conditions:                 *
14 *                                                                          *
15 * The above copyright notice and this permission notice shall be included  *
16 * in all copies or substantial portions of the Software.                   *
17 *                                                                          *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
25 *                                                                          *
26 * Except as contained in this notice, the name(s) of the above copyright   *
27 * holders shall not be used in advertising or otherwise to promote the     *
28 * sale, use or other dealings in this Software without prior written       *
29 * authorization.                                                           *
30 ****************************************************************************/
31
32/****************************************************************************
33 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
34 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
35 *     and: Thomas E. Dickey                        1996-on                 *
36 ****************************************************************************/
37
38/* $Id: curses.h.in,v 1.157 2005/07/02 16:58:28 tom Exp $ */
39
40#ifndef __NCURSES_H
41#define __NCURSES_H
42
43#define CURSES 1
44#define CURSES_H 1
45
46/* This should be defined for the enhanced functionality to be visible.
47 * However, some of the wide-character (enhanced) functionality is missing.
48 * So we do not define it (yet).
49#define _XOPEN_CURSES 1
50 */
51
52/* These are defined only in curses.h, and are used for conditional compiles */
53#define NCURSES_VERSION_MAJOR @NCURSES_MAJOR@
54#define NCURSES_VERSION_MINOR @NCURSES_MINOR@
55#define NCURSES_VERSION_PATCH @NCURSES_PATCH@
56
57/* This is defined in more than one ncurses header, for identification */
58#undef  NCURSES_VERSION
59#define NCURSES_VERSION "@NCURSES_MAJOR@.@NCURSES_MINOR@"
60
61/*
62 * Identify the mouse encoding version.
63 */
64#define NCURSES_MOUSE_VERSION @NCURSES_MOUSE_VERSION@
65
66/*
67 * Definitions to facilitate DLL's.
68 */
69#include <ncurses_dll.h>
70
71/*
72 * User-definable tweak to disable the include of <stdbool.h>.
73 */
74#ifndef NCURSES_ENABLE_STDBOOL_H
75#define NCURSES_ENABLE_STDBOOL_H @cf_cv_header_stdbool_h@
76#endif
77
78/*
79 * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
80 * configured using --disable-macros.
81 */
82#ifdef NCURSES_NOMACROS
83#define NCURSES_ATTR_T attr_t
84#endif
85
86#ifndef NCURSES_ATTR_T
87#define NCURSES_ATTR_T int
88#endif
89
90/*
91 * Expands to 'const' if ncurses is configured using --enable-const.  Note that
92 * doing so makes it incompatible with other implementations of X/Open Curses.
93 */
94#undef  NCURSES_CONST
95#define NCURSES_CONST @NCURSES_CONST@
96
97/*
98 * The internal type used for color values
99 */
100#undef	NCURSES_COLOR_T
101#define	NCURSES_COLOR_T short
102
103/*
104 * The internal type used for window dimensions.
105 */
106#undef	NCURSES_SIZE_T
107#define	NCURSES_SIZE_T short
108
109/*
110 * NCURSES_CH_T is used in building the library, but not used otherwise in
111 * this header file, since that would make the normal/wide-character versions
112 * of the header incompatible.
113 */
114#undef	NCURSES_CH_T
115#define NCURSES_CH_T @NCURSES_CH_T@
116
117#if @cf_cv_enable_lp64@ && defined(_LP64)
118typedef unsigned chtype;
119typedef unsigned mmask_t;
120#else
121typedef unsigned @cf_cv_typeof_chtype@ chtype;
122typedef unsigned @cf_cv_typeof_mmask_t@ mmask_t;
123#endif
124
125#include <stdio.h>
126#include <unctrl.h>
127#include <stdarg.h>	/* we need va_list */
128#ifdef _XOPEN_SOURCE_EXTENDED
129#include <stddef.h>	/* we want wchar_t */
130#endif /* _XOPEN_SOURCE_EXTENDED */
131
132/* XSI and SVr4 specify that curses implements 'bool'.  However, C++ may also
133 * implement it.  If so, we must use the C++ compiler's type to avoid conflict
134 * with other interfaces.
135 *
136 * A further complication is that <stdbool.h> may declare 'bool' to be a
137 * different type, such as an enum which is not necessarily compatible with
138 * C++.  If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
139 * Otherwise, let it remain a typedef to avoid conflicts with other #define's.
140 * In either case, make a typedef for NCURSES_BOOL which can be used if needed
141 * from either C or C++.
142 */
143
144#undef TRUE
145#define TRUE    1
146
147#undef FALSE
148#define FALSE   0
149
150typedef @cf_cv_type_of_bool@ NCURSES_BOOL;
151
152#if @USE_CXX_BOOL@	/* __cplusplus, etc. */
153
154/* use the C++ compiler's bool type */
155#define NCURSES_BOOL bool
156
157#else			/* c89, c99, etc. */
158
159#if NCURSES_ENABLE_STDBOOL_H
160#include <stdbool.h>
161/* use whatever the C compiler decides bool really is */
162#define NCURSES_BOOL bool
163#else
164/* there is no predefined bool - use our own */
165#undef bool
166#define bool NCURSES_BOOL
167#endif
168
169#endif /* !__cplusplus, etc. */
170
171#ifdef __cplusplus
172extern "C" {
173#define NCURSES_CAST(type,value) static_cast<type>(value)
174#else
175#define NCURSES_CAST(type,value) (type)(value)
176#endif
177
178/*
179 * XSI attributes.  In the ncurses implementation, they are identical to the
180 * A_ attributes.
181 */
182#define WA_ATTRIBUTES	A_ATTRIBUTES
183#define WA_NORMAL	A_NORMAL
184#define WA_STANDOUT	A_STANDOUT
185#define WA_UNDERLINE	A_UNDERLINE
186#define WA_REVERSE	A_REVERSE
187#define WA_BLINK	A_BLINK
188#define WA_DIM		A_DIM
189#define WA_BOLD		A_BOLD
190#define WA_ALTCHARSET	A_ALTCHARSET
191#define WA_INVIS	A_INVIS
192#define WA_PROTECT	A_PROTECT
193#define WA_HORIZONTAL	A_HORIZONTAL
194#define WA_LEFT		A_LEFT
195#define WA_LOW		A_LOW
196#define WA_RIGHT	A_RIGHT
197#define WA_TOP		A_TOP
198#define WA_VERTICAL	A_VERTICAL
199
200/* colors */
201extern NCURSES_EXPORT_VAR(int) COLORS;
202extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
203
204#define COLOR_BLACK	0
205#define COLOR_RED	1
206#define COLOR_GREEN	2
207#define COLOR_YELLOW	3
208#define COLOR_BLUE	4
209#define COLOR_MAGENTA	5
210#define COLOR_CYAN	6
211#define COLOR_WHITE	7
212
213/* line graphics */
214
215#if @BROKEN_LINKER@
216extern NCURSES_EXPORT_VAR(chtype*) _nc_acs_map(void);
217#define acs_map (_nc_acs_map())
218#else
219extern NCURSES_EXPORT_VAR(chtype) acs_map[];
220#endif
221
222#define NCURSES_ACS(c)	(acs_map[NCURSES_CAST(unsigned char,c)])
223
224/* VT100 symbols begin here */
225#define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
226#define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
227#define ACS_URCORNER	NCURSES_ACS('k') /* upper right corner */
228#define ACS_LRCORNER	NCURSES_ACS('j') /* lower right corner */
229#define ACS_LTEE	NCURSES_ACS('t') /* tee pointing right */
230#define ACS_RTEE	NCURSES_ACS('u') /* tee pointing left */
231#define ACS_BTEE	NCURSES_ACS('v') /* tee pointing up */
232#define ACS_TTEE	NCURSES_ACS('w') /* tee pointing down */
233#define ACS_HLINE	NCURSES_ACS('q') /* horizontal line */
234#define ACS_VLINE	NCURSES_ACS('x') /* vertical line */
235#define ACS_PLUS	NCURSES_ACS('n') /* large plus or crossover */
236#define ACS_S1		NCURSES_ACS('o') /* scan line 1 */
237#define ACS_S9		NCURSES_ACS('s') /* scan line 9 */
238#define ACS_DIAMOND	NCURSES_ACS('`') /* diamond */
239#define ACS_CKBOARD	NCURSES_ACS('a') /* checker board (stipple) */
240#define ACS_DEGREE	NCURSES_ACS('f') /* degree symbol */
241#define ACS_PLMINUS	NCURSES_ACS('g') /* plus/minus */
242#define ACS_BULLET	NCURSES_ACS('~') /* bullet */
243/* Teletype 5410v1 symbols begin here */
244#define ACS_LARROW	NCURSES_ACS(',') /* arrow pointing left */
245#define ACS_RARROW	NCURSES_ACS('+') /* arrow pointing right */
246#define ACS_DARROW	NCURSES_ACS('.') /* arrow pointing down */
247#define ACS_UARROW	NCURSES_ACS('-') /* arrow pointing up */
248#define ACS_BOARD	NCURSES_ACS('h') /* board of squares */
249#define ACS_LANTERN	NCURSES_ACS('i') /* lantern symbol */
250#define ACS_BLOCK	NCURSES_ACS('0') /* solid square block */
251/*
252 * These aren't documented, but a lot of System Vs have them anyway
253 * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
254 * The ACS_names may not match AT&T's, our source didn't know them.
255 */
256#define ACS_S3		NCURSES_ACS('p') /* scan line 3 */
257#define ACS_S7		NCURSES_ACS('r') /* scan line 7 */
258#define ACS_LEQUAL	NCURSES_ACS('y') /* less/equal */
259#define ACS_GEQUAL	NCURSES_ACS('z') /* greater/equal */
260#define ACS_PI		NCURSES_ACS('{') /* Pi */
261#define ACS_NEQUAL	NCURSES_ACS('|') /* not equal */
262#define ACS_STERLING	NCURSES_ACS('}') /* UK pound sign */
263
264/*
265 * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
266 * is the right, b is the bottom, and l is the left.  t, r, b, and l might
267 * be B (blank), S (single), D (double), or T (thick).  The subset defined
268 * here only uses B and S.
269 */
270#define ACS_BSSB	ACS_ULCORNER
271#define ACS_SSBB	ACS_LLCORNER
272#define ACS_BBSS	ACS_URCORNER
273#define ACS_SBBS	ACS_LRCORNER
274#define ACS_SBSS	ACS_RTEE
275#define ACS_SSSB	ACS_LTEE
276#define ACS_SSBS	ACS_BTEE
277#define ACS_BSSS	ACS_TTEE
278#define ACS_BSBS	ACS_HLINE
279#define ACS_SBSB	ACS_VLINE
280#define ACS_SSSS	ACS_PLUS
281
282#undef	ERR
283#define ERR     (-1)
284
285#undef	OK
286#define OK      (0)
287
288/* values for the _flags member */
289#define _SUBWIN         0x01	/* is this a sub-window? */
290#define _ENDLINE        0x02	/* is the window flush right? */
291#define _FULLWIN        0x04	/* is the window full-screen? */
292#define _SCROLLWIN      0x08	/* bottom edge is at screen bottom? */
293#define _ISPAD	        0x10	/* is this window a pad? */
294#define _HASMOVED       0x20	/* has cursor moved since last refresh? */
295#define _WRAPPED        0x40	/* cursor was just wrappped */
296
297/*
298 * this value is used in the firstchar and lastchar fields to mark
299 * unchanged lines
300 */
301#define _NOCHANGE       -1
302
303/*
304 * this value is used in the oldindex field to mark lines created by insertions
305 * and scrolls.
306 */
307#define _NEWINDEX	-1
308
309typedef struct screen  SCREEN;
310typedef struct _win_st WINDOW;
311
312typedef	chtype	attr_t;		/* ...must be at least as wide as chtype */
313
314#ifdef _XOPEN_SOURCE_EXTENDED
315
316#if @NCURSES_LIBUTF8@
317#ifdef mblen			/* libutf8.h defines it w/o undefining first */
318#undef mblen
319#endif
320#include <libutf8.h>
321#endif
322
323#if @NEED_WCHAR_H@
324#include <wchar.h>		/* ...to get mbstate_t, etc. */
325#endif
326
327#if @NCURSES_WCHAR_T@
328typedef unsigned short wchar_t@NCURSES_OK_WCHAR_T@;
329#endif
330
331#if @NCURSES_WINT_T@
332typedef unsigned int wint_t@NCURSES_OK_WCHAR_T@;
333#endif
334
335#define CCHARW_MAX	5
336typedef struct
337{
338    attr_t	attr;
339    wchar_t	chars[CCHARW_MAX];
340#if @NCURSES_EXT_COLORS@
341    int		ext_color;	/* color pair, must be more than 16-bits */
342#endif
343}
344cchar_t;
345
346#endif /* _XOPEN_SOURCE_EXTENDED */
347
348struct ldat;
349
350struct _win_st
351{
352	NCURSES_SIZE_T _cury, _curx; /* current cursor position */
353
354	/* window location and size */
355	NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
356	NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
357
358	short   _flags;		/* window state flags */
359
360	/* attribute tracking */
361	attr_t  _attrs;		/* current attribute for non-space character */
362	chtype  _bkgd;		/* current background char/attribute pair */
363
364	/* option values set by user */
365	bool	_notimeout;	/* no time out on function-key entry? */
366	bool	_clear;		/* consider all data in the window invalid? */
367	bool	_leaveok;	/* OK to not reset cursor on exit? */
368	bool	_scroll;	/* OK to scroll this window? */
369	bool	_idlok;		/* OK to use insert/delete line? */
370	bool	_idcok;		/* OK to use insert/delete char? */
371	bool	_immed;		/* window in immed mode? (not yet used) */
372	bool	_sync;		/* window in sync mode? */
373	bool	_use_keypad;	/* process function keys into KEY_ symbols? */
374	int	_delay;		/* 0 = nodelay, <0 = blocking, >0 = delay */
375
376	struct ldat *_line;	/* the actual line data */
377
378	/* global screen state */
379	NCURSES_SIZE_T _regtop;	/* top line of scrolling region */
380	NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
381
382	/* these are used only if this is a sub-window */
383	int	_parx;		/* x coordinate of this window in parent */
384	int	_pary;		/* y coordinate of this window in parent */
385	WINDOW	*_parent;	/* pointer to parent if a sub-window */
386
387	/* these are used only if this is a pad */
388	struct pdat
389	{
390	    NCURSES_SIZE_T _pad_y,      _pad_x;
391	    NCURSES_SIZE_T _pad_top,    _pad_left;
392	    NCURSES_SIZE_T _pad_bottom, _pad_right;
393	} _pad;
394
395	NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
396
397#ifdef _XOPEN_SOURCE_EXTENDED
398	cchar_t  _bkgrnd;	/* current background char/attribute pair */
399#if @NCURSES_EXT_COLORS@
400	int	_color;		/* current color-pair for non-space character */
401#endif
402#endif
403};
404
405extern NCURSES_EXPORT_VAR(WINDOW *)   stdscr;
406extern NCURSES_EXPORT_VAR(WINDOW *)   curscr;
407extern NCURSES_EXPORT_VAR(WINDOW *)   newscr;
408
409extern NCURSES_EXPORT_VAR(int)	LINES;
410extern NCURSES_EXPORT_VAR(int)	COLS;
411extern NCURSES_EXPORT_VAR(int)	TABSIZE;
412
413/*
414 * This global was an undocumented feature under AIX curses.
415 */
416extern NCURSES_EXPORT_VAR(int) ESCDELAY;	/* ESC expire time in milliseconds */
417
418extern NCURSES_EXPORT_VAR(char) ttytype[];	/* needed for backward compatibility */
419
420/*
421 * These functions are extensions - not in XSI Curses.
422 */
423#if @NCURSES_EXT_FUNCS@
424extern NCURSES_EXPORT(bool) is_term_resized (int, int);
425extern NCURSES_EXPORT(char *) keybound (int, int);
426extern NCURSES_EXPORT(const char *) curses_version (void);
427extern NCURSES_EXPORT(int) assume_default_colors (int, int);
428extern NCURSES_EXPORT(int) define_key (const char *, int);
429extern NCURSES_EXPORT(int) key_defined (const char *);
430extern NCURSES_EXPORT(int) keyok (int, bool);
431extern NCURSES_EXPORT(int) resize_term (int, int);
432extern NCURSES_EXPORT(int) resizeterm (int, int);
433extern NCURSES_EXPORT(int) use_default_colors (void);
434extern NCURSES_EXPORT(int) use_extended_names (bool);
435extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
436#else
437#define curses_version() NCURSES_VERSION
438#endif
439
440/*
441 * This is an extension to support events...
442 */
443#if @NCURSES_EXT_FUNCS@
444#ifdef NCURSES_WGETCH_EVENTS
445#if !defined(__BEOS__)		/* Fix _nc_timed_wait() on BEOS... */
446#  define NCURSES_EVENT_VERSION	1
447#endif	/* !defined(__BEOS__) */
448
449/*
450 * Bits to set in _nc_event.data.flags
451 */
452#  define _NC_EVENT_TIMEOUT_MSEC	1
453#  define _NC_EVENT_FILE		2
454#  define _NC_EVENT_FILE_READABLE	2
455#  if 0					/* Not supported yet... */
456#    define _NC_EVENT_FILE_WRITABLE	4
457#    define _NC_EVENT_FILE_EXCEPTION	8
458#  endif
459
460typedef struct
461{
462    int type;
463    union
464    {
465	long timeout_msec;	/* _NC_EVENT_TIMEOUT_MSEC */
466	struct
467	{
468	    unsigned int flags;
469	    int fd;
470	    unsigned int result;
471	} fev;				/* _NC_EVENT_FILE */
472    } data;
473} _nc_event;
474
475typedef struct
476{
477    int count;
478    int result_flags;	/* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
479    _nc_event *events[1];
480} _nc_eventlist;
481
482extern NCURSES_EXPORT(int) wgetch_events(WINDOW *, _nc_eventlist *);	/* experimental */
483extern NCURSES_EXPORT(int) wgetnstr_events(WINDOW *,char *,int,_nc_eventlist *);/* experimental */
484
485#endif /* NCURSES_WGETCH_EVENTS */
486#endif /* NCURSES_EXT_FUNCS */
487
488/*
489 * GCC (and some other compilers) define '__attribute__'; we're using this
490 * macro to alert the compiler to flag inconsistencies in printf/scanf-like
491 * function calls.  Just in case '__attribute__' isn't defined, make a dummy.
492 * Old versions of G++ do not accept it anyway, at least not consistently with
493 * GCC.
494 */
495#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__))
496#define __attribute__(p) /* nothing */
497#endif
498
499/*
500 * We cannot define these in ncurses_cfg.h, since they require parameters to be
501 * passed (that's non-portable).
502 */
503#ifndef GCC_PRINTFLIKE
504#if defined(GCC_PRINTF) && !defined(printf)
505#define GCC_PRINTFLIKE(fmt,var) __attribute__((__format__(__printf__, fmt, var)))
506#else
507#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
508#endif
509#endif
510
511#ifndef GCC_SCANFLIKE
512#if defined(GCC_SCANF) && !defined(scanf)
513#define GCC_SCANFLIKE(fmt,var)  __attribute__((__format__(__scanf__, fmt, var)))
514#else
515#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
516#endif
517#endif
518
519#ifndef	GCC_NORETURN
520#define	GCC_NORETURN /* nothing */
521#endif
522
523#ifndef	GCC_UNUSED
524#define	GCC_UNUSED /* nothing */
525#endif
526
527/*
528 * Function prototypes.  This is the complete XSI Curses list of required
529 * functions.  Those marked `generated' will have sources generated from the
530 * macro definitions later in this file, in order to satisfy XPG4.2
531 * requirements.
532 */
533
534extern NCURSES_EXPORT(int) addch (const chtype);			/* generated */
535extern NCURSES_EXPORT(int) addchnstr (const chtype *, int);		/* generated */
536extern NCURSES_EXPORT(int) addchstr (const chtype *);			/* generated */
537extern NCURSES_EXPORT(int) addnstr (const char *, int);			/* generated */
538extern NCURSES_EXPORT(int) addstr (const char *);			/* generated */
539extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T);			/* generated */
540extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T);			/* generated */
541extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T);			/* generated */
542extern NCURSES_EXPORT(int) attr_get (attr_t *, short *, void *);	/* generated */
543extern NCURSES_EXPORT(int) attr_off (attr_t, void *);			/* generated */
544extern NCURSES_EXPORT(int) attr_on (attr_t, void *);			/* generated */
545extern NCURSES_EXPORT(int) attr_set (attr_t, short, void *);		/* generated */
546extern NCURSES_EXPORT(int) baudrate (void);				/* implemented */
547extern NCURSES_EXPORT(int) beep  (void);				/* implemented */
548extern NCURSES_EXPORT(int) bkgd (chtype);				/* generated */
549extern NCURSES_EXPORT(void) bkgdset (chtype);				/* generated */
550extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* generated */
551extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype);		/* generated */
552extern NCURSES_EXPORT(bool) can_change_color (void);			/* implemented */
553extern NCURSES_EXPORT(int) cbreak (void);				/* implemented */
554extern NCURSES_EXPORT(int) chgat (int, attr_t, short, const void *);	/* generated */
555extern NCURSES_EXPORT(int) clear (void);				/* generated */
556extern NCURSES_EXPORT(int) clearok (WINDOW *,bool);			/* implemented */
557extern NCURSES_EXPORT(int) clrtobot (void);				/* generated */
558extern NCURSES_EXPORT(int) clrtoeol (void);				/* generated */
559extern NCURSES_EXPORT(int) color_content (short,short*,short*,short*);	/* implemented */
560extern NCURSES_EXPORT(int) color_set (short,void*);			/* generated */
561extern NCURSES_EXPORT(int) COLOR_PAIR (int);				/* generated */
562extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int);	/* implemented */
563extern NCURSES_EXPORT(int) curs_set (int);				/* implemented */
564extern NCURSES_EXPORT(int) def_prog_mode (void);			/* implemented */
565extern NCURSES_EXPORT(int) def_shell_mode (void);			/* implemented */
566extern NCURSES_EXPORT(int) delay_output (int);				/* implemented */
567extern NCURSES_EXPORT(int) delch (void);				/* generated */
568extern NCURSES_EXPORT(void) delscreen (SCREEN *);			/* implemented */
569extern NCURSES_EXPORT(int) delwin (WINDOW *);				/* implemented */
570extern NCURSES_EXPORT(int) deleteln (void);				/* generated */
571extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int);	/* implemented */
572extern NCURSES_EXPORT(int) doupdate (void);				/* implemented */
573extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *);			/* implemented */
574extern NCURSES_EXPORT(int) echo (void);					/* implemented */
575extern NCURSES_EXPORT(int) echochar (const chtype);			/* generated */
576extern NCURSES_EXPORT(int) erase (void);				/* generated */
577extern NCURSES_EXPORT(int) endwin (void);				/* implemented */
578extern NCURSES_EXPORT(char) erasechar (void);				/* implemented */
579extern NCURSES_EXPORT(void) filter (void);				/* implemented */
580extern NCURSES_EXPORT(int) flash (void);				/* implemented */
581extern NCURSES_EXPORT(int) flushinp (void);				/* implemented */
582extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *);			/* generated */
583extern NCURSES_EXPORT(int) getch (void);				/* generated */
584extern NCURSES_EXPORT(int) getnstr (char *, int);			/* generated */
585extern NCURSES_EXPORT(int) getstr (char *);				/* generated */
586extern NCURSES_EXPORT(WINDOW *) getwin (FILE *);			/* implemented */
587extern NCURSES_EXPORT(int) halfdelay (int);				/* implemented */
588extern NCURSES_EXPORT(bool) has_colors (void);				/* implemented */
589extern NCURSES_EXPORT(bool) has_ic (void);				/* implemented */
590extern NCURSES_EXPORT(bool) has_il (void);				/* implemented */
591extern NCURSES_EXPORT(int) hline (chtype, int);				/* generated */
592extern NCURSES_EXPORT(void) idcok (WINDOW *, bool);			/* implemented */
593extern NCURSES_EXPORT(int) idlok (WINDOW *, bool);			/* implemented */
594extern NCURSES_EXPORT(void) immedok (WINDOW *, bool);			/* implemented */
595extern NCURSES_EXPORT(chtype) inch (void);				/* generated */
596extern NCURSES_EXPORT(int) inchnstr (chtype *, int);			/* generated */
597extern NCURSES_EXPORT(int) inchstr (chtype *);				/* generated */
598extern NCURSES_EXPORT(WINDOW *) initscr (void);				/* implemented */
599extern NCURSES_EXPORT(int) init_color (short,short,short,short);	/* implemented */
600extern NCURSES_EXPORT(int) init_pair (short,short,short);		/* implemented */
601extern NCURSES_EXPORT(int) innstr (char *, int);			/* generated */
602extern NCURSES_EXPORT(int) insch (chtype);				/* generated */
603extern NCURSES_EXPORT(int) insdelln (int);				/* generated */
604extern NCURSES_EXPORT(int) insertln (void);				/* generated */
605extern NCURSES_EXPORT(int) insnstr (const char *, int);			/* generated */
606extern NCURSES_EXPORT(int) insstr (const char *);			/* generated */
607extern NCURSES_EXPORT(int) instr (char *);				/* generated */
608extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool);			/* implemented */
609extern NCURSES_EXPORT(bool) isendwin (void);				/* implemented */
610extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int);		/* implemented */
611extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *);			/* implemented */
612extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int);		/* implemented */
613extern NCURSES_EXPORT(int) keypad (WINDOW *,bool);			/* implemented */
614extern NCURSES_EXPORT(char) killchar (void);				/* implemented */
615extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool);			/* implemented */
616extern NCURSES_EXPORT(char *) longname (void);				/* implemented */
617extern NCURSES_EXPORT(int) meta (WINDOW *,bool);			/* implemented */
618extern NCURSES_EXPORT(int) move (int, int);				/* generated */
619extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);		/* generated */
620extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int);	/* generated */
621extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *);	/* generated */
622extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int);	/* generated */
623extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *);		/* generated */
624extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, short, const void *);	/* generated */
625extern NCURSES_EXPORT(int) mvcur (int,int,int,int);			/* implemented */
626extern NCURSES_EXPORT(int) mvdelch (int, int);				/* generated */
627extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int);		/* implemented */
628extern NCURSES_EXPORT(int) mvgetch (int, int);				/* generated */
629extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int);		/* generated */
630extern NCURSES_EXPORT(int) mvgetstr (int, int, char *);			/* generated */
631extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int);		/* generated */
632extern NCURSES_EXPORT(chtype) mvinch (int, int);			/* generated */
633extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int);	/* generated */
634extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *);		/* generated */
635extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int);		/* generated */
636extern NCURSES_EXPORT(int) mvinsch (int, int, chtype);			/* generated */
637extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int);	/* generated */
638extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *);		/* generated */
639extern NCURSES_EXPORT(int) mvinstr (int, int, char *);			/* generated */
640extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...)		/* implemented */
641		GCC_PRINTFLIKE(3,4);
642extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...)	/* implemented */
643		GCC_SCANFLIKE(3,4);
644extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int);		/* generated */
645extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype);	/* generated */
646extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */
647extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *);	/* generated */
648extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int);	/* generated */
649extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *);	/* generated */
650extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, short, const void *);/* generated */
651extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int);		/* generated */
652extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int);		/* generated */
653extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int);	/* generated */
654extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *);	/* generated */
655extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int);	/* generated */
656extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int);			/* implemented */
657extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int);			/* generated */
658extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int);	/* generated */
659extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *);		/* generated */
660extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int);		/* generated */
661extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype);		/* generated */
662extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int);	/* generated */
663extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *);		/* generated */
664extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *);		/* generated */
665extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...)	/* implemented */
666		GCC_PRINTFLIKE(4,5);
667extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...)	/* implemented */
668		GCC_SCANFLIKE(4,5);
669extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int);	/* generated */
670extern NCURSES_EXPORT(int) napms (int);					/* implemented */
671extern NCURSES_EXPORT(WINDOW *) newpad (int,int);				/* implemented */
672extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *);	/* implemented */
673extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int);			/* implemented */
674extern NCURSES_EXPORT(int) nl (void);					/* implemented */
675extern NCURSES_EXPORT(int) nocbreak (void);				/* implemented */
676extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool);			/* implemented */
677extern NCURSES_EXPORT(int) noecho (void);				/* implemented */
678extern NCURSES_EXPORT(int) nonl (void);					/* implemented */
679extern NCURSES_EXPORT(void) noqiflush (void);				/* implemented */
680extern NCURSES_EXPORT(int) noraw (void);				/* implemented */
681extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool);			/* implemented */
682extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *);		/* implemented */
683extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *);		/* implemented */
684extern NCURSES_EXPORT(int) pair_content (short,short*,short*);		/* implemented */
685extern NCURSES_EXPORT(int) PAIR_NUMBER (int);				/* generated */
686extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype);		/* implemented */
687extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */
688extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int);	/* implemented */
689extern NCURSES_EXPORT(int) printw (const char *,...)			/* implemented */
690		GCC_PRINTFLIKE(1,2);
691extern NCURSES_EXPORT(int) putp (const char *);				/* implemented */
692extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *);			/* implemented */
693extern NCURSES_EXPORT(void) qiflush (void);				/* implemented */
694extern NCURSES_EXPORT(int) raw (void);					/* implemented */
695extern NCURSES_EXPORT(int) redrawwin (WINDOW *);			/* generated */
696extern NCURSES_EXPORT(int) refresh (void);				/* generated */
697extern NCURSES_EXPORT(int) resetty (void);				/* implemented */
698extern NCURSES_EXPORT(int) reset_prog_mode (void);			/* implemented */
699extern NCURSES_EXPORT(int) reset_shell_mode (void);			/* implemented */
700extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int));	/* implemented */
701extern NCURSES_EXPORT(int) savetty (void);				/* implemented */
702extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...)		/* implemented */
703		GCC_SCANFLIKE(1,2);
704extern NCURSES_EXPORT(int) scr_dump (const char *);			/* implemented */
705extern NCURSES_EXPORT(int) scr_init (const char *);			/* implemented */
706extern NCURSES_EXPORT(int) scrl (int);					/* generated */
707extern NCURSES_EXPORT(int) scroll (WINDOW *);				/* generated */
708extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool);			/* implemented */
709extern NCURSES_EXPORT(int) scr_restore (const char *);			/* implemented */
710extern NCURSES_EXPORT(int) scr_set (const char *);			/* implemented */
711extern NCURSES_EXPORT(int) setscrreg (int,int);				/* generated */
712extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *);			/* implemented */
713extern NCURSES_EXPORT(int) slk_attroff (const chtype);			/* implemented */
714extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *);		/* generated:WIDEC */
715extern NCURSES_EXPORT(int) slk_attron (const chtype);			/* implemented */
716extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*);			/* generated:WIDEC */
717extern NCURSES_EXPORT(int) slk_attrset (const chtype);			/* implemented */
718extern NCURSES_EXPORT(attr_t) slk_attr (void);				/* implemented */
719extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,short,void*);	/* implemented */
720extern NCURSES_EXPORT(int) slk_clear (void);				/* implemented */
721extern NCURSES_EXPORT(int) slk_color (short);				/* implemented */
722extern NCURSES_EXPORT(int) slk_init (int);				/* implemented */
723extern NCURSES_EXPORT(char *) slk_label (int);				/* implemented */
724extern NCURSES_EXPORT(int) slk_noutrefresh (void);			/* implemented */
725extern NCURSES_EXPORT(int) slk_refresh (void);				/* implemented */
726extern NCURSES_EXPORT(int) slk_restore (void);				/* implemented */
727extern NCURSES_EXPORT(int) slk_set (int,const char *,int);		/* implemented */
728extern NCURSES_EXPORT(int) slk_touch (void);				/* implemented */
729extern NCURSES_EXPORT(int) standout (void);				/* generated */
730extern NCURSES_EXPORT(int) standend (void);				/* generated */
731extern NCURSES_EXPORT(int) start_color (void);				/* implemented */
732extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int);	/* implemented */
733extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *,int,int,int,int);	/* implemented */
734extern NCURSES_EXPORT(int) syncok (WINDOW *, bool);			/* implemented */
735extern NCURSES_EXPORT(chtype) termattrs (void);				/* implemented */
736extern NCURSES_EXPORT(char *) termname (void);				/* implemented */
737extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);		/* implemented */
738extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);		/* implemented */
739extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);		/* implemented */
740extern NCURSES_EXPORT(void) timeout (int);				/* generated */
741extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int);		/* generated */
742extern NCURSES_EXPORT(int) touchwin (WINDOW *);				/* generated */
743extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* implemented */
744extern NCURSES_EXPORT(int) typeahead (int);				/* implemented */
745extern NCURSES_EXPORT(int) ungetch (int);				/* implemented */
746extern NCURSES_EXPORT(int) untouchwin (WINDOW *);			/* generated */
747extern NCURSES_EXPORT(void) use_env (bool);				/* implemented */
748extern NCURSES_EXPORT(int) vidattr (chtype);				/* implemented */
749extern NCURSES_EXPORT(int) vidputs (chtype, int (*)(int));		/* implemented */
750extern NCURSES_EXPORT(int) vline (chtype, int);				/* generated */
751extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list);	/* implemented */
752extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list);	/* generated */
753extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list);	/* implemented */
754extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list);	/* generated */
755extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype);		/* implemented */
756extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int);	/* implemented */
757extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *);		/* generated */
758extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int);	/* implemented */
759extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *);		/* generated */
760extern NCURSES_EXPORT(int) wattron (WINDOW *, int);			/* generated */
761extern NCURSES_EXPORT(int) wattroff (WINDOW *, int);			/* generated */
762extern NCURSES_EXPORT(int) wattrset (WINDOW *, int);			/* generated */
763extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, short *, void *);	/* generated */
764extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *);		/* implemented */
765extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *);	/* implemented */
766extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, short, void *);	/* generated */
767extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype);			/* implemented */
768extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype);			/* implemented */
769extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* implemented */
770extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, short, const void *);/* implemented */
771extern NCURSES_EXPORT(int) wclear (WINDOW *);				/* implemented */
772extern NCURSES_EXPORT(int) wclrtobot (WINDOW *);			/* implemented */
773extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *);			/* implemented */
774extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,short,void*);		/* implemented */
775extern NCURSES_EXPORT(void) wcursyncup (WINDOW *);			/* implemented */
776extern NCURSES_EXPORT(int) wdelch (WINDOW *);				/* implemented */
777extern NCURSES_EXPORT(int) wdeleteln (WINDOW *);			/* generated */
778extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype);		/* implemented */
779extern NCURSES_EXPORT(int) werase (WINDOW *);				/* implemented */
780extern NCURSES_EXPORT(int) wgetch (WINDOW *);				/* implemented */
781extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int);		/* implemented */
782extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *);			/* generated */
783extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int);		/* implemented */
784extern NCURSES_EXPORT(chtype) winch (WINDOW *);				/* implemented */
785extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int);		/* implemented */
786extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *);		/* generated */
787extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int);		/* implemented */
788extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype);			/* implemented */
789extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int);			/* implemented */
790extern NCURSES_EXPORT(int) winsertln (WINDOW *);			/* generated */
791extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int);	/* implemented */
792extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *);		/* generated */
793extern NCURSES_EXPORT(int) winstr (WINDOW *, char *);			/* generated */
794extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int);			/* implemented */
795extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *);			/* implemented */
796extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...)		/* implemented */
797		GCC_PRINTFLIKE(2,3);
798extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int);		/* implemented */
799extern NCURSES_EXPORT(int) wrefresh (WINDOW *);				/* implemented */
800extern NCURSES_EXPORT(int) wscanw (WINDOW *, NCURSES_CONST char *,...)	/* implemented */
801		GCC_SCANFLIKE(2,3);
802extern NCURSES_EXPORT(int) wscrl (WINDOW *,int);			/* implemented */
803extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int);		/* implemented */
804extern NCURSES_EXPORT(int) wstandout (WINDOW *);			/* generated */
805extern NCURSES_EXPORT(int) wstandend (WINDOW *);			/* generated */
806extern NCURSES_EXPORT(void) wsyncdown (WINDOW *);			/* implemented */
807extern NCURSES_EXPORT(void) wsyncup (WINDOW *);				/* implemented */
808extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int);			/* implemented */
809extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int);		/* implemented */
810extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int);		/* implemented */
811
812/*
813 * vid_attr() was implemented originally based on the draft of XSI curses.
814 */
815#ifndef _XOPEN_SOURCE_EXTENDED
816#define vid_attr(a,pair,opts) vidattr(a)
817#endif
818
819/* attributes */
820
821#define NCURSES_ATTR_SHIFT       8
822#define NCURSES_BITS(mask,shift) ((mask) << ((shift) + NCURSES_ATTR_SHIFT))
823
824#define A_NORMAL	(@cf_cv_1UL@ - @cf_cv_1UL@)
825#define A_ATTRIBUTES	NCURSES_BITS(~(@cf_cv_1UL@ - @cf_cv_1UL@),0)
826#define A_CHARTEXT	(NCURSES_BITS(@cf_cv_1UL@,0) - @cf_cv_1UL@)
827#define A_COLOR		NCURSES_BITS(((@cf_cv_1UL@) << 8) - @cf_cv_1UL@,0)
828#define A_STANDOUT	NCURSES_BITS(@cf_cv_1UL@,8)
829#define A_UNDERLINE	NCURSES_BITS(@cf_cv_1UL@,9)
830#define A_REVERSE	NCURSES_BITS(@cf_cv_1UL@,10)
831#define A_BLINK		NCURSES_BITS(@cf_cv_1UL@,11)
832#define A_DIM		NCURSES_BITS(@cf_cv_1UL@,12)
833#define A_BOLD		NCURSES_BITS(@cf_cv_1UL@,13)
834#define A_ALTCHARSET	NCURSES_BITS(@cf_cv_1UL@,14)
835#define A_INVIS		NCURSES_BITS(@cf_cv_1UL@,15)
836#define A_PROTECT	NCURSES_BITS(@cf_cv_1UL@,16)
837#define A_HORIZONTAL	NCURSES_BITS(@cf_cv_1UL@,17)
838#define A_LEFT		NCURSES_BITS(@cf_cv_1UL@,18)
839#define A_LOW		NCURSES_BITS(@cf_cv_1UL@,19)
840#define A_RIGHT		NCURSES_BITS(@cf_cv_1UL@,20)
841#define A_TOP		NCURSES_BITS(@cf_cv_1UL@,21)
842#define A_VERTICAL	NCURSES_BITS(@cf_cv_1UL@,22)
843
844/*
845 * These apply to the first 256 color pairs.
846 */
847#define COLOR_PAIR(n)	NCURSES_BITS(n, 0)
848#define PAIR_NUMBER(a)	(NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
849
850/*
851 * pseudo functions
852 */
853#define wgetstr(w, s)		wgetnstr(w, s, -1)
854#define getnstr(s, n)		wgetnstr(stdscr, s, n)
855
856#define setterm(term)		setupterm(term, 1, (int *)0)
857
858#define fixterm()		reset_prog_mode()
859#define resetterm()		reset_shell_mode()
860#define saveterm()		def_prog_mode()
861#define crmode()		cbreak()
862#define nocrmode()		nocbreak()
863#define gettmode()
864
865#define getyx(win,y,x)   	(y = getcury(win), x = getcurx(win))
866#define getbegyx(win,y,x)	(y = getbegy(win), x = getbegx(win))
867#define getmaxyx(win,y,x)	(y = getmaxy(win), x = getmaxx(win))
868#define getparyx(win,y,x)	(y = getpary(win), x = getparx(win))
869
870#define getsyx(y,x) do { if(newscr->_leaveok) (y)=(x)=-1; \
871			 else getyx(newscr,(y),(x)); \
872		    } while(0)
873#define setsyx(y,x) do { if((y)==-1 && (x)==-1) newscr->_leaveok=TRUE; \
874			 else {newscr->_leaveok=FALSE;wmove(newscr,(y),(x));} \
875		    } while(0)
876
877/* It seems older SYSV curses versions define these */
878#define getattrs(win)		((win)?(win)->_attrs:A_NORMAL)
879#define getcurx(win)		((win)?(win)->_curx:ERR)
880#define getcury(win)		((win)?(win)->_cury:ERR)
881#define getbegx(win)		((win)?(win)->_begx:ERR)
882#define getbegy(win)		((win)?(win)->_begy:ERR)
883#define getmaxx(win)		((win)?((win)->_maxx + 1):ERR)
884#define getmaxy(win)		((win)?((win)->_maxy + 1):ERR)
885#define getparx(win)		((win)?(win)->_parx:ERR)
886#define getpary(win)		((win)?(win)->_pary:ERR)
887
888#define wstandout(win)      	(wattrset(win,A_STANDOUT))
889#define wstandend(win)      	(wattrset(win,A_NORMAL))
890
891#define wattron(win,at)		wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
892#define wattroff(win,at)	wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
893
894#if @NCURSES_EXT_COLORS@
895#define wattrset(win,at)	((win)->_color = PAIR_NUMBER(at), \
896				 (win)->_attrs = (at))
897#else
898#define wattrset(win,at)	((win)->_attrs = (at))
899#endif
900
901#define scroll(win)		wscrl(win,1)
902
903#define touchwin(win)		wtouchln((win), 0, getmaxy(win), 1)
904#define touchline(win, s, c)	wtouchln((win), s, c, 1)
905#define untouchwin(win)		wtouchln((win), 0, getmaxy(win), 0)
906
907#define box(win, v, h)		wborder(win, v, v, h, h, 0, 0, 0, 0)
908#define border(ls, rs, ts, bs, tl, tr, bl, br)	wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
909#define hline(ch, n)		whline(stdscr, ch, n)
910#define vline(ch, n)		wvline(stdscr, ch, n)
911
912#define winstr(w, s)		winnstr(w, s, -1)
913#define winchstr(w, s)		winchnstr(w, s, -1)
914#define winsstr(w, s)		winsnstr(w, s, -1)
915
916#define redrawwin(win)		wredrawln(win, 0, (win)->_maxy+1)
917#define waddstr(win,str)	waddnstr(win,str,-1)
918#define waddchstr(win,str)	waddchnstr(win,str,-1)
919
920/*
921 * pseudo functions for standard screen
922 */
923
924#define addch(ch)		waddch(stdscr,ch)
925#define addchnstr(str,n)	waddchnstr(stdscr,str,n)
926#define addchstr(str)		waddchstr(stdscr,str)
927#define addnstr(str,n)		waddnstr(stdscr,str,n)
928#define addstr(str)		waddnstr(stdscr,str,-1)
929#define attroff(at)		wattroff(stdscr,at)
930#define attron(at)		wattron(stdscr,at)
931#define attrset(at)		wattrset(stdscr,at)
932#define attr_get(ap,cp,o)	wattr_get(stdscr,ap,cp,o)
933#define attr_off(a,o)		wattr_off(stdscr,a,o)
934#define attr_on(a,o)		wattr_on(stdscr,a,o)
935#define attr_set(a,c,o)		wattr_set(stdscr,a,c,o)
936#define bkgd(ch)		wbkgd(stdscr,ch)
937#define bkgdset(ch)		wbkgdset(stdscr,ch)
938#define chgat(n,a,c,o)		wchgat(stdscr,n,a,c,o)
939#define clear()			wclear(stdscr)
940#define clrtobot()		wclrtobot(stdscr)
941#define clrtoeol()		wclrtoeol(stdscr)
942#define color_set(c,o)		wcolor_set(stdscr,c,o)
943#define delch()			wdelch(stdscr)
944#define deleteln()		winsdelln(stdscr,-1)
945#define echochar(c)		wechochar(stdscr,c)
946#define erase()			werase(stdscr)
947#define getch()			wgetch(stdscr)
948#define getstr(str)		wgetstr(stdscr,str)
949#define inch()			winch(stdscr)
950#define inchnstr(s,n)		winchnstr(stdscr,s,n)
951#define inchstr(s)		winchstr(stdscr,s)
952#define innstr(s,n)		winnstr(stdscr,s,n)
953#define insch(c)		winsch(stdscr,c)
954#define insdelln(n)		winsdelln(stdscr,n)
955#define insertln()		winsdelln(stdscr,1)
956#define insnstr(s,n)		winsnstr(stdscr,s,n)
957#define insstr(s)		winsstr(stdscr,s)
958#define instr(s)		winstr(stdscr,s)
959#define move(y,x)		wmove(stdscr,y,x)
960#define refresh()		wrefresh(stdscr)
961#define scrl(n)			wscrl(stdscr,n)
962#define setscrreg(t,b)		wsetscrreg(stdscr,t,b)
963#define standend()		wstandend(stdscr)
964#define standout()		wstandout(stdscr)
965#define timeout(delay)		wtimeout(stdscr,delay)
966#define wdeleteln(win)		winsdelln(win,-1)
967#define winsertln(win)		winsdelln(win,1)
968
969/*
970 * mv functions
971 */
972
973#define mvwaddch(win,y,x,ch)		(wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
974#define mvwaddchnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,n))
975#define mvwaddchstr(win,y,x,str)	(wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
976#define mvwaddnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,n))
977#define mvwaddstr(win,y,x,str)		(wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
978#define mvwdelch(win,y,x)		(wmove(win,y,x) == ERR ? ERR : wdelch(win))
979#define mvwchgat(win,y,x,n,a,c,o)	(wmove(win,y,x) == ERR ? ERR : wchgat(win,n,a,c,o))
980#define mvwgetch(win,y,x)		(wmove(win,y,x) == ERR ? ERR : wgetch(win))
981#define mvwgetnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : wgetnstr(win,str,n))
982#define mvwgetstr(win,y,x,str)		(wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
983#define mvwhline(win,y,x,c,n)		(wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
984#define mvwinch(win,y,x)		(wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
985#define mvwinchnstr(win,y,x,s,n)	(wmove(win,y,x) == ERR ? ERR : winchnstr(win,s,n))
986#define mvwinchstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winchstr(win,s))
987#define mvwinnstr(win,y,x,s,n)		(wmove(win,y,x) == ERR ? ERR : winnstr(win,s,n))
988#define mvwinsch(win,y,x,c)		(wmove(win,y,x) == ERR ? ERR : winsch(win,c))
989#define mvwinsnstr(win,y,x,s,n)		(wmove(win,y,x) == ERR ? ERR : winsnstr(win,s,n))
990#define mvwinsstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winsstr(win,s))
991#define mvwinstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winstr(win,s))
992#define mvwvline(win,y,x,c,n)		(wmove(win,y,x) == ERR ? ERR : wvline(win,c,n))
993
994#define mvaddch(y,x,ch)			mvwaddch(stdscr,y,x,ch)
995#define mvaddchnstr(y,x,str,n)		mvwaddchnstr(stdscr,y,x,str,n)
996#define mvaddchstr(y,x,str)		mvwaddchstr(stdscr,y,x,str)
997#define mvaddnstr(y,x,str,n)		mvwaddnstr(stdscr,y,x,str,n)
998#define mvaddstr(y,x,str)		mvwaddstr(stdscr,y,x,str)
999#define mvchgat(y,x,n,a,c,o)		mvwchgat(stdscr,y,x,n,a,c,o)
1000#define mvdelch(y,x)			mvwdelch(stdscr,y,x)
1001#define mvgetch(y,x)			mvwgetch(stdscr,y,x)
1002#define mvgetnstr(y,x,str,n)		mvwgetnstr(stdscr,y,x,str,n)
1003#define mvgetstr(y,x,str)		mvwgetstr(stdscr,y,x,str)
1004#define mvhline(y,x,c,n)		mvwhline(stdscr,y,x,c,n)
1005#define mvinch(y,x)			mvwinch(stdscr,y,x)
1006#define mvinchnstr(y,x,s,n)		mvwinchnstr(stdscr,y,x,s,n)
1007#define mvinchstr(y,x,s)		mvwinchstr(stdscr,y,x,s)
1008#define mvinnstr(y,x,s,n)		mvwinnstr(stdscr,y,x,s,n)
1009#define mvinsch(y,x,c)			mvwinsch(stdscr,y,x,c)
1010#define mvinsnstr(y,x,s,n)		mvwinsnstr(stdscr,y,x,s,n)
1011#define mvinsstr(y,x,s)			mvwinsstr(stdscr,y,x,s)
1012#define mvinstr(y,x,s)			mvwinstr(stdscr,y,x,s)
1013#define mvvline(y,x,c,n)		mvwvline(stdscr,y,x,c,n)
1014
1015/*
1016 * Some wide-character functions can be implemented without the extensions.
1017 */
1018#define getbkgd(win)                    ((win)->_bkgd)
1019
1020#define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
1021#define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
1022
1023#if @NCURSES_EXT_COLORS@
1024#define wattr_set(win,a,p,opts)		((win)->_attrs = ((a) & ~A_COLOR), \
1025					 (win)->_color = (p), \
1026					 OK)
1027#define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
1028					 (void)((p) != 0 && (*(p) = (win)->_color)), \
1029					 OK)
1030#else
1031#define wattr_set(win,a,p,opts)		((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
1032#define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
1033					 (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
1034					 OK)
1035#endif
1036
1037/*
1038 * XSI curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
1039 * varargs.h.  It adds new calls vw_printw/vw_scanw, which are supposed to
1040 * use POSIX stdarg.h.  The ncurses versions of vwprintw/vwscanw already
1041 * use stdarg.h, so...
1042 */
1043#define vw_printw		vwprintw
1044#define vw_scanw		vwscanw
1045
1046/*
1047 * Export fallback function for use in C++ binding.
1048 */
1049#if !@HAVE_VSSCANF@
1050#define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
1051NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
1052#endif
1053
1054/*
1055 * Pseudo-character tokens outside ASCII range.  The curses wgetch() function
1056 * will return any given one of these only if the corresponding k- capability
1057 * is defined in your terminal's terminfo entry.
1058 *
1059 * Some keys (KEY_A1, etc) are arranged like this:
1060 *	a1     up    a3
1061 *	left   b2    right
1062 *	c1     down  c3
1063 *
1064 * A few key codes do not depend upon the terminfo entry.
1065 */
1066#define KEY_CODE_YES	0400		/* A wchar_t contains a key code */
1067#define KEY_MIN		0401		/* Minimum curses key */
1068#define KEY_BREAK	0401		/* Break key (unreliable) */
1069#define KEY_SRESET	0530		/* Soft (partial) reset (unreliable) */
1070#define KEY_RESET	0531		/* Reset or hard reset (unreliable) */
1071