1998-03-01 12:21:12 +08:00
|
|
|
/****************************************************************************
|
2007-01-07 09:32:36 +08:00
|
|
|
* Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
|
1998-03-01 12:21:12 +08:00
|
|
|
* *
|
|
|
|
* 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> *
|
2005-10-10 02:41:57 +08:00
|
|
|
* and: Thomas E. Dickey 1996-on *
|
1998-03-01 12:21:12 +08:00
|
|
|
****************************************************************************/
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2007-03-04 08:18:45 +08:00
|
|
|
* $Id: curses.priv.h,v 1.321 2007/03/03 21:56:33 tom Exp $
|
1997-05-15 12:00:00 +08:00
|
|
|
*
|
|
|
|
* curses.priv.h
|
|
|
|
*
|
|
|
|
* Header file for curses library objects which are private to
|
|
|
|
* the library.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CURSES_PRIV_H
|
|
|
|
#define CURSES_PRIV_H 1
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#include <ncurses_dll.h>
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#include <ncurses_cfg.h>
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#if USE_RCS_IDS
|
1997-05-15 12:00:00 +08:00
|
|
|
#define MODULE_ID(id) static const char Ident[] = id;
|
|
|
|
#else
|
|
|
|
#define MODULE_ID(id) /*nothing*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_SYS_BSDTYPES_H
|
|
|
|
#include <sys/bsdtypes.h> /* needed for ISC */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_LIMITS_H
|
|
|
|
# include <limits.h>
|
|
|
|
#elif HAVE_SYS_PARAM_H
|
|
|
|
# include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
# if defined(_POSIX_PATH_MAX)
|
|
|
|
# define PATH_MAX _POSIX_PATH_MAX
|
|
|
|
# elif defined(MAXPATHLEN)
|
|
|
|
# define PATH_MAX MAXPATHLEN
|
|
|
|
# else
|
|
|
|
# define PATH_MAX 255 /* the Posix minimum path-size */
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#if DECL_ERRNO
|
1997-05-15 12:00:00 +08:00
|
|
|
extern int errno;
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#include <nc_panel.h>
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* Some systems have a broken 'select()', but workable 'poll()'. Use that */
|
2000-07-09 10:46:08 +08:00
|
|
|
#if HAVE_WORKING_POLL
|
1997-05-15 12:00:00 +08:00
|
|
|
#define USE_FUNC_POLL 1
|
2000-10-21 12:42:11 +08:00
|
|
|
#if HAVE_POLL_H
|
2000-07-09 10:46:08 +08:00
|
|
|
#include <poll.h>
|
|
|
|
#else
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
#else
|
|
|
|
#define USE_FUNC_POLL 0
|
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */
|
|
|
|
#include <signal.h>
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* Alessandro Rubini's GPM (general-purpose mouse) */
|
|
|
|
#if HAVE_LIBGPM && HAVE_GPM_H
|
|
|
|
#define USE_GPM_SUPPORT 1
|
|
|
|
#else
|
|
|
|
#define USE_GPM_SUPPORT 0
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/* QNX mouse support */
|
|
|
|
#if defined(__QNX__) && !defined(__QNXNTO__)
|
|
|
|
#define USE_QNX_MOUSE 1
|
|
|
|
#else
|
|
|
|
#define USE_QNX_MOUSE 0
|
|
|
|
#endif
|
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
/* EMX mouse support */
|
|
|
|
#ifdef __EMX__
|
2004-02-09 10:15:26 +08:00
|
|
|
#define USE_EMX_MOUSE 1
|
|
|
|
#else
|
|
|
|
#define USE_EMX_MOUSE 0
|
1999-10-24 12:32:42 +08:00
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#define DEFAULT_MAXCLICK 166
|
|
|
|
#define EV_MAX 8 /* size of mouse circular event queue */
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
1998-03-01 12:21:12 +08:00
|
|
|
* If we don't have signals to support it, don't add a sigwinch handler.
|
|
|
|
* In any case, resizing is an extended feature. Use it if we've got it.
|
1997-05-15 12:00:00 +08:00
|
|
|
*/
|
2000-10-21 12:42:11 +08:00
|
|
|
#if !NCURSES_EXT_FUNCS
|
1998-03-01 12:21:12 +08:00
|
|
|
#undef HAVE_SIZECHANGE
|
2002-10-13 11:35:53 +08:00
|
|
|
#define HAVE_SIZECHANGE 0
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#if HAVE_SIZECHANGE && defined(SIGWINCH)
|
1998-03-01 12:21:12 +08:00
|
|
|
#define USE_SIZECHANGE 1
|
|
|
|
#else
|
2002-10-13 11:35:53 +08:00
|
|
|
#define USE_SIZECHANGE 0
|
1998-03-01 12:21:12 +08:00
|
|
|
#undef USE_SIGWINCH
|
2002-10-13 11:35:53 +08:00
|
|
|
#define USE_SIGWINCH 0
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-10-21 12:42:11 +08:00
|
|
|
/*
|
|
|
|
* If desired, one can configure this, disabling environment variables that
|
|
|
|
* point to custom terminfo/termcap locations.
|
|
|
|
*/
|
|
|
|
#ifdef USE_ROOT_ENVIRON
|
|
|
|
#define use_terminfo_vars() 1
|
|
|
|
#else
|
|
|
|
#define use_terminfo_vars() _nc_env_access()
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_env_access (void);
|
2000-10-21 12:42:11 +08:00
|
|
|
#endif
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
1999-10-24 12:32:42 +08:00
|
|
|
* Not all platforms have memmove; some have an equivalent bcopy. (Some may
|
|
|
|
* have neither).
|
|
|
|
*/
|
|
|
|
#if USE_OK_BCOPY
|
|
|
|
#define memmove(d,s,n) bcopy(s,d,n)
|
|
|
|
#elif USE_MY_MEMMOVE
|
|
|
|
#define memmove(d,s,n) _nc_memmove(d,s,n)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
|
1999-10-24 12:32:42 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scroll hints are useless when hashmap is used
|
1998-03-01 12:21:12 +08:00
|
|
|
*/
|
|
|
|
#if !USE_SCROLL_HINTS
|
1999-10-24 12:32:42 +08:00
|
|
|
#if !USE_HASHMAP
|
1998-03-01 12:21:12 +08:00
|
|
|
#define USE_SCROLL_HINTS 1
|
|
|
|
#else
|
|
|
|
#define USE_SCROLL_HINTS 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_SCROLL_HINTS
|
|
|
|
#define if_USE_SCROLL_HINTS(stmt) stmt
|
|
|
|
#else
|
|
|
|
#define if_USE_SCROLL_HINTS(stmt) /*nothing*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
|
|
|
|
* when we're throwing control codes at the screen at high volume. To see
|
|
|
|
* this, re-enable USE_HARD_TABS and run worm for a while. Other systems
|
|
|
|
* probably don't want to define this either due to uncertainties about tab
|
|
|
|
* delays and expansion in raw mode.
|
1997-05-15 12:00:00 +08:00
|
|
|
*/
|
|
|
|
|
2006-12-24 10:11:39 +08:00
|
|
|
#define TRIES struct tries
|
|
|
|
typedef TRIES {
|
|
|
|
TRIES *child; /* ptr to child. NULL if none */
|
|
|
|
TRIES *sibling; /* ptr to sibling. NULL if none */
|
1997-05-15 12:00:00 +08:00
|
|
|
unsigned char ch; /* character at this node */
|
|
|
|
unsigned short value; /* code of string so far. 0 if none. */
|
2006-12-24 10:11:39 +08:00
|
|
|
#undef TRIES
|
|
|
|
} TRIES;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
/*
|
|
|
|
* Common/troublesome character definitions
|
|
|
|
*/
|
|
|
|
#define L_BRACE '{'
|
|
|
|
#define R_BRACE '}'
|
|
|
|
#define S_QUOTE '\''
|
2002-10-13 11:35:53 +08:00
|
|
|
#define D_QUOTE '"'
|
|
|
|
|
|
|
|
#define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
|
1999-10-24 12:32:42 +08:00
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
|
|
|
* Structure for palette tables
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2002-10-13 11:35:53 +08:00
|
|
|
short red, green, blue; /* what color_content() returns */
|
|
|
|
short r, g, b; /* params to init_color() */
|
|
|
|
int init; /* true if we called init_color() */
|
1997-05-15 12:00:00 +08:00
|
|
|
}
|
|
|
|
color_t;
|
|
|
|
|
|
|
|
#define MAXCOLUMNS 135
|
|
|
|
#define MAXLINES 66
|
1998-03-01 12:21:12 +08:00
|
|
|
#define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */
|
|
|
|
|
|
|
|
#define ACS_LEN 128
|
|
|
|
|
|
|
|
#define WINDOWLIST struct _win_list
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
#define _nc_bkgd _bkgrnd
|
|
|
|
#else
|
|
|
|
#undef _XOPEN_SOURCE_EXTENDED
|
|
|
|
#define _nc_bkgd _bkgd
|
|
|
|
#define wgetbkgrnd(win, wch) *wch = win->_bkgd
|
|
|
|
#define wbkgrnd wbkgd
|
|
|
|
#endif
|
|
|
|
|
2007-03-04 08:18:45 +08:00
|
|
|
#undef NCURSES_OPAQUE
|
|
|
|
#define NCURSES_OPAQUE 0
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#include <curses.h> /* we'll use -Ipath directive to get the right one! */
|
2002-10-13 11:35:53 +08:00
|
|
|
#include <term.h>
|
2005-10-10 02:41:57 +08:00
|
|
|
#include <term_entry.h>
|
2006-12-18 12:32:42 +08:00
|
|
|
#include <nc_tparm.h>
|
2005-10-10 02:41:57 +08:00
|
|
|
|
|
|
|
#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
|
|
|
|
#define if_EXT_COLORS(stmt) stmt
|
|
|
|
#define NetPair(value,p) (value).ext_color = (p), \
|
|
|
|
AttrOf(value) &= ALL_BUT_COLOR, \
|
|
|
|
AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
|
|
|
|
#define SetPair(value,p) (value).ext_color = (p)
|
|
|
|
#define GetPair(value) (value).ext_color
|
|
|
|
#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
|
|
|
|
#define GET_WINDOW_PAIR(w) (w)->_color
|
|
|
|
#define SET_WINDOW_PAIR(w,p) (w)->_color = (p)
|
|
|
|
#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
|
|
|
|
#define VIDATTR(attr, pair) vid_attr(attr, pair, 0)
|
|
|
|
#else
|
|
|
|
#define if_EXT_COLORS(stmt) /* nothing */
|
|
|
|
#define SetPair(value,p) RemAttr(value, A_COLOR), \
|
|
|
|
SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
|
|
|
|
#define GetPair(value) PAIR_NUMBER(AttrOf(value))
|
|
|
|
#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
|
2006-12-18 12:32:42 +08:00
|
|
|
#define GET_WINDOW_PAIR(w) PAIR_NUMBER(WINDOW_ATTRS(w))
|
|
|
|
#define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
|
|
|
|
WINDOW_ATTRS(w) |= (A_COLOR & COLOR_PAIR(p))
|
2005-10-10 02:41:57 +08:00
|
|
|
#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))
|
|
|
|
#define VIDATTR(attr, pair) vidattr(attr)
|
|
|
|
#endif
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
#define WINDOW_ATTRS(w) ((w)->_attrs)
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define SCREEN_ATTRS(s) (*((s)->_current_attr))
|
|
|
|
#define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s))
|
|
|
|
#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions for color pairs
|
|
|
|
*/
|
|
|
|
typedef unsigned colorpair_t; /* type big enough to store PAIR_OF() */
|
|
|
|
#define C_SHIFT 9 /* we need more bits than there are colors */
|
|
|
|
#define C_MASK ((1 << C_SHIFT) - 1)
|
|
|
|
#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
|
|
|
|
#define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define COLOR_DEFAULT C_MASK
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
#if defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)
|
2005-10-10 02:41:57 +08:00
|
|
|
|
|
|
|
#undef NCURSES_CH_T /* this is not a termlib feature */
|
|
|
|
#define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */
|
|
|
|
|
|
|
|
#endif /* USE_TERMLIB */
|
|
|
|
|
|
|
|
#ifndef USE_TERMLIB
|
2002-10-13 11:35:53 +08:00
|
|
|
struct ldat
|
|
|
|
{
|
2004-02-09 10:15:26 +08:00
|
|
|
NCURSES_CH_T *text; /* text of the line */
|
|
|
|
NCURSES_SIZE_T firstchar; /* first changed character in the line */
|
|
|
|
NCURSES_SIZE_T lastchar; /* last changed character in the line */
|
|
|
|
NCURSES_SIZE_T oldindex; /* index of the line at last update */
|
2002-10-13 11:35:53 +08:00
|
|
|
};
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif /* USE_TERMLIB */
|
1998-03-01 12:21:12 +08:00
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
typedef enum {
|
|
|
|
M_XTERM = -1 /* use xterm's mouse tracking? */
|
|
|
|
,M_NONE = 0 /* no mouse device */
|
|
|
|
#if USE_GPM_SUPPORT
|
|
|
|
,M_GPM /* use GPM */
|
|
|
|
#endif
|
|
|
|
#if USE_SYSMOUSE
|
|
|
|
,M_SYSMOUSE /* FreeBSD sysmouse on console */
|
|
|
|
#endif
|
|
|
|
} MouseType;
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/*
|
2005-10-10 02:41:57 +08:00
|
|
|
* Structures for scrolling.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long hashval;
|
|
|
|
int oldcount, newcount;
|
|
|
|
int oldindex, newindex;
|
|
|
|
} HASHMAP;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structures for soft labels.
|
1998-03-01 12:21:12 +08:00
|
|
|
*/
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
struct _SLK;
|
|
|
|
|
|
|
|
#ifndef USE_TERMLIB
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2006-12-18 12:32:42 +08:00
|
|
|
char *ent_text; /* text for the label */
|
|
|
|
char *form_text; /* formatted text (left/center/...) */
|
|
|
|
int ent_x; /* x coordinate of this field */
|
|
|
|
char dirty; /* this label has changed */
|
|
|
|
char visible; /* field is visible */
|
1998-03-01 12:21:12 +08:00
|
|
|
} slk_ent;
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
typedef struct _SLK {
|
2006-12-18 12:32:42 +08:00
|
|
|
char dirty; /* all labels have changed */
|
|
|
|
char hidden; /* soft labels are hidden */
|
2002-10-13 11:35:53 +08:00
|
|
|
WINDOW *win;
|
1998-03-01 12:21:12 +08:00
|
|
|
slk_ent *ent;
|
2006-12-18 12:32:42 +08:00
|
|
|
short maxlab; /* number of available labels */
|
|
|
|
short labcnt; /* number of allocated labels */
|
|
|
|
short maxlen; /* length of labels */
|
|
|
|
NCURSES_CH_T attr; /* soft label attribute */
|
1998-03-01 12:21:12 +08:00
|
|
|
} SLK;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif /* USE_TERMLIB */
|
2002-10-13 11:35:53 +08:00
|
|
|
|
|
|
|
typedef struct {
|
2006-12-18 12:32:42 +08:00
|
|
|
int line; /* lines to take, < 0 => from bottom*/
|
|
|
|
int (*hook)(WINDOW *, int); /* callback for user */
|
|
|
|
WINDOW *w; /* maybe we need this for cleanup */
|
2002-10-13 11:35:53 +08:00
|
|
|
} ripoff_t;
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
#if USE_GPM_SUPPORT
|
|
|
|
#undef buttons /* term.h defines this, and gpm uses it! */
|
|
|
|
#include <gpm.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBDL
|
|
|
|
/* link dynamically to GPM */
|
|
|
|
typedef int *TYPE_gpm_fd;
|
|
|
|
typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
|
|
|
|
typedef int (*TYPE_Gpm_Close) (void);
|
|
|
|
typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
|
|
|
|
|
|
|
|
#define my_gpm_fd SP->_mouse_gpm_fd
|
|
|
|
#define my_Gpm_Open SP->_mouse_Gpm_Open
|
|
|
|
#define my_Gpm_Close SP->_mouse_Gpm_Close
|
|
|
|
#define my_Gpm_GetEvent SP->_mouse_Gpm_GetEvent
|
|
|
|
#else
|
|
|
|
/* link statically to GPM */
|
|
|
|
#define my_gpm_fd &gpm_fd
|
|
|
|
#define my_Gpm_Open Gpm_Open
|
|
|
|
#define my_Gpm_Close Gpm_Close
|
|
|
|
#define my_Gpm_GetEvent Gpm_GetEvent
|
|
|
|
#endif /* HAVE_LIBDL */
|
|
|
|
#endif /* USE_GPM_SUPPORT */
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
/*
|
|
|
|
* The SCREEN structure.
|
|
|
|
*/
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
struct screen {
|
2006-12-18 12:32:42 +08:00
|
|
|
int _ifd; /* input file ptr for screen */
|
|
|
|
FILE *_ofp; /* output file ptr for screen */
|
|
|
|
char *_setbuf; /* buffered I/O for output */
|
|
|
|
bool _filtered; /* filter() was called */
|
|
|
|
bool _buffered; /* setvbuf uses _setbuf data */
|
|
|
|
int _checkfd; /* filedesc for typeahead check */
|
|
|
|
TERMINAL *_term; /* terminal type information */
|
2006-12-24 10:11:39 +08:00
|
|
|
TTY _saved_tty; /* savetty/resetty information */
|
2007-01-07 09:32:36 +08:00
|
|
|
NCURSES_SIZE_T _lines; /* screen lines */
|
|
|
|
NCURSES_SIZE_T _columns; /* screen columns */
|
2006-12-18 12:32:42 +08:00
|
|
|
|
2007-01-07 09:32:36 +08:00
|
|
|
NCURSES_SIZE_T _lines_avail; /* lines available for stdscr */
|
|
|
|
NCURSES_SIZE_T _topstolen; /* lines stolen from top */
|
2002-10-13 11:35:53 +08:00
|
|
|
ripoff_t _rippedoff[5]; /* list of lines stolen */
|
|
|
|
int _rip_count; /* ...and total lines stolen */
|
1998-03-01 12:21:12 +08:00
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
WINDOW *_curscr; /* current screen */
|
|
|
|
WINDOW *_newscr; /* virtual screen to be updated to */
|
|
|
|
WINDOW *_stdscr; /* screen's full-window context */
|
1998-03-01 12:21:12 +08:00
|
|
|
|
2006-12-24 10:11:39 +08:00
|
|
|
TRIES *_keytry; /* "Try" for use with keypad mode */
|
|
|
|
TRIES *_key_ok; /* Disabled keys via keyok(,FALSE) */
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _tried; /* keypad mode was initialized */
|
|
|
|
bool _keypad_on; /* keypad mode is currently on */
|
1998-03-01 12:21:12 +08:00
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
bool _called_wgetch; /* check for recursion in wgetch() */
|
2005-10-10 02:41:57 +08:00
|
|
|
int _fifo[FIFO_SIZE]; /* input push-back buffer */
|
2006-12-18 12:32:42 +08:00
|
|
|
short _fifohead, /* head of fifo queue */
|
|
|
|
_fifotail, /* tail of fifo queue */
|
|
|
|
_fifopeek, /* where to peek for next char */
|
|
|
|
_fifohold; /* set if breakout marked */
|
|
|
|
|
|
|
|
int _endwin; /* are we out of window mode? */
|
|
|
|
NCURSES_CH_T *_current_attr; /* holds current attributes set */
|
|
|
|
int _coloron; /* is color enabled? */
|
2002-10-13 11:35:53 +08:00
|
|
|
int _color_defs; /* are colors modified */
|
2006-12-18 12:32:42 +08:00
|
|
|
int _cursor; /* visibility of the cursor */
|
|
|
|
int _cursrow; /* physical cursor row */
|
|
|
|
int _curscol; /* physical cursor column */
|
2004-02-09 10:15:26 +08:00
|
|
|
bool _notty; /* true if we cannot switch non-tty */
|
2006-12-18 12:32:42 +08:00
|
|
|
int _nl; /* True if NL -> CR/NL is on */
|
|
|
|
int _raw; /* True if in raw mode */
|
|
|
|
int _cbreak; /* 1 if in cbreak mode */
|
|
|
|
/* > 1 if in halfdelay mode */
|
|
|
|
int _echo; /* True if echo on */
|
|
|
|
int _use_meta; /* use the meta key? */
|
|
|
|
struct _SLK *_slk; /* ptr to soft key struct / NULL */
|
|
|
|
int slk_format; /* selected format for this screen */
|
1997-05-15 12:00:00 +08:00
|
|
|
/* cursor movement costs; units are 10ths of milliseconds */
|
2000-10-21 12:42:11 +08:00
|
|
|
#if NCURSES_NO_PADDING
|
2006-12-18 12:32:42 +08:00
|
|
|
int _no_padding; /* flag to set if padding disabled */
|
1999-10-24 12:32:42 +08:00
|
|
|
#endif
|
2006-12-18 12:32:42 +08:00
|
|
|
int _char_padding; /* cost of character put */
|
|
|
|
int _cr_cost; /* cost of (carriage_return) */
|
|
|
|
int _cup_cost; /* cost of (cursor_address) */
|
|
|
|
int _home_cost; /* cost of (cursor_home) */
|
|
|
|
int _ll_cost; /* cost of (cursor_to_ll) */
|
1998-03-01 12:21:12 +08:00
|
|
|
#if USE_HARD_TABS
|
2006-12-18 12:32:42 +08:00
|
|
|
int _ht_cost; /* cost of (tab) */
|
|
|
|
int _cbt_cost; /* cost of (backtab) */
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif /* USE_HARD_TABS */
|
2006-12-18 12:32:42 +08:00
|
|
|
int _cub1_cost; /* cost of (cursor_left) */
|
|
|
|
int _cuf1_cost; /* cost of (cursor_right) */
|
|
|
|
int _cud1_cost; /* cost of (cursor_down) */
|
|
|
|
int _cuu1_cost; /* cost of (cursor_up) */
|
|
|
|
int _cub_cost; /* cost of (parm_cursor_left) */
|
|
|
|
int _cuf_cost; /* cost of (parm_cursor_right) */
|
|
|
|
int _cud_cost; /* cost of (parm_cursor_down) */
|
|
|
|
int _cuu_cost; /* cost of (parm_cursor_up) */
|
|
|
|
int _hpa_cost; /* cost of (column_address) */
|
|
|
|
int _vpa_cost; /* cost of (row_address) */
|
2000-07-09 10:46:08 +08:00
|
|
|
/* used in tty_update.c, must be chars */
|
2006-12-18 12:32:42 +08:00
|
|
|
int _ed_cost; /* cost of (clr_eos) */
|
|
|
|
int _el_cost; /* cost of (clr_eol) */
|
|
|
|
int _el1_cost; /* cost of (clr_bol) */
|
|
|
|
int _dch1_cost; /* cost of (delete_character) */
|
|
|
|
int _ich1_cost; /* cost of (insert_character) */
|
|
|
|
int _dch_cost; /* cost of (parm_dch) */
|
|
|
|
int _ich_cost; /* cost of (parm_ich) */
|
|
|
|
int _ech_cost; /* cost of (erase_chars) */
|
|
|
|
int _rep_cost; /* cost of (repeat_char) */
|
|
|
|
int _hpa_ch_cost; /* cost of (column_address) */
|
|
|
|
int _cup_ch_cost; /* cost of (cursor_address) */
|
|
|
|
int _cuf_ch_cost; /* cost of (parm_cursor_right) */
|
|
|
|
int _inline_cost; /* cost of inline-move */
|
|
|
|
int _smir_cost; /* cost of (enter_insert_mode) */
|
|
|
|
int _rmir_cost; /* cost of (exit_insert_mode) */
|
|
|
|
int _ip_cost; /* cost of (insert_padding) */
|
1997-05-15 12:00:00 +08:00
|
|
|
/* used in lib_mvcur.c */
|
2006-12-18 12:32:42 +08:00
|
|
|
char * _address_cursor;
|
2000-10-21 12:42:11 +08:00
|
|
|
/* used in tty_update.c */
|
2006-12-18 12:32:42 +08:00
|
|
|
int _scrolling; /* 1 if terminal's smart enough to */
|
1998-03-01 12:21:12 +08:00
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* used in lib_color.c */
|
2006-12-18 12:32:42 +08:00
|
|
|
color_t *_color_table; /* screen's color palette */
|
|
|
|
int _color_count; /* count of colors in palette */
|
|
|
|
colorpair_t *_color_pairs; /* screen's color pair list */
|
|
|
|
int _pair_count; /* count of color pairs */
|
2000-10-21 12:42:11 +08:00
|
|
|
#if NCURSES_EXT_FUNCS
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _default_color; /* use default colors */
|
|
|
|
bool _has_sgr_39_49; /* has ECMA default color support */
|
|
|
|
int _default_fg; /* assumed default foreground */
|
|
|
|
int _default_bg; /* assumed default background */
|
2000-07-09 10:46:08 +08:00
|
|
|
#endif
|
2006-12-18 12:32:42 +08:00
|
|
|
chtype _ok_attributes; /* valid attributes for terminal */
|
|
|
|
chtype _xmc_suppress; /* attributes to suppress if xmc */
|
|
|
|
chtype _xmc_triggers; /* attributes to process if xmc */
|
|
|
|
chtype * _acs_map; /* the real alternate-charset map */
|
|
|
|
bool * _screen_acs_map;
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
/* used in lib_vidattr.c */
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _use_rmso; /* true if we may use 'rmso' */
|
|
|
|
bool _use_rmul; /* true if we may use 'rmul' */
|
1999-10-24 12:32:42 +08:00
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/*
|
|
|
|
* These data correspond to the state of the idcok() and idlok()
|
|
|
|
* functions. A caveat is in order here: the XSI and SVr4
|
|
|
|
* documentation specify that these functions apply to the window which
|
|
|
|
* is given as an argument. However, ncurses implements this logic
|
|
|
|
* only for the newscr/curscr update process, _not_ per-window.
|
|
|
|
*/
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _nc_sp_idlok;
|
|
|
|
bool _nc_sp_idcok;
|
1998-03-01 12:21:12 +08:00
|
|
|
#define _nc_idlok SP->_nc_sp_idlok
|
|
|
|
#define _nc_idcok SP->_nc_sp_idcok
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are the data that support the mouse interface.
|
|
|
|
*/
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _mouse_initialized;
|
2004-02-09 10:15:26 +08:00
|
|
|
MouseType _mouse_type;
|
2006-12-18 12:32:42 +08:00
|
|
|
int _maxclick;
|
|
|
|
bool (*_mouse_event) (SCREEN *);
|
|
|
|
bool (*_mouse_inline)(SCREEN *);
|
|
|
|
bool (*_mouse_parse) (int);
|
|
|
|
void (*_mouse_resume)(SCREEN *);
|
|
|
|
void (*_mouse_wrap) (SCREEN *);
|
|
|
|
int _mouse_fd; /* file-descriptor, if any */
|
2005-10-10 02:41:57 +08:00
|
|
|
bool _mouse_active; /* true if initialized */
|
2006-12-18 12:32:42 +08:00
|
|
|
mmask_t _mouse_mask;
|
2004-02-09 10:15:26 +08:00
|
|
|
NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
|
2006-12-18 12:32:42 +08:00
|
|
|
MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */
|
|
|
|
MEVENT *_mouse_eventp; /* next free slot in event queue */
|
|
|
|
|
|
|
|
#if USE_GPM_SUPPORT
|
|
|
|
bool _mouse_gpm_loaded;
|
|
|
|
bool _mouse_gpm_found;
|
|
|
|
#ifdef HAVE_LIBDL
|
|
|
|
TYPE_gpm_fd _mouse_gpm_fd;
|
|
|
|
TYPE_Gpm_Open _mouse_Gpm_Open;
|
|
|
|
TYPE_Gpm_Close _mouse_Gpm_Close;
|
|
|
|
TYPE_Gpm_GetEvent _mouse_Gpm_GetEvent;
|
|
|
|
#endif
|
|
|
|
Gpm_Connect _mouse_gpm_connect;
|
|
|
|
#endif /* USE_GPM_SUPPORT */
|
|
|
|
|
|
|
|
#if USE_EMX_MOUSE
|
|
|
|
int _emxmouse_wfd;
|
|
|
|
int _emxmouse_thread;
|
|
|
|
int _emxmouse_activated;
|
|
|
|
char _emxmouse_buttons[4];
|
|
|
|
#endif
|
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
#if USE_SYSMOUSE
|
|
|
|
MEVENT _sysmouse_fifo[FIFO_SIZE];
|
|
|
|
int _sysmouse_head;
|
|
|
|
int _sysmouse_tail;
|
|
|
|
int _sysmouse_char_width; /* character width */
|
|
|
|
int _sysmouse_char_height; /* character height */
|
|
|
|
int _sysmouse_old_buttons;
|
|
|
|
int _sysmouse_new_buttons;
|
|
|
|
#endif
|
1998-03-01 12:21:12 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This supports automatic resizing
|
|
|
|
*/
|
|
|
|
#if USE_SIZECHANGE
|
|
|
|
int (*_resize)(int,int);
|
|
|
|
#endif
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
/*
|
1998-03-01 12:21:12 +08:00
|
|
|
* These are data that support the proper handling of the panel stack on an
|
|
|
|
* per screen basis.
|
|
|
|
*/
|
2006-12-18 12:32:42 +08:00
|
|
|
struct panelhook _panelHook;
|
1998-03-01 12:21:12 +08:00
|
|
|
/*
|
|
|
|
* Linked-list of all windows, to support '_nc_resizeall()' and
|
|
|
|
* '_nc_freeall()'
|
|
|
|
*/
|
2006-12-18 12:32:42 +08:00
|
|
|
WINDOWLIST *_nc_sp_windows;
|
1998-03-01 12:21:12 +08:00
|
|
|
#define _nc_windows SP->_nc_sp_windows
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _sig_winch;
|
|
|
|
SCREEN *_next_screen;
|
1999-10-24 12:32:42 +08:00
|
|
|
|
|
|
|
/* hashes for old and new lines */
|
|
|
|
unsigned long *oldhash, *newhash;
|
2005-10-10 02:41:57 +08:00
|
|
|
HASHMAP *hashtab;
|
2002-10-13 11:35:53 +08:00
|
|
|
int hashtab_len;
|
2006-12-24 10:11:39 +08:00
|
|
|
int *_oldnum_list;
|
|
|
|
int _oldnum_size;
|
1999-10-24 12:32:42 +08:00
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
bool _cleanup; /* cleanup after int/quit signal */
|
|
|
|
int (*_outch)(int); /* output handler if not putc */
|
2004-02-09 10:15:26 +08:00
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
int _legacy_coding; /* see use_legacy_coding() */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ncurses/ncursesw are the same up to this point.
|
|
|
|
*/
|
|
|
|
#if USE_WIDEC_SUPPORT
|
2004-02-09 10:15:26 +08:00
|
|
|
/* recent versions of 'screen' have partially-working support for
|
|
|
|
* UTF-8, but do not permit ACS at the same time (see tty_update.c).
|
|
|
|
*/
|
|
|
|
bool _screen_acs_fix;
|
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
};
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
WINDOWLIST {
|
2004-02-09 10:15:26 +08:00
|
|
|
WINDOW win; /* first, so WINDOW_EXT() works */
|
1997-05-15 12:00:00 +08:00
|
|
|
WINDOWLIST *next;
|
2004-02-09 10:15:26 +08:00
|
|
|
#ifdef _XOPEN_SOURCE_EXTENDED
|
|
|
|
char addch_work[(MB_LEN_MAX * 9) + 1];
|
2005-10-10 02:41:57 +08:00
|
|
|
unsigned addch_used; /* number of bytes in addch_work[] */
|
|
|
|
int addch_x; /* x-position for addch_work[] */
|
|
|
|
int addch_y; /* y-position for addch_work[] */
|
2002-10-13 11:35:53 +08:00
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
};
|
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
#define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
/* usually in <limits.h> */
|
|
|
|
#ifndef UCHAR_MAX
|
|
|
|
#define UCHAR_MAX 255
|
|
|
|
#endif
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* The terminfo source is assumed to be 7-bit ASCII */
|
|
|
|
#define is7bits(c) ((unsigned)(c) < 128)
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
/* Checks for isprint() should be done on 8-bit characters (non-wide) */
|
|
|
|
#define is8bits(c) ((unsigned)(c) <= UCHAR_MAX)
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#ifndef min
|
|
|
|
#define min(a,b) ((a) > (b) ? (b) : (a))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef max
|
|
|
|
#define max(a,b) ((a) < (b) ? (b) : (a))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* usually in <unistd.h> */
|
1999-10-24 12:32:42 +08:00
|
|
|
#ifndef STDIN_FILENO
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#endif
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#ifndef STDOUT_FILENO
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STDERR_FILENO
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EXIT_SUCCESS
|
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EXIT_FAILURE
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef R_OK
|
|
|
|
#define R_OK 4 /* Test for read permission. */
|
|
|
|
#endif
|
|
|
|
#ifndef W_OK
|
|
|
|
#define W_OK 2 /* Test for write permission. */
|
|
|
|
#endif
|
|
|
|
#ifndef X_OK
|
|
|
|
#define X_OK 1 /* Test for execute permission. */
|
|
|
|
#endif
|
|
|
|
#ifndef F_OK
|
|
|
|
#define F_OK 0 /* Test for existence. */
|
|
|
|
#endif
|
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
#if HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h> /* may define O_BINARY */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef O_BINARY
|
|
|
|
#define O_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
#ifdef TRACE
|
|
|
|
#define TRACE_OUTCHARS(n) _nc_outchars += (n);
|
|
|
|
#else
|
|
|
|
#define TRACE_OUTCHARS(n) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#define UChar(c) ((unsigned char)(c))
|
|
|
|
#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
|
2006-12-18 12:32:42 +08:00
|
|
|
#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
#ifndef MB_LEN_MAX
|
|
|
|
#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
|
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#if USE_WIDEC_SUPPORT /* { */
|
2005-10-10 02:41:57 +08:00
|
|
|
#define isEILSEQ(status) ((status == (size_t)-1) && (errno == EILSEQ))
|
|
|
|
|
|
|
|
#define init_mb(state) memset(&state, 0, sizeof(state))
|
|
|
|
|
|
|
|
#if NCURSES_EXT_COLORS
|
|
|
|
#define NulColor , 0
|
|
|
|
#else
|
|
|
|
#define NulColor /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
#define NulChar 0,0,0,0 /* FIXME: see CCHARW_MAX */
|
2002-10-13 11:35:53 +08:00
|
|
|
#define CharOf(c) ((c).chars[0])
|
|
|
|
#define AttrOf(c) ((c).attr)
|
2006-12-18 12:32:42 +08:00
|
|
|
#define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES)
|
|
|
|
#define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES)
|
|
|
|
#define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES)
|
2005-10-10 02:41:57 +08:00
|
|
|
#define NewChar2(c,a) { a, { c, NulChar } NulColor }
|
2006-12-18 12:32:42 +08:00
|
|
|
#define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch))
|
|
|
|
#define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a)))
|
2005-10-10 02:41:57 +08:00
|
|
|
#define SetChar(ch,c,a) do { \
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_CH_T *_cp = &ch; \
|
2005-10-10 02:41:57 +08:00
|
|
|
memset(_cp, 0, sizeof(ch)); \
|
2006-12-18 12:32:42 +08:00
|
|
|
_cp->chars[0] = (c); \
|
|
|
|
_cp->attr = (a); \
|
2005-10-10 02:41:57 +08:00
|
|
|
if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a))); \
|
2002-10-13 11:35:53 +08:00
|
|
|
} while (0)
|
|
|
|
#define CHREF(wch) (&wch)
|
|
|
|
#define CHDEREF(wch) (*wch)
|
|
|
|
#define ARG_CH_T NCURSES_CH_T *
|
|
|
|
#define CARG_CH_T const NCURSES_CH_T *
|
|
|
|
#define PUTC_DATA char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
|
|
|
|
mbstate_t PUT_st; wchar_t PUTC_ch
|
2006-12-18 12:32:42 +08:00
|
|
|
#define PUTC_INIT init_mb (PUT_st)
|
2005-10-10 02:41:57 +08:00
|
|
|
#define PUTC(ch,b) do { if(!isWidecExt(ch)) { \
|
2004-02-09 10:15:26 +08:00
|
|
|
if (Charable(ch)) { \
|
|
|
|
fputc(CharOf(ch), b); \
|
|
|
|
TRACE_OUTCHARS(1); \
|
|
|
|
} else { \
|
|
|
|
PUTC_INIT; \
|
2006-12-18 12:32:42 +08:00
|
|
|
for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \
|
|
|
|
PUTC_ch = (ch).chars[PUTC_i]; \
|
|
|
|
if (PUTC_ch == L'\0') \
|
|
|
|
break; \
|
2002-10-13 11:35:53 +08:00
|
|
|
PUTC_n = wcrtomb(PUTC_buf, \
|
|
|
|
(ch).chars[PUTC_i], &PUT_st); \
|
2006-12-18 12:32:42 +08:00
|
|
|
if (PUTC_n <= 0) { \
|
|
|
|
if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) \
|
|
|
|
putc(PUTC_ch,b); \
|
2002-10-13 11:35:53 +08:00
|
|
|
break; \
|
2006-12-18 12:32:42 +08:00
|
|
|
} \
|
2002-10-13 11:35:53 +08:00
|
|
|
fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
|
2006-12-18 12:32:42 +08:00
|
|
|
} \
|
2004-02-09 10:15:26 +08:00
|
|
|
TRACE_OUTCHARS(PUTC_i); \
|
|
|
|
} } } while (0)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define BLANK { WA_NORMAL, {' '} NulColor }
|
|
|
|
#define ZEROS { WA_NORMAL, {'\0'} NulColor }
|
2002-10-13 11:35:53 +08:00
|
|
|
#define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
/*
|
|
|
|
* Wide characters cannot be represented in the A_CHARTEXT mask of
|
|
|
|
* attr_t's but an application might have set a narrow character there.
|
|
|
|
* But even in that case, it would only be a printable character, or
|
|
|
|
* zero. Otherwise we can use those bits to tell if a cell is the
|
|
|
|
* first or extension part of a wide character.
|
|
|
|
*/
|
|
|
|
#define WidecExt(ch) (AttrOf(ch) & A_CHARTEXT)
|
|
|
|
#define isWidecBase(ch) (WidecExt(ch) == 1)
|
|
|
|
#define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32)
|
|
|
|
#define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \
|
|
|
|
AttrOf(dst) |= (ext + 1)
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#define if_WIDEC(code) code
|
2005-10-10 02:41:57 +08:00
|
|
|
#define Charable(ch) ((SP != 0 && SP->_legacy_coding) \
|
|
|
|
|| (AttrOf(ch) & A_ALTCHARSET) \
|
|
|
|
|| (!isWidecExt(ch) && \
|
2004-02-09 10:15:26 +08:00
|
|
|
(ch).chars[1] == L'\0' && \
|
2006-12-18 12:32:42 +08:00
|
|
|
_nc_is_charable(CharOf(ch))))
|
2002-10-13 11:35:53 +08:00
|
|
|
|
|
|
|
#define L(ch) L ## ch
|
|
|
|
#else /* }{ */
|
|
|
|
#define CharOf(c) ChCharOf(c)
|
|
|
|
#define AttrOf(c) ChAttrOf(c)
|
2006-12-18 12:32:42 +08:00
|
|
|
#define AddAttr(c,a) c |= (a)
|
|
|
|
#define RemAttr(c,a) c &= ~((a) & A_ATTRIBUTES)
|
|
|
|
#define SetAttr(c,a) c = ((c) & ~A_ATTRIBUTES) | (a)
|
2002-10-13 11:35:53 +08:00
|
|
|
#define NewChar(ch) (ch)
|
2006-12-18 12:32:42 +08:00
|
|
|
#define NewChar2(c,a) ((c) | (a))
|
|
|
|
#define CharEq(a,b) ((a) == (b))
|
|
|
|
#define SetChar(ch,c,a) ch = (c) | (a)
|
2002-10-13 11:35:53 +08:00
|
|
|
#define CHREF(wch) wch
|
|
|
|
#define CHDEREF(wch) wch
|
|
|
|
#define ARG_CH_T NCURSES_CH_T
|
|
|
|
#define CARG_CH_T NCURSES_CH_T
|
|
|
|
#define PUTC_DATA int data = 0
|
2006-12-18 12:32:42 +08:00
|
|
|
#define PUTC(ch,b) do { data = CharOf(ch); putc(data,b); } while (0)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
|
|
|
#define BLANK (' '|A_NORMAL)
|
2005-10-10 02:41:57 +08:00
|
|
|
#define ZEROS ('\0'|A_NORMAL)
|
2002-10-13 11:35:53 +08:00
|
|
|
#define ISBLANK(ch) (CharOf(ch) == ' ')
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define isWidecExt(ch) (0)
|
2002-10-13 11:35:53 +08:00
|
|
|
#define if_WIDEC(code) /* nothing */
|
|
|
|
|
|
|
|
#define L(ch) ch
|
|
|
|
#endif /* } */
|
|
|
|
|
|
|
|
#define AttrOfD(ch) AttrOf(CHDEREF(ch))
|
|
|
|
#define CharOfD(ch) CharOf(CHDEREF(ch))
|
|
|
|
#define SetChar2(wch,ch) SetChar(wch,ChCharOf(ch),ChAttrOf(ch))
|
|
|
|
|
|
|
|
#define BLANK_ATTR A_NORMAL
|
|
|
|
#define BLANK_TEXT L(' ')
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#define CHANGED -1
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define LEGALYX(w, y, x) \
|
|
|
|
((w) != 0 && \
|
|
|
|
((x) >= 0 && (x) <= (w)->_maxx && \
|
|
|
|
(y) >= 0 && (y) <= (w)->_maxy))
|
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
#define CHANGED_CELL(line,col) \
|
|
|
|
if (line->firstchar == _NOCHANGE) \
|
|
|
|
line->firstchar = line->lastchar = col; \
|
|
|
|
else if ((col) < line->firstchar) \
|
|
|
|
line->firstchar = col; \
|
|
|
|
else if ((col) > line->lastchar) \
|
|
|
|
line->lastchar = col
|
|
|
|
|
|
|
|
#define CHANGED_RANGE(line,start,end) \
|
|
|
|
if (line->firstchar == _NOCHANGE \
|
|
|
|
|| line->firstchar > (start)) \
|
|
|
|
line->firstchar = start; \
|
|
|
|
if (line->lastchar == _NOCHANGE \
|
|
|
|
|| line->lastchar < (end)) \
|
|
|
|
line->lastchar = end
|
|
|
|
|
|
|
|
#define CHANGED_TO_EOL(line,start,end) \
|
|
|
|
if (line->firstchar == _NOCHANGE \
|
|
|
|
|| line->firstchar > (start)) \
|
|
|
|
line->firstchar = start; \
|
|
|
|
line->lastchar = end
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
|
2000-07-09 10:46:08 +08:00
|
|
|
|
|
|
|
#define FreeIfNeeded(p) if ((p) != 0) free(p)
|
|
|
|
|
|
|
|
/* FreeAndNull() is not a comma-separated expression because some compilers
|
|
|
|
* do not accept a mixture of void with values.
|
|
|
|
*/
|
1997-05-15 12:00:00 +08:00
|
|
|
#define FreeAndNull(p) free(p); p = 0
|
|
|
|
|
|
|
|
#include <nc_alloc.h>
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
/*
|
|
|
|
* TTY bit definition for converting tabs to spaces.
|
|
|
|
*/
|
|
|
|
#ifdef TAB3
|
|
|
|
# define OFLAGS_TABS TAB3 /* POSIX specifies TAB3 */
|
|
|
|
#else
|
|
|
|
# ifdef XTABS
|
|
|
|
# define OFLAGS_TABS XTABS /* XTABS is usually the "same" */
|
|
|
|
# else
|
|
|
|
# ifdef OXTABS
|
|
|
|
# define OFLAGS_TABS OXTABS /* the traditional BSD equivalent */
|
|
|
|
# else
|
|
|
|
# define OFLAGS_TABS 0
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
|
|
|
* Prefixes for call/return points of library function traces. We use these to
|
|
|
|
* instrument the public functions so that the traces can be easily transformed
|
|
|
|
* into regression scripts.
|
|
|
|
*/
|
2002-10-13 11:35:53 +08:00
|
|
|
#define T_CALLED(fmt) "called {" fmt
|
|
|
|
#define T_CREATE(fmt) "create :" fmt
|
|
|
|
#define T_RETURN(fmt) "return }" fmt
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#ifdef TRACE
|
2002-10-13 11:35:53 +08:00
|
|
|
|
|
|
|
#define START_TRACE() \
|
|
|
|
if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
|
|
|
|
int t = _nc_getenv_num("NCURSES_TRACE"); \
|
|
|
|
if (t >= 0) \
|
|
|
|
trace((unsigned) t); \
|
|
|
|
}
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#define TR(n, a) if (_nc_tracing & (n)) _tracef a
|
|
|
|
#define T(a) TR(TRACE_CALLS, a)
|
|
|
|
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
|
|
|
|
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define returnAttr(code) TRACE_RETURN(code,attr_t)
|
|
|
|
#define returnBits(code) TRACE_RETURN(code,unsigned)
|
|
|
|
#define returnBool(code) TRACE_RETURN(code,bool)
|
|
|
|
#define returnCPtr(code) TRACE_RETURN(code,cptr)
|
|
|
|
#define returnCVoidPtr(code) TRACE_RETURN(code,cvoid_ptr)
|
|
|
|
#define returnChar(code) TRACE_RETURN(code,chtype)
|
|
|
|
#define returnCode(code) TRACE_RETURN(code,int)
|
|
|
|
#define returnPtr(code) TRACE_RETURN(code,ptr)
|
|
|
|
#define returnSP(code) TRACE_RETURN(code,sp)
|
|
|
|
#define returnVoid T((T_RETURN(""))); return
|
|
|
|
#define returnVoidPtr(code) TRACE_RETURN(code,void_ptr)
|
|
|
|
#define returnWin(code) TRACE_RETURN(code,win)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
|
|
|
extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (NCURSES_BOOL);
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
|
|
|
|
extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
|
|
|
|
extern NCURSES_EXPORT(attr_t) _nc_retrace_attr_t (attr_t);
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_retrace_ptr (char *);
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_trace_ttymode(TTY *tty);
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_varargs (const char *, va_list);
|
|
|
|
extern NCURSES_EXPORT(chtype) _nc_retrace_chtype (chtype);
|
|
|
|
extern NCURSES_EXPORT(const char *) _nc_altcharset_name(attr_t, chtype);
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(const char *) _nc_retrace_cptr (const char *);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_retrace_int (int);
|
|
|
|
extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned);
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(void *) _nc_retrace_void_ptr (void *);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_fifo_dump (void);
|
|
|
|
extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
|
|
|
|
extern NCURSES_EXPORT_VAR(long) _nc_outchars;
|
|
|
|
extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
|
|
|
|
|
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
extern NCURSES_EXPORT(const char *) _nc_viswbuf2 (int, const wchar_t *);
|
|
|
|
extern NCURSES_EXPORT(const char *) _nc_viswbufn (const wchar_t *, int);
|
|
|
|
#endif
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(const char *) _nc_viscbuf2 (int, const NCURSES_CH_T *, int);
|
|
|
|
extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int);
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#else /* !TRACE */
|
|
|
|
|
|
|
|
#define START_TRACE() /* nothing */
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#define T(a)
|
|
|
|
#define TR(n, a)
|
|
|
|
#define TPUTS_TRACE(s)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define returnAttr(code) return code
|
|
|
|
#define returnBits(code) return code
|
|
|
|
#define returnBool(code) return code
|
|
|
|
#define returnCPtr(code) return code
|
|
|
|
#define returnCVoidPtr(code) return code
|
|
|
|
#define returnChar(code) return code
|
|
|
|
#define returnCode(code) return code
|
|
|
|
#define returnPtr(code) return code
|
|
|
|
#define returnSP(code) return code
|
|
|
|
#define returnVoid return
|
|
|
|
#define returnVoidPtr(code) return code
|
|
|
|
#define returnWin(code) return code
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#endif /* TRACE/!TRACE */
|
1999-10-24 12:32:42 +08:00
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
/*
|
|
|
|
* Return-codes for tgetent() and friends.
|
|
|
|
*/
|
|
|
|
#define TGETENT_YES 1 /* entry is found */
|
|
|
|
#define TGETENT_NO 0 /* entry is not found */
|
|
|
|
#define TGETENT_ERR -1 /* an error occurred */
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
|
|
|
|
extern NCURSES_EXPORT(const char *) _nc_visbufn (const char *, int);
|
|
|
|
|
|
|
|
#define empty_module(name) \
|
|
|
|
extern NCURSES_EXPORT(void) name (void); \
|
|
|
|
NCURSES_EXPORT(void) name (void) { }
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
|
2004-02-09 10:15:26 +08:00
|
|
|
#define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
|
1998-03-01 12:21:12 +08:00
|
|
|
#define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
#define toggle_attr_on(S,at) {\
|
2005-10-10 02:41:57 +08:00
|
|
|
if (PAIR_NUMBER(at) > 0) {\
|
1997-05-15 12:00:00 +08:00
|
|
|
(S) = ((S) & ALL_BUT_COLOR) | (at);\
|
2005-10-10 02:41:57 +08:00
|
|
|
} else {\
|
1997-05-15 12:00:00 +08:00
|
|
|
(S) |= (at);\
|
2005-10-10 02:41:57 +08:00
|
|
|
}\
|
2000-10-21 12:42:11 +08:00
|
|
|
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
#define toggle_attr_off(S,at) {\
|
2005-10-10 02:41:57 +08:00
|
|
|
if (PAIR_NUMBER(at) > 0) {\
|
|
|
|
(S) &= ~(at|A_COLOR);\
|
1997-05-15 12:00:00 +08:00
|
|
|
} else {\
|
2005-10-10 02:41:57 +08:00
|
|
|
(S) &= ~(at);\
|
1997-05-15 12:00:00 +08:00
|
|
|
}\
|
2000-10-21 12:42:11 +08:00
|
|
|
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#define DelCharCost(count) \
|
|
|
|
((parm_dch != 0) \
|
|
|
|
? SP->_dch_cost \
|
|
|
|
: ((delete_character != 0) \
|
|
|
|
? (SP->_dch1_cost * count) \
|
|
|
|
: INFINITY))
|
|
|
|
|
|
|
|
#define InsCharCost(count) \
|
|
|
|
((parm_ich != 0) \
|
|
|
|
? SP->_ich_cost \
|
1999-10-24 12:32:42 +08:00
|
|
|
: ((enter_insert_mode && exit_insert_mode) \
|
|
|
|
? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
|
|
|
|
: ((insert_character != 0) \
|
2004-02-09 10:15:26 +08:00
|
|
|
? ((SP->_ich1_cost + SP->_ip_cost) * count) \
|
1999-10-24 12:32:42 +08:00
|
|
|
: INFINITY)))
|
1997-05-15 12:00:00 +08:00
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#if USE_XMC_SUPPORT
|
2005-10-10 02:41:57 +08:00
|
|
|
#define UpdateAttrs(c) if (!SameAttrOf(SCREEN_ATTRS(SP), c)) { \
|
|
|
|
attr_t chg = AttrOf(SCREEN_ATTRS(SP)); \
|
|
|
|
VIDATTR(AttrOf(c), GetPair(c)); \
|
1998-03-01 12:21:12 +08:00
|
|
|
if (magic_cookie_glitch > 0 \
|
2005-10-10 02:41:57 +08:00
|
|
|
&& XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(SP))))) { \
|
2002-10-13 11:35:53 +08:00
|
|
|
T(("%s @%d before glitch %d,%d", \
|
1998-03-01 12:21:12 +08:00
|
|
|
__FILE__, __LINE__, \
|
|
|
|
SP->_cursrow, \
|
|
|
|
SP->_curscol)); \
|
|
|
|
_nc_do_xmc_glitch(chg); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#else
|
2005-10-10 02:41:57 +08:00
|
|
|
#define UpdateAttrs(c) if (!SameAttrOf(SCREEN_ATTRS(SP), c)) \
|
|
|
|
VIDATTR(AttrOf(c), GetPair(c));
|
2002-10-13 11:35:53 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros to make additional parameter to implement wgetch_events()
|
|
|
|
*/
|
|
|
|
#ifdef NCURSES_WGETCH_EVENTS
|
|
|
|
#define EVENTLIST_0th(param) param
|
|
|
|
#define EVENTLIST_1st(param) param
|
|
|
|
#define EVENTLIST_2nd(param) , param
|
|
|
|
#else
|
|
|
|
#define EVENTLIST_0th(param) void
|
|
|
|
#define EVENTLIST_1st(param) /* nothing */
|
|
|
|
#define EVENTLIST_2nd(param) /* nothing */
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-10-21 12:42:11 +08:00
|
|
|
#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef toggle_attr_on
|
|
|
|
#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *, attr_t);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef toggle_attr_off
|
|
|
|
#define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *, attr_t);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef DelCharCost
|
|
|
|
#define DelCharCost(count) _nc_DelCharCost(count)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef InsCharCost
|
|
|
|
#define InsCharCost(count) _nc_InsCharCost(count)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef UpdateAttrs
|
|
|
|
#define UpdateAttrs(c) _nc_UpdateAttrs(c)
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_expanded (void);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
#if !HAVE_GETCWD
|
|
|
|
#define getcwd(buf,len) getwd(buf)
|
|
|
|
#endif
|
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
/* charable.c */
|
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
extern NCURSES_EXPORT(bool) _nc_is_charable(wchar_t);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_to_char(wint_t);
|
|
|
|
extern NCURSES_EXPORT(wint_t) _nc_to_widechar(int);
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/* doupdate.c */
|
|
|
|
#if USE_XMC_SUPPORT
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t);
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* hardscroll.c */
|
1999-10-24 12:32:42 +08:00
|
|
|
#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_linedump (void);
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* lib_acs.c */
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_init_acs (void); /* corresponds to traditional 'init_acs()' */
|
|
|
|
extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int); /* used by 'tack' program */
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
/* lib_addch.c */
|
2002-10-13 11:35:53 +08:00
|
|
|
#if USE_WIDEC_SUPPORT
|
2005-10-10 02:41:57 +08:00
|
|
|
NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* lib_addstr.c */
|
|
|
|
#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* lib_color.c */
|
|
|
|
extern NCURSES_EXPORT(bool) _nc_reset_colors(void);
|
|
|
|
|
|
|
|
/* lib_getch.c */
|
|
|
|
extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
/* lib_insch.c */
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
|
2004-02-09 10:15:26 +08:00
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* lib_mvcur.c */
|
|
|
|
#define INFINITY 1000000 /* cost: too high to use */
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
|
1998-03-01 12:21:12 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
|
1998-03-01 12:21:12 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_screen_init (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_screen_resume (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-10-21 12:42:11 +08:00
|
|
|
/* lib_mouse.c */
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_has_mouse (void);
|
2000-10-21 12:42:11 +08:00
|
|
|
|
|
|
|
/* lib_mvcur.c */
|
|
|
|
#define INFINITY 1000000 /* cost: too high to use */
|
2004-02-09 10:15:26 +08:00
|
|
|
#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
|
|
|
|
|
|
|
|
/* lib_setup.c */
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_get_locale(void);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, bool);
|
|
|
|
|
|
|
|
/* lib_tstp.c */
|
|
|
|
#if USE_SIGWINCH
|
|
|
|
extern NCURSES_EXPORT(int) _nc_handle_sigwinch(int);
|
|
|
|
#else
|
|
|
|
#define _nc_handle_sigwinch(a) /* nothing */
|
|
|
|
#endif
|
2000-10-21 12:42:11 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
/* lib_wacs.c */
|
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
extern NCURSES_EXPORT(void) _nc_init_wacs(void);
|
|
|
|
#endif
|
|
|
|
|
2000-10-21 12:42:11 +08:00
|
|
|
typedef struct {
|
2004-02-09 10:15:26 +08:00
|
|
|
char *s_head; /* beginning of the string (may be null) */
|
|
|
|
char *s_tail; /* end of the string (may be null) */
|
|
|
|
size_t s_size; /* current remaining size available */
|
|
|
|
size_t s_init; /* total size available */
|
2000-10-21 12:42:11 +08:00
|
|
|
} string_desc;
|
|
|
|
|
|
|
|
/* strings.c */
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(string_desc *) _nc_str_init (string_desc *, char *, size_t);
|
|
|
|
extern NCURSES_EXPORT(string_desc *) _nc_str_null (string_desc *, size_t);
|
|
|
|
extern NCURSES_EXPORT(string_desc *) _nc_str_copy (string_desc *, string_desc *);
|
|
|
|
extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
|
|
|
|
extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
|
2000-10-21 12:42:11 +08:00
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
#if !HAVE_STRSTR
|
|
|
|
#define strstr _nc_strstr
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
|
1999-10-24 12:32:42 +08:00
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/* safe_sprintf.c */
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(char *) _nc_printf_string (const char *, va_list);
|
1998-03-01 12:21:12 +08:00
|
|
|
|
|
|
|
/* tries.c */
|
2006-12-24 10:11:39 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_add_to_try (TRIES **, const char *, unsigned);
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_expand_try (TRIES *, unsigned, int *, size_t);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_remove_key (TRIES **, unsigned);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_remove_string (TRIES **, const char *);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
/* elsewhere ... */
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry(ENTRY *, TERMTYPE *);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
|
2004-02-09 10:15:26 +08:00
|
|
|
extern NCURSES_EXPORT(char *) _nc_trace_bufcat (int, const char *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_access (const char *, int);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_baudrate (int);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_keypad (bool);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_ospeed (int);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_outch (int);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_timed_wait(int, int, int * EVENTLIST_2nd(_nc_eventlist *));
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_do_color (short, short, bool, int (*)(int));
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_flush (void);
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_free_entry(ENTRY *, TERMTYPE *);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_freeall (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_hash_map (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_init_keytry (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_keep_tic_dir (const char *);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
|
2006-12-24 10:11:39 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_trace_tries (TRIES *);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#if NO_LEAKS
|
|
|
|
extern NCURSES_EXPORT(void) _nc_alloc_entry_leaks(void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_captoinfo_leaks(void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef USE_TERMLIB
|
|
|
|
extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T);
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB)
|
|
|
|
#ifdef linux
|
|
|
|
extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
|
|
|
|
#else
|
|
|
|
#define _nc_wcrtomb(s,wc,ps) wcrtomb(s,wc,ps)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#if USE_SIZECHANGE
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_update_screensize (void);
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#if HAVE_RESIZETERM
|
|
|
|
extern NCURSES_EXPORT(void) _nc_resize_margins (WINDOW *);
|
|
|
|
#else
|
|
|
|
#define _nc_resize_margins(wp) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NCURSES_WGETCH_EVENTS
|
|
|
|
extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *);
|
|
|
|
#else
|
|
|
|
#define wgetch_events(win, evl) wgetch(win)
|
|
|
|
#define wgetnstr_events(win, str, maxlen, evl) wgetnstr(win, str, maxlen)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Not everyone has vsscanf(), but we'd like to use it for scanw().
|
|
|
|
*/
|
|
|
|
#if !HAVE_VSSCANF
|
|
|
|
extern int vsscanf(const char *str, const char *format, va_list __arg);
|
2000-07-09 10:46:08 +08:00
|
|
|
#endif
|
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
/* scroll indices */
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
|
1999-10-24 12:32:42 +08:00
|
|
|
|
|
|
|
#define USE_SETBUF_0 0
|
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
#define NC_BUFFERED(flag) _nc_set_buffer(SP->_ofp, flag)
|
1999-10-24 12:32:42 +08:00
|
|
|
|
|
|
|
#define NC_OUTPUT ((SP != 0) ? SP->_ofp : stdout)
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
|
|
|
* On systems with a broken linker, define 'SP' as a function to force the
|
|
|
|
* linker to pull in the data-only module with 'SP'.
|
|
|
|
*/
|
|
|
|
#if BROKEN_LINKER
|
|
|
|
#define SP _nc_screen()
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(SCREEN *) _nc_screen (void);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_alloc_screen (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
|
1997-05-15 12:00:00 +08:00
|
|
|
#else
|
1998-03-01 12:21:12 +08:00
|
|
|
/* current screen is private data; avoid possible linking conflicts too */
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(SCREEN *) SP;
|
1997-05-15 12:00:00 +08:00
|
|
|
#define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
|
|
|
|
#define _nc_set_screen(sp) SP = sp
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2002-10-13 11:35:53 +08:00
|
|
|
* We don't want to use the lines or columns capabilities internally, because
|
|
|
|
* if the application is running multiple screens under X, it's quite possible
|
|
|
|
* they could all have type xterm but have different sizes! So...
|
1997-05-15 12:00:00 +08:00
|
|
|
*/
|
|
|
|
#define screen_lines SP->_lines
|
|
|
|
#define screen_columns SP->_columns
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(int) _nc_slk_format; /* != 0 if slk_init() called */
|
|
|
|
extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
/*
|
|
|
|
* Some constants related to SLK's
|
1998-03-01 12:21:12 +08:00
|
|
|
*/
|
|
|
|
#define MAX_SKEY_OLD 8 /* count of soft keys */
|
|
|
|
#define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */
|
|
|
|
#define MAX_SKEY_PC 12 /* This is what most PC's have */
|
|
|
|
#define MAX_SKEY_LEN_PC 5
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/* Macro to check whether or not we use a standard format */
|
1999-10-24 12:32:42 +08:00
|
|
|
#define SLK_STDFMT(fmt) (fmt < 3)
|
1997-05-15 12:00:00 +08:00
|
|
|
/* Macro to determine height of label window */
|
1999-10-24 12:32:42 +08:00
|
|
|
#define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
|
|
|
|
|
|
|
|
#define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
|
|
|
|
#define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_ripoffline (int line, int (*init)(WINDOW *,int));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Common error messages
|
|
|
|
*/
|
|
|
|
#define MSG_NO_MEMORY "Out of memory"
|
|
|
|
#define MSG_NO_INPUTS "Premature EOF"
|
1997-05-15 12:00:00 +08:00
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#endif /* CURSES_PRIV_H */
|