summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-07-30 19:04:08 +0000
committerache <ache@FreeBSD.org>1997-07-30 19:04:08 +0000
commit77cbca4b7f94cffcf1f790fa294d58aded728280 (patch)
tree504282277ce29eb688244120cd02b9cc993eeb21 /lib
parentd6cf2089bc5887f137a83ede9767e5154e3b8186 (diff)
downloadFreeBSD-src-77cbca4b7f94cffcf1f790fa294d58aded728280.zip
FreeBSD-src-77cbca4b7f94cffcf1f790fa294d58aded728280.tar.gz
Fix handling of mixed colors+attributes case by merging from ncurses 4.1
Diffstat (limited to 'lib')
-rw-r--r--lib/libncurses/lib_vidattr.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/libncurses/lib_vidattr.c b/lib/libncurses/lib_vidattr.c
index eb796f4..c8b62e7 100644
--- a/lib/libncurses/lib_vidattr.c
+++ b/lib/libncurses/lib_vidattr.c
@@ -73,20 +73,34 @@ int vidputs(chtype newmode, int (*outc)(int))
{
chtype turn_off = (~newmode & previous_attr) & ~A_COLOR;
chtype turn_on = (newmode & ~previous_attr) & ~A_COLOR;
+int pair, current_pair;
T(("vidputs(%x) called %s", newmode, _traceattr(newmode)));
T(("previous attribute was %s", _traceattr(previous_attr)));
if (newmode == previous_attr)
return OK;
+
+ pair = PAIR_NUMBER(newmode);
+ current_pair = PAIR_NUMBER(previous_attr);
+
+ if ((!SP || SP->_coloron) && pair == 0) {
+ T(("old pair = %d -- new pair = %d", current_pair, pair));
+ if (pair != current_pair) {
+ do_color(pair, outc);
+ previous_attr &= ~A_COLOR;
+ }
+ }
+
if (newmode == A_NORMAL && exit_attribute_mode) {
if((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
tputs(exit_alt_charset_mode, 1, outc);
previous_attr &= ~A_ALTCHARSET;
}
- if (previous_attr)
+ if (previous_attr) {
tputs(exit_attribute_mode, 1, outc);
-
+ previous_attr &= ~A_COLOR;
+ }
} else if (set_attributes) {
if (turn_on || turn_off) {
tputs(tparm(set_attributes,
@@ -99,6 +113,7 @@ chtype turn_on = (newmode & ~previous_attr) & ~A_COLOR;
(newmode & A_INVIS) != 0,
(newmode & A_PROTECT) != 0,
(newmode & A_ALTCHARSET) != 0), 1, outc);
+ previous_attr &= ~A_COLOR;
}
} else {
@@ -122,6 +137,7 @@ chtype turn_on = (newmode & ~previous_attr) & ~A_COLOR;
if (turn_off && exit_attribute_mode) {
tputs(exit_attribute_mode, 1, outc);
turn_on |= newmode & (A_UNDERLINE|A_REVERSE|A_BLINK|A_DIM|A_BOLD|A_INVIS|A_PROTECT);
+ previous_attr &= ~A_COLOR;
}
T(("turning %x on", _traceattr(turn_on)));
@@ -155,12 +171,10 @@ chtype turn_on = (newmode & ~previous_attr) & ~A_COLOR;
}
- if (SP->_coloron) {
- int pair = PAIR_NUMBER(newmode);
- int current_pair = PAIR_NUMBER(previous_attr);
-
+ if ((!SP || SP->_coloron) && pair != 0) {
+ current_pair = PAIR_NUMBER(previous_attr);
T(("old pair = %d -- new pair = %d", current_pair, pair));
- if (pair != current_pair || turn_off) {
+ if (pair != current_pair) {
do_color(pair, outc);
}
}
OpenPOWER on IntegriCloud