diff options
| author | blymn <blymn@NetBSD.org> | 2007-05-28 15:01:53 +0000 |
|---|---|---|
| committer | blymn <blymn@NetBSD.org> | 2007-05-28 15:01:53 +0000 |
| commit | e124de36d8a3bb2fd90b77ec25eb7736f29ee44d (patch) | |
| tree | 0dac708fd51eee66b5194f8e69d6fe165e953031 /lib/libcurses/attributes.c | |
| parent | 599840187d9b53fe3353daa7f2892b387a1c2f29 (diff) | |
Merge in wide curses code done as a Summer of Code project by
Ruibiao Qiu.
Diffstat (limited to 'lib/libcurses/attributes.c')
| -rw-r--r-- | lib/libcurses/attributes.c | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/lib/libcurses/attributes.c b/lib/libcurses/attributes.c index 92b9bd08dba..b5011e16c71 100644 --- a/lib/libcurses/attributes.c +++ b/lib/libcurses/attributes.c @@ -1,4 +1,4 @@ -/* $NetBSD: attributes.c,v 1.14 2007/01/21 13:25:36 jdc Exp $ */ +/* $NetBSD: attributes.c,v 1.15 2007/05/28 15:01:54 blymn Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: attributes.c,v 1.14 2007/01/21 13:25:36 jdc Exp $"); +__RCSID("$NetBSD: attributes.c,v 1.15 2007/05/28 15:01:54 blymn Exp $"); #endif /* not lint */ #include "curses.h" @@ -146,8 +146,13 @@ wattr_get(WINDOW *win, attr_t *attr, short *pair, void *opt) #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wattr_get: win %p\n", win); #endif - if (attr != NULL) + if (attr != NULL) { *attr = win->wattr; +#ifdef HAVE_WCHAR + *attr &= WA_ATTRIBUTES; +#endif + } + if (pair != NULL) *pair = PAIR_NUMBER(win->wattr); return OK; @@ -181,6 +186,20 @@ wattr_on(WINDOW *win, attr_t attr, void *opt) win->wattr |= __PROTECT; if (attr & __REVERSE && __tc_mr != NULL) win->wattr |= __REVERSE; +#ifdef HAVE_WCHAR + if (attr & WA_LOW && __tc_Xo != NULL) + win->wattr |= WA_LOW; + if (attr & WA_TOP && __tc_Xt != NULL) + win->wattr |= WA_TOP; + if (attr & WA_LEFT && __tc_Xl != NULL) + win->wattr |= WA_LEFT; + if (attr & WA_RIGHT && __tc_Xr != NULL) + win->wattr |= WA_RIGHT; + if (attr & WA_HORIZONTAL && __tc_Xh != NULL) + win->wattr |= WA_HORIZONTAL; + if (attr & WA_VERTICAL && __tc_Xv != NULL) + win->wattr |= WA_VERTICAL; +#endif /* HAVE_WCHAR */ } if (attr & __STANDOUT) wstandout(win); @@ -219,6 +238,20 @@ wattr_off(WINDOW *win, attr_t attr, void *opt) win->wattr &= ~__PROTECT; if (attr & __REVERSE) win->wattr &= ~__REVERSE; +#ifdef HAVE_WCHAR + if (attr & WA_LOW) + win->wattr &= ~WA_LOW; + if (attr & WA_TOP) + win->wattr &= ~WA_TOP; + if (attr & WA_LEFT) + win->wattr &= ~WA_LEFT; + if (attr & WA_RIGHT) + win->wattr &= ~WA_RIGHT; + if (attr & WA_HORIZONTAL) + win->wattr &= ~WA_HORIZONTAL; + if (attr & WA_VERTICAL) + win->wattr &= ~WA_VERTICAL; +#endif /* HAVE_WCHAR */ } if (attr & __STANDOUT) wstandend(win); @@ -235,7 +268,6 @@ wattr_off(WINDOW *win, attr_t attr, void *opt) * wattr_set -- * Set attributes and color pair on stdscr */ -/* ARGSUSED */ int wattr_set(WINDOW *win, attr_t attr, short pair, void *opt) { @@ -243,14 +275,13 @@ wattr_set(WINDOW *win, attr_t attr, short pair, void *opt) __CTRACE(__CTRACE_ATTR, "wattr_set: win %p, attr %08x, pair %d\n", win, attr, pair); #endif - wattr_on(win, attr, NULL); - wattr_off(win, (~attr & ~__COLOR) | ((attr & __COLOR) ? 0 : __COLOR), - NULL); + wattr_off(win, __ATTRIBUTES, opt); /* - * This overwrites any colour setting from the attributes + * This overwrites any colour setting from the attributes * and is compatible with ncurses. */ - __wcolor_set(win, (attr_t) COLOR_PAIR(pair)); + attr = (attr & ~__COLOR) | COLOR_PAIR(pair); + wattr_on(win, attr, opt); return OK; } @@ -258,7 +289,6 @@ wattr_set(WINDOW *win, attr_t attr, short pair, void *opt) * wattron -- * Test and set attributes. */ - int wattron(WINDOW *win, int attr) { @@ -292,10 +322,8 @@ wattrset(WINDOW *win, int attr) #ifdef DEBUG __CTRACE(__CTRACE_ATTR, "wattrset: win %p, attr %08x\n", win, attr); #endif + wattr_off(win, __ATTRIBUTES, NULL); wattr_on(win, (attr_t) attr, NULL); - wattr_off(win, - (attr_t) (~attr & ~__COLOR) | ((attr & __COLOR) ? 0 : __COLOR), - NULL); return OK; } |
