bug-ncurses
[Top][All Lists]
Advanced

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

Multicolumn characters and Panels


From: Sadrul H Chowdhury
Subject: Multicolumn characters and Panels
Date: Sat, 17 Feb 2007 05:24:21 -0500

Hi. I came across this bug when using gaim-text. It's kind of difficult to explain. So I have included a sample test-program:

/*** START ***/
#include <ncurses.h>
#include <panel.h>
#include < locale.h>

int main()
{  
    setlocale(LC_ALL, "");
    initscr();

    WINDOW * 10, 0, 0);
    PANEL *pone = new_panel(one);
    WINDOW *two = newwin(10, 10, 2, 2);
    PANEL *ptwo = new_panel(two);

    mvwprintw(one, 2, 0, "%s", "a\u96e2");
    box(two, 0, 0);

    top_panel(ptwo);
    update_panels();
    doupdate();

    getch();
    endwin();
    return 0;
}

/*** END ***/
The problem is, ptwo tries to split the wide-character in displayed in pone. I have attached a very small screenshot (q.png) which makes the problem apparent.

I tried to come up with a patch, and I got:
--- ncurses/base/lib_refresh.c
+++ ncurses/base/lib_refresh.c
@@ -150,7 +150,19 @@
            if (last > limit_x)
                last = limit_x;
 
-           for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
+           j = oline->firstchar;
+           n = j + begx;
+           if (j <= last && n && isWidecExt(nline->text[n-1])) {
+               /* It's a multicolumn character. Replace with a space. */
+#if 0
+               NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+               nline->text[n-1] = blank;
+#else
+               nline->text[n-1].chars[0] = ' ';
+#endif
+               CHANGED_CELL(nline, n-1);
+           }
+           for (; j <= last; j++, n++) {
                if (!CharEq(oline->text[j], nline->text[n])) {
                    nline->text[n] = oline->text[j];
                    CHANGED_CELL(nline, n);

It did seem to work (by replacing the wide-character by a space to make sure it doesn't get displayed at all). However, if I bring up pone again (using top_panel), the wide-character remains invisible. So I think this probably is not the best fix. Is there any other fix I should try?

Cheers,
Sadrul

Attachment: q.png
Description: PNG image


reply via email to

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