NetBSD-Bugs archive

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

Re: lib/23910 (libcurses: bug in redraw()?)



The following reply was made to PR lib/23910; it has been noted by GNATS.

From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: Julian Coleman <jdc%coris.org.uk@localhost>, Roy Marples <roy%marples.name@localhost>
Subject: Re: lib/23910 (libcurses: bug in redraw()?)
Date: Sun, 11 Nov 2018 05:17:06 +0300

 Simplified test follows.
 
 Using explicit wbkgd(w, COLOR_PAIR(2) | ' '); instead of wbkgdset()
 makes it work.  When it fails it emits
 
     \E[37m\E[41mA \E[C\E[CZ\E[37m\E[40m  ...
 
 so the curses knows to use space to fill the screen with background
 color, but doesn't do that for the test window.
 
 Using mvwaddstr(w, 0, 0, "A\n"); (with wbkgdset) also does the right
 thing, the window is filled with spaces.  So, wclrtoeol() (that the
 newline translates to) does the right thing here.  So does wclrtobot()
 too.
 
 #include <curses.h>
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
 
 int
 main()
 {
     const char *errmsg = NULL;
     int err = OK;
 
 #define CHECKERR(_msg)                          \
     do {                                        \
         if (err != OK) {                        \
             errmsg = _msg " failed";            \
             goto out;                           \
         }                                       \
     } while (0)
 
 
     WINDOW *scrw = initscr();
     if (scrw == NULL)
         errx(EXIT_FAILURE, "initscr failed");
 
     if (!has_colors()) {
         errmsg = "no colors";
         goto out;
     }
 
     start_color();
     init_pair(2, COLOR_WHITE, COLOR_RED);
 
     const int width = 5;
 
     WINDOW *w = newwin(1, width, 0, 0);
     if (border == NULL) {
         errmsg = "newwin failed";
         goto out;
     }
 
     wbkgdset(w, COLOR_PAIR(2));
     // wbkgd(w, COLOR_PAIR(2) | ' '); // this works
 
     werase(w);
 
 #if 1
     mvwaddstr(w, 0, 0, "A ");
     mvwaddstr(w, 0, width-1, "Z");
 #else
     mvwaddstr(w, 0, 0, "A\n"); // this works (with wbkgdset)
 #endif
 
     wnoutrefresh(stdscr);
     wnoutrefresh(w);
     doupdate();
 
 out:
     endwin();
 
     if (err != OK || errmsg != NULL) {
         if (errmsg == NULL)
             errmsg = "unknown error";
         fprintf(stderr, "%s\n", errmsg);
         return EXIT_FAILURE;
     }
 
     return EXIT_SUCCESS;
 }
 
 
 -uwe
 


Home | Main Index | Thread Index | Old Index