Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses Fixes for lib/56926 amongst other things:



details:   https://anonhg.NetBSD.org/src/rev/1202b37dec63
branches:  trunk
changeset: 371937:1202b37dec63
user:      blymn <blymn%NetBSD.org@localhost>
date:      Wed Oct 19 06:09:27 2022 +0000

description:
Fixes for lib/56926 amongst other things:
 - plod now correctly accounts for wide characters when plodding
 - use erase line when in color mode if the terminal has the capability
 - ensure that the CA_CONTINUATION flag is applied consistently to the
   subsequent characters in a wide character.
 - fix a bunch of refresh bugs that caused inconsistent placement of
   wide characters.

diffstat:

 lib/libcurses/add_wchstr.c |   13 +-
 lib/libcurses/addbytes.c   |   25 +++-
 lib/libcurses/background.c |    8 +-
 lib/libcurses/chgat.c      |    5 +-
 lib/libcurses/clrtobot.c   |    5 +-
 lib/libcurses/color.c      |    5 +-
 lib/libcurses/cr_put.c     |   64 +++++++------
 lib/libcurses/curses.c     |    7 +-
 lib/libcurses/delch.c      |    7 +-
 lib/libcurses/erase.c      |    5 +-
 lib/libcurses/ins_wch.c    |    5 +-
 lib/libcurses/ins_wstr.c   |   18 ++-
 lib/libcurses/insch.c      |   12 +-
 lib/libcurses/insdelln.c   |   14 ++-
 lib/libcurses/insstr.c     |    6 +-
 lib/libcurses/refresh.c    |  213 ++++++++++++++++++++++++++++++--------------
 lib/libcurses/resize.c     |    5 +-
 17 files changed, 271 insertions(+), 146 deletions(-)

diffs (truncated from 1240 to 300 lines):

diff -r 337567599770 -r 1202b37dec63 lib/libcurses/add_wchstr.c
--- a/lib/libcurses/add_wchstr.c        Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/add_wchstr.c        Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*   $NetBSD: add_wchstr.c,v 1.13 2022/05/03 07:25:34 blymn Exp $ */
+/*   $NetBSD: add_wchstr.c,v 1.14 2022/10/19 06:09:27 blymn Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: add_wchstr.c,v 1.13 2022/05/03 07:25:34 blymn Exp $");
+__RCSID("$NetBSD: add_wchstr.c,v 1.14 2022/10/19 06:09:27 blymn Exp $");
 #endif                         /* not lint */
 
 #include <stdlib.h>
@@ -174,7 +174,8 @@
                                if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
                                        return ERR;
                                tp->attr = win->battr;
-                               (*tp).wcols = 1;
+                               tp->wcols = 1;
+                               tp->cflags = CA_BACKGROUND;
                                np = tp->nsp;
                        }
                } else {
@@ -186,7 +187,7 @@
        }
        lnp->flags |= __ISDIRTY;
        newx = sx + win->ch_off;
-       if (newx < *lnp->firstchp)
+       if (newx < *lnp->firstchp) 
                *lnp->firstchp = newx;
 
        /* add characters in the string */
@@ -210,7 +211,7 @@
                                            == ERR)
                                                return ERR;
                                        lp->attr = win->battr;
-                                       lp->cflags |= CA_BACKGROUND;
+                                       lp->cflags = CA_BACKGROUND;
                                        (*lp).wcols = 1;
                                        lp++, ex++;
                                }
@@ -259,6 +260,8 @@
                                }
                                lp->ch = chp->vals[0];
                                lp->attr = chp->attributes & WA_ATTRIBUTES;
+                               lp->cflags &= ~CA_BACKGROUND;
+                               lp->cflags |= CA_CONTINUATION;
                                (*lp).wcols = x - ex;
                                lp++, ex++;
                        }
diff -r 337567599770 -r 1202b37dec63 lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c  Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/addbytes.c  Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 blymn Exp $      */
+/*     $NetBSD: addbytes.c,v 1.65 2022/10/19 06:09:27 blymn Exp $      */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: addbytes.c,v 1.64 2022/05/19 07:41:26 blymn Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.65 2022/10/19 06:09:27 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -293,6 +293,7 @@
         */
        if (newx < *(*lp)->firstchp)
                *(*lp)->firstchp = newx;
