1/****************************************************************************
2 * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
3 *                                                                          *
4 * Permission is hereby granted, free of charge, to any person obtaining a  *
5 * copy of this software and associated documentation files (the            *
6 * "Software"), to deal in the Software without restriction, including      *
7 * without limitation the rights to use, copy, modify, merge, publish,      *
8 * distribute, distribute with modifications, sublicense, and/or sell       *
9 * copies of the Software, and to permit persons to whom the Software is    *
10 * furnished to do so, subject to the following conditions:                 *
11 *                                                                          *
12 * The above copyright notice and this permission notice shall be included  *
13 * in all copies or substantial portions of the Software.                   *
14 *                                                                          *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 *                                                                          *
23 * Except as contained in this notice, the name(s) of the above copyright   *
24 * holders shall not be used in advertising or otherwise to promote the     *
25 * sale, use or other dealings in this Software without prior written       *
26 * authorization.                                                           *
27 ****************************************************************************/
28
29/****************************************************************************
30 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32 *     and: Thomas E. Dickey                        1996-on                 *
33 ****************************************************************************/
34
35/* $Id: curses.h.in,v 1.157 2005/07/02 16:58:28 tom Exp $ */
36
37#ifndef __NCURSES_H
38#define __NCURSES_H
39
40#define CURSES 1
41#define CURSES_H 1
42
43/* This should be defined for the enhanced functionality to be visible.
44 * However, some of the wide-character (enhanced) functionality is missing.
45 * So we do not define it (yet).
46#define _XOPEN_CURSES 1
47 */
48
49/* These are defined only in curses.h, and are used for conditional compiles */
50#define NCURSES_VERSION_MAJOR 5
51#define NCURSES_VERSION_MINOR 5
52#define NCURSES_VERSION_PATCH 20051010
53
54/* This is defined in more than one ncurses header, for identification */
55#undef  NCURSES_VERSION
56#define NCURSES_VERSION "5.5"
57
58/*
59 * Identify the mouse encoding version.
60 */
61#define NCURSES_MOUSE_VERSION 1
62
63/*
64 * Definitions to facilitate DLL's.
65 */
66#include <ncurses_dll.h>
67
68/*
69 * User-definable tweak to disable the include of <stdbool.h>.
70 */
71#ifndef NCURSES_ENABLE_STDBOOL_H
72#define NCURSES_ENABLE_STDBOOL_H 0
73#endif
74
75/*
76 * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
77 * configured using --disable-macros.
78 */
79#ifdef NCURSES_NOMACROS
80#define NCURSES_ATTR_T attr_t
81#endif
82
83#ifndef NCURSES_ATTR_T
84#define NCURSES_ATTR_T int
85#endif
86
87/*
88 * Expands to 'const' if ncurses is configured using --enable-const.  Note that
89 * doing so makes it incompatible with other implementations of X/Open Curses.
90 */
91#undef  NCURSES_CONST
92#define NCURSES_CONST /*nothing*/
93
94/*
95 * The internal type used for color values
96 */
97#undef	NCURSES_COLOR_T
98#define	NCURSES_COLOR_T short
99
100/*
101 * The internal type used for window dimensions.
102 */
103#undef	NCURSES_SIZE_T
104#define	NCURSES_SIZE_T short
105
106/*
107 * NCURSES_CH_T is used in building the library, but not used otherwise in
108 * this header file, since that would make the normal/wide-character versions
109 * of the header incompatible.
110 */
111#undef	NCURSES_CH_T
112#define NCURSES_CH_T chtype
113
114#if 0 && defined(_LP64)
115typedef unsigned chtype;
116typedef unsigned mmask_t;
117#else
118typedef unsigned long chtype;
119typedef unsigned long mmask_t;
120#endif
121
122#include <stdio.h>
123#include <unctrl.h>
124#include <stdarg.h>	/* we need va_list */
125#ifdef _XOPEN_SOURCE_EXTENDED
126#include <stddef.h>	/* we want wchar_t */
127#endif /* _XOPEN_SOURCE_EXTENDED */
128
129/* XSI and SVr4 specify that curses implements 'bool'.  However, C++ may also
130 * implement it.  If so, we must use the C++ compiler's type to avoid conflict
131 * with other interfaces.
132 *
133 * A further complication is that <stdbool.h> may declare 'bool' to be a
134 * different type, such as an enum which is not necessarily compatible with
135 * C++.  If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
136 * Otherwise, let it remain a typedef to avoid conflicts with other #define's.
137 * In either case, make a typedef for NCURSES_BOOL which can be used if needed
138 * from either C or C++.
139 */
140
141#undef TRUE
142#define TRUE    1
143
144#undef FALSE
145#define FALSE   0
146
147typedef unsigned char NCURSES_BOOL;
148
149#if defined(__cplusplus)	/* __cplusplus, etc. */
150
151/* use the C++ compiler's bool type */
152#define NCURSES_BOOL bool
153
154#else			/* c89, c99, etc. */
155
156#if NCURSES_ENABLE_STDBOOL_H
157#include <stdbool.h>
158/* use whatever the C compiler decides bool really is */
159#define NCURSES_BOOL bool
160#else
161/* there is no predefined bool - use our own */
162#undef bool
163#define bool NCURSES_BOOL
164#endif
165
166#endif /* !__cplusplus, etc. */
167
168#ifdef __cplusplus
169extern "C" {
170#define NCURSES_CAST(type,value) static_cast<type>(value)
171#else
172#define NCURSES_CAST(type,value) (type)(value)
173#endif
174
175/*
176 * XSI attributes.  In the ncurses implementation, they are identical to the
177 * A_ attributes.
178 */
179#define WA_ATTRIBUTES	A_ATTRIBUTES
180#define WA_NORMAL	A_NORMAL
181#define WA_STANDOUT	A_STANDOUT
182#define WA_UNDERLINE	A_UNDERLINE
183#define WA_REVERSE	A_REVERSE
184#define WA_BLINK	A_BLINK
185#define WA_DIM		A_DIM
186#define WA_BOLD		A_BOLD
187#define WA_ALTCHARSET	A_ALTCHARSET
188#define WA_INVIS	A_INVIS
189#define WA_PROTECT	A_PROTECT
190#define WA_HORIZONTAL	A_HORIZONTAL
191#define WA_LEFT		A_LEFT
192#define WA_LOW		A_LOW
193#define WA_RIGHT	A_RIGHT
194#define WA_TOP		A_TOP
195#define WA_VERTICAL	A_VERTICAL
196
197/* colors */
198extern NCURSES_EXPORT_VAR(int) COLORS;
199extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS;
200
201#define COLOR_BLACK	0
202#define COLOR_RED	1
203#define COLOR_GREEN	2
204#define COLOR_YELLOW	3
205#define COLOR_BLUE	4
206#define COLOR_MAGENTA	5
207#define COLOR_CYAN	6
208#define COLOR_WHITE	7
209
210/* line graphics */
211
212#if 0
213extern NCURSES_EXPORT_VAR(chtype*) _nc_acs_map(void);
214#define acs_map (_nc_acs_map())
215#else
216extern NCURSES_EXPORT_VAR(chtype) acs_map[];
217#endif
218
219#define NCURSES_ACS(c)	(acs_map[NCURSES_CAST(unsigned char,c)])
220
221/* VT100 symbols begin here */
222#define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
223#define ACS_LLCORNER	NCURSES_ACS('m') /* lower left corner */
224#define ACS_URCORNER	NCURSES_ACS('k') /* upper right corner */
225#define ACS_LRCORNER	NCURSES_ACS('j') /* lower right corner */
226#define ACS_LTEE	NCURSES_ACS('t') /* tee pointing right */
227#define ACS_RTEE	NCURSES_ACS('u') /* tee pointing left */
228#define ACS_BTEE	NCURSES_ACS('v') /* tee pointing up */
229#define ACS_TTEE	NCURSES_ACS('w') /* tee pointing down */
230#define ACS_HLINE	NCURSES_ACS('q') /* horizontal line */
231#define ACS_VLINE	NCURSES_ACS('x') /* vertical line */
232#define ACS_PLUS	NCURSES_ACS('n') /* large plus or crossover */
233#define ACS_S1		NCURSES_ACS('o') /* scan line 1 */
234#define ACS_S9		NCURSES_ACS('s') /* scan line 9 */
235#define ACS_DIAMOND	NCURSES_ACS('`') /* diamond */
236#define ACS_CKBOARD	NCURSES_ACS('a') /* checker board (stipple) */
237#define ACS_DEGREE	NCURSES_ACS('f') /* degree symbol */
238#define ACS_PLMINUS	NCURSES_ACS('g') /* plus/minus */
239#define ACS_BULLET	NCURSES_ACS('~') /* bullet */
240/* Teletype 5410v1 symbols begin here */
241#define ACS_LARROW	NCURSES_ACS(',') /* arrow pointing left */
242#define ACS_RARROW	NCURSES_ACS('+') /* arrow pointing right */
243#define ACS_DARROW	NCURSES_ACS('.') /* arrow pointing down */
244#define ACS_UARROW	NCURSES_ACS('-') /* arrow pointing up */
245#define ACS_BOARD	NCURSES_ACS('h') /* board of squares */
246#define ACS_LANTERN	NCURSES_ACS('i') /* lantern symbol */
247#define ACS_BLOCK	NCURSES_ACS('0') /* solid square block */
248/*
249 * These aren't documented, but a lot of System Vs have them anyway
250 * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
251 * The ACS_names may not match AT&T's, our source didn't know them.
252 */
253#define ACS_S3		NCURSES_ACS('p') /* scan line 3 */
254#define ACS_S7		NCURSES_ACS('r') /* scan line 7 */
255#define ACS_LEQUAL	NCURSES_ACS('y') /* less/equal */
256#define ACS_GEQUAL	NCURSES_ACS('z') /* greater/equal */
257#define ACS_PI		NCURSES_ACS('{') /* Pi */
258#define ACS_NEQUAL	NCURSES_ACS('|') /* not equal */
259#define ACS_STERLING	NCURSES_ACS('}') /* UK pound sign */
260
261/*
262 * Line drawing ACS names are of the form ACS_trbl, where t is the top, r
263 * is the right, b is the bottom, and l is the left.  t, r, b, and l might
264 * be B (blank), S (single), D (double), or T (thick).  The subset defined
265 * here only uses B and S.
266 */
267#define ACS_BSSB	ACS_ULCORNER
268#define ACS_SSBB	ACS_LLCORNER
269#define ACS_BBSS	ACS_URCORNER
270#define ACS_SBBS	ACS_LRCORNER
271#define ACS_SBSS	ACS_RTEE
272#define ACS_SSSB	ACS_LTEE
273#define ACS_SSBS	ACS_BTEE
274#define ACS_BSSS	ACS_TTEE
275#define ACS_BSBS	ACS_HLINE
276#define ACS_SBSB	ACS_VLINE
277#define ACS_SSSS	ACS_PLUS
278
279#undef	ERR
280#define ERR     (-1)
281
282#undef	OK
283#define OK      (0)
284
285/* values for the _flags member */
286#define _SUBWIN         0x01	/* is this a sub-window? */
287#define _ENDLINE        0x02	/* is the window flush right? */
288#define _FULLWIN        0x04	/* is the window full-screen? */
289#define _SCROLLWIN      0x08	/* bottom edge is at screen bottom? */
290#define _ISPAD	        0x10	/* is this window a pad? */
291#define _HASMOVED       0x20	/* has cursor moved since last refresh? */
292#define _WRAPPED        0x40	/* cursor was just wrappped */
293
294/*
295 * this value is used in the firstchar and lastchar fields to mark
296 * unchanged lines
297 */
298#define _NOCHANGE       -1
299
300/*
301 * this value is used in the oldindex field to mark lines created by insertions
302 * and scrolls.
303 */
304#define _NEWINDEX	-1
305
306typedef struct screen  SCREEN;
307typedef struct _win_st WINDOW;
308
309typedef	chtype	attr_t;		/* ...must be at least as wide as chtype */
310
311#ifdef _XOPEN_SOURCE_EXTENDED
312
313#if 0
314#ifdef mblen			/* libutf8.h defines it w/o undefining first */
315#undef mblen
316#endif
317#include <libutf8.h>
318#endif
319
320#if 0
321#include <wchar.h>		/* ...to get mbstate_t, etc. */
322#endif
323
324#if 0
325typedef unsigned short wchar_t;
326#endif
327
328#if 0
329typedef unsigned int wint_t;
330#endif
331
332#define CCHARW_MAX	5
333typedef struct
334{
335    attr_t	attr;
336    wchar_t	chars[CCHARW_MAX];
337#if 0
338    int		ext_color;	/* color pair, must be more than 16-bits */
339#endif
340}
341cchar_t;
342
343#endif /* _XOPEN_SOURCE_EXTENDED */
344
345struct ldat;
346
347struct _win_st
348{
349	NCURSES_SIZE_T _cury, _curx; /* current cursor position */
350
351	/* window location and size */
352	NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */
353	NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */
354
355	short   _flags;		/* window state flags */
356
357	/* attribute tracking */
358	attr_t  _attrs;		/* current attribute for non-space character */
359	chtype  _bkgd;		/* current background char/attribute pair */
360
361	/* option values set by user */
362	bool	_notimeout;	/* no time out on function-key entry? */
363	bool	_clear;		/* consider all data in the window invalid? */
364	bool	_leaveok;	/* OK to not reset cursor on exit? */
365	bool	_scroll;	/* OK to scroll this window? */
366	bool	_idlok;		/* OK to use insert/delete line? */
367	bool	_idcok;		/* OK to use insert/delete char? */
368	bool	_immed;		/* window in immed mode? (not yet used) */
369	bool	_sync;		/* window in sync mode? */
370	bool	_use_keypad;	/* process function keys into KEY_ symbols? */
371	int	_delay;		/* 0 = nodelay, <0 = blocking, >0 = delay */
372
373	struct ldat *_line;	/* the actual line data */
374
375	/* global screen state */
376	NCURSES_SIZE_T _regtop;	/* top line of scrolling region */
377	NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */
378
379	/* these are used only if this is a sub-window */
380	int	_parx;		/* x coordinate of this window in parent */
381	int	_pary;		/* y coordinate of this window in parent */
382	WINDOW	*_parent;	/* pointer to parent if a sub-window */
383
384	/* these are used only if this is a pad */
385	struct pdat
386	{
387	    NCURSES_SIZE_T _pad_y,      _pad_x;
388	    NCURSES_SIZE_T _pad_top,    _pad_left;
389	    NCURSES_SIZE_T _pad_bottom, _pad_right;
390	} _pad;
391
392	NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */
393
394#ifdef _XOPEN_SOURCE_EXTENDED
395	cchar_t  _bkgrnd;	/* current background char/attribute pair */
396#if 0
397	int	_color;		/* current color-pair for non-space character */
398#endif
399#endif
400};
401
402extern NCURSES_EXPORT_VAR(WINDOW *)   stdscr;
403extern NCURSES_EXPORT_VAR(WINDOW *)   curscr;
404extern NCURSES_EXPORT_VAR(WINDOW *)   newscr;
405
406extern NCURSES_EXPORT_VAR(int)	LINES;
407extern NCURSES_EXPORT_VAR(int)	COLS;
408extern NCURSES_EXPORT_VAR(int)	TABSIZE;
409
410/*
411 * This global was an undocumented feature under AIX curses.
412 */
413extern NCURSES_EXPORT_VAR(int) ESCDELAY;	/* ESC expire time in milliseconds */
414
415extern NCURSES_EXPORT_VAR(char) ttytype[];	/* needed for backward compatibility */
416
417/*
418 * These functions are extensions - not in XSI Curses.
419 */
420#if 1
421extern NCURSES_EXPORT(bool) is_term_resized (int, int);
422extern NCURSES_EXPORT(char *) keybound (int, int);
423extern NCURSES_EXPORT(const char *) curses_version (void);
424extern NCURSES_EXPORT(int) assume_default_colors (int, int);
425extern NCURSES_EXPORT(int) define_key (const char *, int);
426extern NCURSES_EXPORT(int) key_defined (const char *);
427extern NCURSES_EXPORT(int) keyok (int, bool);
428extern NCURSES_EXPORT(int) resize_term (int, int);
429extern NCURSES_EXPORT(int) resizeterm (int, int);
430extern NCURSES_EXPORT(int) use_default_colors (void);
431extern NCURSES_EXPORT(int) use_extended_names (bool);
432extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int);
433#else
434#define curses_version() NCURSES_VERSION
435#endif
436
437/*
438 * This is an extension to support events...
439 */
440#if 1
441#ifdef NCURSES_WGETCH_EVENTS
442#if !(defined(__BEOS__) || defined(__HAIKU__))		/* Fix _nc_timed_wait() on BEOS... */
443#  define NCURSES_EVENT_VERSION	1
444#endif	/* !defined(__BEOS__) */
445
446/*
447 * Bits to set in _nc_event.data.flags
448 */
449#  define _NC_EVENT_TIMEOUT_MSEC	1
450#  define _NC_EVENT_FILE		2
451#  define _NC_EVENT_FILE_READABLE	2
452#  if 0					/* Not supported yet... */
453#    define _NC_EVENT_FILE_WRITABLE	4
454#    define _NC_EVENT_FILE_EXCEPTION	8
455#  endif
456
457typedef struct
458{
459    int type;
460    union
461    {
462	long timeout_msec;	/* _NC_EVENT_TIMEOUT_MSEC */
463	struct
464	{
465	    unsigned int flags;
466	    int fd;
467	    unsigned int result;
468	} fev;				/* _NC_EVENT_FILE */
469    } data;
470} _nc_event;
471
472typedef struct
473{
474    int count;
475    int result_flags;	/* _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE */
476    _nc_event *events[1];
477} _nc_eventlist;
478
479extern NCURSES_EXPORT(int) wgetch_events(WINDOW *, _nc_eventlist *);	/* experimental */
480extern NCURSES_EXPORT(int) wgetnstr_events(WINDOW *,char *,int,_nc_eventlist *);/* experimental */
481
482#endif /* NCURSES_WGETCH_EVENTS */
483#endif /* NCURSES_EXT_FUNCS */
484
485/*
486 * GCC (and some other compilers) define '__attribute__'; we're using this
487 * macro to alert the compiler to flag inconsistencies in printf/scanf-like
488 * function calls.  Just in case '__attribute__' isn't defined, make a dummy.
489 * Old versions of G++ do not accept it anyway, at least not consistently with
490 * GCC.
491 */
492#if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__))
493#define __attribute__(p) /* nothing */
494#endif
495
496/*
497 * We cannot define these in ncurses_cfg.h, since they require parameters to be
498 * passed (that's non-portable).
499 */
500#ifndef GCC_PRINTFLIKE
501#if defined(GCC_PRINTF) && !defined(printf)
502#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
503#else
504#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
505#endif
506#endif
507
508#ifndef GCC_SCANFLIKE
509#if defined(GCC_SCANF) && !defined(scanf)
510#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
511#else
512#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
513#endif
514#endif
515
516#ifndef	GCC_NORETURN
517#define	GCC_NORETURN /* nothing */
518#endif
519
520#ifndef	GCC_UNUSED
521#define	GCC_UNUSED /* nothing */
522#endif
523
524/*
525 * Function prototypes.  This is the complete XSI Curses list of required
526 * functions.  Those marked `generated' will have sources generated from the
527 * macro definitions later in this file, in order to satisfy XPG4.2
528 * requirements.
529 */
530
531extern NCURSES_EXPORT(int) addch (const chtype);			/* generated */
532extern NCURSES_EXPORT(int) addchnstr (const chtype *, int);		/* generated */
533extern NCURSES_EXPORT(int) addchstr (const chtype *);			/* generated */
534extern NCURSES_EXPORT(int) addnstr (const char *, int);			/* generated */
535extern NCURSES_EXPORT(int) addstr (const char *);			/* generated */
536extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T);			/* generated */
537extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T);			/* generated */
538extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T);			/* generated */
539extern NCURSES_EXPORT(int) attr_get (attr_t *, short *, void *);	/* generated */
540extern NCURSES_EXPORT(int) attr_off (attr_t, void *);			/* generated */
541extern NCURSES_EXPORT(int) attr_on (attr_t, void *);			/* generated */
542extern NCURSES_EXPORT(int) attr_set (attr_t, short, void *);		/* generated */
543extern NCURSES_EXPORT(int) baudrate (void);				/* implemented */
544extern NCURSES_EXPORT(int) beep  (void);				/* implemented */
545extern NCURSES_EXPORT(int) bkgd (chtype);				/* generated */
546extern NCURSES_EXPORT(void) bkgdset (chtype);				/* generated */
547extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* generated */
548extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype);		/* generated */
549extern NCURSES_EXPORT(bool) can_change_color (void);			/* implemented */
550extern NCURSES_EXPORT(int) cbreak (void);				/* implemented */
551extern NCURSES_EXPORT(int) chgat (int, attr_t, short, const void *);	/* generated */
552extern NCURSES_EXPORT(int) clear (void);				/* generated */
553extern NCURSES_EXPORT(int) clearok (WINDOW *,bool);			/* implemented */
554extern NCURSES_EXPORT(int) clrtobot (void);				/* generated */
555extern NCURSES_EXPORT(int) clrtoeol (void);				/* generated */
556extern NCURSES_EXPORT(int) color_content (short,short*,short*,short*);	/* implemented */
557extern NCURSES_EXPORT(int) color_set (short,void*);			/* generated */
558extern NCURSES_EXPORT(int) COLOR_PAIR (int);				/* generated */
559extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int);	/* implemented */
560extern NCURSES_EXPORT(int) curs_set (int);				/* implemented */
561extern NCURSES_EXPORT(int) def_prog_mode (void);			/* implemented */
562extern NCURSES_EXPORT(int) def_shell_mode (void);			/* implemented */
563extern NCURSES_EXPORT(int) delay_output (int);				/* implemented */
564extern NCURSES_EXPORT(int) delch (void);				/* generated */
565extern NCURSES_EXPORT(void) delscreen (SCREEN *);			/* implemented */
566extern NCURSES_EXPORT(int) delwin (WINDOW *);				/* implemented */
567extern NCURSES_EXPORT(int) deleteln (void);				/* generated */
568extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int);	/* implemented */
569extern NCURSES_EXPORT(int) doupdate (void);				/* implemented */
570extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *);			/* implemented */
571extern NCURSES_EXPORT(int) echo (void);					/* implemented */
572extern NCURSES_EXPORT(int) echochar (const chtype);			/* generated */
573extern NCURSES_EXPORT(int) erase (void);				/* generated */
574extern NCURSES_EXPORT(int) endwin (void);				/* implemented */
575extern NCURSES_EXPORT(char) erasechar (void);				/* implemented */
576extern NCURSES_EXPORT(void) filter (void);				/* implemented */
577extern NCURSES_EXPORT(int) flash (void);				/* implemented */
578extern NCURSES_EXPORT(int) flushinp (void);				/* implemented */
579extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *);			/* generated */
580extern NCURSES_EXPORT(int) getch (void);				/* generated */
581extern NCURSES_EXPORT(int) getnstr (char *, int);			/* generated */
582extern NCURSES_EXPORT(int) getstr (char *);				/* generated */
583extern NCURSES_EXPORT(WINDOW *) getwin (FILE *);			/* implemented */
584extern NCURSES_EXPORT(int) halfdelay (int);				/* implemented */
585extern NCURSES_EXPORT(bool) has_colors (void);				/* implemented */
586extern NCURSES_EXPORT(bool) has_ic (void);				/* implemented */
587extern NCURSES_EXPORT(bool) has_il (void);				/* implemented */
588extern NCURSES_EXPORT(int) hline (chtype, int);				/* generated */
589extern NCURSES_EXPORT(void) idcok (WINDOW *, bool);			/* implemented */
590extern NCURSES_EXPORT(int) idlok (WINDOW *, bool);			/* implemented */
591extern NCURSES_EXPORT(void) immedok (WINDOW *, bool);			/* implemented */
592extern NCURSES_EXPORT(chtype) inch (void);				/* generated */
593extern NCURSES_EXPORT(int) inchnstr (chtype *, int);			/* generated */
594extern NCURSES_EXPORT(int) inchstr (chtype *);				/* generated */
595extern NCURSES_EXPORT(WINDOW *) initscr (void);				/* implemented */
596extern NCURSES_EXPORT(int) init_color (short,short,short,short);	/* implemented */
597extern NCURSES_EXPORT(int) init_pair (short,short,short);		/* implemented */
598extern NCURSES_EXPORT(int) innstr (char *, int);			/* generated */
599extern NCURSES_EXPORT(int) insch (chtype);				/* generated */
600extern NCURSES_EXPORT(int) insdelln (int);				/* generated */
601extern NCURSES_EXPORT(int) insertln (void);				/* generated */
602extern NCURSES_EXPORT(int) insnstr (const char *, int);			/* generated */
603extern NCURSES_EXPORT(int) insstr (const char *);			/* generated */
604extern NCURSES_EXPORT(int) instr (char *);				/* generated */
605extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool);			/* implemented */
606extern NCURSES_EXPORT(bool) isendwin (void);				/* implemented */
607extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int);		/* implemented */
608extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *);			/* implemented */
609extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int);		/* implemented */
610extern NCURSES_EXPORT(int) keypad (WINDOW *,bool);			/* implemented */
611extern NCURSES_EXPORT(char) killchar (void);				/* implemented */
612extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool);			/* implemented */
613extern NCURSES_EXPORT(char *) longname (void);				/* implemented */
614extern NCURSES_EXPORT(int) meta (WINDOW *,bool);			/* implemented */
615extern NCURSES_EXPORT(int) move (int, int);				/* generated */
616extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype);		/* generated */
617extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int);	/* generated */
618extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *);	/* generated */
619extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int);	/* generated */
620extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *);		/* generated */
621extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, short, const void *);	/* generated */
622extern NCURSES_EXPORT(int) mvcur (int,int,int,int);			/* implemented */
623extern NCURSES_EXPORT(int) mvdelch (int, int);				/* generated */
624extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int);		/* implemented */
625extern NCURSES_EXPORT(int) mvgetch (int, int);				/* generated */
626extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int);		/* generated */
627extern NCURSES_EXPORT(int) mvgetstr (int, int, char *);			/* generated */
628extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int);		/* generated */
629extern NCURSES_EXPORT(chtype) mvinch (int, int);			/* generated */
630extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int);	/* generated */
631extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *);		/* generated */
632extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int);		/* generated */
633extern NCURSES_EXPORT(int) mvinsch (int, int, chtype);			/* generated */
634extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int);	/* generated */
635extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *);		/* generated */
636extern NCURSES_EXPORT(int) mvinstr (int, int, char *);			/* generated */
637extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...)		/* implemented */
638		GCC_PRINTFLIKE(3,4);
639extern NCURSES_EXPORT(int) mvscanw (int,int, NCURSES_CONST char *,...)	/* implemented */
640		GCC_SCANFLIKE(3,4);
641extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int);		/* generated */
642extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype);	/* generated */
643extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */
644extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *);	/* generated */
645extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int);	/* generated */
646extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *);	/* generated */
647extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, short, const void *);/* generated */
648extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int);		/* generated */
649extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int);		/* generated */
650extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int);	/* generated */
651extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *);	/* generated */
652extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int);	/* generated */
653extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int);			/* implemented */
654extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int);			/* generated */
655extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int);	/* generated */
656extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *);		/* generated */
657extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int);		/* generated */
658extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype);		/* generated */
659extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int);	/* generated */
660extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *);		/* generated */
661extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *);		/* generated */
662extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...)	/* implemented */
663		GCC_PRINTFLIKE(4,5);
664extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, NCURSES_CONST char *,...)	/* implemented */
665		GCC_SCANFLIKE(4,5);
666extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int);	/* generated */
667extern NCURSES_EXPORT(int) napms (int);					/* implemented */
668extern NCURSES_EXPORT(WINDOW *) newpad (int,int);				/* implemented */
669extern NCURSES_EXPORT(SCREEN *) newterm (NCURSES_CONST char *,FILE *,FILE *);	/* implemented */
670extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int);			/* implemented */
671extern NCURSES_EXPORT(int) nl (void);					/* implemented */
672extern NCURSES_EXPORT(int) nocbreak (void);				/* implemented */
673extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool);			/* implemented */
674extern NCURSES_EXPORT(int) noecho (void);				/* implemented */
675extern NCURSES_EXPORT(int) nonl (void);					/* implemented */
676extern NCURSES_EXPORT(void) noqiflush (void);				/* implemented */
677extern NCURSES_EXPORT(int) noraw (void);				/* implemented */
678extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool);			/* implemented */
679extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *);		/* implemented */
680extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *);		/* implemented */
681extern NCURSES_EXPORT(int) pair_content (short,short*,short*);		/* implemented */
682extern NCURSES_EXPORT(int) PAIR_NUMBER (int);				/* generated */
683extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype);		/* implemented */
684extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */
685extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int);	/* implemented */
686extern NCURSES_EXPORT(int) printw (const char *,...)			/* implemented */
687		GCC_PRINTFLIKE(1,2);
688extern NCURSES_EXPORT(int) putp (const char *);				/* implemented */
689extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *);			/* implemented */
690extern NCURSES_EXPORT(void) qiflush (void);				/* implemented */
691extern NCURSES_EXPORT(int) raw (void);					/* implemented */
692extern NCURSES_EXPORT(int) redrawwin (WINDOW *);			/* generated */
693extern NCURSES_EXPORT(int) refresh (void);				/* generated */
694extern NCURSES_EXPORT(int) resetty (void);				/* implemented */
695extern NCURSES_EXPORT(int) reset_prog_mode (void);			/* implemented */
696extern NCURSES_EXPORT(int) reset_shell_mode (void);			/* implemented */
697extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int));	/* implemented */
698extern NCURSES_EXPORT(int) savetty (void);				/* implemented */
699extern NCURSES_EXPORT(int) scanw (NCURSES_CONST char *,...)		/* implemented */
700		GCC_SCANFLIKE(1,2);
701extern NCURSES_EXPORT(int) scr_dump (const char *);			/* implemented */
702extern NCURSES_EXPORT(int) scr_init (const char *);			/* implemented */
703extern NCURSES_EXPORT(int) scrl (int);					/* generated */
704extern NCURSES_EXPORT(int) scroll (WINDOW *);				/* generated */
705extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool);			/* implemented */
706extern NCURSES_EXPORT(int) scr_restore (const char *);			/* implemented */
707extern NCURSES_EXPORT(int) scr_set (const char *);			/* implemented */
708extern NCURSES_EXPORT(int) setscrreg (int,int);				/* generated */
709extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *);			/* implemented */
710extern NCURSES_EXPORT(int) slk_attroff (const chtype);			/* implemented */
711extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *);		/* generated:WIDEC */
712extern NCURSES_EXPORT(int) slk_attron (const chtype);			/* implemented */
713extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*);			/* generated:WIDEC */
714extern NCURSES_EXPORT(int) slk_attrset (const chtype);			/* implemented */
715extern NCURSES_EXPORT(attr_t) slk_attr (void);				/* implemented */
716extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,short,void*);	/* implemented */
717extern NCURSES_EXPORT(int) slk_clear (void);				/* implemented */
718extern NCURSES_EXPORT(int) slk_color (short);				/* implemented */
719extern NCURSES_EXPORT(int) slk_init (int);				/* implemented */
720extern NCURSES_EXPORT(char *) slk_label (int);				/* implemented */
721extern NCURSES_EXPORT(int) slk_noutrefresh (void);			/* implemented */
722extern NCURSES_EXPORT(int) slk_refresh (void);				/* implemented */
723extern NCURSES_EXPORT(int) slk_restore (void);				/* implemented */
724extern NCURSES_EXPORT(int) slk_set (int,const char *,int);		/* implemented */
725extern NCURSES_EXPORT(int) slk_touch (void);				/* implemented */
726extern NCURSES_EXPORT(int) standout (void);				/* generated */
727extern NCURSES_EXPORT(int) standend (void);				/* generated */
728extern NCURSES_EXPORT(int) start_color (void);				/* implemented */
729extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int);	/* implemented */
730extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *,int,int,int,int);	/* implemented */
731extern NCURSES_EXPORT(int) syncok (WINDOW *, bool);			/* implemented */
732extern NCURSES_EXPORT(chtype) termattrs (void);				/* implemented */
733extern NCURSES_EXPORT(char *) termname (void);				/* implemented */
734extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);		/* implemented */
735extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);		/* implemented */
736extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);		/* implemented */
737extern NCURSES_EXPORT(void) timeout (int);				/* generated */
738extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int);		/* generated */
739extern NCURSES_EXPORT(int) touchwin (WINDOW *);				/* generated */
740extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* implemented */
741extern NCURSES_EXPORT(int) typeahead (int);				/* implemented */
742extern NCURSES_EXPORT(int) ungetch (int);				/* implemented */
743extern NCURSES_EXPORT(int) untouchwin (WINDOW *);			/* generated */
744extern NCURSES_EXPORT(void) use_env (bool);				/* implemented */
745extern NCURSES_EXPORT(int) vidattr (chtype);				/* implemented */
746extern NCURSES_EXPORT(int) vidputs (chtype, int (*)(int));		/* implemented */
747extern NCURSES_EXPORT(int) vline (chtype, int);				/* generated */
748extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list);	/* implemented */
749extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list);	/* generated */
750extern NCURSES_EXPORT(int) vwscanw (WINDOW *, NCURSES_CONST char *,va_list);	/* implemented */
751extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, NCURSES_CONST char *,va_list);	/* generated */
752extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype);		/* implemented */
753extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int);	/* implemented */
754extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *);		/* generated */
755extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int);	/* implemented */
756extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *);		/* generated */
757extern NCURSES_EXPORT(int) wattron (WINDOW *, int);			/* generated */
758extern NCURSES_EXPORT(int) wattroff (WINDOW *, int);			/* generated */
759extern NCURSES_EXPORT(int) wattrset (WINDOW *, int);			/* generated */
760extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, short *, void *);	/* generated */
761extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *);		/* implemented */
762extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *);	/* implemented */
763extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, short, void *);	/* generated */
764extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype);			/* implemented */
765extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype);			/* implemented */
766extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);	/* implemented */
767extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, short, const void *);/* implemented */
768extern NCURSES_EXPORT(int) wclear (WINDOW *);				/* implemented */
769extern NCURSES_EXPORT(int) wclrtobot (WINDOW *);			/* implemented */
770extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *);			/* implemented */
771extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,short,void*);		/* implemented */
772extern NCURSES_EXPORT(void) wcursyncup (WINDOW *);			/* implemented */
773extern NCURSES_EXPORT(int) wdelch (WINDOW *);				/* implemented */
774extern NCURSES_EXPORT(int) wdeleteln (WINDOW *);			/* generated */
775extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype);		/* implemented */
776extern NCURSES_EXPORT(int) werase (WINDOW *);				/* implemented */
777extern NCURSES_EXPORT(int) wgetch (WINDOW *);				/* implemented */
778extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int);		/* implemented */
779extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *);			/* generated */
780extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int);		/* implemented */
781extern NCURSES_EXPORT(chtype) winch (WINDOW *);				/* implemented */
782extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int);		/* implemented */
783extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *);		/* generated */
784extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int);		/* implemented */
785extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype);			/* implemented */
786extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int);			/* implemented */
787extern NCURSES_EXPORT(int) winsertln (WINDOW *);			/* generated */
788extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int);	/* implemented */
789extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *);		/* generated */
790extern NCURSES_EXPORT(int) winstr (WINDOW *, char *);			/* generated */
791extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int);			/* implemented */
792extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *);			/* implemented */
793extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...)		/* implemented */
794		GCC_PRINTFLIKE(2,3);
795extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int);		/* implemented */
796extern NCURSES_EXPORT(int) wrefresh (WINDOW *);				/* implemented */
797extern NCURSES_EXPORT(int) wscanw (WINDOW *, NCURSES_CONST char *,...)	/* implemented */
798		GCC_SCANFLIKE(2,3);
799extern NCURSES_EXPORT(int) wscrl (WINDOW *,int);			/* implemented */
800extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int);		/* implemented */
801extern NCURSES_EXPORT(int) wstandout (WINDOW *);			/* generated */
802extern NCURSES_EXPORT(int) wstandend (WINDOW *);			/* generated */
803extern NCURSES_EXPORT(void) wsyncdown (WINDOW *);			/* implemented */
804extern NCURSES_EXPORT(void) wsyncup (WINDOW *);				/* implemented */
805extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int);			/* implemented */
806extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int);		/* implemented */
807extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int);		/* implemented */
808
809/*
810 * vid_attr() was implemented originally based on the draft of XSI curses.
811 */
812#ifndef _XOPEN_SOURCE_EXTENDED
813#define vid_attr(a,pair,opts) vidattr(a)
814#endif
815
816/* attributes */
817
818#define NCURSES_ATTR_SHIFT       8
819#define NCURSES_BITS(mask,shift) ((mask) << ((shift) + NCURSES_ATTR_SHIFT))
820
821#define A_NORMAL	(1UL - 1UL)
822#define A_ATTRIBUTES	NCURSES_BITS(~(1UL - 1UL),0)
823#define A_CHARTEXT	(NCURSES_BITS(1UL,0) - 1UL)
824#define A_COLOR		NCURSES_BITS(((1UL) << 8) - 1UL,0)
825#define A_STANDOUT	NCURSES_BITS(1UL,8)
826#define A_UNDERLINE	NCURSES_BITS(1UL,9)
827#define A_REVERSE	NCURSES_BITS(1UL,10)
828#define A_BLINK		NCURSES_BITS(1UL,11)
829#define A_DIM		NCURSES_BITS(1UL,12)
830#define A_BOLD		NCURSES_BITS(1UL,13)
831#define A_ALTCHARSET	NCURSES_BITS(1UL,14)
832#define A_INVIS		NCURSES_BITS(1UL,15)
833#define A_PROTECT	NCURSES_BITS(1UL,16)
834#define A_HORIZONTAL	NCURSES_BITS(1UL,17)
835#define A_LEFT		NCURSES_BITS(1UL,18)
836#define A_LOW		NCURSES_BITS(1UL,19)
837#define A_RIGHT		NCURSES_BITS(1UL,20)
838#define A_TOP		NCURSES_BITS(1UL,21)
839#define A_VERTICAL	NCURSES_BITS(1UL,22)
840
841/*
842 * These apply to the first 256 color pairs.
843 */
844#define COLOR_PAIR(n)	NCURSES_BITS(n, 0)
845#define PAIR_NUMBER(a)	(NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
846
847/*
848 * pseudo functions
849 */
850#define wgetstr(w, s)		wgetnstr(w, s, -1)
851#define getnstr(s, n)		wgetnstr(stdscr, s, n)
852
853#define setterm(term)		setupterm(term, 1, (int *)0)
854
855#define fixterm()		reset_prog_mode()
856#define resetterm()		reset_shell_mode()
857#define saveterm()		def_prog_mode()
858#define crmode()		cbreak()
859#define nocrmode()		nocbreak()
860#define gettmode()
861
862#define getyx(win,y,x)   	(y = getcury(win), x = getcurx(win))
863#define getbegyx(win,y,x)	(y = getbegy(win), x = getbegx(win))
864#define getmaxyx(win,y,x)	(y = getmaxy(win), x = getmaxx(win))
865#define getparyx(win,y,x)	(y = getpary(win), x = getparx(win))
866
867#define getsyx(y,x) do { if(newscr->_leaveok) (y)=(x)=-1; \
868			 else getyx(newscr,(y),(x)); \
869		    } while(0)
870#define setsyx(y,x) do { if((y)==-1 && (x)==-1) newscr->_leaveok=TRUE; \
871			 else {newscr->_leaveok=FALSE;wmove(newscr,(y),(x));} \
872		    } while(0)
873
874/* It seems older SYSV curses versions define these */
875#define getattrs(win)		((win)?(win)->_attrs:A_NORMAL)
876#define getcurx(win)		((win)?(win)->_curx:ERR)
877#define getcury(win)		((win)?(win)->_cury:ERR)
878#define getbegx(win)		((win)?(win)->_begx:ERR)
879#define getbegy(win)		((win)?(win)->_begy:ERR)
880#define getmaxx(win)		((win)?((win)->_maxx + 1):ERR)
881#define getmaxy(win)		((win)?((win)->_maxy + 1):ERR)
882#define getparx(win)		((win)?(win)->_parx:ERR)
883#define getpary(win)		((win)?(win)->_pary:ERR)
884
885#define wstandout(win)      	(wattrset(win,A_STANDOUT))
886#define wstandend(win)      	(wattrset(win,A_NORMAL))
887
888#define wattron(win,at)		wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
889#define wattroff(win,at)	wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
890
891#if 0
892#define wattrset(win,at)	((win)->_color = PAIR_NUMBER(at), \
893				 (win)->_attrs = (at))
894#else
895#define wattrset(win,at)	((win)->_attrs = (at))
896#endif
897
898#define scroll(win)		wscrl(win,1)
899
900#define touchwin(win)		wtouchln((win), 0, getmaxy(win), 1)
901#define touchline(win, s, c)	wtouchln((win), s, c, 1)
902#define untouchwin(win)		wtouchln((win), 0, getmaxy(win), 0)
903
904#define box(win, v, h)		wborder(win, v, v, h, h, 0, 0, 0, 0)
905#define border(ls, rs, ts, bs, tl, tr, bl, br)	wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
906#define hline(ch, n)		whline(stdscr, ch, n)
907#define vline(ch, n)		wvline(stdscr, ch, n)
908
909#define winstr(w, s)		winnstr(w, s, -1)
910#define winchstr(w, s)		winchnstr(w, s, -1)
911#define winsstr(w, s)		winsnstr(w, s, -1)
912
913#define redrawwin(win)		wredrawln(win, 0, (win)->_maxy+1)
914#define waddstr(win,str)	waddnstr(win,str,-1)
915#define waddchstr(win,str)	waddchnstr(win,str,-1)
916
917/*
918 * pseudo functions for standard screen
919 */
920
921#define addch(ch)		waddch(stdscr,ch)
922#define addchnstr(str,n)	waddchnstr(stdscr,str,n)
923#define addchstr(str)		waddchstr(stdscr,str)
924#define addnstr(str,n)		waddnstr(stdscr,str,n)
925#define addstr(str)		waddnstr(stdscr,str,-1)
926#define attroff(at)		wattroff(stdscr,at)
927#define attron(at)		wattron(stdscr,at)
928#define attrset(at)		wattrset(stdscr,at)
929#define attr_get(ap,cp,o)	wattr_get(stdscr,ap,cp,o)
930#define attr_off(a,o)		wattr_off(stdscr,a,o)
931#define attr_on(a,o)		wattr_on(stdscr,a,o)
932#define attr_set(a,c,o)		wattr_set(stdscr,a,c,o)
933#define bkgd(ch)		wbkgd(stdscr,ch)
934#define bkgdset(ch)		wbkgdset(stdscr,ch)
935#define chgat(n,a,c,o)		wchgat(stdscr,n,a,c,o)
936#define clear()			wclear(stdscr)
937#define clrtobot()		wclrtobot(stdscr)
938#define clrtoeol()		wclrtoeol(stdscr)
939#define color_set(c,o)		wcolor_set(stdscr,c,o)
940#define delch()			wdelch(stdscr)
941#define deleteln()		winsdelln(stdscr,-1)
942#define echochar(c)		wechochar(stdscr,c)
943#define erase()			werase(stdscr)
944#define getch()			wgetch(stdscr)
945#define getstr(str)		wgetstr(stdscr,str)
946#define inch()			winch(stdscr)
947#define inchnstr(s,n)		winchnstr(stdscr,s,n)
948#define inchstr(s)		winchstr(stdscr,s)
949#define innstr(s,n)		winnstr(stdscr,s,n)
950#define insch(c)		winsch(stdscr,c)
951#define insdelln(n)		winsdelln(stdscr,n)
952#define insertln()		winsdelln(stdscr,1)
953#define insnstr(s,n)		winsnstr(stdscr,s,n)
954#define insstr(s)		winsstr(stdscr,s)
955#define instr(s)		winstr(stdscr,s)
956#define move(y,x)		wmove(stdscr,y,x)
957#define refresh()		wrefresh(stdscr)
958#define scrl(n)			wscrl(stdscr,n)
959#define setscrreg(t,b)		wsetscrreg(stdscr,t,b)
960#define standend()		wstandend(stdscr)
961#define standout()		wstandout(stdscr)
962#define timeout(delay)		wtimeout(stdscr,delay)
963#define wdeleteln(win)		winsdelln(win,-1)
964#define winsertln(win)		winsdelln(win,1)
965
966/*
967 * mv functions
968 */
969
970#define mvwaddch(win,y,x,ch)		(wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
971#define mvwaddchnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,n))
972#define mvwaddchstr(win,y,x,str)	(wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
973#define mvwaddnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,n))
974#define mvwaddstr(win,y,x,str)		(wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
975#define mvwdelch(win,y,x)		(wmove(win,y,x) == ERR ? ERR : wdelch(win))
976#define mvwchgat(win,y,x,n,a,c,o)	(wmove(win,y,x) == ERR ? ERR : wchgat(win,n,a,c,o))
977#define mvwgetch(win,y,x)		(wmove(win,y,x) == ERR ? ERR : wgetch(win))
978#define mvwgetnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : wgetnstr(win,str,n))
979#define mvwgetstr(win,y,x,str)		(wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
980#define mvwhline(win,y,x,c,n)		(wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
981#define mvwinch(win,y,x)		(wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
982#define mvwinchnstr(win,y,x,s,n)	(wmove(win,y,x) == ERR ? ERR : winchnstr(win,s,n))
983#define mvwinchstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winchstr(win,s))
984#define mvwinnstr(win,y,x,s,n)		(wmove(win,y,x) == ERR ? ERR : winnstr(win,s,n))
985#define mvwinsch(win,y,x,c)		(wmove(win,y,x) == ERR ? ERR : winsch(win,c))
986#define mvwinsnstr(win,y,x,s,n)		(wmove(win,y,x) == ERR ? ERR : winsnstr(win,s,n))
987#define mvwinsstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winsstr(win,s))
988#define mvwinstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winstr(win,s))
989#define mvwvline(win,y,x,c,n)		(wmove(win,y,x) == ERR ? ERR : wvline(win,c,n))
990
991#define mvaddch(y,x,ch)			mvwaddch(stdscr,y,x,ch)
992#define mvaddchnstr(y,x,str,n)		mvwaddchnstr(stdscr,y,x,str,n)
993#define mvaddchstr(y,x,str)		mvwaddchstr(stdscr,y,x,str)
994#define mvaddnstr(y,x,str,n)		mvwaddnstr(stdscr,y,x,str,n)
995#define mvaddstr(y,x,str)		mvwaddstr(stdscr,y,x,str)
996#define mvchgat(y,x,n,a,c,o)		mvwchgat(stdscr,y,x,n,a,c,o)
997#define mvdelch(y,x)			mvwdelch(stdscr,y,x)
998#define mvgetch(y,x)			mvwgetch(stdscr,y,x)
999#define mvgetnstr(y,x,str,n)		mvwgetnstr(stdscr,y,x,str,n)
1000#define mvgetstr(y,x,str)		mvwgetstr(stdscr,y,x,str)
1001#define mvhline(y,x,c,n)		mvwhline(stdscr,y,x,c,n)
1002#define mvinch(y,x)			mvwinch(stdscr,y,x)
1003#define mvinchnstr(y,x,s,n)		mvwinchnstr(stdscr,y,x,s,n)
1004#define mvinchstr(y,x,s)		mvwinchstr(stdscr,y,x,s)
1005#define mvinnstr(y,x,s,n)		mvwinnstr(stdscr,y,x,s,n)
1006#define mvinsch(y,x,c)			mvwinsch(stdscr,y,x,c)
1007#define mvinsnstr(y,x,s,n)		mvwinsnstr(stdscr,y,x,s,n)
1008#define mvinsstr(y,x,s)			mvwinsstr(stdscr,y,x,s)
1009#define mvinstr(y,x,s)			mvwinstr(stdscr,y,x,s)
1010#define mvvline(y,x,c,n)		mvwvline(stdscr,y,x,c,n)
1011
1012/*
1013 * Some wide-character functions can be implemented without the extensions.
1014 */
1015#define getbkgd(win)                    ((win)->_bkgd)
1016
1017#define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
1018#define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
1019
1020#if 0
1021#define wattr_set(win,a,p,opts)		((win)->_attrs = ((a) & ~A_COLOR), \
1022					 (win)->_color = (p), \
1023					 OK)
1024#define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
1025					 (void)((p) != 0 && (*(p) = (win)->_color)), \
1026					 OK)
1027#else
1028#define wattr_set(win,a,p,opts)		((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
1029#define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
1030					 (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
1031					 OK)
1032#endif
1033
1034/*
1035 * XSI curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
1036 * varargs.h.  It adds new calls vw_printw/vw_scanw, which are supposed to
1037 * use POSIX stdarg.h.  The ncurses versions of vwprintw/vwscanw already
1038 * use stdarg.h, so...
1039 */
1040#define vw_printw		vwprintw
1041#define vw_scanw		vwscanw
1042
1043/*
1044 * Export fallback function for use in C++ binding.
1045 */
1046#if !1
1047#define vsscanf(a,b,c) _nc_vsscanf(a,b,c)
1048NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list);
1049#endif
1050
1051/*
1052 * Pseudo-character tokens outside ASCII range.  The curses wgetch() function
1053 * will return any given one of these only if the corresponding k- capability
1054 * is defined in your terminal's terminfo entry.
1055 *
1056 * Some keys (KEY_A1, etc) are arranged like this:
1057 *	a1     up    a3
1058 *	left   b2    right
1059 *	c1     down  c3
1060 *
1061 * A few key codes do not depend upon the terminfo entry.
1062 */
1063#define KEY_CODE_YES	0400		/* A wchar_t contains a key code */
1064#define KEY_MIN		0401		/* Minimum curses key */
1065#define KEY_BREAK	0401		/* Break key (unreliable) */
1066#define KEY_SRESET	0530		/* Soft (partial) reset (unreliable) */
1067#define KEY_RESET	0531		/* Reset or hard reset (unreliable) */
1068/*
1069 * These definitions were generated by ./MKkey_defs.sh ./Caps
1070 */
1071#define KEY_DOWN	0402		/* down-arrow key */
1072#define KEY_UP		0403		/* up-arrow key */
1073#define KEY_LEFT	0404		/* left-arrow key */
1074#define KEY_RIGHT	0405		/* right-arrow key */
1075#define KEY_HOME	0406		/* home key */
1076#define KEY_BACKSPACE	0407		/* backspace key */
1077#define KEY_F0		0410		/* Function keys.  Space for 64 */
1078#define KEY_F(n)	(KEY_F0+(n))	/* Value of function key n */
1079#define KEY_DL		0510		/* delete-line key */
1080#define KEY_IL		0511		/* insert-line key */
1081#define KEY_DC		0512		/* delete-character key */
1082#define KEY_IC		0513		/* insert-character key */
1083#define KEY_EIC		0514		/* sent by rmir or smir in insert mode */
1084#define KEY_CLEAR	0515		/* clear-screen or erase key */
1085#define KEY_EOS		0516		/* clear-to-end-of-screen key */
1086#define KEY_EOL		0517		/* clear-to-end-of-line key */
1087#define KEY_SF		0520		/* scroll-forward key */
1088#define KEY_SR		0521		/* scroll-backward key */
1089#define KEY_NPAGE	0522		/* next-page key */
1090#define KEY_PPAGE	0523		/* previous-page key */
1091#define KEY_STAB	0524		/* set-tab key */
1092#define KEY_CTAB	0525		/* clear-tab key */
1093#define KEY_CATAB	0526		/* clear-all-tabs key */
1094#define KEY_ENTER	0527		/* enter/send key */
1095#define KEY_PRINT	0532		/* print key */
1096#define KEY_LL		0533		/* lower-left key (home down) */
1097#define KEY_A1		0534		/* upper left of keypad */
1098#define KEY_A3		0535		/* upper right of keypad */
1099#define KEY_B2		0536		/* center of keypad */
1100#define KEY_C1		0537		/* lower left of keypad */
1101#define KEY_C3		0540		/* lower right of keypad */
1102#define KEY_BTAB	0541		/* back-tab key */
1103#define KEY_BEG		0542		/* begin key */
1104#define KEY_CANCEL	0543		/* cancel key */
1105#define KEY_CLOSE	0544		/* close key */
1106#define KEY_COMMAND	0545		/* command key */
1107#define KEY_COPY	0546		/* copy key */
1108#define KEY_CREATE	0547		/* create key */
1109#define KEY_END		0550		/* end key */
1110#define KEY_EXIT	0551		/* exit key */
1111#define KEY_FIND	0552		/* find key */
1112#define KEY_HELP	0553		/* help key */
1113#define KEY_MARK	0554		/* mark key */
1114#define KEY_MESSAGE	0555		/* message key */
1115#define KEY_MOVE	0556		/* move key */
1116#define KEY_NEXT	0557		/* next key */
1117#define KEY_OPEN	0560		/* open key */
1118#define KEY_OPTIONS	0561		/* options key */
1119#define KEY_PREVIOUS	0562		/* previous key */
1120#define KEY_REDO	0563		/* redo key */
1121#define KEY_REFERENCE	0564		/* reference key */
1122#define KEY_REFRESH	0565		/* refresh key */
1123#define KEY_REPLACE	0566		/* replace key */
1124#define KEY_RESTART	0567		/* restart key */
1125#define KEY_RESUME	0570		/* resume key */
1126#define KEY_SAVE	0571		/* save key */
1127#define KEY_SBEG	0572		/* shifted begin key */
1128#define KEY_SCANCEL	0573		/* shifted cancel key */
1129#define KEY_SCOMMAND	0574		/* shifted command key */
1130#define KEY_SCOPY	0575		/* shifted copy key */
1131#define KEY_SCREATE	0576		/* shifted create key */
1132#define KEY_SDC		0577		/* shifted delete-character key */
1133#define KEY_SDL		0600		/* shifted delete-line key */
1134#define KEY_SELECT	0601		/* select key */
1135#define KEY_SEND	0602		/* shifted end key */
1136#define KEY_SEOL	0603		/* shifted clear-to-end-of-line key */
1137#define KEY_SEXIT	0604		/* shifted exit key */
1138#define KEY_SFIND	0605		/* shifted find key */
1139#define KEY_SHELP	0606		/* shifted help key */
1140#define KEY_SHOME	0607		/* shifted home key */
1141#define KEY_SIC		0610		/* shifted insert-character key */
1142#define KEY_SLEFT	0611		/* shifted left-arrow key */
1143#define KEY_SMESSAGE	0612		/* shifted message key */
1144#define KEY_SMOVE	0613		/* shifted move key */
1145#define KEY_SNEXT	0614		/* shifted next key */
1146#define KEY_SOPTIONS	0615		/* shifted options key */
1147#define KEY_SPREVIOUS	0616		/* shifted previous key */
1148#define KEY_SPRINT	0617		/* shifted print key */
1149#define KEY_SREDO	0620		/* shifted redo key */
1150#define KEY_SREPLACE	0621		/* shifted replace key */
1151#define KEY_SRIGHT	0622		/* shifted right-arrow key */
1152#define KEY_SRSUME	0623		/* shifted resume key */
1153#define KEY_SSAVE	0624		/* shifted save key */
1154#define KEY_SSUSPEND	0625		/* shifted suspend key */
1155#define KEY_SUNDO	0626		/* shifted undo key */
1156#define KEY_SUSPEND	0627		/* suspend key */
1157#define KEY_UNDO	0630		/* undo key */
1158#define KEY_MOUSE	0631		/* Mouse event has occurred */
1159#define KEY_RESIZE	0632		/* Terminal resize event */
1160#define KEY_EVENT	0633		/* We were interrupted by an event */
1161
1162#define KEY_MAX		0777		/* Maximum key value is 0633 */
1163/* $Id: curses.tail,v 1.12 2005/03/27 00:09:51 tom Exp $ */
1164
1165/* mouse interface */
1166
1167#if NCURSES_MOUSE_VERSION > 1
1168#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
1169#else
1170#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
1171#endif
1172
1173#define	NCURSES_BUTTON_RELEASED	001L
1174#define	NCURSES_BUTTON_PRESSED	002L
1175#define	NCURSES_BUTTON_CLICKED	004L
1176#define	NCURSES_DOUBLE_CLICKED	010L
1177#define	NCURSES_TRIPLE_CLICKED	020L
1178#define	NCURSES_RESERVED_EVENT	040L
1179
1180/* event masks */
1181#define	BUTTON1_RELEASED	NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
1182#define	BUTTON1_PRESSED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
1183#define	BUTTON1_CLICKED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
1184#define	BUTTON1_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
1185#define	BUTTON1_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
1186
1187#define	BUTTON2_RELEASED	NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
1188#define	BUTTON2_PRESSED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
1189#define	BUTTON2_CLICKED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
1190#define	BUTTON2_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
1191#define	BUTTON2_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
1192
1193#define	BUTTON3_RELEASED	NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
1194#define	BUTTON3_PRESSED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
1195#define	BUTTON3_CLICKED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
1196#define	BUTTON3_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
1197#define	BUTTON3_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
1198
1199#define	BUTTON4_RELEASED	NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
1200#define	BUTTON4_PRESSED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
1201#define	BUTTON4_CLICKED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
1202#define	BUTTON4_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
1203#define	BUTTON4_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
1204
1205/*
1206 * In 32 bits the version-1 scheme does not provide enough space for a 5th
1207 * button, unless we choose to change the ABI by omitting the reserved-events.
1208 */
1209#if NCURSES_MOUSE_VERSION > 1
1210
1211#define	BUTTON5_RELEASED	NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
1212#define	BUTTON5_PRESSED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
1213#define	BUTTON5_CLICKED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
1214#define	BUTTON5_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
1215#define	BUTTON5_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
1216
1217#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(6, 0001L)
1218#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(6, 0002L)
1219#define	BUTTON_ALT		NCURSES_MOUSE_MASK(6, 0004L)
1220#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(6, 0010L)
1221
1222#else
1223
1224#define	BUTTON1_RESERVED_EVENT	NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
1225#define	BUTTON2_RESERVED_EVENT	NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
1226#define	BUTTON3_RESERVED_EVENT	NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
1227#define	BUTTON4_RESERVED_EVENT	NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
1228
1229#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(5, 0001L)
1230#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(5, 0002L)
1231#define	BUTTON_ALT		NCURSES_MOUSE_MASK(5, 0004L)
1232#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(5, 0010L)
1233
1234#endif
1235
1236#define	ALL_MOUSE_EVENTS	(REPORT_MOUSE_POSITION - 1)
1237
1238/* macros to extract single event-bits from masks */
1239#define	BUTTON_RELEASE(e, x)		((e) & (001 << (6 * ((x) - 1))))
1240#define	BUTTON_PRESS(e, x)		((e) & (002 << (6 * ((x) - 1))))
1241#define	BUTTON_CLICK(e, x)		((e) & (004 << (6 * ((x) - 1))))
1242#define	BUTTON_DOUBLE_CLICK(e, x)	((e) & (010 << (6 * ((x) - 1))))
1243#define	BUTTON_TRIPLE_CLICK(e, x)	((e) & (020 << (6 * ((x) - 1))))
1244#define	BUTTON_RESERVED_EVENT(e, x)	((e) & (040 << (6 * ((x) - 1))))
1245
1246typedef struct
1247{
1248    short id;		/* ID to distinguish multiple devices */
1249    int x, y, z;	/* event coordinates (character-cell) */
1250    mmask_t bstate;	/* button state bits */
1251}
1252MEVENT;
1253
1254extern NCURSES_EXPORT(int) getmouse (MEVENT *);
1255extern NCURSES_EXPORT(int) ungetmouse (MEVENT *);
1256extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
1257extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
1258extern NCURSES_EXPORT(int) mouseinterval (int);
1259extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
1260extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool);              /* generated */
1261
1262#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
1263
1264/* other non-XSI functions */
1265
1266extern NCURSES_EXPORT(int) mcprint (char *, int);	/* direct data to printer */
1267extern NCURSES_EXPORT(int) has_key (int);		/* do we have given key? */
1268
1269/* Debugging : use with libncurses_g.a */
1270
1271extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
1272extern NCURSES_EXPORT(void) _tracedump (const char *, WINDOW *);
1273extern NCURSES_EXPORT(char *) _traceattr (attr_t);
1274extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype);
1275extern NCURSES_EXPORT(char *) _nc_tracebits (void);
1276extern NCURSES_EXPORT(char *) _tracechar (int);
1277extern NCURSES_EXPORT(char *) _tracechtype (chtype);
1278extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype);
1279#ifdef _XOPEN_SOURCE_EXTENDED
1280#define _tracech_t		_tracecchar_t
1281extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *);
1282#define _tracech_t2		_tracecchar_t2
1283extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *);
1284#else
1285#define _tracech_t		_tracechtype
1286#define _tracech_t2		_tracechtype2
1287#endif
1288extern NCURSES_EXPORT(char *) _tracemouse (const MEVENT *);
1289extern NCURSES_EXPORT(void) trace (const unsigned int);
1290
1291/* trace masks */
1292#define TRACE_DISABLE	0x0000	/* turn off tracing */
1293#define TRACE_TIMES	0x0001	/* trace user and system times of updates */
1294#define TRACE_TPUTS	0x0002	/* trace tputs calls */
1295#define TRACE_UPDATE	0x0004	/* trace update actions, old & new screens */
1296#define TRACE_MOVE	0x0008	/* trace cursor moves and scrolls */
1297#define TRACE_CHARPUT	0x0010	/* trace all character outputs */
1298#define TRACE_ORDINARY	0x001F	/* trace all update actions */
1299#define TRACE_CALLS	0x0020	/* trace all curses calls */
1300#define TRACE_VIRTPUT	0x0040	/* trace virtual character puts */
1301#define TRACE_IEVENT	0x0080	/* trace low-level input processing */
1302#define TRACE_BITS	0x0100	/* trace state of TTY control bits */
1303#define TRACE_ICALLS	0x0200	/* trace internal/nested calls */
1304#define TRACE_CCALLS	0x0400	/* trace per-character calls */
1305#define TRACE_DATABASE	0x0800	/* trace read/write of terminfo/termcap data */
1306#define TRACE_ATTRS	0x1000	/* trace attribute updates */
1307
1308#define TRACE_SHIFT	13	/* number of bits in the trace masks */
1309#define TRACE_MAXIMUM	((1 << TRACE_SHIFT) - 1) /* maximum trace level */
1310
1311#if defined(TRACE) || defined(NCURSES_TEST)
1312extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable;		/* enable optimizations */
1313#ifdef _XOPEN_SOURCE_EXTENDED
1314extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *);
1315extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *);
1316#endif
1317extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
1318#define OPTIMIZE_MVCUR		0x01	/* cursor movement optimization */
1319#define OPTIMIZE_HASHMAP	0x02	/* diff hashing to detect scrolls */
1320#define OPTIMIZE_SCROLL		0x04	/* scroll optimization */
1321#define OPTIMIZE_ALL		0xff	/* enable all optimizations (dflt) */
1322#endif
1323
1324#ifdef __cplusplus
1325
1326/* these names conflict with STL */
1327#undef box
1328#undef clear
1329#undef erase
1330#undef move
1331#undef refresh
1332
1333}
1334#endif
1335
1336#endif /* __NCURSES_H */
1337