Make the default colour pair be pair 0 which appears to match other

curses implementations.
This commit is contained in:
blymn 2022-04-12 07:03:04 +00:00
parent d1ee79bf8c
commit 301bf8cc44
22 changed files with 234 additions and 193 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: add_wchstr.c,v 1.11 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: add_wchstr.c,v 1.12 2022/04/12 07:03:04 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.11 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: add_wchstr.c,v 1.12 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <stdlib.h>
@ -170,7 +170,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t *wchstr, int n)
if (wcwidth(chp->vals[0])) {
/* clear the partial character before cursor */
for (tp = lp + cw; tp < lp; tp++) {
tp->ch = (wchar_t) btowc((int) win->bch);
tp->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
return ERR;
tp->attr = win->battr;
@ -205,8 +205,7 @@ wadd_wchnstr(WINDOW *win, const cchar_t *wchstr, int n)
if (cw > win->maxx - ex) {
/* clear to EOL */
while (ex < win->maxx) {
lp->ch = (wchar_t)
btowc((int) win->bch);
lp->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, lp)
== ERR)
return ERR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: addbytes.c,v 1.61 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: addbytes.c,v 1.62 2022/04/12 07:03:04 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.61 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: addbytes.c,v 1.62 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -448,7 +448,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
"_cursesi_addwchar: clear current char (%d,%d)\n",
*y, sx);
tp = &win->alines[*y]->line[sx];
tp->ch = (wchar_t) btowc((int) win->bch);
tp->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
return ERR;
@ -481,7 +481,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
if (newx < *(*lnp)->firstchp)
*(*lnp)->firstchp = newx;
for (tp = lp; *x < win->maxx; tp++, (*x)++) {
tp->ch = (wchar_t) btowc((int) win->bch);
tp->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
return ERR;
tp->attr = win->battr;
@ -595,7 +595,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
"_cursesi_addwchar: clear "
"remaining of current char (%d,%d)nn",
*y, ex);
tp->ch = (wchar_t) btowc((int) win->bch);
tp->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, tp) == ERR)
return ERR;
tp->attr = win->battr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: attributes.c,v 1.33 2021/12/08 20:50:01 andvar Exp $ */
/* $NetBSD: attributes.c,v 1.34 2022/04/12 07:03:04 blymn Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: attributes.c,v 1.33 2021/12/08 20:50:01 andvar Exp $");
__RCSID("$NetBSD: attributes.c,v 1.34 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include "curses.h"
@ -460,6 +460,6 @@ __wcolor_set(WINDOW *win, attr_t attr)
/* If another color pair is set, turn that off first. */
win->wattr &= ~__COLOR;
/* If can do color video, set the color pair bits. */
if (t_max_colors(t) != 0 && attr & __COLOR)
if (t_max_colors(t) != 0)
win->wattr |= attr & __COLOR;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: background.c,v 1.28 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: background.c,v 1.29 2022/04/12 07:03:04 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.28 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: background.c,v 1.29 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <stdlib.h>
@ -110,7 +110,7 @@ wbkgd(WINDOW *win, chtype ch)
#endif
}
}
__touchwin(win);
__touchwin(win, 1);
return OK;
}
@ -230,7 +230,7 @@ wbkgrnd(WINDOW *win, const cchar_t *wch)
return ERR;
wbkgrndset(win, wch);
__touchwin(win);
__touchwin(win, 1);
return OK;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: border.c,v 1.22 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: border.c,v 1.23 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: border.c,v 1.22 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: border.c,v 1.23 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <stdlib.h>
@ -154,7 +154,7 @@ wborder(WINDOW *win, chtype left, chtype right, chtype top, chtype bottom,
lp[endx].ch = (wchar_t) botright & __CHARTEXT;
lp[endx].attr = (attr_t) botright & __ATTRIBUTES;
}
__touchwin(win);
__touchwin(win, 0);
return OK;
#else /* HAVE_WCHAR */
cchar_t ls, rs, ts, bs, tl, tr, bl, br;
@ -331,7 +331,7 @@ int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
for (j = cw; win->alines[i]->line[j].wcols < 0; j++) {
__CTRACE(__CTRACE_INPUT,
"wborder_set: clean out partial char[%d]", j);
win->alines[i]->line[j].ch = ( wchar_t )btowc(win->bch);
win->alines[i]->line[j].ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp,
&win->alines[i]->line[j]) == ERR)
return ERR;
@ -377,8 +377,7 @@ int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
endx - cw + pcw, endx - cw);
k = pcw < 0 ? endx -cw + pcw : endx - cw;
for (j = endx - cw; j >= k; j--) {
win->alines[i]->line[j].ch
= (wchar_t)btowc(win->bch);
win->alines[i]->line[j].ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp,
&win->alines[i]->line[j]) == ERR)
return ERR;
@ -435,8 +434,7 @@ int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
}
}
while (i <= endx - trcw) {
win->alines[0]->line[i].ch =
(wchar_t)btowc((int) win->bch);
win->alines[0]->line[i].ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp,
&win->alines[0]->line[i]) == ERR)
return ERR;
@ -476,7 +474,7 @@ int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
}
}
while (i <= endx - brcw) {
win->alines[endy]->line[i].ch = (wchar_t)btowc((int) win->bch );
win->alines[endy]->line[i].ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp,
&win->alines[endy]->line[i]) == ERR)
return ERR;
@ -603,7 +601,7 @@ int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
endx - brcw + 1 - i;
}
}
__touchwin(win);
__touchwin(win, 0);
return OK;
#endif /* HAVE_WCHAR */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: clrtobot.c,v 1.28 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: clrtobot.c,v 1.29 2022/04/12 07:03:04 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.28 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: clrtobot.c,v 1.29 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -68,11 +68,7 @@ wclrtobot(WINDOW *win)
wchar_t bch;
attr_t battr;
#ifdef HAVE_WCHAR
bch = (wchar_t)btowc((int)win->bch);
#else
bch = win->bch;
#endif
if (win != curscr)
battr = win->battr & __ATTRIBUTES;
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: clrtoeol.c,v 1.33 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: clrtoeol.c,v 1.34 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)clrtoeol.c 8.2 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: clrtoeol.c,v 1.33 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: clrtoeol.c,v 1.34 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -68,11 +68,7 @@ wclrtoeol(WINDOW *win)
wchar_t bch;
attr_t battr;
#ifdef HAVE_WCHAR
bch = (wchar_t)btowc((int)win->bch);
#else
bch = win->bch;
#endif
if (win != curscr)
battr = win->battr & __ATTRIBUTES;
else