+
        if (newx > *(*lp)->lastchp)
                *(*lp)->lastchp = newx;
        __CTRACE(__CTRACE_INPUT, "ADDBYTES: change gives f/l: %d/%d [%d/%d]\n",
@@ -311,7 +312,7 @@
 #endif
        }
 
-       (*lp)->line[*x].cflags &= ~ CA_BACKGROUND;
+       (*lp)->line[*x].cflags &= ~ (CA_BACKGROUND | CA_CONTINUATION);
 
        if (attributes & __COLOR)
                (*lp)->line[*x].attr =
@@ -421,6 +422,7 @@
                newx = *x + win->ch_off;
                if (newx < *(*lnp)->firstchp)
                        *(*lnp)->firstchp = newx;
+
                if (newx > *(*lnp)->lastchp)
                        *(*lnp)->lastchp = newx;
                __touchline(win, *y, *x, *x);
@@ -451,7 +453,7 @@
                            *y, sx);
                        tp = &win->alines[*y]->line[sx];
                        tp->ch = win->bch;
-                       tp->cflags |= CA_BACKGROUND;
+                       tp->cflags = CA_BACKGROUND;
                        if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
                                return ERR;
 
@@ -483,12 +485,14 @@
                newx = *x + win->ch_off;
                if (newx < *(*lnp)->firstchp)
                        *(*lnp)->firstchp = newx;
+
                for (tp = lp; *x < win->maxx; tp++, (*x)++) {
                        tp->ch = win->bch;
                        if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
                                return ERR;
                        tp->attr = win->battr;
                        tp->wcols = win->wcols;
+                       tp->cflags = CA_BACKGROUND;
                }
                newx = win->maxx - 1 + win->ch_off;
                if (newx > *(*lnp)->lastchp)
@@ -510,13 +514,14 @@
        newx = *x + win->ch_off;
        if (newx < *(*lnp)->firstchp)
                *(*lnp)->firstchp = newx;
+
        if (lp->nsp) {
                __cursesi_free_nsp(lp->nsp);
                lp->nsp = NULL;
        }
 
        lp->ch = wch->vals[0];
-       lp->cflags &= ~CA_BACKGROUND;
+       lp->cflags &= ~ (CA_BACKGROUND | CA_CONTINUATION);
 
        attributes = (win->wattr | wch->attributes)
                & (WA_ATTRIBUTES & ~__COLOR);
@@ -555,7 +560,9 @@
            sx + 1, sx + cw - 1);
        __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: *x = %d, win->maxx = %d\n",
            *x, win->maxx);
