Revision: 17591
http://svn.sourceforge.net/gaim/?rev=17591&view=rev
Author: sadrul
Date: 2006-10-27 11:30:56 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
This fixes at least some issues with wide-characters in the tree-widget.
Modified Paths:
--------------
trunk/console/libgnt/gnttree.c
trunk/console/libgnt/gntutils.c
Modified: trunk/console/libgnt/gnttree.c
===================================================================
--- trunk/console/libgnt/gnttree.c 2006-10-27 18:19:40 UTC (rev 17590)
+++ trunk/console/libgnt/gnttree.c 2006-10-27 18:30:56 UTC (rev 17591)
@@ -196,8 +196,8 @@
for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next)
{
GntTreeCol *col = iter->data;
- char *text;
- int len = g_utf8_strlen(col->text, -1);
+ const char *text;
+ int len = gnt_util_onscreen_width(col->text, NULL);
int fl = 0;
if (i == 0)
@@ -235,7 +235,7 @@
len = tree->columns[i].width;
}
- text = g_utf8_offset_to_pointer(col->text, len - fl);
+ text = gnt_util_onscreen_width_to_pointer(col->text, len - fl, NULL);
string = g_string_append_len(string, col->text, text - col->text);
if (len < tree->columns[i].width && iter->next)
g_string_append_printf(string, "%*s", tree->columns[i].width - len, "");
@@ -324,6 +324,7 @@
tree->top = get_prev_n(tree->current, rows);
row = tree->top;
+ scrcol = widget->priv.width - 1 - 2 * pos; /* exclude the borders and the scrollbar */
for (i = start + pos; row && i < widget->priv.height - pos;
i++, row = get_next(row))
{
@@ -335,10 +336,10 @@
str = update_row_text(tree, row);
- if ((wr = g_utf8_strlen(str, -1)) >= widget->priv.width - 1 - pos)
+ if ((wr = gnt_util_onscreen_width(str, NULL)) > scrcol)
{
/* XXX: ellipsize */
- char *s = g_utf8_offset_to_pointer(str, widget->priv.width - 1 - pos);
+ char *s = (char*)gnt_util_onscreen_width_to_pointer(str, scrcol, &wr);
*s = '\0';
}
@@ -368,7 +369,7 @@
wbkgdset(widget->window, '\0' | attr);
mvwprintw(widget->window, i, pos, str);
- whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1) - 1);
+ whline(widget->window, ' ', scrcol - wr);
tree->bottom = row;
g_free(str);
tree_mark_columns(tree, pos, i,
@@ -385,7 +386,7 @@
i++;
}
- scrcol = widget->priv.width - pos - 1;
+ scrcol = widget->priv.width - pos - 1; /* position of the scrollbar */
rows--;
if (rows > 0)
{
Modified: trunk/console/libgnt/gntutils.c
===================================================================
--- trunk/console/libgnt/gntutils.c 2006-10-27 18:19:40 UTC (rev 17590)
+++ trunk/console/libgnt/gntutils.c 2006-10-27 18:30:56 UTC (rev 17591)
@@ -60,7 +60,7 @@
const char *str = string;
if (len <= 0) {
- len = g_utf8_strlen(string, -1);
+ len = gnt_util_onscreen_width(string, NULL);
}
while (width < len && *str) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|