X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fcurses.priv.h;h=dcc2b9fbd5d367200c923a52304096b535c893a1;hp=0018291d860c0d0fc79aad10b8168bff1c9c9618;hb=11dead39816318fe9601e27756b9497caf7ff490;hpb=d49a800c7f54c8d9e77f745423c821a8535ada59 diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 0018291d..dcc2b9fb 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -35,7 +35,7 @@ /* - * $Id: curses.priv.h,v 1.452 2010/03/06 19:15:50 tom Exp $ + * $Id: curses.priv.h,v 1.459 2010/04/24 23:21:58 tom Exp $ * * curses.priv.h * @@ -270,6 +270,7 @@ color_t; #define _nc_bkgd _bkgrnd #else #undef _XOPEN_SOURCE_EXTENDED +#undef _XPG5 #define _nc_bkgd _bkgd #define wgetbkgrnd(win, wch) *wch = win->_bkgd #define wbkgrnd wbkgd @@ -285,6 +286,10 @@ color_t; * If curses.h did not expose the SCREEN-functions, then we do not need the * parameter in the corresponding unextended functions. */ + +#define USE_SP_FUNC_SUPPORT NCURSES_SP_FUNCS +#define USE_EXT_SP_FUNC_SUPPORT (NCURSES_SP_FUNCS && NCURSES_EXT_FUNCS) + #if NCURSES_SP_FUNCS #define SP_PARM sp /* use parameter */ #define NCURSES_SP_ARG SP_PARM @@ -335,15 +340,36 @@ color_t; #include -#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT +/* + * 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) +#define PairNumber(a) (NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT))) +#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 #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 SetPair(value,p) SetPair2((value).ext_color, AttrOf(value), p) +#define SetPair2(c,a,p) c = (p), \ + a = (unColor2(a) | (A_COLOR & ColorPair(oldColor(c)))) +#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) #define SET_WINDOW_PAIR(w,p) (w)->_color = (p) #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b)) @@ -353,16 +379,15 @@ color_t; #define VIDATTR(sp,attr,pair) vid_attr(attr, pair, 0) #endif -#else /* !(NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT) */ +#else /* !NCURSES_EXT_COLORS */ #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(WINDOW_ATTRS(w)) + SetAttr(value, AttrOf(value) | (A_COLOR & ColorPair(p))) +#define GetPair(value) PairNumber(AttrOf(value)) +#define GET_WINDOW_PAIR(w) PairNumber(WINDOW_ATTRS(w)) #define SET_WINDOW_PAIR(w,p) WINDOW_ATTRS(w) &= ALL_BUT_COLOR, \ - WINDOW_ATTRS(w) |= (A_COLOR & COLOR_PAIR(p)) + WINDOW_ATTRS(w) |= (A_COLOR & ColorPair(p)) #define SameAttrOf(a,b) (AttrOf(a) == AttrOf(b)) #if NCURSES_SP_FUNCS @@ -371,7 +396,7 @@ color_t; #define VIDATTR(sp,attr,pair) vidattr(attr) #endif -#endif /* NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT */ +#endif /* NCURSES_EXT_COLORS */ #if NCURSES_NO_PADDING #define GetNoPadding(sp) ((sp) ? (sp)->_no_padding : _nc_prescreen._no_padding) @@ -539,14 +564,14 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); 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 PAIR_OF(fg, bg) (colorpair_t) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK)) #define FORE_OF(c) (((c) >> C_SHIFT) & C_MASK) #define BACK_OF(c) ((c) & C_MASK) #define isDefaultColor(c) ((c) >= COLOR_DEFAULT || (c) < 0) #define COLOR_DEFAULT C_MASK -#if defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T) +#if defined(USE_BUILD_CC) || (defined(USE_TERMLIB) && !defined(NEED_NCURSES_CH_T)) #undef NCURSES_CH_T /* this is not a termlib feature */ #define NCURSES_CH_T void /* ...but we need a pointer in SCREEN */ @@ -593,7 +618,7 @@ typedef struct { struct _SLK; -#ifndef USE_TERMLIB +#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) typedef struct { @@ -1126,7 +1151,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; WINDOWLIST *next; SCREEN *screen; /* screen containing the window */ WINDOW win; /* WINDOW_EXT() needs to account for offset */ -#ifdef _XOPEN_SOURCE_EXTENDED +#ifdef NCURSES_WIDECHAR char addch_work[(MB_LEN_MAX * 9) + 1]; unsigned addch_used; /* number of bytes in addch_work[] */ int addch_x; /* x-position for addch_work[] */ @@ -1224,6 +1249,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define RESET_OUTCHARS() COUNT_OUTCHARS(-_nc_outchars) #define UChar(c) ((unsigned char)(c)) +#define UShort(c) ((unsigned short)(c)) #define ChCharOf(c) ((c) & (chtype)A_CHARTEXT) #define ChAttrOf(c) ((c) & (chtype)A_ATTRIBUTES) @@ -1270,7 +1296,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; memset(_cp, 0, sizeof(ch)); \ _cp->chars[0] = (c); \ _cp->attr = (a); \ - if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a))); \ + if_EXT_COLORS(SetPair(ch, PairNumber(a))); \ } while (0) #define CHREF(wch) (&wch) #define CHDEREF(wch) (*wch) @@ -1316,7 +1342,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define isWidecBase(ch) (WidecExt(ch) == 1) #define isWidecExt(ch) (WidecExt(ch) > 1 && WidecExt(ch) < 32) #define SetWidecExt(dst, ext) AttrOf(dst) &= ~A_CHARTEXT, \ - AttrOf(dst) |= (ext + 1) + AttrOf(dst) |= (attr_t) (ext + 1) #define if_WIDEC(code) code #define Charable(ch) ((SP_PARM != 0 && SP_PARM->_legacy_coding) \ @@ -1369,11 +1395,11 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; #define CHANGED_CELL(line,col) \ if (line->firstchar == _NOCHANGE) \ - line->firstchar = line->lastchar = col; \ + line->firstchar = line->lastchar = (NCURSES_SIZE_T) col; \ else if ((col) < line->firstchar) \ - line->firstchar = col; \ + line->firstchar = (NCURSES_SIZE_T) col; \ else if ((col) > line->lastchar) \ - line->lastchar = col + line->lastchar = (NCURSES_SIZE_T) col #define CHANGED_RANGE(line,start,end) \ if (line->firstchar == _NOCHANGE \ @@ -1572,7 +1598,7 @@ extern NCURSES_EXPORT(void) name (void); \ #define XMC_CHANGES(c) ((c) & SP_PARM->_xmc_suppress) #define toggle_attr_on(S,at) {\ - if (PAIR_NUMBER(at) > 0) {\ + if (PairNumber(at) > 0) {\ (S) = ((S) & ALL_BUT_COLOR) | (at);\ } else {\ (S) |= (at);\ @@ -1581,7 +1607,7 @@ extern NCURSES_EXPORT(void) name (void); \ #define toggle_attr_off(S,at) {\ - if (PAIR_NUMBER(at) > 0) {\ + if (PairNumber(at) > 0) {\ (S) &= ~(at|A_COLOR);\ } else {\ (S) &= ~(at);\ @@ -1605,7 +1631,7 @@ extern NCURSES_EXPORT(void) name (void); \ : INFINITY))) #if USE_XMC_SUPPORT -#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ +#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ attr_t chg = AttrOf(SCREEN_ATTRS(sp)); \ VIDATTR(sp, AttrOf(c), GetPair(c)); \ if (magic_cookie_glitch > 0 \ @@ -1618,8 +1644,9 @@ extern NCURSES_EXPORT(void) name (void); \ } \ } #else -#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) \ - VIDATTR(sp, AttrOf(c), GetPair(c)); +#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \ + VIDATTR(sp, AttrOf(c), GetPair(c)); \ + } #endif /* @@ -1629,10 +1656,12 @@ extern NCURSES_EXPORT(void) name (void); \ #define EVENTLIST_0th(param) param #define EVENTLIST_1st(param) param #define EVENTLIST_2nd(param) , param +#define TWAIT_MASK (TW_ANY | TW_EVENT) #else #define EVENTLIST_0th(param) void #define EVENTLIST_1st(param) /* nothing */ #define EVENTLIST_2nd(param) /* nothing */ +#define TWAIT_MASK TW_ANY #endif #if NCURSES_EXPANDED && NCURSES_EXT_FUNCS @@ -1725,7 +1754,7 @@ NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch); #endif /* lib_addstr.c */ -#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB) +#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *); #endif @@ -1856,7 +1885,7 @@ extern NCURSES_EXPORT(void) _nc_names_leaks(void); extern NCURSES_EXPORT(void) _nc_tgetent_leaks(void); #endif -#ifndef USE_TERMLIB +#if !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T); extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T); extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE_T const, NCURSES_SIZE_T const, NCURSES_CH_T); @@ -1866,7 +1895,7 @@ extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, NCURSES_SIZE extern NCURSES_EXPORT(int) _nc_insert_wch(WINDOW *, const cchar_t *); #endif -#if USE_WIDEC_SUPPORT && !defined(USE_TERMLIB) +#if USE_WIDEC_SUPPORT && !(defined(USE_TERMLIB) || defined(USE_BUILD_CC)) extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *); #endif @@ -2018,6 +2047,7 @@ typedef struct _termInfo int maxpairs; int nocolorvideo; + int numbuttons; int numlabels; int labelwidth; int labelheight; @@ -2043,6 +2073,7 @@ typedef struct term_driver { void (*initcolor)(struct DriverTCB*,short,short,short,short); void (*docolor)(struct DriverTCB*,short,short,bool,int(*)(SCREEN*,int)); void (*initmouse)(struct DriverTCB*); + int (*testmouse)(struct DriverTCB*,int); void (*setfilter)(struct DriverTCB*); void (*hwlabel)(struct DriverTCB*,int,char*); void (*hwlabelOnOff)(struct DriverTCB*,bool);