[PATCH v2 3/3] Fixes compute selection
Peng Wu
peng.e.wu at gmail.com
Wed Jul 17 00:50:25 PDT 2013
Correctly compute the mouse selection when some wide glyphs in rows.
---
clients/terminal.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/clients/terminal.c b/clients/terminal.c
index d45b740..37f1af8 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -2437,6 +2437,8 @@ recompute_selection(struct terminal *terminal)
int start_x, end_x;
int cw, ch;
union utf8_char *data;
+ gunichar unichar;
+ gboolean iswide;
cw = terminal->average_width;
ch = terminal->extents.height;
@@ -2479,6 +2481,11 @@ recompute_selection(struct terminal *terminal)
eol = col + 1;
if (start_x < x)
break;
+ /* check dual width unicode character */
+ unichar = g_utf8_get_char((const char*) data[col].byte);
+ iswide = g_unichar_iswide(unichar);
+ if (iswide)
+ x += cw;
}
switch (terminal->dragging) {
@@ -2506,6 +2513,13 @@ recompute_selection(struct terminal *terminal)
if (terminal->dragging == SELECT_WORD &&
end_x < x && wordsep(data[col].ch))
break;
+ /* check dual width unicode character */
+ unichar = g_utf8_get_char((const char*) data[col].byte);
+ iswide = g_unichar_iswide(unichar);
+ if (iswide)
+ x += cw;
+ if (end_x < x)
+ break;
}
terminal->selection_end_col = col;
}
--
1.8.3.1
More information about the wayland-devel
mailing list