From 9a64a8cdd8ce6fac18e3d219dd6e3d1c76dac442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 13 Feb 2016 12:26:57 +0100 Subject: Convert call sites of text_line_char_{get,set} to text_line_width_{get,set} --- main.c | 2 +- text-motions.c | 8 ++++---- vis.c | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index a8529f9..49c41b2 100644 --- a/main.c +++ b/main.c @@ -1176,7 +1176,7 @@ static const char *cursors_align(Vis *vis, const char *keys, const Arg *arg) { for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) { if (view_cursors_cell_set(c, mincol) == -1) { size_t pos = view_cursors_pos(c); - size_t col = text_line_char_set(txt, pos, mincol); + size_t col = text_line_width_set(txt, pos, mincol); view_cursors_to(c, col); } } diff --git a/text-motions.c b/text-motions.c index 04ccab1..298d4ac 100644 --- a/text-motions.c +++ b/text-motions.c @@ -314,15 +314,15 @@ size_t text_line_char_prev(Text *txt, size_t pos) { } size_t text_line_up(Text *txt, size_t pos) { - int count = text_line_char_get(txt, pos); + int width = text_line_width_get(txt, pos); size_t prev = text_line_prev(txt, pos); - return text_line_char_set(txt, prev, count); + return text_line_width_set(txt, prev, width); } size_t text_line_down(Text *txt, size_t pos) { - int count = text_line_char_get(txt, pos); + int width = text_line_width_get(txt, pos); size_t next = text_line_next(txt, pos); - return text_line_char_set(txt, next, count); + return text_line_width_set(txt, next, width); } size_t text_range_line_first(Text *txt, Filerange *r) { diff --git a/vis.c b/vis.c index 1138dd7..848180f 100644 --- a/vis.c +++ b/vis.c @@ -1056,9 +1056,8 @@ void vis_insert_tab(Vis *vis) { int tabwidth = MIN(vis->tabwidth, LENGTH(spaces) - 1); for (Cursor *c = view_cursors(vis->win->view); c; c = view_cursors_next(c)) { size_t pos = view_cursors_pos(c); - /* FIXME: this does not take double width characters into account */ - int chars = text_line_char_get(vis->win->file->text, pos); - int count = tabwidth - (chars % tabwidth); + int width = text_line_width_get(vis->win->file->text, pos); + int count = tabwidth - (width % tabwidth); for (int i = 0; i < count; i++) spaces[i] = ' '; spaces[count] = '\0'; -- cgit v1.2.3