[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue with wbkgrnd and wide chars on ncurses 6.2
From: |
Anton Vidovic |
Subject: |
Issue with wbkgrnd and wide chars on ncurses 6.2 |
Date: |
Sat, 30 Jan 2021 20:21:26 +0100 |
Hello Thomas,
I contacted you last April [0] about a bug I encountered while working on
a Common Lisp binding for ncurses.
When upgrading from ncurses 6.1 to 6.2 the routine wbkgrnd stopped working.
When called with a wide character, it does not copy the character to every
cell of the terminal.
As far as I could, I tracked down the source of the bug to the following
line 209 in ncurses/base/lib_bkgd.c
for (y = 0; y <= win->_maxy; y++) {
int x;
for (x = 0; x <= win->_maxx; x++) {
NCURSES_CH_T *cp = &(win->_line[y].text[x]);
int tmp_pair = GetPair(*cp);
attr_t tmp_attr = AttrOf(*cp);
if (CharEq(*cp, old_bkgd)) {
>>>> SetChar2(*cp, CharOf(new_char)); <<<<<<<
}
In ncurses 6.1, instead of the call to SetChar2, we directly set the
character at y,x to the character set by the call to wbkgrndset.
win->_line[y].text[x] = win->_nc_bkgd;
In addition to the minimal example in Lisp [2] I provided last year,
this would be equivalent minimal example in C:
#define _XOPEN_SOURCE_EXTENDED
#include <locale.h>
#include <ncurses.h>
int main()
{
cchar_t cch;
const wchar_t wch[2] = {L'\u2591', L'\0'};
setlocale(LC_ALL, "");
setcchar(&cch,
wch,
0,
0,
NULL);
initscr();
bkgrnd(&cch);
refresh();
getch();
endwin();
printf("%lc\n", wch[0]);
return 0;
}
This allows setting single-byte chars like 'A' as a background char,
but if any wide char like L'\u2591' is passed, it is simply ignored.
Last year I did not have success replicating the bug in C, but in the
meantime I have upgraded my machine, and now with a fresh install of
Ubuntu 20.04 with a default install of ncurses 6.2.20200212, the C
example replicates the behavior I encountered with Lisp.
I hope you will find an opportunity to address this issue.
Kind regards,
Anton
[0] https://lists.gnu.org/archive/html/bug-ncurses/2020-04/msg00002.html
[1]
https://github.com/ThomasDickey/ncurses-snapshots/blob/b2401f2eb8036772cc8165a7fd863ad56a868969/ncurses/base/lib_bkgd.c#L209
[2]
https://github.com/McParen/croatoan/blob/086f34a48f6dbea511ff72b17a9e054635e37e7d/test/unicode.lisp#L121
- Issue with wbkgrnd and wide chars on ncurses 6.2,
Anton Vidovic <=