Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses wbkgd - when updating window rendition for the...



details:   https://anonhg.NetBSD.org/src/rev/943e2d3b85f0
branches:  trunk
changeset: 445998:943e2d3b85f0
user:      uwe <uwe%NetBSD.org@localhost>
date:      Mon Nov 19 20:37:04 2018 +0000

description:
wbkgd - when updating window rendition for the new background character,
it's the old background characters that need to be updated, not spaces.

While here, simplify and also fix the bug introduced in 1.20 (that
lost the default color) - actually use the results of wbkgdset().

diffstat:

 lib/libcurses/background.c |  33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diffs (66 lines):

diff -r 5eeba1d4b870 -r 943e2d3b85f0 lib/libcurses/background.c
--- a/lib/libcurses/background.c        Mon Nov 19 20:28:01 2018 +0000
+++ b/lib/libcurses/background.c        Mon Nov 19 20:37:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: background.c,v 1.24 2018/11/18 22:53:22 uwe Exp $      */
+/*     $NetBSD: background.c,v 1.25 2018/11/19 20:37:04 uwe Exp $      */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: background.c,v 1.24 2018/11/18 22:53:22 uwe Exp $");
+__RCSID("$NetBSD: background.c,v 1.25 2018/11/19 20:37:04 uwe Exp $");
 #endif                         /* not lint */
 
 #include <stdlib.h>
@@ -89,32 +89,33 @@
 int
 wbkgd(WINDOW *win, chtype ch)
 {
-       int     y, x;
+       chtype obch;
+       int y, x;
 
 #ifdef DEBUG
        __CTRACE(__CTRACE_ATTR, "wbkgd: (%p), '%s', %08x\n",
            win, unctrl(ch & __CHARTEXT), ch & __ATTRIBUTES);
 #endif
+       obch = win->bch;
        wbkgdset(win, ch);
 
-       for (y = 0; y < win->maxy; y++)
+       for (y = 0; y < win->maxy; y++) {
                for (x = 0; x < win->maxx; x++) {
-                       /* Copy character if space */
-                       if (ch & __CHARTEXT && win->alines[y]->line[x].ch == ' ')
-                               win->alines[y]->line[x].ch = ch & __CHARTEXT;
-                       /* Merge attributes */
-                       if (win->alines[y]->line[x].attr & __ALTCHARSET)
-                               win->alines[y]->line[x].attr =
-                                   (ch & __ATTRIBUTES) | __ALTCHARSET;
-                       else
-                               win->alines[y]->line[x].attr =
-                                   ch & __ATTRIBUTES;
+                       __LDATA *cp = &win->alines[y]->line[x];
+
+                       /* Update/switch background characters */
+                       if (cp->ch == obch)
+                               cp->ch = win->bch;
+
+                       /* Update/merge attributes */
+                       cp->attr = win->battr | (cp->attr & __ALTCHARSET);
 #ifdef HAVE_WCHAR
-                       SET_WCOL(win->alines[y]->line[x], 1);
+                       SET_WCOL(*cp, 1);
 #endif
                }
+       }
        __touchwin(win);
-       return(OK);
+       return OK;
 }
 
 /*



Home | Main Index | Thread Index | Old Index