NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/58282: Sysinst terminal output size increased because curses
The following reply was made to PR lib/58282; it has been noted by GNATS.
From: Brett Lymn <blymn%internode.on.net@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: lib-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost,
Andreas Gustafsson <gson%gson.org@localhost>
Subject: Re: lib/58282: Sysinst terminal output size increased because curses
Date: Wed, 12 Feb 2025 14:45:26 +1030
--R55TPpUKwrNW2A+w
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Fri, Jul 12, 2024 at 08:25:01AM +0000, Andreas Gustafsson wrote:
>
> The problem of the missing "erase line" affects both TERM=wsvt25
> (which is used on the i386 testbed) and TERM=xterm (which is used on
> the amd64 testbed). OTOH, with TERM=vt100, sysinst does use
> "erase line".
>
Hi Andreas. Can you please try the attached patch? This should fix the
excessive output from sysinst. Please note that the curses automated
tests will fail with this version of the library due to output
differences. I need to review the tests and ensure the output is
correct in all cases but this update to refresh.c should go a long way
to fixing the excessive output.
--
Brett Lymn
--
Sent from my NetBSD device.
"We are were wolves",
"You mean werewolves?",
"No we were wolves, now we are something else entirely",
"Oh"
--R55TPpUKwrNW2A+w
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="refresh.patch"
Index: refresh.c
===================================================================
RCS file: /cvsroot/src/lib/libcurses/refresh.c,v
retrieving revision 1.129
diff -u -r1.129 refresh.c
--- refresh.c 23 Dec 2024 02:58:04 -0000 1.129
+++ refresh.c 12 Feb 2025 04:07:09 -0000
@@ -226,6 +226,10 @@
screen->__virtscr->flags &= ~__LEAVEOK;
screen->__virtscr->flags |= dwin->flags;
+ /* copy the background char and attributes from win to __virtscr */
+ screen->__virtscr->bch = win->bch;
+ screen->__virtscr->battr = win->battr;
+
if ((dwin->flags & __ISDERWIN) != 0)
endy = begy + maxy;
else
@@ -1143,18 +1147,16 @@
{
WINDOW *win;
static __LDATA blank;
- __LDATA *nsp, *csp, *cp, *cep, *fsp;
+ __LDATA *nsp, *csp, *cp, *fsp;
__LINE *wlp;
int nlsp; /* offset to first space at eol. */
- size_t mlsp;
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 */
+ nlsp = 0; /* XXX gcc -Wuninitialized */
#endif
if (_cursesi_screen->curwin)
win = curscr;
@@ -1200,6 +1202,8 @@
/* Is the cursor still on the end of the last line? */
if (wy > 0 && curscr->alines[wy - 1]->flags & __ISPASTEOL) {
+ /* XXX this looks wrong - bad things will happen if ly
+ is at maxy */
domvcur(win, _cursesi_screen->ly, _cursesi_screen->lx,
_cursesi_screen->ly + 1, 0);
_cursesi_screen->ly++;
@@ -1219,16 +1223,6 @@
if (lch >= (int) win->maxx)
lch = win->maxx - 1;
- if (_cursesi_screen->curwin) {
- csp = ␣
- __CTRACE(__CTRACE_REFRESH, "makech: csp is blank\n");
- } else {
- csp = &curscr->alines[wy]->line[wx];
- __CTRACE(__CTRACE_REFRESH,
- "makech: csp is on curscr:(%d,%d)\n", wy, wx);
- }
-
-
while (win->alines[wy]->line[wx].cflags & CA_CONTINUATION) {
wx--;
if (wx <= 0) {
@@ -1237,6 +1231,15 @@
}
}
+ if (_cursesi_screen->curwin) {
+ csp = ␣
+ __CTRACE(__CTRACE_REFRESH, "makech: csp is blank\n");
+ } else {
+ csp = &curscr->alines[wy]->line[wx];
+ __CTRACE(__CTRACE_REFRESH,
+ "makech: csp is on virtscr:(%d,%d)\n", wy, wx);
+ }
+
nsp = fsp = &win->alines[wy]->line[wx];
#ifdef DEBUG
@@ -1255,25 +1258,34 @@
*/
if (clr_eol && !_cursesi_screen->curwin && (!(__using_color)
|| (__using_color && back_color_erase))) {
+
+ if (__using_color && back_color_erase) {
+ assume_default_colors(
+ _cursesi_screen->colour_pairs[PAIR_NUMBER(win->battr)].fore,
+ _cursesi_screen->colour_pairs[PAIR_NUMBER(win->battr)].back);
+ }
+
nlsp = win->maxx - 1;
cp = &win->alines[wy]->line[win->maxx - 1];
#ifdef HAVE_WCHAR
- while ((_cursesi_celleq(cp, &blank) == 1) &&
-#else
- while (cp->ch == blank.ch &&
-#endif /* HAVE_WCHAR */
- ((cp->attr & attr_mask) == battr)) {
-#ifdef HAVE_WCHAR
+ while (((_cursesi_celleq(cp, &blank) == 1) &&
+ ((cp->attr & attr_mask) == battr)) || ((cp->cflags & CA_BACKGROUND) == CA_BACKGROUND)) {
nlsp -= cp->wcols;
cp -= cp->wcols;
+
+ if (nlsp <= 0)
+ break;
+ }
#else
+ while (cp->ch == blank.ch &&
+ ((cp->attr & attr_mask) == battr)) {
nlsp--;
cp--;
-#endif /* HAVE_WCHAR */
if (nlsp <= 0)
break;
}
+#endif /* HAVE_WCHAR */
if (nlsp < 0)
@@ -1294,11 +1306,12 @@
csp->ch, csp->attr, csp->wcols, win->bch, win->battr,
win->wcols, csp->nsp);
#endif
- if (!(wlp->flags & __ISFORCED) &&
-#ifdef HAVE_WCHAR
- ((nsp->cflags & CA_CONTINUATION) != CA_CONTINUATION) &&
-#endif
- _cursesi_celleq(nsp, csp))
+
+ /*
+ * If the update is not being forced then skip over
+ * all the unchanged characters.
+ */
+ if (!(wlp->flags & __ISFORCED) && _cursesi_celleq(nsp, csp))
{
if (wx <= lch) {
while (wx <= lch && _cursesi_celleq(nsp, csp)) {
@@ -1322,35 +1335,31 @@
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, lch = %d\n",
- wx, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx, lch);
+ "lx = %d, newy = %d, newx = %d, lch = %d, nlsp = %d\n",
+ wx, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx, lch,
+ nlsp);
+
_cursesi_screen->ly = wy;
_cursesi_screen->lx = wx;
owx = wx;
- while (wx <= lch &&
- ((wlp->flags & __ISFORCED) || !_cursesi_celleq(nsp, csp)))
+
+ if (wx <= lch &&
+ ((wlp->flags & __ISFORCED) || !_cursesi_celleq(nsp, csp)))
{
- if ((ce != NULL) && (wx >= nlsp) &&
- (nsp->ch == blank.ch) &&
- (__do_color_init == 1 || nsp->attr == blank.attr))
+ /*
+ * Consider clearing the line, if:
+ * - we have a clear to eol capability
+ * - current x pos is past last non blank char
+ * - the win char is blank
+ * - either we are initing colour or the attributes
+ * match.
+ * - Or the character is marked background
+ */
+ if ((clr_eol != NULL) && (wx >= nlsp) &&
+ (((nsp->cflags & CA_BACKGROUND) == CA_BACKGROUND) ||
+ ((nsp->ch == blank.ch) &&
+ (__do_color_init == 1 || nsp->attr == blank.attr))))
{
- /* Check for clear to end-of-line. */
- cep = &win->alines[wy]->line[win->maxx - 1];
- while (cep->ch == blank.ch && cep->attr == battr)
- if (cep-- <= csp)
- break;
-
- mlsp = &win->alines[wy]->line[win->maxx - 1]
- - win->alines[wy]->line
- - win->begx * __LDATASIZE;
-
- __CTRACE(__CTRACE_REFRESH,
- "makech: nlsp = %d, max = %zu, strlen(ce) = %zu\n",
- nlsp, mlsp, strlen(ce));
- __CTRACE(__CTRACE_REFRESH,
- "makech: line = %p, cep = %p, begx = %u\n",
- win->alines[wy]->line, cep, win->begx);
-
/*
* work out how to clear the line. If:
* - clear len is greater than clear_to_eol len
@@ -1363,17 +1372,15 @@
* then emit the ce string.
*/
if (((wy == win->maxy - 1) ||
- ((mlsp - wx) > strlen(ce))) &&
+ (((win->maxx - 1) - wx) > strlen(ce))) &&
((__using_color && back_color_erase) ||
(! __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)))) {
- __set_color(curscr, lspc &
- __COLOR);
+ (__do_color_init == 1)) {
+ __set_color(curscr,
+ curscr->wattr & __COLOR);
}
tputs(ce, 0, __cputchar);
_cursesi_screen->lx = wx + win->begx;
@@ -1393,6 +1400,7 @@
#endif /* HAVE_WCHAR */
assert(csp != &blank);
}
+
return OK;
}
}
@@ -2073,9 +2081,6 @@
tputs(exit_alt_charset_mode, 0, __cputchar);
curscr->wattr &= ~__ALTCHARSET;
}
- /* Don't leave the screen with colour set (check against ms). */
- if (__using_color && isms)
- __unset_color(curscr);
}
/* compare two line segments */
--R55TPpUKwrNW2A+w--
Home |
Main Index |
Thread Index |
Old Index