|
From: <sa...@us...> - 2006-09-03 02:12:31
|
Revision: 17133
http://svn.sourceforge.net/gaim/?rev=17133&view=rev
Author: sadrul
Date: 2006-09-02 19:12:26 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/console/libgnt/gntmain.c
Modified: trunk/console/libgnt/gntmain.c
===================================================================
--- trunk/console/libgnt/gntmain.c 2006-09-02 23:23:30 UTC (rev 17132)
+++ trunk/console/libgnt/gntmain.c 2006-09-03 02:12:26 UTC (rev 17133)
@@ -1,3 +1,6 @@
+#define _XOPEN_SOURCE
+#define _XOPEN_SOURCE_EXTENDED
+
#include "config.h"
#ifdef HAVE_NCURSESW_INC
@@ -28,6 +31,8 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <wchar.h>
+
/**
* 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++) {
- 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));
- }
+ 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 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);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|