# HG changeset patch # User Sadrul Habib Chowdhury # Date 1157249546 0 # Node ID 3a91ef295cbbdf916cb729e968fe1c7fe9e710ce # Parent c374f45f4c948f4fab5daa212144689f2ac3b4e9 [gaim-migrate @ 17133] If the window-title has wide-characters, and you go in move/resize mode, then reversing the colors screws up the title. This is a fix for that. It's a bit hackish, but that's the way it's gotta be for now. committer: Tailor Script diff -r c374f45f4c94 -r 3a91ef295cbb console/libgnt/gntmain.c --- a/console/libgnt/gntmain.c Sat Sep 02 23:23:30 2006 +0000 +++ b/console/libgnt/gntmain.c Sun Sep 03 02:12:26 2006 +0000 @@ -1,3 +1,6 @@ +#define _XOPEN_SOURCE +#define _XOPEN_SOURCE_EXTENDED + #include "config.h" #ifdef HAVE_NCURSESW_INC @@ -28,6 +31,8 @@ #include #include +#include + /** * Notes: Interesting functions to look at: * scr_dump, scr_init, scr_restore: for workspaces @@ -647,6 +652,28 @@ return FALSE; /* XXX: this should be TRUE */ } +/* Returns the onscreen width of the character at the position */ +static int +reverse_char(WINDOW *d, int y, int x, gboolean set) +{ + /* This is supposed to simply in_wch the cchar_t, set the attribute, + * and add_wch. But that doesn't currently work, possibly because of + * a bug in ncurses. This is an ugly hack to work around that. */ + cchar_t ch; + int wc = 1, j; + +#define DECIDE(ch) (set ? ((ch) | WA_REVERSE) : ((ch) & ~WA_REVERSE)) + + if (mvwin_wch(d, y, x, &ch) == OK) { + wc = wcswidth(ch.chars, CCHARW_MAX); + for (j = 0; j < wc; j++) + mvwdelch(d, y, x); + ch.attr = DECIDE(ch.attr); + mvwins_wch(d, y, x, &ch); + } + return wc; +} + static void window_reverse(GntWidget *win, gboolean set) { @@ -660,23 +687,13 @@ d = win->window; gnt_widget_get_size(win, &w, &h); -#define DECIDE(ch) (set ? ((ch) | A_REVERSE) : ((ch) & ~A_REVERSE)) + /* the top and bottom */ + for (i = 0; i < w; i += reverse_char(d, 0, i, set)); + for (i = 0; i < w; i += reverse_char(d, h-1, i, set)); - /* the top and bottom */ - for (i = 0; i < w; i++) { - chtype ch = mvwinch(d, 0, i); - mvwaddch(win->window, 0, i, DECIDE(ch)); - ch = mvwinch(d, h-1, i); - mvwaddch(win->window, h-1, i, DECIDE(ch)); - } - - /* the left an right */ - for (i = 0; i < h; i++) { - chtype ch = mvwinch(d, i, 0); - mvwaddch(win->window, i, 0, DECIDE(ch)); - ch = mvwinch(d, i, w-1); - mvwaddch(win->window, i, w-1, DECIDE(ch)); - } + /* the left and right */ + for (i = 0; i < h; i += reverse_char(d, i, 0, set)); + for (i = 0; i < h; i += reverse_char(d, i, w-1, set)); wrefresh(win->window); } @@ -854,8 +871,7 @@ else if (buffer[1] == 0) { mode = GNT_KP_MODE_NORMAL; - changed = TRUE; - gnt_widget_draw(widget); + window_reverse(widget, FALSE); } if (changed) @@ -964,7 +980,7 @@ if ((pid == (pid_t) - 1) && (errno != ECHILD)) { char errmsg[BUFSIZ]; - snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid); + g_snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid); perror(errmsg); } }