diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-22 23:29:29 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-22 23:29:29 +0200 |
commit | fc395d40681bdd76b7262d536668ffc093c5246d (patch) | |
tree | 9e8afce81a6cb40eaafaea73d4d13d15c9c1c98d /src | |
parent | 6155c9bf91262ae8a10005f13a61f3bdb5f6eb59 (diff) | |
download | tdv-fc395d40681bdd76b7262d536668ffc093c5246d.tar.gz tdv-fc395d40681bdd76b7262d536668ffc093c5246d.tar.xz tdv-fc395d40681bdd76b7262d536668ffc093c5246d.zip |
Fix mouse clicks on full width characters
Diffstat (limited to 'src')
-rw-r--r-- | src/sdtui.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/sdtui.c b/src/sdtui.c index 0b4bd22..a11646a 100644 --- a/src/sdtui.c +++ b/src/sdtui.c @@ -954,7 +954,7 @@ app_redraw_top (Application *self) guint offset, i; for (offset = i = 0; i < self->input_pos; i++) - // This may be inconsistent with RowBuffer + // FIXME: this may be inconsistent with RowBuffer (locale) offset += unichar_width (g_array_index (self->input, gunichar, i)); move (1, MIN ((gint) (indent + offset), COLS - 1)); @@ -1741,9 +1741,18 @@ app_process_left_mouse_click (Application *self, int line, int column) gint pos = column - label_len; if (pos >= 0) { - self->input_pos = MIN ((guint) pos, self->input->len); - move (1, label_len + self->input_pos); - refresh (); + guint offset, i; + for (offset = i = 0; i < self->input->len; i++) + { + // FIXME: this may be inconsistent with RowBuffer (locale) + size_t width = unichar_width + (g_array_index (self->input, gunichar, i)); + if ((offset += width) > (guint) pos) + break; + } + + self->input_pos = i; + app_redraw_top (self); } } else if (line <= (int) (app_count_view_items (self) - self->top_offset)) |