From 81778bc5d7927f0d0d3cfa862245204363a10bff Mon Sep 17 00:00:00 2001 From: Pavol Babincak Date: Sat, 4 Feb 2006 02:18:00 +0100 Subject: [PATCH] Correct computing of cursor position in UTF-8 textarea. --- src/viewer/text/form.c | 6 +++--- src/viewer/text/textarea.c | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index 814b3f350..82228c9b1 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -1634,12 +1634,12 @@ field_op(struct session *ses, struct document_view *doc_view, i = 0; break; } + if (i == 6) { i = 0; - return FRAME_EVENT_OK; - } else { - return FRAME_EVENT_OK; } + return FRAME_EVENT_OK; + } else { if (!insert_in_string(&fs->value, fs->state, "?", 1)) return FRAME_EVENT_OK; diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index ab5920ec1..bffe0e9fe 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -95,9 +95,9 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format) pos = wrappos - text; } skip = !!wrappos; - char_cnt = 0; - wrappos = NULL; } + char_cnt = 0; + wrappos = NULL; if (!realloc_line_info(&line, line_number)) { mem_free_if(line); @@ -238,10 +238,13 @@ area_cursor(struct form_control *fc, struct form_state *fs) } #ifdef CONFIG_UTF_8 if (utf8) { - unsigned char *text = fs->value + line[y].start; + unsigned char *text = fs->value; unsigned char tmp = fs->value[fs->state]; fs->value[fs->state] = '\0'; + fs->utf8_pos = strlen_utf8(&text); + + text = fs->value + line[y].start; x = strlen_utf8(&text); fs->value[fs->state] = tmp; } else