View File

@ -1,4 +1,4 @@
/* $NetBSD: color.c,v 1.45 2021/12/17 03:50:18 uwe Exp $ */
/* $NetBSD: color.c,v 1.46 2022/04/12 07:03:04 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.45 2021/12/17 03:50:18 uwe Exp $");
__RCSID("$NetBSD: color.c,v 1.46 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include "curses.h"
@ -39,6 +39,7 @@ __RCSID("$NetBSD: color.c,v 1.45 2021/12/17 03:50:18 uwe Exp $");
/* Have we initialised colours? */
int __using_color = 0;
int __do_color_init = 0; /* force refresh to init color in all cells */
/* Default colour number */
attr_t __default_color = 0;
@ -110,7 +111,11 @@ start_color(void)
COLOR_PAIRS = (max_pairs > MAX_PAIRS - 1 ?
MAX_PAIRS - 1 : max_pairs);
/* Use the last colour pair for curses default. */
#ifdef __OLD_DEFAULT_COLOR
__default_color = COLOR_PAIR(MAX_PAIRS - 1);
#else
__default_color = COLOR_PAIR(0);
#endif
}
}
if (!COLORS)
@ -235,6 +240,7 @@ start_color(void)
__default_pair.flags;
__using_color = 1;
__do_color_init = 1;
/* Set all positions on all windows to curses default colours. */
for (wlp = _cursesi_screen->winlistp; wlp != NULL; wlp = wlp->nextp) {
@ -243,12 +249,13 @@ start_color(void)
/* Set color attribute on other windows */
win->battr |= __default_color;
for (y = 0; y < win->maxy; y++) {
win->alines[y]->flags |= __ISFORCED;
for (x = 0; x < win->maxx; x++) {
win->alines[y]->line[x].attr &= ~__COLOR;
win->alines[y]->line[x].attr |= __default_color;
}
}
__touchwin(win);
__touchwin(win, 0);
}
}
@ -528,7 +535,8 @@ __set_color( /*ARGSUSED*/ WINDOW *win, attr_t attr)
{
short pair;
if ((curscr->wattr & __COLOR) == (attr & __COLOR))
if ((__do_color_init != 1) &&
((curscr->wattr & __COLOR) == (attr & __COLOR)))
return;
pair = PAIR_NUMBER((uint32_t)attr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: copywin.c,v 1.20 2021/09/06 07:03:49 rin Exp $ */
/* $NetBSD: copywin.c,v 1.21 2022/04/12 07:03:04 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: copywin.c,v 1.20 2021/09/06 07:03:49 rin Exp $");
__RCSID("$NetBSD: copywin.c,v 1.21 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <ctype.h>
@ -134,6 +134,6 @@ int copywin(const WINDOW *srcwin, WINDOW *dstwin,
}
}
}
__touchwin(dstwin);
__touchwin(dstwin, 0);
return OK;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: curses_private.h,v 1.77 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: curses_private.h,v 1.78 2022/04/12 07:03:04 blymn Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@ -404,7 +404,7 @@ void __swflags(WINDOW *);
void __sync(WINDOW *);
int __timeout(int);
int __touchline(WINDOW *, int, int, int);
int __touchwin(WINDOW *);
int __touchwin(WINDOW *, int);
int __unripoffline(int (*)(WINDOW *, int));
void __unsetattr(int);
void __unset_color(WINDOW *win);

View File

@ -1,4 +1,4 @@
/* $NetBSD: delch.c,v 1.27 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: delch.c,v 1.28 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)delch.c 8.2 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: delch.c,v 1.27 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: delch.c,v 1.28 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -134,7 +134,7 @@ wdelch(WINDOW *win)
}
}
while (temp1 <= end) {
temp1->ch = ( wchar_t )btowc((int) win->bch);
temp1->ch = win->bch;
temp1->attr = 0;
if (_cursesi_copy_nsp(win->bnsp, temp1) == ERR)
return ERR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: erase.c,v 1.34 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: erase.c,v 1.35 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)erase.c 8.2 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: erase.c,v 1.34 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: erase.c,v 1.35 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -70,11 +70,8 @@ werase(WINDOW *win)
attr_t battr;
__CTRACE(__CTRACE_ERASE, "werase: (%p)\n", win);
#ifdef HAVE_WCHAR
bch = (wchar_t)btowc((int)win->bch);
#else
bch = win->bch;
#endif
if (win != curscr)
battr = win->battr & __ATTRIBUTES;
else
@ -101,7 +98,7 @@ werase(WINDOW *win)
* Mark the whole window as changed in case we have overlapping
* windows - this will result in the (intended) clearing of the
* screen over the area covered by the window. */
__touchwin(win);
__touchwin(win, 0);
wmove(win, 0, 0);
return OK;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: get_wstr.c,v 1.10 2021/09/06 07:03:49 rin Exp $ */
/* $NetBSD: get_wstr.c,v 1.11 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: get_wstr.c,v 1.10 2021/09/06 07:03:49 rin Exp $");
__RCSID("$NetBSD: get_wstr.c,v 1.11 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include "curses.h"
@ -167,7 +167,7 @@ __wgetn_wstr(WINDOW *win, wchar_t *wstr, int n)
return ERR;
if (killwchar(&kc) == ERR)
return ERR;
sc[0] = (wchar_t)btowc( ' ' );
sc[0] = win->bch;
sc[1] = L'\0';
setcchar(&cc, sc, win->wattr, 0, NULL);
oldx = win->curx;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ins_wch.c,v 1.18 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: ins_wch.c,v 1.19 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ins_wch.c,v 1.18 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: ins_wch.c,v 1.19 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <string.h>
@ -164,7 +164,7 @@ wins_wch(WINDOW *win, const cchar_t *wch)
}
temp1->nsp = NULL;
}
temp1->ch = (wchar_t)btowc((int)win->bch );
temp1->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, temp1) == ERR)
return ERR;
temp1->attr = win->battr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ins_wstr.c,v 1.22 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: ins_wstr.c,v 1.23 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation Inc.
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ins_wstr.c,v 1.22 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: ins_wstr.c,v 1.23 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <string.h>
@ -317,7 +317,7 @@ loopdone:
win->maxx + pcw, win->maxx - 1);
temp2 += pcw;
while (temp1 > temp2 + width) {
temp1->ch = (wchar_t)btowc((int) win->bch);
temp1->ch = win->bch;
if (_cursesi_copy_nsp(win->bnsp, temp1) == ERR) {
free(lstr);
return ERR;

View File

@ -1,4 +1,4 @@
/* $NetBSD: insdelln.c,v 1.20 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: insdelln.c,v 1.21 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: insdelln.c,v 1.20 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: insdelln.c,v 1.21 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
/*
@ -116,11 +116,8 @@ winsdelln(WINDOW *win, int nlines)
for (i = 0; i < win->maxx; i++) {
win->alines[y]->line[i].ch = win->bch;
win->alines[y]->line[i].attr = attr;
#ifndef HAVE_WCHAR
win->alines[y]->line[i].ch = win->bch;
#else
win->alines[y]->line[i].ch
= (wchar_t)btowc((int)win->bch );
#ifdef HAVE_WCHAR
lp = &win->alines[y]->line[i];
if (_cursesi_copy_nsp(win->bnsp, lp) == ERR)
return ERR;
@ -160,11 +157,8 @@ winsdelln(WINDOW *win, int nlines)
for (i = 0; i < win->maxx; i++) {
win->alines[y]->line[i].ch = win->bch;
win->alines[y]->line[i].attr = attr;
#ifndef HAVE_WCHAR
win->alines[y]->line[i].ch = win->bch;
#else
win->alines[y]->line[i].ch
= (wchar_t)btowc((int)win->bch);
#ifndef HAVE_WCHAR
lp = &win->alines[y]->line[i];
lp->wcols = 1;
if (_cursesi_copy_nsp(win->bnsp, lp) == ERR)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mvwin.c,v 1.23 2021/09/06 07:45:48 rin Exp $ */
/* $NetBSD: mvwin.c,v 1.24 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: mvwin.c,v 1.23 2021/09/06 07:45:48 rin Exp $");
__RCSID("$NetBSD: mvwin.c,v 1.24 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -126,6 +126,6 @@ mvwin(WINDOW *win, int by, int bx)
__swflags(win);
__set_subwin(orig, win);
}
__touchwin(win);
__touchwin(win, 0);
return OK;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: newwin.c,v 1.65 2022/03/26 16:03:02 uwe Exp $ */
/* $NetBSD: newwin.c,v 1.66 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94";
#else
__RCSID("$NetBSD: newwin.c,v 1.65 2022/03/26 16:03:02 uwe Exp $");
__RCSID("$NetBSD: newwin.c,v 1.66 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -142,7 +142,12 @@ __newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad,
if ((win = __makenew(screen, maxy, maxx, by, bx, 0, ispad)) == NULL)
return NULL;
#ifdef HAVE_WCHAR
win->bch = (wchar_t) btowc((int) ' ');
#else
win->bch = ' ';
#endif
if (__using_color)
win->battr |= __default_color;
win->nextp = win;
@ -161,10 +166,8 @@ __newwin(SCREEN *screen, int nlines, int ncols, int by, int bx, int ispad,
lp->flags = 0;
for (sp = lp->line, j = 0; j < maxx; j++, sp++) {
sp->attr = 0;
#ifndef HAVE_WCHAR
sp->ch = win->bch;
#else
sp->ch = (wchar_t)btowc((int) win->bch);
#ifdef HAVE_WCHAR
sp->nsp = NULL;
sp->wcols = 1;
#endif /* HAVE_WCHAR */

View File

@ -1,4 +1,4 @@
/* $NetBSD: refresh.c,v 1.118 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: refresh.c,v 1.119 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94";
#else
__RCSID("$NetBSD: refresh.c,v 1.118 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: refresh.c,v 1.119 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -57,22 +57,8 @@ static void scrolln(int, int, int, int, int);
static int _wnoutrefresh(WINDOW *, int, int, int, int, int, int);
#ifdef HAVE_WCHAR
static int celleq(__LDATA *, __LDATA *);
static int lineeq(__LDATA *, __LDATA *, size_t);
#else /* !HAVE_WCHAR */
static inline int
celleq(__LDATA *x, __LDATA *y)
{
return memcmp(x, y, sizeof(__LDATA)) == 0;
}
static int
lineeq(__LDATA *xl, __LDATA *yl, size_t len)
{
return memcmp(xl, yl, len * __LDATASIZE) == 0;
}
#endif /* HAVE_WCHAR */
#define CHECK_INTERVAL 5 /* Change N lines before checking typeahead */
@ -304,7 +290,7 @@ _wnoutrefresh(WINDOW *win, int begy, int begx, int wbegy, int wbegx,
while (wx < mx) {
__CTRACE(__CTRACE_REFRESH,
"_wnoutrefresh: copy from %d, "
"%d to %d, %d: %s, 0x%x",
"%d to %d, %d: '%s', 0x%x",
wy, wx, y_off, x_off,
unctrl(wlp->line[wx].ch),
wlp->line[wx].attr);
@ -331,8 +317,7 @@ _wnoutrefresh(WINDOW *win, int begy, int begx, int wbegy, int wbegx,
}
#ifdef HAVE_WCHAR
if (wlp->line[wx].ch
== (wchar_t)btowc((int) win->bch)) {
if (wlp->line[wx].ch == win->bch) {
vlp->line[x_off].ch = win->bch;
vlp->line[x_off].wcols = win->wcols;
if (_cursesi_copy_nsp(win->bnsp,
@ -351,10 +336,10 @@ _wnoutrefresh(WINDOW *win, int begy, int begx, int wbegy, int wbegx,
}
}
#endif /* HAVE_WCHAR */
__CTRACE(__CTRACE_REFRESH, " = %s, 0x%x\n",
__CTRACE(__CTRACE_REFRESH, " = '%s', 0x%x\n",
unctrl(vlp->line[x_off].ch),
vlp->line[x_off].attr);
wx++;
wx++; /* XXX should be + wcols, need to properly set continuation flag on multi-col */
x_off++;
dx_off++;
}
@ -557,7 +542,7 @@ doupdate(void)
curscr->curx = 0;
werase(curscr);
}
__touchwin(win);
__touchwin(win, 0);
win->flags &= ~__CLEAROK;
/* note we cleared for later */
was_cleared = 1;
@ -665,9 +650,11 @@ doupdate(void)
/*
* We have just cleared so don't force an update
* otherwise we spray neeedless blanks to a cleared
* screen.
* screen. That is, unless, we are using color,
* in this case we need to force the background
* color to default.
*/
if (was_cleared == 1)
if ((was_cleared == 1) && (__using_color == 0))
win->alines[wy]->flags &= ~__ISFORCED;
if (makech(wy) == ERR)
@ -734,6 +721,7 @@ doupdate(void)
cleanup:
/* Don't leave the screen with attributes set. */
__unsetattr(0);
__do_color_init = 0;
#ifdef DEBUG
#ifdef HAVE_WCHAR
{
@ -770,7 +758,7 @@ putattr(__LDATA *nsp)
attr_t off, on;
__CTRACE(__CTRACE_REFRESH,
"makech: have attr %08x, need attr %08x\n",
"putattr: have attr %08x, need attr %08x\n",
curscr->wattr
#ifndef HAVE_WCHAR
& __ATTRIBUTES
@ -981,9 +969,13 @@ putch(__LDATA *nsp, __LDATA *csp, int wy, int wx)
#else
if (nsp->wcols <= 0)
goto out;
if (((_cursesi_screen->nca & nsp->attr) == 0) && (__using_color == 1) &&
csp == NULL)
__set_color(curscr, nsp->attr & __COLOR);
__cputwchar((int)nsp->ch);
__CTRACE(__CTRACE_REFRESH,
"makech: (%d,%d)putwchar(0x%x)\n", wy, wx - 1, nsp->ch);
"putch: (%d,%d)putwchar(0x%x)\n", wy, wx - 1, nsp->ch);
/* Output non-spacing characters for the cell. */
__cursesi_putnsp(nsp->nsp, wy, wx);
@ -1071,13 +1063,15 @@ static int
makech(int wy)
{
WINDOW *win;
static __LDATA blank;
__LDATA *nsp, *csp, *cp, *cep, *fsp;
static __LDATA blank, space;
__LDATA *nsp, *csp, *cp, *cep, *fsp, *tld;
__LINE *wlp;
size_t clsp, nlsp; /* Last space in lines. */
int lch, wx, owx, chw;
const char *ce;
attr_t lspc; /* Last space colour */
attr_t battr; /* background attribute bits */
attr_t attr_mask; /* attributes mask */
#ifdef __GNUC__
nlsp = lspc = 0; /* XXX gcc -Wuninitialized */
@ -1086,13 +1080,26 @@ makech(int wy)
win = curscr;
else
win = __virtscr;
blank.ch = win->bch;
blank.attr = win->battr;
#ifdef HAVE_WCHAR
blank.ch = (wchar_t)btowc((int) win->bch);
blank.attr = 0;
if (_cursesi_copy_nsp(win->bnsp, &blank) == ERR)
return ERR;
blank.wcols = win->wcols;
attr_mask = WA_ATTRIBUTES;
space.ch = (wchar_t) btowc((int) ' ');
space.nsp = NULL;
space.wcols = 1;
space.attr = WA_NORMAL;
#else
space.ch = ' ';
space.attr = A_NORMAL;
attr_mask = A_ATTRIBUTES;
#endif /* HAVE_WCHAR */
battr = win->battr & attr_mask;
#ifdef DEBUG
#if HAVE_WCHAR
{
@ -1116,6 +1123,7 @@ makech(int wy)
}
#endif /* HAVE_WCHAR */
#endif /* DEBUG */
/* Is the cursor still on the end of the last line? */
if (wy > 0 && curscr->alines[wy - 1]->flags & __ISPASTEOL) {
domvcur(win, _cursesi_screen->ly, _cursesi_screen->lx,
@ -1147,6 +1155,7 @@ makech(int wy)
}
nsp = fsp = &win->alines[wy]->line[wx];
#ifdef DEBUG
if (_cursesi_screen->curwin)
__CTRACE(__CTRACE_REFRESH,
@ -1155,33 +1164,43 @@ makech(int wy)
__CTRACE(__CTRACE_REFRESH,
"makech: nsp is at __virtscr:(%d,%d)\n", wy, wx);
#endif /* DEBUG */
if (clr_eol && !_cursesi_screen->curwin) {
/*
* Work out if we can use a clear to end of line. If we are
* using color then we can only erase the line if the terminal
* can erase to the background color.
*/
if (clr_eol && !_cursesi_screen->curwin && (!(__using_color)
|| (__using_color && back_color_erase))) {
cp = &win->alines[wy]->line[win->maxx - 1];
lspc = cp->attr & __COLOR;
#ifndef HAVE_WCHAR
while (cp->ch == ' ' && cp->attr == lspc) /* XXX */
if (cp-- <= win->alines[wy]->line)
break;
#ifdef HAVE_WCHAR
while ((celleq(cp, &space) == 1) &&
#else
while (cp->ch == ( wchar_t )btowc(( int )' ' )
&& ( cp->attr & WA_ATTRIBUTES ) == lspc)
while (cp->ch == space.ch &&
#endif /* HAVE_WCHAR */
((cp->attr & attr_mask) == battr)) {
if (cp-- <= win->alines[wy]->line)
break;
}
#ifdef HAVE_WCHAR
if ((cp->wflags & WCA_CONTINUATION) == WCA_CONTINUATION)
cp--;
#endif /* HAVE_WCHAR */
if (win->alines[wy]->line > cp)
nlsp = 0;
else
nlsp = cp - win->alines[wy]->line;
}
if (!_cursesi_screen->curwin)
ce = clr_eol;
else
ce = NULL;
ce = clr_eol;
while (wx <= lch) {
#ifndef HAVE_WCHAR
__CTRACE(__CTRACE_REFRESH, "makech: wx=%d,lch=%d\n", wx, lch);
#else
#ifdef HAVE_WCHAR
__CTRACE(__CTRACE_REFRESH, "makech: farnarkle: flags 0x%x, wflags 0x%x, color_init %d, celleq %d\n",
wlp->flags, nsp->wflags, __do_color_init, celleq(nsp, csp));
__CTRACE(__CTRACE_REFRESH, "makech: nsp=(%x,%x,%d,%x,%x,%d,%p)\n",
nsp->ch, nsp->attr, nsp->wcols, win->bch, win->battr,
win->wcols, nsp->nsp);
@ -1214,66 +1233,72 @@ makech(int wy)
domvcur(win, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx);
__CTRACE(__CTRACE_REFRESH, "makech: 1: wx = %d, ly= %d, "
"lx = %d, newy = %d, newx = %d\n",
wx, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx);
"lx = %d, newy = %d, newx = %d, lch = %d\n",
wx, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx, lch);
_cursesi_screen->ly = wy;
_cursesi_screen->lx = wx;
owx = wx;
while (wx <= lch &&
((wlp->flags & __ISFORCED) || !celleq(nsp, csp)))
{
#ifndef HAVE_WCHAR
if (ce != NULL && wx >= nlsp
&& nsp->ch == ' ' && nsp->attr == lspc)
#else
if (ce != NULL && wx >= nlsp
&& nsp->ch == (wchar_t)btowc((int)' ') /* XXX */
&& (nsp->attr & WA_ATTRIBUTES) == lspc)
#endif
if ((ce != NULL) && (wx >= nlsp) &&
(nsp->ch == space.ch) &&
(__do_color_init == 1 || nsp->attr == space.attr))
{
/* Check for clear to end-of-line. */
cep = &curscr->alines[wy]->line[win->maxx - 1];
#ifndef HAVE_WCHAR
while (cep->ch == ' ' && cep->attr == lspc) /* XXX */
#else
while (cep->ch == (wchar_t)btowc((int)' ')
&& (cep->attr & WA_ATTRIBUTES) == lspc)
#endif /* HAVE_WCHAR */
while (cep->ch == blank.ch && cep->attr == battr)
if (cep-- <= csp)
break;
if (cep > (curscr->alines[wy]->line + win->begx * __LDATASIZE))
if (cep >= (curscr->alines[wy]->line + win->begx * __LDATASIZE))
clsp = cep - curscr->alines[wy]->line -
win->begx * __LDATASIZE;
win->begx * __LDATASIZE;
else
clsp = 0;
__CTRACE(__CTRACE_REFRESH,
"makech: clsp = %zu, nlsp = %zu\n",
clsp, nlsp);
"makech: clsp = %zu, nlsp = %zu, strlen(ce) = %ld\n",
clsp, nlsp, strlen(ce));
__CTRACE(__CTRACE_REFRESH,
"makech: line = %p, cep = %p, begx = %u\n",
curscr->alines[wy]->line, cep, win->begx);
if (((clsp - nlsp >= strlen(ce) &&
clsp < win->maxx * __LDATASIZE) ||
wy == win->maxy - 1) &&
(!(lspc & __COLOR) ||
((lspc & __COLOR) && back_color_erase)))
/*
* work out how to clear the line. If:
* - clear len is greater than clear_to_eol len
* - background char == ' '
* - we are not at EOL
* - using color and term can erase to
* background color
* - if we are at the bottom of the window
* (to prevent a scroll)
* then emit the ce string.
*/
if (((((clsp - nlsp > strlen(ce)) ||
(__do_color_init && back_color_erase)) &&
(clsp != win->maxx * __LDATASIZE)) ||
(wy == win->maxy - 1)) &&
(!(__using_color) ||
(__using_color && back_color_erase)))
{
__unsetattr(0);
if (__using_color &&
if(wlp->line[wx].attr & win->screen->nca) {
__unsetattr(0);
} else if (__using_color &&
((__do_color_init == 1) ||
((lspc & __COLOR) !=
(curscr->wattr & __COLOR)))
(curscr->wattr & __COLOR)))) {
__set_color(curscr, lspc &
__COLOR);
}
tputs(ce, 0, __cputchar);
_cursesi_screen->lx = wx + win->begx;
while (wx++ <= clsp) {
csp->attr = lspc;
#ifndef HAVE_WCHAR
csp->ch = ' '; /* XXX */
#else
csp->ch = (wchar_t)btowc((int)' ');
csp->wcols = 1;
csp->attr = blank.attr;
csp->ch = blank.ch;
#ifdef HAVE_WCHAR
if (_cursesi_copy_nsp(blank.nsp, csp) == ERR)
return ERR;
#endif /* HAVE_WCHAR */
csp->wcols = blank.wcols;
assert(csp != &blank);
csp++;
}
@ -1320,7 +1345,11 @@ makech(int wy)
if (wx + chw < win->maxx || wy < win->maxy - 1 ||
!(win->flags & __SCROLLWIN))
{
if (putch(nsp, csp, wy, wx) == ERR)
tld = nsp;
if (celleq(&blank, nsp))
tld = &blank;
if (putch(tld, csp, wy, wx) == ERR)
return ERR;
if (!_cursesi_screen->curwin) {
assert(csp != &blank);
@ -1440,7 +1469,7 @@ quickch(void)
__LINE *clp, *tmp1, *tmp2;
int bsize, curs, curw, starts, startw, i, j;
int n, target, cur_period, bot, top, sc_region;
unsigned int blank_hash;
unsigned int blank_hash, found;
attr_t bcolor;
#ifdef __GNUC__
@ -1454,9 +1483,9 @@ quickch(void)
(__virtscr->alines[top]->hash != curscr->alines[top]->hash ||
!lineeq(__virtscr->alines[top]->line,
curscr->alines[top]->line,
(size_t) __virtscr->maxx)))
(size_t) __virtscr->maxx))) {
break;
else
} else
__virtscr->alines[top]->flags &= ~__ISDIRTY;
}
/*
@ -1467,9 +1496,9 @@ quickch(void)
(__virtscr->alines[bot]->hash != curscr->alines[bot]->hash ||
!lineeq(__virtscr->alines[bot]->line,
curscr->alines[bot]->line,
(size_t) __virtscr->maxx)))
(size_t) __virtscr->maxx))) {
break;
else
} else
__virtscr->alines[bot]->flags &= ~__ISDIRTY;
}
@ -1516,36 +1545,40 @@ quickch(void)
* - bsize is the current size of the examined block.
*/
found = 0;
for (bsize = bot - top; bsize >= THRESH; bsize--) {
for (startw = top; startw <= bot - bsize; startw++)
for (starts = top; starts <= bot - bsize; starts++) {
for (curw = startw, curs = starts;
/* for (curw = startw, curs = starts;
curs < starts + bsize; curw++, curs++)
if (__virtscr->alines[curw]->hash !=
curscr->alines[curs]->hash)
break;
if (curs != starts + bsize)
continue;
continue;*/
for (curw = startw, curs = starts;
curs < starts + bsize; curw++, curs++)
if (!lineeq(__virtscr->alines[curw]->line,
curscr->alines[curs]->line,
(size_t) __virtscr->maxx))
(size_t) __virtscr->maxx)) {
found = 1;
break;
if (curs == starts + bsize)
}
if ((curs == starts + bsize) && (found == 1)) {
goto done;
}
}
}
done:
__CTRACE(__CTRACE_REFRESH, "quickch:bsize=%d, THRESH=%d, starts=%d, "
"startw=%d, curw=%d, curs=%d, top=%d, bot=%d\n",
bsize, THRESH, starts, startw, curw, curs, top, bot);
/* Did not find anything */
if (bsize < THRESH)
return;
__CTRACE(__CTRACE_REFRESH, "quickch:bsize=%d, starts=%d, startw=%d, "
"curw=%d, curs=%d, top=%d, bot=%d\n",
bsize, starts, startw, curw, curs, top, bot);
/*
* Make sure that there is no overlap between the bottom and top
* regions and the middle scrolled block.
@ -1559,6 +1592,7 @@ done:
#ifdef DEBUG
__CTRACE(__CTRACE_REFRESH, "#####################################\n");
__CTRACE(__CTRACE_REFRESH, "quickch: n = %d\n", n);
for (i = 0; i < curscr->maxy; i++) {
__CTRACE(__CTRACE_REFRESH, "C: %d:", i);
__CTRACE(__CTRACE_REFRESH, " 0x%x \n", curscr->alines[i]->hash);
@ -1589,16 +1623,16 @@ done:
#endif
#ifndef HAVE_WCHAR
if (buf[0].ch != ' ') {
if (buf[0].ch != curscr->bch) {
for (i = 0; i < BLANKSIZE; i++) {
buf[i].ch = ' ';
buf[i].ch = curscr->bch;
buf[i].attr = 0;
}
}
#else
if (buf[0].ch != (wchar_t)btowc((int)curscr->bch )) {
if (buf[0].ch != curscr->bch) {
for (i = 0; i < BLANKSIZE; i++) { /* XXXX: BLANKSIZE may not be valid if wcols > 1 */
buf[i].ch = (wchar_t)btowc((int)curscr->bch);
buf[i].ch = curscr->bch;
if (_cursesi_copy_nsp(curscr->bnsp, &buf[i]) == ERR)
return;
buf[i].attr = 0;
@ -1956,19 +1990,24 @@ __unsetattr(int checkms)
__unset_color(curscr);
}
#ifdef HAVE_WCHAR
/* compare two cells on screen, must have the same foreground/background,
* and the same sequence of non-spacing characters */
* and for wide characters the same sequence of non-spacing characters
*/
static int
celleq(__LDATA *x, __LDATA *y)
{
#ifdef HAVE_WCHAR
nschar_t *xnp = x->nsp, *ynp = y->nsp;
#endif /* HAVE_WCHAR */
int ret = ( x->ch == y->ch ) && ( x->attr == y->attr );
#ifdef HAVE_WCHAR
if (!ret)
return 0;
if (!xnp && !ynp)
return 1;
if ((xnp && !ynp) || (!xnp && ynp))
return 0;
@ -1978,7 +2017,11 @@ celleq(__LDATA *x, __LDATA *y)
xnp = xnp->next;
ynp = ynp->next;
}
return !xnp && !ynp;
#else
return ret;
#endif /* HAVE_WCHAR */
}
/* compare two line segments */
@ -1995,6 +2038,7 @@ lineeq(__LDATA *xl, __LDATA *yl, size_t len)
return 1;
}
#ifdef HAVE_WCHAR
/*
* Output the non-spacing characters associated with the given character
* cell to the screen.

View File

@ -1,7 +1,7 @@
# $NetBSD: shlib_version,v 1.46 2021/09/06 15:17:25 rin Exp $
# $NetBSD: shlib_version,v 1.47 2022/04/12 07:03:04 blymn Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
# Remember to increment the major numbers of libform, libmenu and
# libpanel when the libcurses major number increments.
#
major=9
minor=0
minor=1

View File

@ -1,4 +1,4 @@
/* $NetBSD: slk.c,v 1.19 2022/01/25 03:05:06 blymn Exp $ */
/* $NetBSD: slk.c,v 1.20 2022/04/12 07:03:04 blymn Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@ -32,9 +32,10 @@
#include <sys/cdefs.h>
#include <limits.h>
#ifndef lint
__RCSID("$NetBSD: slk.c,v 1.19 2022/01/25 03:05:06 blymn Exp $");
__RCSID("$NetBSD: slk.c,v 1.20 2022/04/12 07:03:04 blymn Exp $");
#endif /* not lint */
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: touchwin.c,v 1.33 2021/09/06 07:03:50 rin Exp $ */
/* $NetBSD: touchwin.c,v 1.34 2022/04/12 07:03:04 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94";
#else
__RCSID("$NetBSD: touchwin.c,v 1.33 2021/09/06 07:03:50 rin Exp $");
__RCSID("$NetBSD: touchwin.c,v 1.34 2022/04/12 07:03:04 blymn Exp $");
#endif
#endif /* not lint */
@ -187,15 +187,20 @@ wtouchln(WINDOW *win, int line, int n, int changed)
return OK;
}
/*
* Touch all the lines in a window. If force is set to 1 then screen
* update optimisation will disabled to force the change out.
*/
int
__touchwin(WINDOW *win)
__touchwin(WINDOW *win, int force)
{
int y, maxy;
__CTRACE(__CTRACE_LINE, "__touchwin: (%p)\n", win);
maxy = win->maxy;
for (y = 0; y < maxy; y++)
__touchline(win, y, 0, (int) win->maxx - 1);
_cursesi_touchline_force(win, y, 0, (int) win->maxx - 1,
force);
return OK;
}
@ -241,7 +246,7 @@ wsyncup(WINDOW *win)
{
do {
__touchwin(win);
__touchwin(win, 0);
win = win->orig;
} while (win);
}
@ -253,7 +258,7 @@ wsyncdown(WINDOW *win)
while (w) {
if (is_wintouched(w)) {
__touchwin(win);
__touchwin(win, 0);
break;
}
w = w->orig;