summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2007-02-07 18:20:49 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2007-02-07 18:20:49 +0000
commit4f49a38402a8c5e04f6901e5296fb391400236be (patch)
tree8a3b4c7fb5a026820c9a478212d5ef4b39ea8463 /src
parent7c48fc2fb30cf13ff5075c6d0ef78a38e07f8dd2 (diff)
downloadirssi-4f49a38402a8c5e04f6901e5296fb391400236be.zip
Redraw input line correctly in an utf8 locale when deleting a
nonspacing char by taking in account the cell width, bug #459. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4414 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-text/gui-entry.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index 63813af3..f11d7b15 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -507,8 +507,18 @@ void gui_entry_erase_to(GUI_ENTRY_REC *entry, int pos, int update_cutbuffer)
gui_entry_erase(entry, size, update_cutbuffer);
}
+static size_t cell_width(unichar *buf, int len)
+{
+ unichar *str = buf;
+
+ while (len-- && utf8_width(*str--) == 0);
+ return buf - str;
+}
+
void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer)
{
+ size_t w = 0;
+
g_return_if_fail(entry != NULL);
if (entry->pos < size)
@@ -532,13 +542,16 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size, int update_cutbuffer)
return;
}
+ if (entry->utf8)
+ w = cell_width(entry->text + entry->pos - size, entry->pos - size + 1)-1;
+
g_memmove(entry->text + entry->pos - size, entry->text + entry->pos,
(entry->text_len-entry->pos+1) * sizeof(unichar));
entry->pos -= size;
entry->text_len -= size;
- gui_entry_redraw_from(entry, entry->pos);
+ gui_entry_redraw_from(entry, entry->pos-w);
gui_entry_fix_cursor(entry);
gui_entry_draw(entry);
}