📄 curses.priv.h
字号:
/**************************************************************************** * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************//**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996-on * ****************************************************************************//* * $Id: curses.priv.h,v 1.286 2005/09/10 22:34:50 tom Exp $ * * curses.priv.h * * Header file for curses library objects which are private to * the library. * */#ifndef CURSES_PRIV_H#define CURSES_PRIV_H 1#include <ncurses_dll.h>#ifdef __cplusplusextern "C" {#endif#include <ncurses_cfg.h>#if USE_RCS_IDS#define MODULE_ID(id) static const char Ident[] = id;#else#define MODULE_ID(id) /*nothing*/#endif#include <stdlib.h>#include <string.h>#include <sys/types.h>#if HAVE_UNISTD_H#include <unistd.h>#endif#if HAVE_SYS_BSDTYPES_H#include <sys/bsdtypes.h> /* needed for ISC */#endif#if HAVE_LIMITS_H# include <limits.h>#elif HAVE_SYS_PARAM_H# include <sys/param.h>#endif#include <assert.h>#include <stdio.h>#include <errno.h>#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#if DECL_ERRNOextern int errno;#endif#include <nc_panel.h>/* Some systems have a broken 'select()', but workable 'poll()'. Use that */#if HAVE_WORKING_POLL#define USE_FUNC_POLL 1#if HAVE_POLL_H#include <poll.h>#else#include <sys/poll.h>#endif#else#define USE_FUNC_POLL 0#endif/* include signal.h before curses.h to work-around defect in glibc 2.1.3 */#include <signal.h>/* 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/* QNX mouse support */#if defined(__QNX__) && !defined(__QNXNTO__)#define USE_QNX_MOUSE 1#else#define USE_QNX_MOUSE 0#endif/* EMX mouse support */#ifdef __EMX__#define USE_EMX_MOUSE 1#else#define USE_EMX_MOUSE 0#endif#define DEFAULT_MAXCLICK 166#define EV_MAX 8 /* size of mouse circular event queue *//* * 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. */#if !NCURSES_EXT_FUNCS#undef HAVE_SIZECHANGE#define HAVE_SIZECHANGE 0#endif#if HAVE_SIZECHANGE && defined(SIGWINCH)#define USE_SIZECHANGE 1#else#define USE_SIZECHANGE 0#undef USE_SIGWINCH#define USE_SIGWINCH 0#endif/* * 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()extern NCURSES_EXPORT(int) _nc_env_access (void);#endif/* * 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)extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);#endif/* * Scroll hints are useless when hashmap is used */#if !USE_SCROLL_HINTS#if !USE_HASHMAP#define USE_SCROLL_HINTS 1#else#define USE_SCROLL_HINTS 0#endif#endif#if USE_SCROLL_HINTS#define if_USE_SCROLL_HINTS(stmt) stmt#else#define if_USE_SCROLL_HINTS(stmt) /*nothing*/#endif/* * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only * when we're throwing control codes at the screen at high volume. To see * this, re-enable USE_HARD_TABS and run worm for a while. Other systems * probably don't want to define this either due to uncertainties about tab * delays and expansion in raw mode. */struct tries { struct tries *child; /* ptr to child. NULL if none */ struct tries *sibling; /* ptr to sibling. NULL if none */ unsigned char ch; /* character at this node */ unsigned short value; /* code of string so far. 0 if none. */};/* * Common/troublesome character definitions */#define L_BRACE '{'#define R_BRACE '}'#define S_QUOTE '\''#define D_QUOTE '"'#define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"/* * Structure for palette tables */typedef struct{ short red, green, blue; /* what color_content() returns */ short r, g, b; /* params to init_color() */ int init; /* true if we called init_color() */}color_t;#define MAXCOLUMNS 135#define MAXLINES 66#define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */#define ACS_LEN 128#define WINDOWLIST struct _win_list#if USE_WIDEC_SUPPORT#define _nc_bkgd _bkgrnd#else#undef _XOPEN_SOURCE_EXTENDED#define _nc_bkgd _bkgd#define wgetbkgrnd(win, wch) *wch = win->_bkgd#define wbkgrnd wbkgd#endif#include <curses.h> /* we'll use -Ipath directive to get the right one! */#include <term.h>#include <term_entry.h>#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT#define if_EXT_COLORS(stmt) stmt#define NetPair(value,p) (value).ext_color = (p), \ AttrOf(value) &= ALL_BUT_COLOR, \ AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))#define SetPair(value,p) (value).ext_color = (p)#define GetPair(value) (value).ext_color#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)#define GET_WINDOW_PAIR(w) (w)->_color#define SET_WINDOW_PAIR(w,p) (w)->_color = (p)#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))#define VIDATTR(attr, pair) vid_attr(attr, pair, 0)#else#define if_EXT_COLORS(stmt) /* nothing */#define SetPair(value,p) RemAttr(value, A_COLOR), \ SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))#define GetPair(value) PAIR_NUMBER(AttrOf(value))#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)#define GET_WINDOW_PAIR(w) PAIR_NUMBER((w)->_attrs)#define SET_WINDOW_PAIR(w,p) (w)->_attrs &= ALL_BUT_COLOR, \ (w)->_attrs |= (A_COLOR & COLOR_PAIR(p))#define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b))#define VIDATTR(attr, pair) vidattr(attr)#endif#define SCREEN_ATTRS(s) (*((s)->_current_attr))#define GET_SCREEN_PAIR(s) GetPair(SCREEN_ATTRS(s))#define SET_SCREEN_PAIR(s,p) SetPair(SCREEN_ATTRS(s), p)/* * Definitions for color pairs */typedef unsigned colorpair_t; /* type big enough to store PAIR_OF() */#define C_SHIFT 9 /* we need more bits than there are colors */#define C_MASK ((1 << C_SHIFT) - 1)#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))#define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0)#define COLOR_DEFAULT C_MASK#ifdef USE_TERMLIB#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_TERMLIBstruct ldat{ 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 */};#endif /* USE_TERMLIB */typedef enum { M_XTERM = -1 /* use xterm's mouse tracking? */ ,M_NONE = 0 /* no mouse device */#if USE_GPM_SUPPORT ,M_GPM /* use GPM */#endif#if USE_SYSMOUSE ,M_SYSMOUSE /* FreeBSD sysmouse on console */#endif} MouseType;/* * Structures for scrolling. */typedef struct { unsigned long hashval; int oldcount, newcount; int oldindex, newindex;} HASHMAP;/* * Structures for soft labels. */struct _SLK;#ifndef USE_TERMLIBtypedef struct{ 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 */} slk_ent;typedef struct _SLK { char dirty; /* all labels have changed */ char hidden; /* soft labels are hidden */ WINDOW *win; slk_ent *ent; short maxlab; /* number of available labels */ short labcnt; /* number of allocated labels */ short maxlen; /* length of labels */ NCURSES_CH_T attr; /* soft label attribute */} SLK;#endif /* USE_TERMLIB */typedef struct { int line; /* lines to take, < 0 => from bottom*/ int (*hook)(WINDOW *, int); /* callback for user */ WINDOW *w; /* maybe we need this for cleanup */} ripoff_t;/* * The SCREEN structure. */struct screen { int _ifd; /* input file ptr for screen */ FILE *_ofp; /* output file ptr for screen */ char *_setbuf; /* buffered I/O for output */ int _buffered; /* setvbuf uses _setbuf data */ int _checkfd; /* filedesc for typeahead check */ TERMINAL *_term; /* terminal type information */ short _lines; /* screen lines */ short _columns; /* screen columns */ short _lines_avail; /* lines available for stdscr */ short _topstolen; /* lines stolen from top */ ripoff_t _rippedoff[5]; /* list of lines stolen */ int _rip_count; /* ...and total lines stolen */ WINDOW *_curscr; /* current screen */ WINDOW *_newscr; /* virtual screen to be updated to */ WINDOW *_stdscr; /* screen's full-window context */ struct tries *_keytry; /* "Try" for use with keypad mode */ struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */ bool _tried; /* keypad mode was initialized */ bool _keypad_on; /* keypad mode is currently on */ bool _called_wgetch; /* check for recursion in wgetch() */ int _fifo[FIFO_SIZE]; /* input push-back buffer */ 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? */ int _color_defs; /* are colors modified */ int _cursor; /* visibility of the cursor */ int _cursrow; /* physical cursor row */ int _curscol; /* physical cursor column */ bool _notty; /* true if we cannot switch non-tty */ int _nl; /* True if NL -> CR/NL is on */ int _raw; /* True if in raw mode */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -