bug-ncurses
[Top][All Lists]
Advanced

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

Re: in_wch and add_wch


From: Sadrul H Chowdhury
Subject: Re: in_wch and add_wch
Date: Sat, 2 Sep 2006 22:08:08 -0400


On 9/2/06, Thomas Dickey <address@hidden> wrote:
On Sat, 2 Sep 2006, Sadrul H Chowdhury wrote:

> Hi.
>
> I am trying to in_wch a wide-character (cchar_t), change the attribute and
> add_wch that to the screen again in the same position. But I am not sure
> what I am doing wrong, because it's not behaving properly.

at the moment, I don't see either.  I built it with a debugging version of
ncurses, so I could trace it.  I see this chunk:
<snip>

and checking the original value written to the 0,0 position, it matches
the parameter given to wadd_wch().  The trace of the corresponding
waddch's does not look right - perhaps you've found a bug (will check).


I am currently using a hack to work around this problem. Instead of doing add_wch(), I am delch()ing W times from that location (where W is the column-width of the character), changing the attribute, and then ins_wch()ing, and it seems to work! The code follows:

/*** START ***/
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED
#include <ncursesw/ncurses.h>
#include <wchar.h>
#include <locale.h>

int main()
{
    cchar_t ch;
    int i, j, w = 1;

    setlocale(LC_ALL, "");
    initscr();

    mvprintw(0, 0, "%s", "\u4e0a\u6d77\u6700\u4f4e\u6708\u5de5");
    mvprintw(5, 0, "%s", "\u4e0a\u6d77\u6700\u4f4e\u6708\u5de5");

    for (i = 0; i < 12; i += w) {
        if (mvin_wch(0, i, &ch) == OK) {
            w = wcswidth(ch.chars, CCHARW_MAX);
            for (j = 0; j < w; j++) {
                mvdelch(0, i);
            }
            ch.attr |= WA_REVERSE;
            mvins_wch(0, i, &ch);
        }
    }

    mvgetch(1,0);
    endwin();
    return 0;
}
/*** END ***/

Cheers,
Sadrul

reply via email to

[Prev in Thread] Current Thread [Next in Thread]