curses_p.h
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 1,062 行 · 第 1/3 页
H
1,062 行
#if NCURSES_NO_PADDING
int _no_padding; /* flag to set if padding disabled */
#endif
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) */
#if USE_HARD_TABS
int _ht_cost; /* cost of (tab) */
int _cbt_cost; /* cost of (backtab) */
#endif /* USE_HARD_TABS */
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) */
/* used in tty_update.c, must be chars */
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) */
/* used in lib_mvcur.c */
char * _address_cursor;
/* used in tty_update.c */
int _scrolling; /* 1 if terminal's smart enough to */
/* used in lib_color.c */
color_t *_color_table; /* screen's color palette */
int _color_count; /* count of colors in palette */
unsigned short *_color_pairs; /* screen's color pair list */
int _pair_count; /* count of color pairs */
#if NCURSES_EXT_FUNCS
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 */
#endif
chtype _xmc_suppress; /* attributes to suppress if xmc */
chtype _xmc_triggers; /* attributes to process if xmc */
chtype _acs_map[ACS_LEN];
/* used in lib_vidattr.c */
bool _use_rmso; /* true if we may use 'rmso' */
bool _use_rmul; /* true if we may use 'rmul' */
/*
* 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.
*/
bool _nc_sp_idlok;
bool _nc_sp_idcok;
#define _nc_idlok SP->_nc_sp_idlok
#define _nc_idcok SP->_nc_sp_idcok
/*
* These are the data that support the mouse interface.
*/
int _maxclick;
bool (*_mouse_event) (SCREEN *);
bool (*_mouse_inline)(SCREEN *);
bool (*_mouse_parse) (int);
void (*_mouse_resume)(SCREEN *);
void (*_mouse_wrap) (SCREEN *);
int _mouse_fd; /* file-descriptor, if any */
/*
* This supports automatic resizing
*/
#if USE_SIZECHANGE
int (*_resize)(int,int);
#endif
/*
* These are data that support the proper handling of the panel stack on an
* per screen basis.
*/
struct panelhook _panelHook;
/*
* Linked-list of all windows, to support '_nc_resizeall()' and
* '_nc_freeall()'
*/
WINDOWLIST *_nc_sp_windows;
#define _nc_windows SP->_nc_sp_windows
bool _sig_winch;
SCREEN *_next_screen;
/* hashes for old and new lines */
unsigned long *oldhash, *newhash;
HASHMAP *hashtab;
int hashtab_len;
bool _cleanup; /* cleanup after int/quit signal */
int (*_outch)(int); /* output handler if not putc */
};
extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
#if NCURSES_NOMACROS
#include <nomacros.h>
#endif
/*
* The margins are used in resizeterm() to retain the original layout after
* resizing.
*/
WINDOWLIST {
WINDOWLIST *next;
#if HAVE_RESIZETERM
int l_margin;
int r_margin;
int t_margin;
int b_margin;
#endif
WINDOW win;
};
/* The terminfo source is assumed to be 7-bit ASCII */
#define is7bits(c) ((unsigned)(c) < 128)
#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> */
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#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
#if HAVE_FCNTL_H
#include <fcntl.h> /* may define O_BINARY */
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#define UChar(c) ((unsigned char)(c))
#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
#define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
#if USE_WIDEC_SUPPORT /* { */
#define CharOf(c) ((c).chars[0])
#define AttrOf(c) ((c).attr)
#define AddAttr(c,a) (c).attr |= a
#define RemAttr(c,a) (c).attr &= ~(a)
#define SetAttr(c,a) (c).attr = a
#define NewChar(ch) { ChAttrOf(ch), { ChCharOf(ch) } }
#define NewChar2(c,a) { a, { c } }
#define CharEq(a,b) (!memcmp(&a, &b, sizeof(a)))
#define SetChar(ch,c,a) do { \
NCURSES_CH_T *_cp = &ch; \
memset(_cp,0,sizeof(ch)); _cp->chars[0] = c; _cp->attr = a; \
} 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
#define PUTC(ch,b) do { if(!isnac(ch)) { \
memset (&PUT_st, '\0', sizeof (PUT_st)); \
PUTC_i = 0; \
do { \
PUTC_ch = PUTC_i < CCHARW_MAX ? \
(ch).chars[PUTC_i] : L'\0'; \
PUTC_n = wcrtomb(PUTC_buf, \
(ch).chars[PUTC_i], &PUT_st); \
if (PUTC_ch == L'\0') \
--PUTC_n; \
if (PUTC_n <= 0) \
break; \
fwrite(PUTC_buf, (unsigned) PUTC_n, 1, b); \
++PUTC_i; \
} while (PUTC_ch != L'\0'); \
} } while (0)
#define BLANK { WA_NORMAL, ' ' }
#define ISBLANK(ch) ((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
#define WA_NAC 1
#define isnac(ch) (AttrOf(ch) & WA_NAC)
#define if_WIDEC(code) code
#define Charable(ch) (!isnac(ch) && \
(ch).chars[1] == L'\0' && \
(wctob(CharOf(ch)) == (char)CharOf(ch)))
#define L(ch) L ## ch
#else /* }{ */
#define CharOf(c) ChCharOf(c)
#define AttrOf(c) ChAttrOf(c)
#define AddAttr(c,a) c |= a
#define RemAttr(c,a) c &= ~(a & A_ATTRIBUTES)
#define SetAttr(c,a) c = (c & ~A_ATTRIBUTES) | a
#define NewChar(ch) (ch)
#define NewChar2(c,a) (c | a)
#define CharEq(a,b) (a == b)
#define SetChar(ch,c,a) ch = c | a
#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
#define PUTC(a,b) do { data = CharOf(ch); putc(data,b); } while (0)
#define BLANK (' '|A_NORMAL)
#define ISBLANK(ch) (CharOf(ch) == ' ')
#define isnac(ch) (0)
#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(' ')
#define CHANGED -1
#define CHANGED_CELL(line,col) \
if (line->firstchar == _NOCHANGE) \
line->firstchar = line->lastchar = col; \
else if ((col) < line->firstchar) \
line->firstchar = col; \
else if ((col) > line->lastchar) \
line->lastchar = col
#define CHANGED_RANGE(line,start,end) \
if (line->firstchar == _NOCHANGE \
|| line->firstchar > (start)) \
line->firstchar = start; \
if (line->lastchar == _NOCHANGE \
|| line->lastchar < (end)) \
line->lastchar = end
#define CHANGED_TO_EOL(line,start,end) \
if (line->firstchar == _NOCHANGE \
|| line->firstchar > (start)) \
line->firstchar = start; \
line->lastchar = end
#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
#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.
*/
#define FreeAndNull(p) free(p); p = 0
#include <nc_alloc.h>
/*
* 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.
*/
#define T_CALLED(fmt) "called {" fmt
#define T_CREATE(fmt) "create :" fmt
#define T_RETURN(fmt) "return }" fmt
#ifdef TRACE
#define START_TRACE() \
if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
int t = _nc_getenv_num("NCURSES_TRACE"); \
if (t >= 0) \
trace((unsigned) t); \
}
#define TR(n, a) if (_nc_tracing & (n)) _tracef a
#define T(a) TR(TRACE_CALLS, a)
#define TPUTS_TRACE(s) _nc_tputs_trace = s;
#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
#define returnAttr(code) TRACE_RETURN(code,attr_t)
#define returnChar(code) TRACE_RETURN(code,chtype)
#define returnBool(code) TRACE_RETURN(code,bool)
#define returnBits(code) TRACE_RETURN(code,unsigned)
#define returnCode(code) TRACE_RETURN(code,int)
#define returnPtr(code) TRACE_RETURN(code,ptr)
#define returnSP(code) TRACE_RETURN(code,sp)
#define returnVoid T((T_RETURN(""))); return
#define returnWin(code) TRACE_RETURN(code,win)
extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (NCURSES_BOOL);
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);
extern NCURSES_EXPORT(int) _nc_retrace_int (int);
extern NCURSES_EXPORT(unsigned) _nc_retrace_unsigned (unsigned);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?