-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
-
-/* $Id: curses.h.in,v 1.44 1997/04/20 01:32:08 tom Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/* $Id: curses.h.in,v 1.60 1998/02/11 12:13:46 tom Exp $ */
#ifndef __NCURSES_H
#define __NCURSES_H
+
#define CURSES 1
#define CURSES_H 1
+/* This should be defined for the enhanced functionality to be visible.
+ * However, none of the wide-character (enhanced) functionality is implemented.
+ * So we do not define it (yet).
+#define _XOPEN_CURSES 1
+ */
+
/* These are defined only in curses.h, and are used for conditional compiles */
#define NCURSES_VERSION_MAJOR @NCURSES_MAJOR@
#define NCURSES_VERSION_MINOR @NCURSES_MINOR@
#define NCURSES_CONST /* nothing */
#endif
-#ifndef _UNCTRL_H
-typedef unsigned long chtype;
-#endif
+typedef unsigned @cf_cv_typeof_chtype@ chtype;
#include <stdio.h>
#include <unctrl.h>
#undef TRUE
#undef FALSE
-#define CXX_BUILTIN_BOOL @nc_cv_builtin_bool@
-#define CXX_TYPE_OF_BOOL @nc_cv_type_of_bool@
+#define CXX_BUILTIN_BOOL @cf_cv_builtin_bool@
+#define CXX_TYPE_OF_BOOL @cf_cv_type_of_bool@
#if defined(__cplusplus) && CXX_BUILTIN_BOOL
#define TRUE ((CXX_TYPE_OF_BOOL)true)
/*
* XSI attributes. In the ncurses implementation, they are identical to the
- * A_ attributes because attr_t is just an int. The XSI Curses attr_* and
- * wattr_* entry points are all mapped to attr* and wattr* entry points.
+ * A_ attributes.
*/
-#define WA_ATTRIBUTES 0xffffff00
-#define WA_NORMAL 0x00000000
-#define WA_STANDOUT 0x00010000
-#define WA_UNDERLINE 0x00020000
-#define WA_REVERSE 0x00040000
-#define WA_BLINK 0x00080000
-#define WA_DIM 0x00100000
-#define WA_BOLD 0x00200000
-#define WA_ALTCHARSET 0x00400000
-#define WA_INVIS 0x00800000
-#define WA_PROTECT 0x01000000
-#define WA_HORIZONTAL 0x02000000 /* XSI Curses attr -- not yet used */
-#define WA_LEFT 0x04000000 /* XSI Curses attr -- not yet used */
-#define WA_LOW 0x08000000 /* XSI Curses attr -- not yet used */
-#define WA_RIGHT 0x10000000 /* XSI Curses attr -- not yet used */
-#define WA_TOP 0x20000000 /* XSI Curses attr -- not yet used */
-#define WA_VERTICAL 0x40000000 /* XSI Curses attr -- not yet used */
+#define WA_ATTRIBUTES A_ATTRIBUTES
+#define WA_NORMAL A_NORMAL
+#define WA_STANDOUT A_STANDOUT
+#define WA_UNDERLINE A_UNDERLINE
+#define WA_REVERSE A_REVERSE
+#define WA_BLINK A_BLINK
+#define WA_DIM A_DIM
+#define WA_BOLD A_BOLD
+#define WA_ALTCHARSET A_ALTCHARSET
+#define WA_INVIS A_INVIS
+#define WA_PROTECT A_PROTECT
+#define WA_HORIZONTAL A_HORIZONTAL
+#define WA_LEFT A_LEFT
+#define WA_LOW A_LOW
+#define WA_RIGHT A_RIGHT
+#define WA_TOP A_TOP
+#define WA_VERTICAL A_VERTICAL
/* colors */
extern int COLORS;
#define ACS_DARROW (acs_map['.']) /* arrow pointing down */
#define ACS_UARROW (acs_map['-']) /* arrow pointing up */
#define ACS_BOARD (acs_map['h']) /* board of squares */
-#define ACS_LANTERN (acs_map['I']) /* lantern symbol */
+#define ACS_LANTERN (acs_map['i']) /* lantern symbol */
#define ACS_BLOCK (acs_map['0']) /* solid square block */
/*
* These aren't documented, but a lot of System Vs have them anyway
cchar_t;
#endif /* _XOPEN_SOURCE_EXTENDED */
-struct _win_st {
+struct ldat
+{
+ chtype *text; /* text of the line */
+ short firstchar; /* first changed character in the line */
+ short lastchar; /* last changed character in the line */
+ short oldindex; /* index of the line at last update */
+};
+
+struct _win_st
+{
short _cury, _curx; /* current cursor position */
/* window location and size */
bool _use_keypad; /* process function keys into KEY_ symbols? */
int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */
- /* the actual line data */
- struct ldat
- {
- chtype *text; /* text of the line */
- short firstchar; /* first changed character in the line */
- short lastchar; /* last changed character in the line */
- short oldindex; /* index of the line at last update */
- }
- *_line;
+ struct ldat *_line; /* the actual line data */
/* global screen state */
short _regtop; /* top line of scrolling region */
short _yoffset; /* real begy is _begy + _yoffset */
};
-extern WINDOW *stdscr, *curscr, *newscr;
+extern WINDOW *stdscr;
+extern WINDOW *curscr;
+extern WINDOW *newscr;
-extern int LINES, COLS, TABSIZE;
+extern int LINES;
+extern int COLS;
+extern int TABSIZE;
/*
* This global was an undocumented feature under AIX curses.
extern int ESCDELAY; /* ESC expire time in milliseconds */
/* non-XSI extensions (dickey@clark.net) */
+extern int define_key (char *, int);
+extern int keyok (int, bool);
extern int resizeterm (int, int);
-extern int wresize (WINDOW *, int, int);
extern int use_default_colors (void);
+extern int wresize (WINDOW *, int, int);
extern char ttytype[]; /* needed for backward compatibility */
* GCC (and some other compilers) define '__attribute__'; we're using this
* macro to alert the compiler to flag inconsistencies in printf/scanf-like
* function calls. Just in case '__attribute__' isn't defined, make a dummy.
+ * G++ doesn't accept it anyway.
*/
-#if !defined(__GNUC__) && !defined(__attribute__)
+#if defined(__cplusplus) || (!defined(__GNUC__) && !defined(__attribute__))
#define __attribute__(p) /* nothing */
#endif
extern int clrtobot(void); /* generated */
extern int clrtoeol(void); /* generated */
extern int color_content(short,short*,short*,short*); /* implemented */
+extern int color_set(short,void*); /* missing */
extern int COLOR_PAIR(int); /* generated */
extern int copywin(const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */
extern int curs_set(int); /* implemented */
extern int echochar(const chtype); /* generated */
#ifdef _XOPEN_SOURCE_EXTENDED
extern int echo_wchar(const cchar_t *); /* missing */
+extern int erasewchar(wchar_t*); /* missing */
#endif /* _XOPEN_SOURCE_EXTENDED */
extern int endwin(void); /* implemented */
extern char erasechar(void); /* implemented */
#ifdef _XOPEN_SOURCE_EXTENDED
extern int get_wch(wint_t *); /* missing */
#endif /* _XOPEN_SOURCE_EXTENDED */
-extern WINDOW *getwin(FILE *); /* not in XPG4 */
+extern WINDOW *getwin(FILE *); /* implemented */
#ifdef _XOPEN_SOURCE_EXTENDED
extern int get_wstr(wint_t *); /* missing */
#endif /* _XOPEN_SOURCE_EXTENDED */
extern int overwrite(const WINDOW*,WINDOW *); /* implemented */
extern int pair_content(short,short*,short*); /* implemented */
extern int PAIR_NUMBER(int); /* generated */
-extern int pechochar(WINDOW *, chtype); /* implemented */
+extern int pechochar(WINDOW *, const chtype); /* implemented */
#ifdef _XOPEN_SOURCE_EXTENDED
extern int pecho_wchar(WINDOW *, const cchar_t *); /* missing */
#endif /* _XOPEN_SOURCE_EXTENDED */
extern int setscrreg(int,int); /* generated */
extern SCREEN *set_term(SCREEN *); /* implemented */
extern int slk_attroff(const attr_t); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern int slk_attr_off(attr_t); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int slk_attr_off(attr_t); /* generated:WIDEC */
extern int slk_attron(const attr_t); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern int slk_attr_on(attr_t); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int slk_attr_on(attr_t); /* generated:WIDEC */
extern int slk_attrset(const attr_t); /* implemented */
extern attr_t slk_attr(void); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern int slk_attr_set(attr_t); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int slk_attr_set(attr_t); /* generated:WIDEC */
extern int slk_clear(void); /* implemented */
extern int slk_init(int); /* implemented */
extern char *slk_label(int); /* implemented */
extern WINDOW *subpad(WINDOW *, int, int, int, int); /* implemented */
extern WINDOW *subwin(WINDOW *,int,int,int,int); /* implemented */
extern int syncok(WINDOW *, bool); /* implemented */
-extern attr_t termattrs(void); /* implemented */
+extern chtype termattrs(void); /* implemented */
+extern attr_t term_attrs(void); /* missing */
extern char *termname(void); /* implemented */
extern int tigetflag(const char *); /* implemented */
extern int tigetnum(const char *); /* implemented */
extern int untouchwin(WINDOW *); /* generated */
extern void use_env(bool); /* implemented */
extern int vidattr(chtype); /* implemented */
-#ifdef _XOPEN_SOURCE_EXTENDED
-extern int vid_attr(attr_t); /* missing */
-#endif /* _XOPEN_SOURCE_EXTENDED */
+extern int vid_attr(attr_t); /* generated:WIDEC */
extern int vidputs(chtype, int (*)(int)); /* implemented */
#ifdef _XOPEN_SOURCE_EXTENDED
extern int vid_puts(attr_t, int (*)(int)); /* missing */
extern int wattr_off(WINDOW *, const attr_t); /* implemented */
extern int wattr_set(WINDOW *, attr_t); /* generated */
extern int wbkgd(WINDOW *,const chtype); /* implemented */
-extern void wbkgdset(WINDOW *,chtype); /* generated */
+extern void wbkgdset(WINDOW *,chtype); /* implemented */
#ifdef _XOPEN_SOURCE_EXTENDED
extern int wbkgrndset(WINDOW *,const cchar_t *); /* missing */
extern int wbkgrnd(WINDOW *,const cchar_t *); /* missing */
extern int wclear(WINDOW *); /* implemented */
extern int wclrtobot(WINDOW *); /* implemented */
extern int wclrtoeol(WINDOW *); /* implemented */
+extern int wcolor_set(WINDOW*,short,void*); /* missing */
extern void wcursyncup(WINDOW *); /* implemented */
extern int wdelch(WINDOW *); /* implemented */
extern int wdeleteln(WINDOW *); /* generated */
#endif /* _XOPEN_SOURCE_EXTENDED */
/* attributes */
-#define A_ATTRIBUTES 0xffffff00
-#define A_NORMAL 0x00000000
-#define A_STANDOUT 0x00010000
-#define A_UNDERLINE 0x00020000
-#define A_REVERSE 0x00040000
-#define A_BLINK 0x00080000
-#define A_DIM 0x00100000
-#define A_BOLD 0x00200000
-#define A_ALTCHARSET 0x00400000
-#define A_INVIS 0x00800000
-#define A_PROTECT 0x01000000
-#define A_HORIZONTAL 0x02000000 /* XSI Curses attr -- not yet used */
-#define A_LEFT 0x04000000 /* XSI Curses attr -- not yet used */
-#define A_LOW 0x08000000 /* XSI Curses attr -- not yet used */
-#define A_RIGHT 0x10000000 /* XSI Curses attr -- not yet used */
-#define A_TOP 0x20000000 /* XSI Curses attr -- not yet used */
-#define A_VERTICAL 0x40000000 /* XSI Curses attr -- not yet used */
-#define A_CHARTEXT 0x000000ff
-#define A_COLOR 0x0000ff00
-#define COLOR_PAIR(n) ((n) << 8)
-#define PAIR_NUMBER(a) (((a) & A_COLOR) >> 8)
+
+#define NCURSES_BITS(mask,shift) ((mask) << ((shift) + @cf_cv_widec_shift@))
+
+#define A_NORMAL 0L
+#define A_ATTRIBUTES NCURSES_BITS(~(@cf_cv_1UL@ - @cf_cv_1UL@),0)
+#define A_CHARTEXT (NCURSES_BITS(@cf_cv_1UL@,0) - @cf_cv_1UL@)
+#define A_COLOR NCURSES_BITS(((@cf_cv_1UL@) << 8) - @cf_cv_1UL@,0)
+#define A_STANDOUT NCURSES_BITS(@cf_cv_1UL@,8)
+#define A_UNDERLINE NCURSES_BITS(@cf_cv_1UL@,9)
+#define A_REVERSE NCURSES_BITS(@cf_cv_1UL@,10)
+#define A_BLINK NCURSES_BITS(@cf_cv_1UL@,11)
+#define A_DIM NCURSES_BITS(@cf_cv_1UL@,12)
+#define A_BOLD NCURSES_BITS(@cf_cv_1UL@,13)
+#define A_ALTCHARSET NCURSES_BITS(@cf_cv_1UL@,14)
+#define A_INVIS NCURSES_BITS(@cf_cv_1UL@,15)
+
+/* Tradeoff on 32-bit machines ('protect' vs widec). The others (e.g., left
+ * highlight are not implemented in any terminal descriptions, anyway.
+ */
+#if ((16 + @cf_cv_widec_shift@) < @cf_cv_shift_limit@)
+#define A_PROTECT NCURSES_BITS(@cf_cv_1UL@,16)
+#define A_HORIZONTAL NCURSES_BITS(@cf_cv_1UL@,17)
+#define A_LEFT NCURSES_BITS(@cf_cv_1UL@,18)
+#define A_LOW NCURSES_BITS(@cf_cv_1UL@,19)
+#define A_RIGHT NCURSES_BITS(@cf_cv_1UL@,20)
+#define A_TOP NCURSES_BITS(@cf_cv_1UL@,21)
+#define A_VERTICAL NCURSES_BITS(@cf_cv_1UL@,22)
+#else
+#define A_PROTECT 0L
+#define A_HORIZONTAL 0L
+#define A_LEFT 0L
+#define A_LOW 0L
+#define A_RIGHT 0L
+#define A_TOP 0L
+#define A_VERTICAL 0L
+#endif
+
+#define COLOR_PAIR(n) NCURSES_BITS(n, 0)
+#define PAIR_NUMBER(a) (((a) & A_COLOR) >> @cf_cv_widec_shift@)
/*
* pseudo functions
#define nocrmode() nocbreak()
#define gettmode()
-#define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
-#define getbegyx(win,y,x) (y = (win)->_begy, x = (win)->_begx)
-#define getmaxyx(win,y,x) (y = (win)->_maxy + 1, x = (win)->_maxx + 1)
-#define getparyx(win,y,x) (y = (win)->_pary, x = (win)->_parx)
+#define getyx(win,y,x) (y = (win)?(win)->_cury:ERR, x = (win)?(win)->_curx:ERR)
+#define getbegyx(win,y,x) (y = (win)?(win)->_begy:ERR, x = (win)?(win)->_begx:ERR)
+#define getmaxyx(win,y,x) (y = (win)?((win)->_maxy + 1):ERR, x = (win)?((win)->_maxx + 1):ERR)
+#define getparyx(win,y,x) (y = (win)?(win)->_pary:ERR, x = (win)?(win)->_parx:ERR)
#define getsyx(y,x) getyx(stdscr, y, x)
#define setsyx(y,x) (stdscr->_cury = y, stdscr->_curx = x)
-#define wbkgdset(win, ch) \
- (((win)->_attrs = (((win)->_attrs & ~((win)->_bkgd & A_ATTRIBUTES)) | \
- ((ch) & A_ATTRIBUTES))), \
- ((win)->_bkgd = (ch)))
-
/* It seems older SYSV curses versions define these */
-#define getattrs(win) ((win)->_attrs)
-#define getmaxx(win) ((win)->_maxx + 1)
-#define getmaxy(win) ((win)->_maxy + 1)
-
-#define winch(win) ((win)->_line[(win)->_cury].text[(win)->_curx])
+#define getattrs(win) ((win)?(win)->_attrs:A_NORMAL)
+#define getcurx(win) ((win)?(win)->_curx:ERR)
+#define getcury(win) ((win)?(win)->_cury:ERR)
+#define getbegx(win) ((win)?(win)->_begx:ERR)
+#define getbegy(win) ((win)?(win)->_begy:ERR)
+#define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
+#define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
+#define getparx(win) ((win)?(win)->_parx:ERR)
+#define getpary(win) ((win)?(win)->_pary:ERR)
+
+#define winch(win) ((win)?(win)->_line[(win)->_cury].text[(win)->_curx]:0)
#define wstandout(win) (wattr_set(win,A_STANDOUT))
#define wstandend(win) (wattr_set(win,A_NORMAL))
-#define wattr_set(win,at) ((win)->_attrs = (at))
+#define wattr_set(win,at) ((win)?((win)->_attrs = (at)):0)
#define wattron(win,at) wattr_on(win, at)
#define wattroff(win,at) wattr_off(win, at)
#define scroll(win) wscrl(win,1)
-#define touchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 1)
+#define touchwin(win) wtouchln((win), 0, getmaxy(win), 1)
#define touchline(win, s, c) wtouchln((win), s, c, 1)
-#define untouchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 0)
+#define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0)
#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0)
#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
#define mvwinwstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winnwstr(stdscr,c,-1))
#define mvwvline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline_set(win,c,n))
+#define slk_attr_off(a) slk_attroff(a)
+#define slk_attr_on(a) slk_attron(a)
+#define slk_attr_set(a) slk_attrset(a)
+#define vid_attr(a) vidattr(a)
#define vline_set(c,n) vhline_set(stdscr,c,n)
#define waddwstr(win,wstr,n) waddnwstr(win,wstr,-1)
#define wattr_get(win) ((win)->_attrs)
#define KEY_SUSPEND 0627 /* Suspend */
#define KEY_UNDO 0630 /* Undo */
#define KEY_MOUSE 0631 /* Mouse event has occurred */
+#define KEY_RESIZE 0632 /* Terminal resize event */
#define KEY_MAX 0777 /* Maximum key value */
/* mouse interface */
extern int getmouse(MEVENT *);
extern int ungetmouse(MEVENT *);
extern mmask_t mousemask(mmask_t, mmask_t *);
-extern bool wenclose(WINDOW *, int, int);
+extern bool wenclose(const WINDOW *, int, int);
extern int mouseinterval(int);
/* other non-XSI functions */
#if defined(TRACE) || defined(NCURSES_TEST)
extern int _nc_optimize_enable; /* enable optimizations */
+extern const char *_nc_visbuf(const char *);
#define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */
#define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */
#define OPTIMIZE_SCROLL 0x04 /* scroll optimization */