1998-03-01 12:21:12 +08:00
|
|
|
/****************************************************************************
|
2012-01-22 09:23:31 +08:00
|
|
|
* Copyright (c) 1998-2011,2012 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 *
|
2009-03-01 07:06:36 +08:00
|
|
|
* and: Juergen Pfeifer *
|
1998-03-01 12:21:12 +08:00
|
|
|
****************************************************************************/
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
/*
|
2012-03-11 09:59:25 +08:00
|
|
|
* $Id: curses.priv.h,v 1.499 2012/03/10 21:16:32 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
|
2010-12-26 09:22:11 +08:00
|
|
|
/* *INDENT-OFF* */
|
1997-05-15 12:00:00 +08:00
|
|
|
|
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
|
|
|
|
|
2010-01-24 09:42:57 +08:00
|
|
|
#include <stddef.h> /* for offsetof */
|
1997-05-15 12:00:00 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2011-06-05 09:01:53 +08:00
|
|
|
#include <sys/stat.h>
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
2012-02-26 09:59:00 +08:00
|
|
|
#if HAVE_INTTYPES_H
|
|
|
|
# include <inttypes.h>
|
|
|
|
#else
|
|
|
|
# if HAVE_STDINT_H
|
|
|
|
# include <stdint.h>
|
|
|
|
# endif
|
|
|
|
#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
|
|
|
|
|
2012-01-22 09:23:31 +08:00
|
|
|
/* kLIBC keyboard/mouse support */
|
|
|
|
#if defined(__OS2__) && defined(__KLIBC__)
|
|
|
|
#define USE_KLIBC_KBD 1
|
|
|
|
#define USE_KLIBC_MOUSE 1
|
|
|
|
#else
|
|
|
|
#define USE_KLIBC_KBD 0
|
|
|
|
#define USE_KLIBC_MOUSE 0
|
|
|
|
#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
|
|
|
|
|
2008-09-28 09:08:36 +08:00
|
|
|
#if HAVE_SIZECHANGE && USE_SIGWINCH && 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
|
|
|
|
|
2010-03-07 08:37:08 +08:00
|
|
|
/*
|
|
|
|
* If we have va_copy(), use it for assigning va_list's.
|
|
|
|
*/
|
|
|
|
#if defined(HAVE___VA_COPY)
|
|
|
|
#define begin_va_copy(dst,src) __va_copy(dst, src)
|
|
|
|
#define end_va_copy(dst) va_end(dst)
|
|
|
|
#elif defined(va_copy) || defined(HAVE_VA_COPY)
|
|
|
|
#define begin_va_copy(dst,src) va_copy(dst, src)
|
|
|
|
#define end_va_copy(dst) va_end(dst)
|
|
|
|
#else
|
|
|
|
#define begin_va_copy(dst,src) (dst) = (src)
|
|
|
|
#define end_va_copy(dst) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2011-06-05 09:01:53 +08:00
|
|
|
/*
|
|
|
|
* Either/both S_ISxxx and/or S_IFxxx are defined in sys/types.h; some systems
|
|
|
|
* lack one or the other.
|
|
|
|
*/
|
|
|
|
#ifndef S_ISDIR
|
|
|
|
#define S_ISDIR(mode) ((mode & S_IFMT) == S_IFDIR)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef S_ISREG
|
|
|
|
#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG)
|
|
|
|
#endif
|
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2012-02-26 09:59:00 +08:00
|
|
|
#include <nc_string.h>
|
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
/*
|
2009-05-24 09:18:15 +08:00
|
|
|
* Options for terminal drivers, etc...
|
2009-05-11 07:36:12 +08:00
|
|
|
*/
|
2009-09-20 08:37:00 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
2009-05-24 09:18:15 +08:00
|
|
|
#define USE_SP_RIPOFF 1
|
|
|
|
#define USE_SP_TERMTYPE 1
|
|
|
|
#define USE_SP_WINDOWLIST 1
|
|
|
|
#endif
|
2009-05-11 07:36:12 +08:00
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2007-06-10 08:41:32 +08:00
|
|
|
#define StringOf(ch) {ch, 0}
|
|
|
|
|
1999-10-24 12:32:42 +08:00
|
|
|
#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
|
2010-04-04 09:26:17 +08:00
|
|
|
#undef _XPG5
|
2002-10-13 11:35:53 +08:00
|
|
|
#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
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#define NCURSES_INTERNALS 1
|
2007-03-04 08:18:45 +08:00
|
|
|
#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! */
|
2009-02-15 10:14:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If curses.h did not expose the SCREEN-functions, then we do not need the
|
|
|
|
* parameter in the corresponding unextended functions.
|
|
|
|
*/
|
2010-04-04 09:26:17 +08:00
|
|
|
|
|
|
|
#define USE_SP_FUNC_SUPPORT NCURSES_SP_FUNCS
|
|
|
|
#define USE_EXT_SP_FUNC_SUPPORT (NCURSES_SP_FUNCS && NCURSES_EXT_FUNCS)
|
|
|
|
|
2009-02-15 10:14:18 +08:00
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
#define SP_PARM sp /* use parameter */
|
|
|
|
#define NCURSES_SP_ARG SP_PARM
|
|
|
|
#define NCURSES_SP_DCL SCREEN *NCURSES_SP_ARG
|
|
|
|
#define NCURSES_SP_DCL0 NCURSES_SP_DCL
|
|
|
|
#define NCURSES_SP_ARGx NCURSES_SP_ARG,
|
|
|
|
#define NCURSES_SP_DCLx SCREEN *NCURSES_SP_ARGx
|
|
|
|
#else
|
|
|
|
#define SP_PARM SP /* use global variable */
|
|
|
|
#define NCURSES_SP_ARG
|
|
|
|
#define NCURSES_SP_DCL
|
|
|
|
#define NCURSES_SP_DCL0 void
|
|
|
|
#define NCURSES_SP_ARGx
|
|
|
|
#define NCURSES_SP_DCLx
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <nc_panel.h>
|
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
#define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen)
|
|
|
|
#define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term)))
|
|
|
|
#define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp))
|
|
|
|
|
2009-02-15 10:14:18 +08:00
|
|
|
#if BROKEN_LINKER || USE_REENTRANT
|
2009-05-11 07:36:12 +08:00
|
|
|
#define CurTerm _nc_prescreen._cur_term
|
|
|
|
#else
|
|
|
|
#define CurTerm cur_term
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
#define TerminalOf(sp) ((sp) ? ((sp)->_term ? (sp)->_term : CurTerm) : CurTerm)
|
2009-02-15 10:14:18 +08:00
|
|
|
#else
|
2009-05-11 07:36:12 +08:00
|
|
|
#define TerminalOf(sp) CurTerm
|
2009-02-15 10:14:18 +08:00
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#include <term.h>
|
2011-06-26 08:21:18 +08:00
|
|
|
#include <nc_termios.h>
|
2009-05-11 07:36:12 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reduce dependency on cur_term global by using terminfo data from SCREEN's
|
|
|
|
* pointer to this data.
|
|
|
|
*/
|
|
|
|
#ifdef USE_SP_TERMTYPE
|
|
|
|
#undef CUR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SP_TERMTYPE TerminalOf(sp)->type.
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#include <term_entry.h>
|
2009-05-11 07:36:12 +08:00
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
#include <nc_tparm.h>
|
2005-10-10 02:41:57 +08:00
|
|
|
|
2010-04-04 09:26:17 +08:00
|
|
|
/*
|
|
|
|
* Use these macros internally, to make tracing less verbose. But leave the
|
|
|
|
* option for compiling the tracing into the library.
|
|
|
|
*/
|
|
|
|
#if 1
|
|
|
|
#define ColorPair(n) NCURSES_BITS(n, 0)
|
2010-12-26 09:22:11 +08:00
|
|
|
#define PairNumber(a) (NCURSES_CAST(int,(((unsigned long)(a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
|
2010-04-04 09:26:17 +08:00
|
|
|
#else
|
|
|
|
#define ColorPair(pair) COLOR_PAIR(pair)
|
|
|
|
#define PairNumber(attr) PAIR_NUMBER(attr)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define unColor(n) unColor2(AttrOf(n))
|
|
|
|
#define unColor2(a) ((a) & ALL_BUT_COLOR)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extended-colors stores the color pair in a separate struct-member than the
|
|
|
|
* attributes. But for compatibility, we handle most cases where a program
|
|
|
|
* written for non-extended colors stores the color in the attributes by
|
|
|
|
* checking for a color pair in both places.
|
|
|
|
*/
|
|
|
|
#if NCURSES_EXT_COLORS
|
2005-10-10 02:41:57 +08:00
|
|
|
#define if_EXT_COLORS(stmt) stmt
|
2010-04-04 09:26:17 +08:00
|
|
|
#define SetPair(value,p) SetPair2((value).ext_color, AttrOf(value), p)
|
|
|
|
#define SetPair2(c,a,p) c = (p), \
|
2012-03-11 09:59:25 +08:00
|
|
|
a = (unColor2(a) | (A_COLOR & (unsigned) ColorPair(oldColor(c))))
|
2010-04-04 09:26:17 +08:00
|
|
|
#define GetPair(value) GetPair2((value).ext_color, AttrOf(value))
|
|
|
|
#define GetPair2(c,a) ((c) ? (c) : PairNumber(a))
|
|
|
|
#define oldColor(p) (((p) > 255) ? 255 : (p))
|
|
|
|
#define GET_WINDOW_PAIR(w) GetPair2((w)->_color, (w)->_attrs)
|
2005-10-10 02:41:57 +08:00
|
|
|
#define SET_WINDOW_PAIR(w,p) (w)->_color = (p)
|
|
|
|
#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
|
2009-05-03 08:59:25 +08:00
|
|
|
|
|
|
|
#if NCURSES_SP_FUNCS
|
2012-03-11 09:59:25 +08:00
|
|
|
#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vid_attr)(sp, attr, (short) pair, 0)
|
2005-10-10 02:41:57 +08:00
|
|
|
#else
|
2012-03-11 09:59:25 +08:00
|
|
|
#define VIDATTR(sp,attr,pair) vid_attr(attr, (short) pair, 0)
|
2009-05-03 08:59:25 +08:00
|
|
|
#endif
|
|
|
|
|
2010-04-04 09:26:17 +08:00
|
|
|
#else /* !NCURSES_EXT_COLORS */
|
2009-06-07 08:51:13 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
#define if_EXT_COLORS(stmt) /* nothing */
|
|
|
|
#define SetPair(value,p) RemAttr(value, A_COLOR), \
|
2010-12-26 09:22:11 +08:00
|
|
|
SetAttr(value, AttrOf(value) | (A_COLOR & (attr_t) ColorPair(p)))
|
2010-04-04 09:26:17 +08:00
|
|
|
#define GetPair(value) PairNumber(AttrOf(value))
|
|
|
|
#define GET_WINDOW_PAIR(w) PairNumber(WINDOW_ATTRS(w))
|
2006-12-18 12:32:42 +08:00
|
|
|
#define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \
|
2010-12-26 09:22:11 +08:00
|
|
|
WINDOW_ATTRS(w) |= (A_COLOR & (attr_t) ColorPair(p))
|
2005-10-10 02:41:57 +08:00
|
|
|
#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))
|
2009-05-03 08:59:25 +08:00
|
|
|
|
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
#define VIDATTR(sp,attr,pair) NCURSES_SP_NAME(vidattr)(sp, attr)
|
|
|
|
#else
|
|
|
|
#define VIDATTR(sp,attr,pair) vidattr(attr)
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif
|
|
|
|
|
2010-04-04 09:26:17 +08:00
|
|
|
#endif /* NCURSES_EXT_COLORS */
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2008-06-29 08:12:36 +08:00
|
|
|
#if NCURSES_NO_PADDING
|
|
|
|
#define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding)
|
|
|
|
#define SetNoPadding(sp) _nc_set_no_padding(sp)
|
2009-02-22 10:08:00 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_set_no_padding(SCREEN *);
|
2008-06-29 08:12:36 +08:00
|
|
|
#else
|
|
|
|
#define GetNoPadding(sp) FALSE
|
|
|
|
#define SetNoPadding(sp) /*nothing*/
|
|
|
|
#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)
|
|
|
|
|
2009-08-23 09:14:12 +08:00
|
|
|
#if USE_REENTRANT || NCURSES_SP_FUNCS
|
2009-05-31 07:24:28 +08:00
|
|
|
NCURSES_EXPORT(int *) _nc_ptr_Lines (SCREEN *);
|
|
|
|
NCURSES_EXPORT(int *) _nc_ptr_Cols (SCREEN *);
|
|
|
|
NCURSES_EXPORT(int *) _nc_ptr_Tabsize (SCREEN *);
|
|
|
|
NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *);
|
2009-08-23 09:14:12 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_REENTRANT
|
2009-05-31 07:24:28 +08:00
|
|
|
|
2009-04-19 08:38:07 +08:00
|
|
|
#define ptrLines(sp) (sp ? &(sp->_LINES) : &(_nc_prescreen._LINES))
|
|
|
|
#define ptrCols(sp) (sp ? &(sp->_COLS) : &(_nc_prescreen._COLS))
|
2009-05-31 07:24:28 +08:00
|
|
|
#define ptrTabsize(sp) (sp ? &(sp->_TABSIZE) : &(_nc_prescreen._TABSIZE))
|
|
|
|
#define ptrEscdelay(sp) (sp ? &(sp->_ESCDELAY) : &(_nc_prescreen._ESCDELAY))
|
|
|
|
|
|
|
|
#define SET_LINES(value) *_nc_ptr_Lines(SP_PARM) = value
|
|
|
|
#define SET_COLS(value) *_nc_ptr_Cols(SP_PARM) = value
|
|
|
|
#define SET_TABSIZE(value) *_nc_ptr_Tabsize(SP_PARM) = value
|
|
|
|
#define SET_ESCDELAY(value) *_nc_ptr_Escdelay(SP_PARM) = value
|
|
|
|
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#else
|
2009-05-31 07:24:28 +08:00
|
|
|
|
2009-04-19 08:38:07 +08:00
|
|
|
#define ptrLines(sp) &LINES
|
|
|
|
#define ptrCols(sp) &COLS
|
2009-07-05 07:55:21 +08:00
|
|
|
#define ptrTabsize(sp) &TABSIZE
|
|
|
|
#define ptrEscdelay(sp) &ESCDELAY
|
|
|
|
|
2009-04-19 08:38:07 +08:00
|
|
|
#define SET_LINES(value) LINES = value
|
|
|
|
#define SET_COLS(value) COLS = value
|
2009-05-31 07:24:28 +08:00
|
|
|
#define SET_TABSIZE(value) TABSIZE = value
|
|
|
|
#define SET_ESCDELAY(value) ESCDELAY = value
|
|
|
|
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#endif
|
|
|
|
|
2007-12-23 09:43:39 +08:00
|
|
|
#define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \
|
|
|
|
__FILE__, __LINE__, \
|
|
|
|
(unsigned long) (pthread_self()), \
|
|
|
|
data.__data.__lock, \
|
|
|
|
data.__data.__count, \
|
|
|
|
data.__data.__owner, \
|
|
|
|
data.__data.__kind, \
|
|
|
|
(data.__data.__nusers > 5) ? " OOPS " : "", \
|
|
|
|
data.__data.__nusers)
|
|
|
|
#define TR_GLOBAL_MUTEX(name) TR_MUTEX(_nc_globals.mutex_##name)
|
|
|
|
|
2010-05-16 08:56:17 +08:00
|
|
|
#if USE_WEAK_SYMBOLS
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
# if defined __USE_ISOC99
|
|
|
|
# define _cat_pragma(exp) _Pragma(#exp)
|
|
|
|
# define _weak_pragma(exp) _cat_pragma(weak name)
|
|
|
|
# else
|
|
|
|
# define _weak_pragma(exp)
|
|
|
|
# endif
|
|
|
|
# define _declare(name) __extension__ extern __typeof__(name) name
|
|
|
|
# define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak))
|
2012-03-04 08:07:09 +08:00
|
|
|
#else
|
|
|
|
# undef USE_WEAK_SYMBOLS
|
|
|
|
# define USE_WEAK_SYMBOLS 0
|
2010-05-16 08:56:17 +08:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2007-09-02 08:20:31 +08:00
|
|
|
#ifdef USE_PTHREADS
|
2008-02-24 09:25:21 +08:00
|
|
|
|
2007-09-02 08:20:31 +08:00
|
|
|
#if USE_REENTRANT
|
|
|
|
#include <pthread.h>
|
2008-08-17 09:51:55 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_init_pthreads(void);
|
2008-02-24 09:25:21 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_mutex_init(pthread_mutex_t *);
|
2008-01-13 10:05:47 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *);
|
|
|
|
#define _nc_lock_global(name) _nc_mutex_lock(&_nc_globals.mutex_##name)
|
|
|
|
#define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name)
|
|
|
|
#define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name)
|
2007-10-21 07:21:19 +08:00
|
|
|
|
2007-09-02 08:20:31 +08:00
|
|
|
#else
|
|
|
|
#error POSIX threads requires --enable-reentrant option
|
|
|
|
#endif
|
2008-02-24 09:25:21 +08:00
|
|
|
|
2008-08-17 09:51:55 +08:00
|
|
|
#ifdef USE_PTHREADS
|
|
|
|
# if USE_WEAK_SYMBOLS
|
|
|
|
weak_symbol(pthread_sigmask);
|
2011-01-23 09:23:10 +08:00
|
|
|
weak_symbol(pthread_kill);
|
2008-08-17 09:51:55 +08:00
|
|
|
weak_symbol(pthread_self);
|
|
|
|
weak_symbol(pthread_equal);
|
|
|
|
weak_symbol(pthread_mutex_init);
|
|
|
|
weak_symbol(pthread_mutex_lock);
|
|
|
|
weak_symbol(pthread_mutex_unlock);
|
|
|
|
weak_symbol(pthread_mutex_trylock);
|
|
|
|
weak_symbol(pthread_mutexattr_settype);
|
2008-09-08 01:49:37 +08:00
|
|
|
weak_symbol(pthread_mutexattr_init);
|
2008-08-17 09:51:55 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
|
|
|
|
# undef sigprocmask
|
|
|
|
# define sigprocmask _nc_sigprocmask
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2008-02-24 09:25:21 +08:00
|
|
|
#if HAVE_NANOSLEEP
|
|
|
|
#undef HAVE_NANOSLEEP
|
|
|
|
#define HAVE_NANOSLEEP 0 /* nanosleep suspends all threads */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else /* !USE_PTHREADS */
|
|
|
|
|
2010-05-16 08:56:17 +08:00
|
|
|
#if USE_PTHREADS_EINTR
|
|
|
|
# if USE_WEAK_SYMBOLS
|
|
|
|
#include <pthread.h>
|
|
|
|
weak_symbol(pthread_sigmask);
|
|
|
|
weak_symbol(pthread_kill);
|
|
|
|
weak_symbol(pthread_self);
|
|
|
|
weak_symbol(pthread_equal);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *);
|
|
|
|
# undef sigprocmask
|
|
|
|
# define sigprocmask _nc_sigprocmask
|
|
|
|
# endif
|
|
|
|
#endif /* USE_PTHREADS_EINTR */
|
|
|
|
|
2008-08-17 09:51:55 +08:00
|
|
|
#define _nc_init_pthreads() /* nothing */
|
2008-02-24 09:25:21 +08:00
|
|
|
#define _nc_mutex_init(obj) /* nothing */
|
|
|
|
|
2007-09-09 06:25:05 +08:00
|
|
|
#define _nc_lock_global(name) /* nothing */
|
2007-12-23 09:43:39 +08:00
|
|
|
#define _nc_try_global(name) 0
|
2007-09-09 06:25:05 +08:00
|
|
|
#define _nc_unlock_global(name) /* nothing */
|
2007-10-21 07:21:19 +08:00
|
|
|
|
2008-02-24 09:25:21 +08:00
|
|
|
#endif /* USE_PTHREADS */
|
2007-09-02 08:20:31 +08:00
|
|
|
|
2009-09-06 08:18:02 +08:00
|
|
|
/*
|
|
|
|
* When using sp-funcs, locks are targeted to SCREEN-level granularity.
|
|
|
|
* So the locking is done in the non-sp-func (which calls the sp-func) rather
|
|
|
|
* than in the sp-func itself.
|
|
|
|
*
|
|
|
|
* Use the _nc_nonsp_XXX functions in the function using "NCURSES_SP_NAME()".
|
|
|
|
* Use the _nc_sp_XXX functions in the function using "#if NCURSES_SP_FUNCS".
|
|
|
|
*/
|
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
|
|
|
|
#define _nc_nonsp_lock_global(name) /* nothing */
|
|
|
|
#define _nc_nonsp_try_global(name) 0
|
|
|
|
#define _nc_nonsp_unlock_global(name) /* nothing */
|
|
|
|
|
|
|
|
#define _nc_sp_lock_global(name) _nc_lock_global(name)
|
|
|
|
#define _nc_sp_try_global(name) _nc_try_global(name)
|
|
|
|
#define _nc_sp_unlock_global(name) _nc_unlock_global(name)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define _nc_nonsp_lock_global(name) _nc_lock_global(name)
|
|
|
|
#define _nc_nonsp_try_global(name) _nc_try_global(name)
|
|
|
|
#define _nc_nonsp_unlock_global(name) _nc_unlock_global(name)
|
|
|
|
|
|
|
|
#define _nc_sp_lock_global(name) /* nothing */
|
|
|
|
#define _nc_sp_try_global(name) 0
|
|
|
|
#define _nc_sp_unlock_global(name) /* nothing */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-03-02 08:28:54 +08:00
|
|
|
#if HAVE_GETTIMEOFDAY
|
|
|
|
# define PRECISE_GETTIME 1
|
|
|
|
# define TimeType struct timeval
|
|
|
|
#else
|
|
|
|
# define PRECISE_GETTIME 0
|
|
|
|
# define TimeType time_t
|
|
|
|
#endif
|
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
/*
|
|
|
|
* 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)
|
2010-04-25 09:40:39 +08:00
|
|
|
#define PAIR_OF(fg, bg) (colorpair_t) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
|
2009-01-25 10:04:12 +08:00
|
|
|
#define FORE_OF(c) (((c) >> C_SHIFT) & C_MASK)
|
|
|
|
#define BACK_OF(c) ((c) & C_MASK)
|
2005-10-10 02:41:57 +08:00
|
|
|
#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
|
|
|
|
|
2010-03-14 05:18:05 +08:00
|
|
|
#if defined(USE_BUILD_CC) || (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
|
2010-02-07 09:40:29 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
|
|
|
,M_TERM_DRIVER /* Win32 console, etc */
|
|
|
|
#endif
|
2004-02-09 10:15:26 +08:00
|
|
|
} 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;
|
|
|
|
|
2010-03-14 05:18:05 +08:00
|
|
|
#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
|
2005-10-10 02:41:57 +08:00
|
|
|
|
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 {
|
2009-02-22 10:08:00 +08:00
|
|
|
bool dirty; /* all labels have changed */
|
|
|
|
bool hidden; /* soft labels are hidden */
|
|
|
|
WINDOW *win;
|
1998-03-01 12:21:12 +08:00
|
|
|
slk_ent *ent;
|
2009-02-22 10:08:00 +08:00
|
|
|
short maxlab; /* number of available labels */
|
|
|
|
short labcnt; /* number of allocated labels */
|
|
|
|
short maxlen; /* length of labels */
|
2006-12-18 12:32:42 +08:00
|
|
|
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 {
|
2008-01-06 10:04:59 +08:00
|
|
|
WINDOW *win; /* the window used in the hook */
|
2006-12-18 12:32:42 +08:00
|
|
|
int line; /* lines to take, < 0 => from bottom*/
|
|
|
|
int (*hook)(WINDOW *, int); /* callback for user */
|
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>
|
2012-03-04 08:07:09 +08:00
|
|
|
#if USE_WEAK_SYMBOLS
|
|
|
|
weak_symbol(Gpm_Wgetch);
|
|
|
|
#endif
|
2006-12-18 12:32:42 +08:00
|
|
|
|
|
|
|
#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 *);
|
|
|
|
|
2009-04-19 08:38:07 +08:00
|
|
|
#define my_gpm_fd SP_PARM->_mouse_gpm_fd
|
|
|
|
#define my_Gpm_Open SP_PARM->_mouse_Gpm_Open
|
|
|
|
#define my_Gpm_Close SP_PARM->_mouse_Gpm_Close
|
|
|
|
#define my_Gpm_GetEvent SP_PARM->_mouse_Gpm_GetEvent
|
2006-12-18 12:32:42 +08:00
|
|
|
#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 */
|
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
typedef struct {
|
|
|
|
long sequence;
|
|
|
|
bool last_used;
|
|
|
|
char *fix_sgr0; /* this holds the filtered sgr0 string */
|
|
|
|
char *last_bufp; /* help with fix_sgr0 leak */
|
|
|
|
TERMINAL *last_term;
|
|
|
|
} TGETENT_CACHE;
|
|
|
|
|
|
|
|
#define TGETENT_MAX 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* State of tparm().
|
|
|
|
*/
|
|
|
|
#define STACKSIZE 20
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
union {
|
|
|
|
int num;
|
|
|
|
char *str;
|
|
|
|
} data;
|
|
|
|
bool num_type;
|
|
|
|
} STACK_FRAME;
|
|
|
|
|
|
|
|
#define NUM_VARS 26
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
#ifdef TRACE
|
|
|
|
const char *tname;
|
|
|
|
#endif
|
|
|
|
const char *tparam_base;
|
|
|
|
|
|
|
|
STACK_FRAME stack[STACKSIZE];
|
|
|
|
int stack_ptr;
|
|
|
|
|
|
|
|
char *out_buff;
|
|
|
|
size_t out_size;
|
|
|
|
size_t out_used;
|
|
|
|
|
|
|
|
char *fmt_buff;
|
|
|
|
size_t fmt_size;
|
|
|
|
|
|
|
|
int dynamic_var[NUM_VARS];
|
|
|
|
int static_vars[NUM_VARS];
|
|
|
|
} TPARM_STATE;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *text;
|
|
|
|
size_t size;
|
|
|
|
} TRACEBUF;
|
|
|
|
|
2007-11-18 10:09:05 +08:00
|
|
|
/*
|
|
|
|
* The filesystem database normally uses a single-letter for the lower level
|
|
|
|
* of directories. Use a hexadecimal code for filesystems which do not
|
|
|
|
* preserve mixed-case names.
|
|
|
|
*/
|
|
|
|
#if MIXEDCASE_FILENAMES
|
|
|
|
#define LEAF_FMT "%c"
|
2009-12-06 09:32:45 +08:00
|
|
|
#define LEAF_LEN 1
|
2007-11-18 10:09:05 +08:00
|
|
|
#else
|
|
|
|
#define LEAF_FMT "%02x"
|
2009-12-06 09:32:45 +08:00
|
|
|
#define LEAF_LEN 2
|
2007-11-18 10:09:05 +08:00
|
|
|
#endif
|
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
/*
|
|
|
|
* TRACEMSE_FMT is no longer than 80 columns, there are 5 numbers that
|
|
|
|
* could at most have 10 digits, and the mask contains no more than 32 bits
|
|
|
|
* with each bit representing less than 15 characters. Usually the whole
|
|
|
|
* string is less than 80 columns, but this buffer size is an absolute
|
|
|
|
* limit.
|
|
|
|
*/
|
|
|
|
#define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15))
|
|
|
|
#define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */
|
|
|
|
|
2009-11-29 10:00:36 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
|
|
|
struct DriverTCB; /* Terminal Control Block forward declaration */
|
|
|
|
#define INIT_TERM_DRIVER() _nc_globals.term_driver = _nc_get_driver
|
|
|
|
#else
|
|
|
|
#define INIT_TERM_DRIVER() /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2011-10-09 08:51:26 +08:00
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
char *value;
|
|
|
|
} ITERATOR_VARS;
|
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
/*
|
|
|
|
* Global data which is not specific to a screen.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
SIG_ATOMIC_T have_sigwinch;
|
|
|
|
SIG_ATOMIC_T cleanup_nested;
|
|
|
|
|
|
|
|
bool init_signals;
|
|
|
|
bool init_screen;
|
|
|
|
|
ncurses 5.9 - patch 20110730
+ modify configure script and makefiles in c++ and progs to allow the
directory used for rpath option to be overridden, e.g., to work
around updates to the variables used by tic during an install.
+ add -K option to tic/infocmp, to provide stricter BSD-compatibility
for termcap output.
+ add _nc_strict_bsd variable in tic library which controls the
"strict" BSD termcap compatibility from 20110723, plus these
features:
+ allow escapes such as "\8" and "\9" when reading termcap
+ disallow "\a", "\e", "\l", "\s" and "\:" escapes when reading
termcap files, passing through "a", "e", etc.
+ expand "\:" as "\072" on output.
+ modify _nc_get_token() to reset the token's string value in case
there is a string-typed token lacking the "=" marker.
+ fix a few memory leaks in _nc_tgetent.
+ fix a few places where reading from a termcap file could refer to
freed memory.
+ add an overflow check when converting terminfo/termcap numeric
values, since terminfo stores those in a short, and they must be
positive.
+ correct internal variables used for translating to termcap "%>"
feature, and translating from termcap %B to terminfo, needed by
tctest (cf: 19991211).
+ amend a minor fix to acsc when loading a termcap file to separate it
from warnings needed for tic (cf: 20040710)
+ modify logic in _nc_read_entry() and _nc_read_tic_entry() to allow
a termcap file to be handled via TERMINFO_DIRS.
+ modify _nc_infotocap() to include non-mandatory padding when
translating to termcap.
+ modify _nc_read_termcap_entry(), passing a flag in the case where
getcap is used, to reduce interactive warning messages.
2011-07-31 09:15:59 +08:00
|
|
|
char *comp_sourcename;
|
2007-04-22 08:57:08 +08:00
|
|
|
char *comp_termtype;
|
|
|
|
|
|
|
|
bool have_tic_directory;
|
|
|
|
bool keep_tic_directory;
|
|
|
|
const char *tic_directory;
|
|
|
|
|
|
|
|
char *dbi_list;
|
|
|
|
int dbi_size;
|
|
|
|
|
|
|
|
char *first_name;
|
|
|
|
char **keyname_table;
|
|
|
|
|
2008-01-13 10:05:47 +08:00
|
|
|
int slk_format;
|
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
char *safeprint_buf;
|
|
|
|
size_t safeprint_used;
|
|
|
|
|
|
|
|
TGETENT_CACHE tgetent_cache[TGETENT_MAX];
|
|
|
|
int tgetent_index;
|
|
|
|
long tgetent_sequence;
|
|
|
|
|
2011-10-09 08:51:26 +08:00
|
|
|
char *dbd_blob; /* string-heap for dbd_list[] */
|
|
|
|
char **dbd_list; /* distinct places to look for data */
|
|
|
|
int dbd_size; /* length of dbd_list[] */
|
|
|
|
time_t dbd_time; /* cache last updated */
|
|
|
|
ITERATOR_VARS dbd_vars[dbdLAST];
|
|
|
|
|
2009-05-24 09:18:15 +08:00
|
|
|
#ifndef USE_SP_WINDOWLIST
|
2008-03-30 07:48:44 +08:00
|
|
|
WINDOWLIST *_nc_windowlist;
|
2009-05-11 07:36:12 +08:00
|
|
|
#define WindowList(sp) _nc_globals._nc_windowlist
|
2009-05-24 09:18:15 +08:00
|
|
|
#endif
|
2008-03-30 07:48:44 +08:00
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
#if USE_HOME_TERMINFO
|
|
|
|
char *home_terminfo;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !USE_SAFE_SPRINTF
|
|
|
|
int safeprint_cols;
|
|
|
|
int safeprint_rows;
|
|
|
|
#endif
|
|
|
|
|
2009-11-29 10:00:36 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
|
|
|
int (*term_driver)(struct DriverTCB*, const char*, int*);
|
|
|
|
#endif
|
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
#ifdef TRACE
|
|
|
|
bool init_trace;
|
|
|
|
char trace_fname[PATH_MAX];
|
|
|
|
int trace_level;
|
|
|
|
FILE *trace_fp;
|
|
|
|
|
|
|
|
char *tracearg_buf;
|
|
|
|
size_t tracearg_used;
|
|
|
|
|
|
|
|
TRACEBUF *tracebuf_ptr;
|
|
|
|
size_t tracebuf_used;
|
|
|
|
|
|
|
|
char tracechr_buf[40];
|
|
|
|
|
|
|
|
char *tracedmp_buf;
|
|
|
|
size_t tracedmp_used;
|
|
|
|
|
|
|
|
unsigned char *tracetry_buf;
|
|
|
|
size_t tracetry_used;
|
|
|
|
|
|
|
|
char traceatr_color_buf[2][80];
|
|
|
|
int traceatr_color_sel;
|
|
|
|
int traceatr_color_last;
|
2009-05-11 07:36:12 +08:00
|
|
|
#if !defined(USE_PTHREADS) && USE_REENTRANT
|
|
|
|
int nested_tracef;
|
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
#endif /* TRACE */
|
2007-09-02 08:20:31 +08:00
|
|
|
|
|
|
|
#ifdef USE_PTHREADS
|
2008-08-17 09:51:55 +08:00
|
|
|
pthread_mutex_t mutex_curses;
|
|
|
|
pthread_mutex_t mutex_tst_tracef;
|
|
|
|
pthread_mutex_t mutex_tracef;
|
|
|
|
int nested_tracef;
|
|
|
|
int use_pthreads;
|
|
|
|
#define _nc_use_pthreads _nc_globals.use_pthreads
|
2007-09-02 08:20:31 +08:00
|
|
|
#endif
|
2010-05-16 08:56:17 +08:00
|
|
|
#if USE_PTHREADS_EINTR
|
|
|
|
pthread_t read_thread; /* The reading thread */
|
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
} NCURSES_GLOBALS;
|
|
|
|
|
|
|
|
extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals;
|
|
|
|
|
2007-05-13 08:52:59 +08:00
|
|
|
#define N_RIPS 5
|
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
/*
|
2008-04-13 09:03:15 +08:00
|
|
|
* Global data which can be swept up into a SCREEN when one is created.
|
2007-04-22 08:57:08 +08:00
|
|
|
* It may be modified before the next SCREEN is created.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
bool use_env;
|
|
|
|
bool filter_mode;
|
|
|
|
attr_t previous_attr;
|
2009-05-24 09:18:15 +08:00
|
|
|
#ifndef USE_SP_RIPOFF
|
2007-05-13 08:52:59 +08:00
|
|
|
ripoff_t rippedoff[N_RIPS];
|
2007-04-22 08:57:08 +08:00
|
|
|
ripoff_t *rsp;
|
2009-05-24 09:18:15 +08:00
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
TPARM_STATE tparm_state;
|
2007-05-27 07:44:27 +08:00
|
|
|
TTY *saved_tty; /* savetty/resetty information */
|
2008-06-29 08:12:36 +08:00
|
|
|
#if NCURSES_NO_PADDING
|
|
|
|
bool _no_padding; /* flag to set if padding disabled */
|
|
|
|
#endif
|
2009-11-22 09:54:35 +08:00
|
|
|
NCURSES_SP_OUTC _outch; /* output handler if not putc */
|
2007-04-22 08:57:08 +08:00
|
|
|
#if BROKEN_LINKER || USE_REENTRANT
|
|
|
|
chtype *real_acs_map;
|
2007-07-17 06:24:03 +08:00
|
|
|
int _LINES;
|
|
|
|
int _COLS;
|
2009-05-31 07:24:28 +08:00
|
|
|
int _TABSIZE;
|
|
|
|
int _ESCDELAY;
|
2008-05-25 08:49:27 +08:00
|
|
|
TERMINAL *_cur_term;
|
2007-09-30 07:30:37 +08:00
|
|
|
#ifdef TRACE
|
|
|
|
long _outchars;
|
|
|
|
const char *_tputs_trace;
|
|
|
|
#endif
|
2007-04-22 08:57:08 +08:00
|
|
|
#endif
|
|
|
|
} NCURSES_PRESCREEN;
|
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
/*
|
|
|
|
* Use screen-specific ripoff data (for softkeys) rather than global.
|
|
|
|
*/
|
|
|
|
#ifdef USE_SP_RIPOFF
|
|
|
|
#define safe_ripoff_sp (sp)->rsp
|
|
|
|
#define safe_ripoff_stack (sp)->rippedoff
|
|
|
|
#else
|
|
|
|
#define safe_ripoff_sp _nc_prescreen.rsp
|
|
|
|
#define safe_ripoff_stack _nc_prescreen.rippedoff
|
|
|
|
#endif
|
2008-01-06 10:04:59 +08:00
|
|
|
|
2007-04-22 08:57:08 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen;
|
|
|
|
|
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 */
|
2009-02-22 10:08:00 +08:00
|
|
|
bool _prescreen; /* is in prescreen phase */
|
|
|
|
bool _use_env; /* LINES & COLS from environment? */
|
2006-12-18 12:32:42 +08:00
|
|
|
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 */
|
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
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
#define CurScreen(sp) (sp)->_curscr
|
|
|
|
#define NewScreen(sp) (sp)->_newscr
|
|
|
|
#define StdScreen(sp) (sp)->_stdscr
|
|
|
|
|
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
|
2008-06-29 08:12:36 +08:00
|
|
|
bool _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 */
|
2009-01-25 10:04:12 +08:00
|
|
|
int _pair_limit; /* actual limit of color-pairs */
|
2000-10-21 12:42:11 +08:00
|
|
|
#if NCURSES_EXT_FUNCS
|
2011-04-24 08:53:45 +08:00
|
|
|
bool _assumed_color; /* use assumed colors */
|
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 */
|
2009-01-25 10:04:12 +08:00
|
|
|
int _default_pairs; /* count pairs using default color */
|
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
|
|
|
|
2012-01-22 09:23:31 +08:00
|
|
|
#if USE_KLIBC_KBD
|
|
|
|
bool _extended_key; /* true if an extended key */
|
|
|
|
#endif
|
|
|
|
|
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;
|
2009-06-07 08:51:13 +08:00
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
/*
|
|
|
|
* 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 *);
|
2008-06-01 07:49:39 +08:00
|
|
|
bool (*_mouse_parse) (SCREEN *, int);
|
2006-12-18 12:32:42 +08:00
|
|
|
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 */
|
2011-10-23 09:04:18 +08:00
|
|
|
mmask_t _mouse_mask; /* set via mousemask() */
|
|
|
|
mmask_t _mouse_mask2; /* OR's in press/release bits */
|
2011-09-18 09:02:06 +08:00
|
|
|
mmask_t _mouse_bstate;
|
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
|
2008-09-21 09:01:25 +08:00
|
|
|
void *_dlopen_gpm;
|
2006-12-18 12:32:42 +08:00
|
|
|
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
|
|
|
|
2010-02-07 09:40:29 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
|
|
|
MEVENT _drv_mouse_fifo[FIFO_SIZE];
|
|
|
|
int _drv_mouse_head;
|
|
|
|
int _drv_mouse_tail;
|
|
|
|
int _drv_mouse_old_buttons;
|
|
|
|
int _drv_mouse_new_buttons;
|
|
|
|
#endif
|
1998-03-01 12:21:12 +08:00
|
|
|
/*
|
|
|
|
* This supports automatic resizing
|
|
|
|
*/
|
|
|
|
#if USE_SIZECHANGE
|
2009-06-07 08:51:13 +08:00
|
|
|
int (*_resize)(NCURSES_SP_DCLx int y, int x);
|
1998-03-01 12:21:12 +08:00
|
|
|
#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
|
|
|
|
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 */
|
2009-05-11 07:36:12 +08:00
|
|
|
NCURSES_SP_OUTC _outch; /* 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 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#if USE_REENTRANT
|
|
|
|
char _ttytype[NAMESIZE];
|
|
|
|
int _ESCDELAY;
|
|
|
|
int _TABSIZE;
|
|
|
|
int _LINES;
|
|
|
|
int _COLS;
|
2007-09-30 07:30:37 +08:00
|
|
|
#ifdef TRACE
|
2008-04-13 09:03:15 +08:00
|
|
|
long _outchars;
|
2007-09-30 07:30:37 +08:00
|
|
|
const char *_tputs_trace;
|
|
|
|
#endif
|
2008-06-01 07:49:39 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TRACE
|
|
|
|
char tracechr_buf[40];
|
|
|
|
char tracemse_buf[TRACEMSE_MAX];
|
ncurses 5.6 - patch 20070310
+ increase size of array in _nc_visbuf2n() to make "tic -v" work
properly in its similar_sgr() function (report/analysis by Peter
Santoro).
+ add --enable-reentrant configure option for ongoing changes to
implement a reentrant version of ncurses:
+ libraries are suffixed with "t"
+ wrap several global variables (curscr, newscr, stdscr, ttytype,
COLORS, COLOR_PAIRS, COLS, ESCDELAY, LINES and TABSIZE) as
functions returning values stored in SCREEN or cur_term.
+ move some initialization (LINES, COLS) from lib_setup.c,
i.e., setupterm() to _nc_setupscreen(), i.e., newterm().
2007-03-11 09:07:00 +08:00
|
|
|
#endif
|
2009-05-24 09:18:15 +08:00
|
|
|
#ifdef USE_SP_WINDOWLIST
|
2009-05-11 07:36:12 +08:00
|
|
|
WINDOWLIST* _windowlist;
|
|
|
|
#define WindowList(sp) (sp)->_windowlist
|
|
|
|
#endif
|
|
|
|
NCURSES_OUTC jump;
|
|
|
|
|
|
|
|
ripoff_t rippedoff[N_RIPS];
|
|
|
|
ripoff_t *rsp;
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
/*
|
|
|
|
* 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;
|
2007-04-22 08:57:08 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
WINDOWLIST {
|
|
|
|
WINDOWLIST *next;
|
2008-06-01 07:49:39 +08:00
|
|
|
SCREEN *screen; /* screen containing the window */
|
2010-01-24 09:42:57 +08:00
|
|
|
WINDOW win; /* WINDOW_EXT() needs to account for offset */
|
2011-10-31 07:32:22 +08:00
|
|
|
#if NCURSES_WIDECHAR
|
2004-02-09 10:15:26 +08:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2010-12-26 09:22:11 +08:00
|
|
|
#define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m)
|
2004-02-09 10:15:26 +08:00
|
|
|
|
2009-04-19 08:38:07 +08:00
|
|
|
#define SP_PRE_INIT(sp) \
|
|
|
|
sp->_cursrow = -1; \
|
|
|
|
sp->_curscol = -1; \
|
|
|
|
sp->_nl = TRUE; \
|
|
|
|
sp->_raw = FALSE; \
|
|
|
|
sp->_cbreak = 0; \
|
|
|
|
sp->_echo = TRUE; \
|
|
|
|
sp->_fifohead = -1; \
|
|
|
|
sp->_endwin = TRUE; \
|
|
|
|
sp->_cursor = -1; \
|
2009-05-11 07:36:12 +08:00
|
|
|
WindowList(sp) = 0; \
|
2009-04-19 08:38:07 +08:00
|
|
|
sp->_outch = NCURSES_SP_NAME(_nc_outch); \
|
|
|
|
sp->jump = 0 \
|
|
|
|
|
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
|
2007-09-30 07:30:37 +08:00
|
|
|
#if USE_REENTRANT
|
|
|
|
#define COUNT_OUTCHARS(n) _nc_count_outchars(n);
|
|
|
|
#else
|
|
|
|
#define COUNT_OUTCHARS(n) _nc_outchars += (n);
|
|
|
|
#endif
|
2004-02-09 10:15:26 +08:00
|
|
|
#else
|
2007-09-30 07:30:37 +08:00
|
|
|
#define COUNT_OUTCHARS(n) /* nothing */
|
2004-02-09 10:15:26 +08:00
|
|
|
#endif
|
|
|
|
|
2007-09-30 07:30:37 +08:00
|
|
|
#define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars)
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#define UChar(c) ((unsigned char)(c))
|
2010-04-25 09:40:39 +08:00
|
|
|
#define UShort(c) ((unsigned short)(c))
|
2002-10-13 11:35:53 +08:00
|
|
|
#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 /* { */
|
2007-11-25 10:05:21 +08:00
|
|
|
#define isEILSEQ(status) (((size_t)status == (size_t)-1) && (errno == EILSEQ))
|
2005-10-10 02:41:57 +08:00
|
|
|
|
|
|
|
#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)
|
2007-10-14 08:38:28 +08:00
|
|
|
|
2007-06-03 08:04:38 +08:00
|
|
|
#define AddAttr(c,a) AttrOf(c) |= ((a) & A_ATTRIBUTES)
|
2006-12-18 12:32:42 +08:00
|
|
|
#define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES)
|
2007-06-03 08:04:38 +08:00
|
|
|
#define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c)
|
2007-10-14 08:38:28 +08:00
|
|
|
|
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))
|
2007-10-14 08:38:28 +08:00
|
|
|
|
|
|
|
#if CCHARW_MAX == 5
|
|
|
|
#define CharEq(a,b) (((a).attr == (b).attr) \
|
|
|
|
&& (a).chars[0] == (b).chars[0] \
|
|
|
|
&& (a).chars[1] == (b).chars[1] \
|
|
|
|
&& (a).chars[2] == (b).chars[2] \
|
|
|
|
&& (a).chars[3] == (b).chars[3] \
|
|
|
|
&& (a).chars[4] == (b).chars[4] \
|
|
|
|
if_EXT_COLORS(&& (a).ext_color == (b).ext_color))
|
|
|
|
#else
|
|
|
|
#define CharEq(a,b) (!memcmp(&(a), &(b), sizeof(a)))
|
|
|
|
#endif
|
|
|
|
|
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)); \
|
2010-12-26 09:22:11 +08:00
|
|
|
_cp->chars[0] = (wchar_t) (c); \
|
2006-12-18 12:32:42 +08:00
|
|
|
_cp->attr = (a); \
|
2010-04-04 09:26:17 +08:00
|
|
|
if_EXT_COLORS(SetPair(ch, PairNumber(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); \
|
2007-09-30 07:30:37 +08:00
|
|
|
COUNT_OUTCHARS(1); \
|
2004-02-09 10:15:26 +08:00
|
|
|
} 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; \
|
2010-12-26 09:22:11 +08:00
|
|
|
PUTC_n = (int) 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
|
|
|
} \
|
2011-10-23 09:04:18 +08:00
|
|
|
IGNORE_RC(fwrite(PUTC_buf, (size_t) PUTC_n, (size_t) 1, b)); \
|
2006-12-18 12:32:42 +08:00
|
|
|
} \
|
2007-09-30 07:30:37 +08:00
|
|
|
COUNT_OUTCHARS(PUTC_i); \
|
2004-02-09 10:15:26 +08:00
|
|
|
} } } while (0)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2007-10-07 07:01:06 +08:00
|
|
|
#define BLANK NewChar2(' ', WA_NORMAL)
|
|
|
|
#define ZEROS NewChar2('\0', WA_NORMAL)
|
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.
|
|
|
|
*/
|
2010-12-26 09:22:11 +08:00
|
|
|
#define WidecExt(ch) (int) (AttrOf(ch) & A_CHARTEXT)
|
2005-10-10 02:41:57 +08:00
|
|
|
#define isWidecBase(ch) (WidecExt(ch) == 1)
|
|
|
|
#define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32)
|
|
|
|
#define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \
|
2010-04-25 09:40:39 +08:00
|
|
|
AttrOf(dst) |= (attr_t) (ext + 1)
|
2005-10-10 02:41:57 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#define if_WIDEC(code) code
|
2009-04-26 09:00:20 +08:00
|
|
|
#define Charable(ch) ((SP_PARM != 0 && SP_PARM->_legacy_coding) \
|
2005-10-10 02:41:57 +08:00
|
|
|
|| (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) \
|
2011-05-15 08:38:25 +08:00
|
|
|
line->firstchar = line->lastchar = (NCURSES_SIZE_T) (col); \
|
1999-10-24 12:32:42 +08:00
|
|
|
else if ((col) < line->firstchar) \
|
2011-05-15 08:38:25 +08:00
|
|
|
line->firstchar = (NCURSES_SIZE_T) (col); \
|
1999-10-24 12:32:42 +08:00
|
|
|
else if ((col) > line->lastchar) \
|
2011-05-15 08:38:25 +08:00
|
|
|
line->lastchar = (NCURSES_SIZE_T) (col)
|
1999-10-24 12:32:42 +08:00
|
|
|
|
|
|
|
#define CHANGED_RANGE(line,start,end) \
|
|
|
|
if (line->firstchar == _NOCHANGE \
|
|
|
|
|| line->firstchar > (start)) \
|
2011-05-15 08:38:25 +08:00
|
|
|
line->firstchar = (NCURSES_SIZE_T) (start); \
|
1999-10-24 12:32:42 +08:00
|
|
|
if (line->lastchar == _NOCHANGE \
|
|
|
|
|| line->lastchar < (end)) \
|
2011-05-15 08:38:25 +08:00
|
|
|
line->lastchar = (NCURSES_SIZE_T) (end)
|
1999-10-24 12:32:42 +08:00
|
|
|
|
|
|
|
#define CHANGED_TO_EOL(line,start,end) \
|
|
|
|
if (line->firstchar == _NOCHANGE \
|
|
|
|
|| line->firstchar > (start)) \
|
2011-05-15 08:38:25 +08:00
|
|
|
line->firstchar = (NCURSES_SIZE_T) (start); \
|
|
|
|
line->lastchar = (NCURSES_SIZE_T) (end)
|
1999-10-24 12:32:42 +08:00
|
|
|
|
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
|
|
|
|
|
2008-05-04 08:48:16 +08:00
|
|
|
/*
|
|
|
|
* Standardize/simplify common loops
|
|
|
|
*/
|
|
|
|
#define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen
|
2009-05-11 07:36:12 +08:00
|
|
|
#define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next
|
|
|
|
#define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p
|
2008-05-04 08:48:16 +08:00
|
|
|
|
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
|
|
|
|
2007-09-30 07:30:37 +08:00
|
|
|
#if USE_REENTRANT
|
|
|
|
#define TPUTS_TRACE(s) _nc_set_tputs_trace(s);
|
|
|
|
#else
|
|
|
|
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
|
|
|
|
#endif
|
|
|
|
|
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); \
|
|
|
|
}
|
|
|
|
|
2007-09-30 07:30:37 +08:00
|
|
|
/*
|
|
|
|
* Many of the _tracef() calls use static buffers; lock the trace state before
|
|
|
|
* trying to fill them.
|
|
|
|
*/
|
|
|
|
#if USE_REENTRANT
|
|
|
|
#define USE_TRACEF(mask) _nc_use_tracef(mask)
|
|
|
|
extern NCURSES_EXPORT(int) _nc_use_tracef (unsigned);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE(1,2);
|
|
|
|
#else
|
|
|
|
#define USE_TRACEF(mask) (_nc_tracing & (mask))
|
|
|
|
#define _nc_locked_tracef _tracef
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TR(n, a) if (USE_TRACEF(n)) _nc_locked_tracef a
|
1997-05-15 12:00:00 +08:00
|
|
|
#define T(a) TR(TRACE_CALLS, a)
|
2011-01-02 09:08:28 +08:00
|
|
|
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
|
|
|
|
#define TRACE_RETURN2(value,dst,src) return _nc_retrace_##dst##_##src(value)
|
|
|
|
#define TRACE_RETURN_SP(value,type) return _nc_retrace_##type(SP_PARM, value)
|
2002-10-13 11:35:53 +08:00
|
|
|
|
2010-01-17 09:52:00 +08:00
|
|
|
#define NonNull(s) ((s) != 0 ? s : "<null>")
|
|
|
|
|
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)
|
2010-01-17 09:52:00 +08:00
|
|
|
#define returnChar(code) TRACE_RETURN(code,char)
|
2009-02-22 10:08:00 +08:00
|
|
|
#define returnChtype(code) TRACE_RETURN(code,chtype)
|
2005-10-10 02:41:57 +08:00
|
|
|
#define returnCode(code) TRACE_RETURN(code,int)
|
2011-01-02 09:08:28 +08:00
|
|
|
#define returnIntAttr(code) TRACE_RETURN2(code,int,attr_t)
|
|
|
|
#define returnMMask(code) TRACE_RETURN_SP(code,mmask_t)
|
2005-10-10 02:41:57 +08:00
|
|
|
#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
|
|
|
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int);
|
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 *);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(char) _nc_retrace_char (int);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_retrace_int (int);
|
2011-01-02 09:08:28 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_retrace_int_attr_t (attr_t);
|
|
|
|
extern NCURSES_EXPORT(mmask_t) _nc_retrace_mmask_t (SCREEN *, mmask_t);
|
2002-10-13 11:35:53 +08:00
|
|
|
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 *);
|
2008-05-04 08:48:16 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_fifo_dump (SCREEN *);
|
2007-09-30 07:30:37 +08:00
|
|
|
|
|
|
|
#if USE_REENTRANT
|
|
|
|
NCURSES_WRAPPED_VAR(long, _nc_outchars);
|
|
|
|
NCURSES_WRAPPED_VAR(const char *, _nc_tputs_trace);
|
|
|
|
#define _nc_outchars NCURSES_PUBLIC_VAR(_nc_outchars())
|
|
|
|
#define _nc_tputs_trace NCURSES_PUBLIC_VAR(_nc_tputs_trace())
|
|
|
|
extern NCURSES_EXPORT(void) _nc_set_tputs_trace (const char *);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_count_outchars (long);
|
|
|
|
#else
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
|
|
|
|
extern NCURSES_EXPORT_VAR(long) _nc_outchars;
|
2007-09-30 07:30:37 +08:00
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
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
|
2010-01-17 09:52:00 +08:00
|
|
|
#define returnChar(code) return ((char) code)
|
2009-02-22 10:08:00 +08:00
|
|
|
#define returnChtype(code) return code
|
2005-10-10 02:41:57 +08:00
|
|
|
#define returnCode(code) return code
|
2011-01-02 09:08:28 +08:00
|
|
|
#define returnIntAttr(code) return code
|
|
|
|
#define returnMMask(code) return code
|
2005-10-10 02:41:57 +08:00
|
|
|
#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
|
|
|
|
2009-10-25 09:06:00 +08:00
|
|
|
/*
|
|
|
|
* Workaround for defective implementation of gcc attribute warn_unused_result
|
|
|
|
*/
|
|
|
|
#if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
|
2010-12-26 09:22:11 +08:00
|
|
|
#define IGNORE_RC(func) errno = (int) func
|
2009-10-25 09:06:00 +08:00
|
|
|
#else
|
|
|
|
#define IGNORE_RC(func) (void) func
|
|
|
|
#endif /* gcc workarounds */
|
|
|
|
|
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);
|
|
|
|
|
2008-08-05 09:06:16 +08:00
|
|
|
#define EMPTY_MODULE(name) \
|
2002-10-13 11:35:53 +08:00
|
|
|
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)
|
2009-05-03 08:59:25 +08:00
|
|
|
#define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress)
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
#define toggle_attr_on(S,at) {\
|
2010-04-04 09:26:17 +08:00
|
|
|
if (PairNumber(at) > 0) {\
|
2010-12-26 09:22:11 +08:00
|
|
|
(S) = ((S) & ALL_BUT_COLOR) | (attr_t) (at);\
|
2005-10-10 02:41:57 +08:00
|
|
|
} else {\
|
2010-12-26 09:22:11 +08:00
|
|
|
(S) |= (attr_t) (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) {\
|
2010-04-04 09:26:17 +08:00
|
|
|
if (PairNumber(at) > 0) {\
|
2005-10-10 02:41:57 +08:00
|
|
|
(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
|
|
|
|
2009-04-26 09:00:20 +08:00
|
|
|
#define DelCharCost(sp,count) \
|
1997-05-15 12:00:00 +08:00
|
|
|
((parm_dch != 0) \
|
2009-04-26 09:00:20 +08:00
|
|
|
? sp->_dch_cost \
|
1997-05-15 12:00:00 +08:00
|
|
|
: ((delete_character != 0) \
|
2009-04-26 09:00:20 +08:00
|
|
|
? (sp->_dch1_cost * count) \
|
1997-05-15 12:00:00 +08:00
|
|
|
: INFINITY))
|
|
|
|
|
2009-04-26 09:00:20 +08:00
|
|
|
#define InsCharCost(sp,count) \
|
1997-05-15 12:00:00 +08:00
|
|
|
((parm_ich != 0) \
|
2009-04-26 09:00:20 +08:00
|
|
|
? sp->_ich_cost \
|
1999-10-24 12:32:42 +08:00
|
|
|
: ((enter_insert_mode && exit_insert_mode) \
|
2009-04-26 09:00:20 +08:00
|
|
|
? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \
|
1999-10-24 12:32:42 +08:00
|
|
|
: ((insert_character != 0) \
|
2009-04-26 09:00:20 +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
|
2010-04-04 09:26:17 +08:00
|
|
|
#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
|
2009-04-26 09:00:20 +08:00
|
|
|
attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \
|
2009-05-03 08:59:25 +08:00
|
|
|
VIDATTR(sp, AttrOf(c), GetPair(c)); \
|
1998-03-01 12:21:12 +08:00
|
|
|
if (magic_cookie_glitch > 0 \
|
2009-04-26 09:00:20 +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__, \
|
2009-04-26 09:00:20 +08:00
|
|
|
sp->_cursrow, \
|
|
|
|
sp->_curscol)); \
|
2009-05-11 07:36:12 +08:00
|
|
|
NCURSES_SP_NAME(_nc_do_xmc_glitch)(NCURSES_SP_ARGx chg); \
|
1998-03-01 12:21:12 +08:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#else
|
2010-04-04 09:26:17 +08:00
|
|
|
#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
|
|
|
|
VIDATTR(sp, 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
|
2010-04-11 07:46:02 +08:00
|
|
|
#define TWAIT_MASK (TW_ANY | TW_EVENT)
|
2002-10-13 11:35:53 +08:00
|
|
|
#else
|
|
|
|
#define EVENTLIST_0th(param) void
|
|
|
|
#define EVENTLIST_1st(param) /* nothing */
|
|
|
|
#define EVENTLIST_2nd(param) /* nothing */
|
2010-04-11 07:46:02 +08:00
|
|
|
#define TWAIT_MASK TW_ANY
|
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
|
2009-06-28 09:00:34 +08:00
|
|
|
#define DelCharCost(sp, count) NCURSES_SP_NAME(_nc_DelCharCost)(NCURSES_SP_ARGx count)
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef InsCharCost
|
2009-06-28 09:00:34 +08:00
|
|
|
#define InsCharCost(sp, count) NCURSES_SP_NAME(_nc_InsCharCost)(NCURSES_SP_ARGx count)
|
|
|
|
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int _c);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int _c);
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#undef UpdateAttrs
|
2009-06-28 09:00:34 +08:00
|
|
|
#define UpdateAttrs(sp,c) NCURSES_SP_NAME(_nc_UpdateAttrs)(NCURSES_SP_ARGx CHREF(c))
|
|
|
|
|
2011-01-23 09:23:10 +08:00
|
|
|
#if USE_WIDEC_SUPPORT || defined(NEED_NCURSES_CH_T)
|
2009-06-28 09:00:34 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T _c);
|
|
|
|
#else
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx chtype c);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
extern NCURSES_EXPORT(int) _nc_DelCharCost (int);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_InsCharCost (int);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_UpdateAttrs (CARG_CH_T);
|
|
|
|
#endif /* NCURSES_SP_FUNCS */
|
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
|
|
|
|
|
2008-10-05 08:17:19 +08:00
|
|
|
#if !NCURSES_EXT_FUNCS
|
|
|
|
#define set_escdelay(value) ESCDELAY = value
|
|
|
|
#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
|
|
|
|
|
2007-08-13 00:31:21 +08:00
|
|
|
/* comp_captab.c */
|
|
|
|
typedef struct {
|
|
|
|
short nte_name; /* offset of name to hash on */
|
|
|
|
int nte_type; /* BOOLEAN, NUMBER or STRING */
|
|
|
|
short nte_index; /* index of associated variable in its array */
|
|
|
|
short nte_link; /* index in table of next hash, or -1 */
|
|
|
|
} name_table_data;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
short from;
|
|
|
|
short to;
|
|
|
|
short source;
|
|
|
|
} alias_table_data;
|
|
|
|
|
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 */
|
2009-05-11 07:36:12 +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 */
|
2002-10-13 11:35:53 +08:00
|
|
|
|
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 */
|
2010-03-14 05:18:05 +08:00
|
|
|
#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
|
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 */
|
2010-08-29 08:20:14 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eventlist *));
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2004-02-09 10:15:26 +08:00
|
|
|
/* lib_insch.c */
|
2009-05-31 07:24:28 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, 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 */
|
2008-11-23 09:33:11 +08:00
|
|
|
extern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *);
|
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);
|
2009-05-03 08:59:25 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, int);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int);
|
2006-12-18 12:32:42 +08:00
|
|
|
|
2009-05-31 07:24:28 +08:00
|
|
|
/* lib_set_term.c */
|
|
|
|
extern NCURSES_EXPORT(int) _nc_ripoffline(int, int(*)(WINDOW*, int));
|
|
|
|
|
2011-08-14 08:27:10 +08:00
|
|
|
/* lib_setup.c */
|
|
|
|
#define ret_error(code, fmt, arg) if (errret) {\
|
|
|
|
*errret = code;\
|
|
|
|
returnCode(ERR);\
|
|
|
|
} else {\
|
|
|
|
fprintf(stderr, fmt, arg);\
|
|
|
|
exit(EXIT_FAILURE);\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ret_error1(code, fmt, arg) ret_error(code, "'%s': " fmt, arg)
|
|
|
|
|
|
|
|
#define ret_error0(code, msg) if (errret) {\
|
|
|
|
*errret = code;\
|
|
|
|
returnCode(ERR);\
|
|
|
|
} else {\
|
|
|
|
fprintf(stderr, msg);\
|
|
|
|
exit(EXIT_FAILURE);\
|
|
|
|
}
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
/* lib_tstp.c */
|
|
|
|
#if USE_SIGWINCH
|
2008-05-04 08:48:16 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_handle_sigwinch(SCREEN *);
|
2006-12-18 12:32:42 +08:00
|
|
|
#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 ... */
|
2008-06-01 07:49:39 +08:00
|
|
|
extern NCURSES_EXPORT(ENTRY *) _nc_delink_entry (ENTRY *, TERMTYPE *);
|
|
|
|
extern NCURSES_EXPORT(SCREEN *) _nc_screen_of (WINDOW *);
|
2009-08-23 09:14:12 +08:00
|
|
|
extern NCURSES_EXPORT(TERMINAL*) _nc_get_cur_term (void);
|
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 *);
|
2008-06-01 07:49:39 +08:00
|
|
|
extern NCURSES_EXPORT(char *) _nc_tracechar (SCREEN *, int);
|
|
|
|
extern NCURSES_EXPORT(char *) _nc_tracemouse (SCREEN *, MEVENT const *);
|
2004-02-09 10:15:26 +08:00
|
|
|
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 *);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_ospeed (int);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_outch (int);
|
2009-03-01 07:06:36 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int);
|
2010-08-01 08:45:28 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE *);
|
2008-06-01 07:49:39 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC);
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_flush (void);
|
2009-05-03 08:59:25 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_free_and_exit (int) GCC_NORETURN;
|
2008-06-01 07:49:39 +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);
|
2008-05-04 08:48:16 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
|
2002-10-13 11:35:53 +08:00
|
|
|
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);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, int);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_signal_handler (int);
|
2002-10-13 11:35:53 +08:00
|
|
|
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);
|
2007-11-04 08:06:31 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_codes_leaks(void);
|
2007-08-13 00:31:21 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void);
|
2012-02-26 09:59:00 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_comp_error_leaks(void);
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void);
|
2011-10-09 08:51:26 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_keyname_leaks(void);
|
2007-11-04 08:06:31 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_names_leaks(void);
|
2006-12-18 12:32:42 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void);
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif
|
|
|
|
|
2010-03-14 05:18:05 +08:00
|
|
|
#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, int const, int const, NCURSES_CH_T);
|
2005-10-10 02:41:57 +08:00
|
|
|
#endif
|
|
|
|
|
2009-09-13 09:17:05 +08:00
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *);
|
|
|
|
#endif
|
|
|
|
|
2010-03-14 05:18:05 +08:00
|
|
|
#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC))
|
2005-10-10 02:41:57 +08:00
|
|
|
extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#if USE_SIZECHANGE
|
2008-05-04 08:48:16 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_update_screensize (SCREEN *);
|
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
|
|
|
|
|
2009-10-25 09:06:00 +08:00
|
|
|
/*
|
|
|
|
* Wide-character macros to hide some platform-differences.
|
|
|
|
*/
|
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
#if HAVE_MBTOWC && HAVE_MBLEN
|
2011-10-23 09:04:18 +08:00
|
|
|
#define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0))
|
2009-10-25 09:06:00 +08:00
|
|
|
#define count_mbytes(buffer,length,state) mblen(buffer,length)
|
|
|
|
#define check_mbytes(wch,buffer,length,state) \
|
|
|
|
(int) mbtowc(&wch, buffer, length)
|
|
|
|
#define state_unused
|
|
|
|
#elif HAVE_MBRTOWC && HAVE_MBRLEN
|
|
|
|
#define reset_mbytes(state) init_mb(state)
|
|
|
|
#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
|
|
|
|
#define check_mbytes(wch,buffer,length,state) \
|
|
|
|
(int) mbrtowc(&wch, buffer, length, &state)
|
|
|
|
#else
|
|
|
|
make an error
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
#define NC_BUFFERED(sp,flag) NCURSES_SP_NAME(_nc_set_buffer)(NCURSES_SP_ARGx sp->_ofp, flag)
|
1999-10-24 12:32:42 +08:00
|
|
|
|
2009-05-03 08:59:25 +08:00
|
|
|
#define NC_OUTPUT(sp) ((sp != 0) ? sp->_ofp : stdout)
|
1999-10-24 12:32:42 +08:00
|
|
|
|
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'.
|
|
|
|
*/
|
2009-06-07 08:51:13 +08:00
|
|
|
#define _nc_alloc_screen_sp() typeCalloc(SCREEN, 1)
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#if BROKEN_LINKER
|
2010-05-23 08:52:44 +08:00
|
|
|
#define SP _nc_screen()
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(SCREEN *) _nc_screen (void);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_alloc_screen (void);
|
|
|
|
extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
|
2009-05-11 07:36:12 +08:00
|
|
|
#define CURRENT_SCREEN _nc_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;
|
2009-05-11 07:36:12 +08:00
|
|
|
#define CURRENT_SCREEN SP
|
2009-06-07 08:51:13 +08:00
|
|
|
#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0)
|
2009-04-26 09:00:20 +08:00
|
|
|
#define _nc_set_screen(sp) SP = sp
|
1997-05-15 12:00:00 +08:00
|
|
|
#endif
|
|
|
|
|
2009-09-20 08:37:00 +08:00
|
|
|
#if NCURSES_SP_FUNCS
|
2009-04-19 08:38:07 +08:00
|
|
|
#define CURRENT_SCREEN_PRE (IsPreScreen(CURRENT_SCREEN) ? CURRENT_SCREEN : new_prescr())
|
2009-05-11 07:36:12 +08:00
|
|
|
#else
|
|
|
|
#define CURRENT_SCREEN_PRE CURRENT_SCREEN
|
|
|
|
#endif
|
2009-04-19 08:38:07 +08:00
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
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
|
|
|
*/
|
2009-04-26 09:00:20 +08:00
|
|
|
#define screen_lines(sp) (sp)->_lines
|
|
|
|
#define screen_columns(sp) (sp)->_columns
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
|
2009-07-05 07:55:21 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_format_slks (NCURSES_SP_DCLx int _c);
|
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
|
|
|
/*
|
|
|
|
* Common error messages
|
|
|
|
*/
|
|
|
|
#define MSG_NO_MEMORY "Out of memory"
|
|
|
|
#define MSG_NO_INPUTS "Premature EOF"
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2009-05-24 09:18:15 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_set_tty_mode(TTY *);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *);
|
|
|
|
|
2009-02-22 10:08:00 +08:00
|
|
|
/* timed_wait flag definitions */
|
|
|
|
#define TW_NONE 0
|
|
|
|
#define TW_INPUT 1
|
|
|
|
#define TW_MOUSE 2
|
|
|
|
#define TW_ANY (TW_INPUT | TW_MOUSE)
|
|
|
|
#define TW_EVENT 4
|
|
|
|
|
2009-05-03 08:59:25 +08:00
|
|
|
#define SetSafeOutcWrapper(outc) \
|
|
|
|
SCREEN* sp = CURRENT_SCREEN; \
|
|
|
|
if (sp==0) { \
|
|
|
|
struct screen dummy; \
|
|
|
|
sp = &dummy; \
|
|
|
|
memset(sp,0,sizeof(struct screen)); \
|
|
|
|
sp->_outch = _nc_outc_wrapper; \
|
|
|
|
}\
|
|
|
|
sp->jump = outc
|
|
|
|
|
2009-08-23 09:14:12 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
2009-05-03 08:59:25 +08:00
|
|
|
typedef void* TERM_HANDLE;
|
|
|
|
|
|
|
|
typedef struct _termInfo
|
|
|
|
{
|
2009-05-11 07:36:12 +08:00
|
|
|
bool caninit;
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
bool hascolor;
|
|
|
|
bool initcolor;
|
|
|
|
bool canchange;
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
int tabsize;
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
int maxcolors;
|
|
|
|
int maxpairs;
|
|
|
|
int nocolorvideo;
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2010-04-11 07:46:02 +08:00
|
|
|
int numbuttons;
|
2009-05-11 07:36:12 +08:00
|
|
|
int numlabels;
|
|
|
|
int labelwidth;
|
|
|
|
int labelheight;
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
const color_t* defaultPalette;
|
2009-05-03 08:59:25 +08:00
|
|
|
} TerminalInfo;
|
|
|
|
|
|
|
|
typedef struct term_driver {
|
|
|
|
bool isTerminfo;
|
2011-10-23 09:04:18 +08:00
|
|
|
bool (*CanHandle)(struct DriverTCB*, const char*, int*);
|
2009-05-03 08:59:25 +08:00
|
|
|
void (*init)(struct DriverTCB*);
|
|
|
|
void (*release)(struct DriverTCB*);
|
|
|
|
int (*size)(struct DriverTCB*, int* Line, int *Cols);
|
2011-10-23 09:04:18 +08:00
|
|
|
int (*sgmode)(struct DriverTCB*, int setFlag, TTY*);
|
2009-05-03 08:59:25 +08:00
|
|
|
chtype (*conattr)(struct DriverTCB*);
|
|
|
|
int (*hwcur)(struct DriverTCB*, int yold, int xold, int y, int x);
|
2011-10-23 09:04:18 +08:00
|
|
|
int (*mode)(struct DriverTCB*, int progFlag, int defFlag);
|
2009-05-03 08:59:25 +08:00
|
|
|
bool (*rescol)(struct DriverTCB*);
|
|
|
|
bool (*rescolors)(struct DriverTCB*);
|
2011-10-23 09:04:18 +08:00
|
|
|
void (*color)(struct DriverTCB*, int fore, int color, int(*)(SCREEN*, int));
|
|
|
|
int (*doBeepOrFlash)(struct DriverTCB*, int);
|
|
|
|
void (*initpair)(struct DriverTCB*, int, int, int);
|
|
|
|
void (*initcolor)(struct DriverTCB*, int, int, int, int);
|
|
|
|
void (*docolor)(struct DriverTCB*, int, int, int, int(*)(SCREEN*, int));
|
2009-05-03 08:59:25 +08:00
|
|
|
void (*initmouse)(struct DriverTCB*);
|
2011-12-18 08:13:30 +08:00
|
|
|
int (*testmouse)(struct DriverTCB*, int EVENTLIST_2nd(_nc_eventlist*));
|
2009-05-03 08:59:25 +08:00
|
|
|
void (*setfilter)(struct DriverTCB*);
|
2011-10-23 09:04:18 +08:00
|
|
|
void (*hwlabel)(struct DriverTCB*, int, char*);
|
|
|
|
void (*hwlabelOnOff)(struct DriverTCB*, int);
|
2009-05-03 08:59:25 +08:00
|
|
|
int (*update)(struct DriverTCB*);
|
2011-10-23 09:04:18 +08:00
|
|
|
int (*defaultcolors)(struct DriverTCB*, int, int);
|
|
|
|
int (*print)(struct DriverTCB*, char*, int);
|
|
|
|
int (*getsize)(struct DriverTCB*, int*, int*);
|
|
|
|
int (*setsize)(struct DriverTCB*, int, int);
|
|
|
|
void (*initacs)(struct DriverTCB*, chtype*, chtype*);
|
2009-05-03 08:59:25 +08:00
|
|
|
void (*scinit)(SCREEN *);
|
|
|
|
void (*scexit)(SCREEN *);
|
2011-10-23 09:04:18 +08:00
|
|
|
int (*twait)(struct DriverTCB*, int, int, int* EVENTLIST_2nd(_nc_eventlist*));
|
|
|
|
int (*read)(struct DriverTCB*, int*);
|
|
|
|
int (*nap)(struct DriverTCB*, int);
|
|
|
|
int (*kpad)(struct DriverTCB*, int);
|
|
|
|
int (*kyOk)(struct DriverTCB*, int, int);
|
2009-05-03 08:59:25 +08:00
|
|
|
bool (*kyExist)(struct DriverTCB*, int);
|
|
|
|
} TERM_DRIVER;
|
|
|
|
|
|
|
|
typedef struct DriverTCB
|
|
|
|
{
|
|
|
|
TERMINAL term; /* needs to be the first Element !!! */
|
|
|
|
TERM_HANDLE inp; /* The input handle of the Terminal */
|
|
|
|
TERM_HANDLE out; /* The output handle of the Terminal in shell mode */
|
|
|
|
TERM_HANDLE hdl; /* The output handle of the Terminal in prog mode */
|
|
|
|
TERM_DRIVER* drv; /* The driver for that Terminal */
|
|
|
|
SCREEN* csp; /* The screen that owns that Terminal */
|
|
|
|
TerminalInfo info; /* Driver independent core capabilities of the Terminal */
|
|
|
|
void* prop; /* Driver dependent property storage to be used by the Driver */
|
|
|
|
long magic;
|
|
|
|
} TERMINAL_CONTROL_BLOCK;
|
|
|
|
|
|
|
|
#define NCDRV_MAGIC(id) (0x47110000 | (id&0xffff))
|
|
|
|
#define NCDRV_TINFO 0x01
|
|
|
|
#define NCDRV_WINCONSOLE 0x02
|
|
|
|
|
|
|
|
#define TCBOf(sp) ((TERMINAL_CONTROL_BLOCK*)(TerminalOf(sp)))
|
|
|
|
#define InfoOf(sp) TCBOf(sp)->info
|
|
|
|
#define CallDriver(sp,method) TCBOf(sp)->drv->method(TCBOf(sp))
|
|
|
|
#define CallDriver_1(sp,method,arg1) TCBOf(sp)->drv->method(TCBOf(sp),arg1)
|
|
|
|
#define CallDriver_2(sp,method,arg1,arg2) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2)
|
|
|
|
#define CallDriver_3(sp,method,arg1,arg2,arg3) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3)
|
|
|
|
#define CallDriver_4(sp,method,arg1,arg2,arg3,arg4) TCBOf(sp)->drv->method(TCBOf(sp),arg1,arg2,arg3,arg4)
|
|
|
|
|
|
|
|
extern NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette;
|
|
|
|
extern NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette;
|
|
|
|
|
2009-05-24 09:18:15 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_get_driver(TERMINAL_CONTROL_BLOCK*, const char*, int*);
|
2009-08-23 09:14:12 +08:00
|
|
|
extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int *, int *);
|
|
|
|
#endif /* USE_TERM_DRIVER */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entrypoints which are actually provided in the terminal driver, which would
|
|
|
|
* be an sp-name otherwise.
|
|
|
|
*/
|
|
|
|
#ifdef USE_TERM_DRIVER
|
|
|
|
#define TINFO_HAS_KEY _nc_tinfo_has_key
|
|
|
|
#define TINFO_DOUPDATE _nc_tinfo_doupdate
|
|
|
|
#define TINFO_MVCUR _nc_tinfo_mvcur
|
|
|
|
extern NCURSES_EXPORT(int) TINFO_HAS_KEY(SCREEN*, int);
|
|
|
|
extern NCURSES_EXPORT(int) TINFO_DOUPDATE(SCREEN *);
|
|
|
|
extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int);
|
|
|
|
#else
|
|
|
|
#define TINFO_HAS_KEY NCURSES_SP_NAME(has_key)
|
|
|
|
#define TINFO_DOUPDATE NCURSES_SP_NAME(doupdate)
|
|
|
|
#define TINFO_MVCUR NCURSES_SP_NAME(mvcur)
|
2009-05-24 09:18:15 +08:00
|
|
|
#endif
|
|
|
|
|
2009-08-23 09:14:12 +08:00
|
|
|
/*
|
|
|
|
* Entrypoints using an extra parameter with the terminal driver.
|
|
|
|
*/
|
|
|
|
#ifdef USE_TERM_DRIVER
|
|
|
|
extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, NCURSES_CONST char *, int , int *, int);
|
2009-08-23 09:14:12 +08:00
|
|
|
#define TINFO_GET_SIZE(sp, tp, lp, cp) \
|
|
|
|
_nc_get_screensize(sp, tp, lp, cp)
|
|
|
|
#define TINFO_SET_CURTERM(sp, tp) \
|
|
|
|
NCURSES_SP_NAME(set_curterm)(sp, tp)
|
|
|
|
#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \
|
|
|
|
_nc_setupterm_ex(tpp, name, fd, err, reuse)
|
|
|
|
#else /* !USE_TERM_DRIVER */
|
|
|
|
extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
|
|
|
|
#define TINFO_GET_SIZE(sp, tp, lp, cp) \
|
|
|
|
_nc_get_screensize(sp, lp, cp)
|
|
|
|
#define TINFO_SET_CURTERM(sp, tp) \
|
|
|
|
set_curterm(tp)
|
|
|
|
#define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \
|
|
|
|
_nc_setupterm(name, fd, err, reuse)
|
|
|
|
#endif /* !USE_TERM_DRIVER */
|
|
|
|
|
|
|
|
#ifdef USE_TERM_DRIVER
|
2009-05-03 08:59:25 +08:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#include <nc_mingw.h>
|
|
|
|
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER;
|
|
|
|
#endif
|
|
|
|
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
|
2009-08-23 09:14:12 +08:00
|
|
|
#endif
|
2009-05-03 08:59:25 +08:00
|
|
|
|
2009-05-24 09:18:15 +08:00
|
|
|
#ifdef USE_TERM_DRIVER
|
2009-05-11 07:36:12 +08:00
|
|
|
#define IsTermInfo(sp) (TCBOf(sp) && ((TCBOf(sp)->drv->isTerminfo)))
|
|
|
|
#else
|
|
|
|
#define IsTermInfo(sp) TRUE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
|
2009-04-19 08:38:07 +08:00
|
|
|
#define IsValidTIScreen(sp) (HasTInfoTerminal(sp))
|
|
|
|
|
2009-02-22 10:08:00 +08:00
|
|
|
/*
|
|
|
|
* Exported entrypoints beyond the published API
|
|
|
|
*/
|
2009-03-01 07:06:36 +08:00
|
|
|
#if NCURSES_SP_FUNCS
|
2009-02-22 10:08:00 +08:00
|
|
|
extern NCURSES_EXPORT(WINDOW *) _nc_curscr_of(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(WINDOW *) _nc_newscr_of(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(WINDOW *) _nc_stdscr_of(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(int) _nc_outc_wrapper(SCREEN*,int);
|
|
|
|
|
2009-05-03 08:59:25 +08:00
|
|
|
#if USE_REENTRANT
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_TABSIZE)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname)(SCREEN*);
|
|
|
|
#endif
|
2009-02-22 10:08:00 +08:00
|
|
|
|
|
|
|
#if NCURSES_EXT_FUNCS
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tabsize)(SCREEN*, int);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We put the safe versions of various calls here as they are not published
|
|
|
|
* part of the API up to now
|
|
|
|
*/
|
2009-08-23 09:14:12 +08:00
|
|
|
extern NCURSES_EXPORT(TERMINAL*) NCURSES_SP_NAME(_nc_get_cur_term) (SCREEN *sp);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(_nc_makenew) (SCREEN*, int, int, int, int, int);
|
2009-05-03 08:59:25 +08:00
|
|
|
extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(_nc_reset_colors)(SCREEN*);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(_nc_printf_string)(SCREEN*, const char *, va_list);
|
|
|
|
extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(_nc_acs_char)(SCREEN*,int);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_curs_set)(SCREEN*,int);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_get_tty_mode)(SCREEN*,TTY*);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_mcprint)(SCREEN*,char*, int);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost)(SCREEN*, const char *, int);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_outch)(SCREEN*, int);
|
2009-05-24 09:18:15 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp)(SCREEN*, const char *, const char*);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const char *, const char *);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resetty)(SCREEN*);
|
2009-02-22 10:08:00 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_resize_term)(SCREEN*,int,int);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int));
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_savetty)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_init)(SCREEN*,const char*);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scr_restore)(SCREEN*, const char*);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int);
|
2009-05-11 07:36:12 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tigetnum)(SCREEN*,NCURSES_CONST char*);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vid_attr)(SCREEN *, attr_t, short, void *);
|
|
|
|
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_vidputs)(SCREEN*,chtype,int(*) (SCREEN*, int));
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_flush)(SCREEN*);
|
2009-05-03 08:59:25 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_free_and_exit)(SCREEN*, int) GCC_NORETURN;
|
2009-04-19 08:38:07 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_freeall)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_hash_map)(SCREEN*);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_init_acs)(SCREEN*);
|
2009-04-19 08:38:07 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_make_oldhash)(SCREEN*, int i);
|
2009-04-26 09:00:20 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_init)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_resume)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_mvcur_wrap)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_init)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_resume)(SCREEN*);
|
2009-04-19 08:38:07 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap)(SCREEN*);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_oldhash)(SCREEN*, int n, int top, int bot);
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_scroll_optimize)(SCREEN*);
|
2011-10-23 09:04:18 +08:00
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_set_buffer)(SCREEN*, FILE *, int);
|
2009-02-22 10:08:00 +08:00
|
|
|
|
|
|
|
extern NCURSES_EXPORT(void) _nc_cookie_init(SCREEN *sp);
|
2009-04-19 08:38:07 +08:00
|
|
|
|
|
|
|
#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
|
|
|
|
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_linedump)(SCREEN*);
|
|
|
|
#endif
|
|
|
|
|
2009-02-22 10:08:00 +08:00
|
|
|
#if USE_WIDEC_SUPPORT
|
|
|
|
extern NCURSES_EXPORT(wchar_t *) NCURSES_SP_NAME(_nc_wunctrl)(SCREEN*, cchar_t *);
|
|
|
|
#endif
|
|
|
|
|
2009-03-01 07:06:36 +08:00
|
|
|
#endif /* NCURSES_SP_FUNCS */
|
|
|
|
|
2009-04-19 08:38:07 +08:00
|
|
|
#if NCURSES_SP_FUNCS
|
|
|
|
|
|
|
|
#define safe_keyname NCURSES_SP_NAME(keyname)
|
|
|
|
#define safe_unctrl NCURSES_SP_NAME(unctrl)
|
|
|
|
#define safe_ungetch NCURSES_SP_NAME(ungetch)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define safe_keyname _nc_keyname
|
|
|
|
#define safe_unctrl _nc_unctrl
|
|
|
|
#define safe_ungetch _nc_ungetch
|
|
|
|
|
2009-05-11 07:36:12 +08:00
|
|
|
extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *, int);
|
2009-04-19 08:38:07 +08:00
|
|
|
extern NCURSES_EXPORT(int) _nc_ungetch (SCREEN *, int);
|
|
|
|
extern NCURSES_EXPORT(NCURSES_CONST char *) _nc_unctrl (SCREEN *, chtype);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1998-03-01 12:21:12 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2010-12-26 09:22:11 +08:00
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
1997-05-15 12:00:00 +08:00
|
|
|
#endif /* CURSES_PRIV_H */
|