-       for (tp = lp + 1, *x = sx + 1; *x - sx <= cw - 1; tp++, (*x)++) {
+       for (tp = lp + 1, *x = sx + 1, i = cw - 1; i > 0; tp++, (*x)++, i--) {
+               __CTRACE(__CTRACE_INPUT,
+                   "_cursesi_addwchar: setting continuation at x %d\n", *x);
                if (tp->nsp) {
                        __cursesi_free_nsp(tp->nsp);
                        tp->nsp = NULL;
@@ -564,9 +571,10 @@
                tp->attr = lp->attr & WA_ATTRIBUTES;
                /* Mark as "continuation" cell */
                tp->cflags |= CA_CONTINUATION;
+               tp->cflags &= ~ CA_BACKGROUND;
+               tp->wcols = i;
        }
 
-
        if (*x >= win->maxx) {
                __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: do line wrap\n");
                if (*y == win->scr_b) {
@@ -590,7 +598,6 @@
                (*lnp) = win->alines[*y];
                *(*lnp)->lastchp = win->ch_off + win->maxx - 1;
        } else {
-
                /* clear the remaining of the current character */
                if (*x && *x < win->maxx) {
                        ex = sx + cw;
@@ -601,7 +608,7 @@
                                    "remaining of current char (%d,%d)nn",
                                    *y, ex);
                                tp->ch = win->bch;
-                               tp->cflags |= CA_BACKGROUND;
+                               tp->cflags = CA_BACKGROUND;
                                if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
                                        return ERR;
                                tp->attr = win->battr;
diff -r 337567599770 -r 1202b37dec63 lib/libcurses/background.c
--- a/lib/libcurses/background.c        Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/background.c        Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: background.c,v 1.32 2022/05/05 22:02:17 blymn Exp $    */
+/*     $NetBSD: background.c,v 1.33 2022/10/19 06:09:27 blymn Exp $    */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: background.c,v 1.32 2022/05/05 22:02:17 blymn Exp $");
+__RCSID("$NetBSD: background.c,v 1.33 2022/10/19 06:09:27 blymn Exp $");
 #endif                         /* not lint */
 
 #include <stdlib.h>
@@ -172,7 +172,7 @@
        /* get a copy of the old background, we will need it. */
        obkgrnd.ch = win->bch;
        obkgrnd.attr = win->battr;
-       obkgrnd.cflags |= CA_BACKGROUND;
+       obkgrnd.cflags = CA_BACKGROUND;
        obkgrnd.wcols = win->wcols;
        obkgrnd.nsp = NULL;
        _cursesi_copy_nsp(win->bnsp, &obkgrnd);
@@ -223,7 +223,7 @@
 
        nbkgrnd.ch = win->bch;
        nbkgrnd.attr = win->battr;
-       nbkgrnd.cflags |= CA_BACKGROUND;
+       nbkgrnd.cflags = CA_BACKGROUND;
        nbkgrnd.wcols = win->wcols;
        nbkgrnd.nsp = NULL;
        _cursesi_copy_nsp(win->bnsp, &nbkgrnd);
diff -r 337567599770 -r 1202b37dec63 lib/libcurses/chgat.c
--- a/lib/libcurses/chgat.c     Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/chgat.c     Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chgat.c,v 1.8 2021/11/22 21:25:25 blymn Exp $  */
+/*     $NetBSD: chgat.c,v 1.9 2022/10/19 06:09:27 blymn Exp $  */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: chgat.c,v 1.8 2021/11/22 21:25:25 blymn Exp $");
+__RCSID("$NetBSD: chgat.c,v 1.9 2022/10/19 06:09:27 blymn Exp $");
 
 #include "curses.h"
 #include "curses_private.h"
@@ -79,6 +79,7 @@
 
        if (x + win->ch_off < *lp->firstchp)
                *lp->firstchp = x + win->ch_off;
+
        if (x + win->ch_off + count > *lp->lastchp)
                *lp->lastchp = x + win->ch_off + count;
 
diff -r 337567599770 -r 1202b37dec63 lib/libcurses/clrtobot.c
--- a/lib/libcurses/clrtobot.c  Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/clrtobot.c  Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clrtobot.c,v 1.30 2022/05/03 07:25:34 blymn Exp $      */
+/*     $NetBSD: clrtobot.c,v 1.31 2022/10/19 06:09:27 blymn Exp $      */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)clrtobot.c 8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: clrtobot.c,v 1.30 2022/05/03 07:25:34 blymn Exp $");
+__RCSID("$NetBSD: clrtobot.c,v 1.31 2022/10/19 06:09:27 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -98,6 +98,7 @@
 
                        sp->ch = bch;
                        sp->cflags |= CA_BACKGROUND;
+                       sp->cflags &= CA_CONTINUATION;
                        sp->attr = battr | (sp->attr & __ALTCHARSET);
 #ifdef HAVE_WCHAR
                        if (_cursesi_copy_nsp(win->bnsp, sp) == ERR)
diff -r 337567599770 -r 1202b37dec63 lib/libcurses/color.c
--- a/lib/libcurses/color.c     Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/color.c     Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: color.c,v 1.46 2022/04/12 07:03:04 blymn Exp $ */
+/*     $NetBSD: color.c,v 1.47 2022/10/19 06:09:27 blymn Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: color.c,v 1.46 2022/04/12 07:03:04 blymn Exp $");
+__RCSID("$NetBSD: color.c,v 1.47 2022/10/19 06:09:27 blymn Exp $");
 #endif                         /* not lint */
 
 #include "curses.h"
@@ -678,6 +678,7 @@
                                                 */
                                                if (*lp->firstchp > x)
                                                        *lp->firstchp = x;
+
                                                if (*lp->lastchp < x)
                                                        *lp->lastchp = x;
                                        }
diff -r 337567599770 -r 1202b37dec63 lib/libcurses/cr_put.c
--- a/lib/libcurses/cr_put.c    Tue Oct 18 19:04:57 2022 +0000
+++ b/lib/libcurses/cr_put.c    Wed Oct 19 06:09:27 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cr_put.c,v 1.39 2022/04/10 09:50:44 andvar Exp $       */
+/*     $NetBSD: cr_put.c,v 1.40 2022/10/19 06:09:27 blymn Exp $        */
 
 /*



Home | Main Index | Thread Index | Old Index