From 711ee0a33f0c27dd892eb5796f3bbd7ff85c777b Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sat, 2 Dec 2006 16:35:51 +0000 Subject: [PATCH] Fix horizontal scrolling of textareas when UTF-8 I/O is enabled As draw_textarea_utf8 loops over each character of the textarea content, it checks whether the character is on the screen; draws it if so; increments the screen co-ordinate; and updates the position in the textarea text. The last step was being skipped when the character was not on the line, so a line would be drawn from the beginning, even if the left edge of the textarea is off the screen. Closes: Bug 835 - Text in textarea is unaffected by horizontal scrolling of document in UTF-8 mode --- src/viewer/text/textarea.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index dcd38959..b6c9457d 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -363,24 +363,23 @@ draw_textarea_utf8(struct terminal *term, struct form_state *fs, for (i = 0, x = xbase; i < fc->cols; i++, x++) { unicode_val_T data; - if (!col_is_in_box(box, x)) - continue; - if (i >= -fs->vpos && text < end) { - int cell; - + /* utf8_to_unicode will increment text. */ data = utf8_to_unicode(&text, end); - cell = unicode_to_cell(data); + } else + data = '_'; + + if (col_is_in_box(box, x)) { + int cell = unicode_to_cell(data); + if (cell == 2) { draw_char_data(term, x++, y, data); i++; data = UCS_NO_CHAR; } - } else - data = '_'; - - draw_char_data(term, x, y, data); + draw_char_data(term, x, y, data); + } } }