Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses hline, vline - don't lose attributes when usin...



details:   https://anonhg.NetBSD.org/src/rev/4478ee788b35
branches:  trunk
changeset: 973442:4478ee788b35
user:      uwe <uwe%NetBSD.org@localhost>
date:      Wed Jul 01 02:57:01 2020 +0000

description:
hline, vline - don't lose attributes when using default character.

Make default (wide) and non-wide behavior match.  If the character
argument has (only) attributes set, use them with the default line
character.

In the wide case don't do the fallback in hline - it just calls
hline_set that needs to do it anyway.  Fix the latter to check the
wcwidth of the right character and avoid division by zero.

diffstat:

 lib/libcurses/line.c |  47 +++++++++++++++++++++--------------------------
 1 files changed, 21 insertions(+), 26 deletions(-)

diffs (98 lines):

diff -r fda2cfd813fd -r 4478ee788b35 lib/libcurses/line.c
--- a/lib/libcurses/line.c      Wed Jul 01 02:14:41 2020 +0000
+++ b/lib/libcurses/line.c      Wed Jul 01 02:57:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: line.c,v 1.15 2020/07/01 02:14:41 uwe Exp $    */
+/*     $NetBSD: line.c,v 1.16 2020/07/01 02:57:01 uwe Exp $    */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: line.c,v 1.15 2020/07/01 02:14:41 uwe Exp $");
+__RCSID("$NetBSD: line.c,v 1.16 2020/07/01 02:57:01 uwe Exp $");
 #endif                         /* not lint */
 
 #include <string.h>
@@ -101,15 +101,10 @@
        wmove(win, ocury, ocurx);
        return OK;
 #else
-       cchar_t cch, *cchp;
+       cchar_t cch;
 
-       if (ch & __CHARTEXT) {
-               __cursesi_chtype_to_cchar(ch, &cch);
-               cchp = & cch;
-       } else
-               cchp = WACS_HLINE;
-
-       return whline_set(win, cchp, count);
+       __cursesi_chtype_to_cchar(ch, &cch);
+       return whline_set(win, &cch, count);
 #endif
 }
 
@@ -174,15 +169,10 @@
        wmove(win, ocury, ocurx);
        return OK;
 #else
-       cchar_t cch, *cchp;
+       cchar_t cch;
 
-       if (ch & __CHARTEXT) {
-               __cursesi_chtype_to_cchar(ch, &cch);
-               cchp = & cch;
-       } else
-               cchp = WACS_VLINE;
-
-       return wvline_set(win, cchp, count);
+       __cursesi_chtype_to_cchar(ch, &cch);
+       return wvline_set(win, &cch, count);
 #endif
 }
 
@@ -224,8 +214,14 @@
        int ocury, ocurx, wcn, i, cw;
        cchar_t cc;
 
-       cw = wcwidth( wch->vals[ 0 ]);
-       if (cw < 0)
+       cc = *wch;
+       if (!cc.vals[0]) {
+               cc.vals[0] = WACS_HLINE->vals[0];
+               cc.attributes |= WACS_HLINE->attributes;
+       }
+
+       cw = wcwidth(cc.vals[0]);
+       if (cw <= 0)
                cw = 1;
        if ( ( win->maxx - win->curx ) < cw )
                return ERR;
@@ -236,9 +232,6 @@
        ocury = win->cury;
        ocurx = win->curx;
 
-       memcpy( &cc, wch, sizeof( cchar_t ));
-       if (!(wch->vals[ 0 ]))
-               cc.vals[ 0 ] |= WACS_HLINE->vals[0];
        for (i = 0; i < wcn; i++ ) {
 #ifdef DEBUG
                __CTRACE(__CTRACE_LINE, "whline_set: (%d,%d)\n",
@@ -298,9 +291,11 @@
        ocury = win->cury;
        ocurx = win->curx;
 
-       memcpy(&cc, wch, sizeof(cchar_t));
-       if (!(wch->vals[0]))
-               cc.vals[0] |= WACS_VLINE->vals[0];
+       cc = *wch;
+       if (!cc.vals[0]) {
+               cc.vals[0] = WACS_VLINE->vals[0];
+               cc.attributes |= WACS_VLINE->attributes;
+       }
        for (i = 0; i < wcn; i++) {
                mvwadd_wch(win, ocury + i, ocurx, &cc);
 #ifdef DEBUG



Home | Main Index | Thread Index | Old Index