1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Correct computing of cursor position in UTF-8 textarea.

This commit is contained in:
Pavol Babincak 2006-02-04 02:18:00 +01:00 committed by Jonas Fonseca
parent f9d67aeb73
commit 81778bc5d7
2 changed files with 9 additions and 6 deletions

View File

@ -1634,12 +1634,12 @@ field_op(struct session *ses, struct document_view *doc_view,
i = 0; i = 0;
break; break;
} }
if (i == 6) { if (i == 6) {
i = 0; i = 0;
return FRAME_EVENT_OK;
} else {
return FRAME_EVENT_OK;
} }
return FRAME_EVENT_OK;
} else { } else {
if (!insert_in_string(&fs->value, fs->state, "?", 1)) if (!insert_in_string(&fs->value, fs->state, "?", 1))
return FRAME_EVENT_OK; return FRAME_EVENT_OK;

View File

@ -95,9 +95,9 @@ format_textutf8(unsigned char *text, int width, enum form_wrap wrap, int format)
pos = wrappos - text; pos = wrappos - text;
} }
skip = !!wrappos; skip = !!wrappos;
char_cnt = 0;
wrappos = NULL;
} }
char_cnt = 0;
wrappos = NULL;
if (!realloc_line_info(&line, line_number)) { if (!realloc_line_info(&line, line_number)) {
mem_free_if(line); mem_free_if(line);
@ -238,10 +238,13 @@ area_cursor(struct form_control *fc, struct form_state *fs)
} }
#ifdef CONFIG_UTF_8 #ifdef CONFIG_UTF_8
if (utf8) { if (utf8) {
unsigned char *text = fs->value + line[y].start; unsigned char *text = fs->value;
unsigned char tmp = fs->value[fs->state]; unsigned char tmp = fs->value[fs->state];
fs->value[fs->state] = '\0'; fs->value[fs->state] = '\0';
fs->utf8_pos = strlen_utf8(&text);
text = fs->value + line[y].start;
x = strlen_utf8(&text); x = strlen_utf8(&text);
fs->value[fs->state] = tmp; fs->value[fs->state] = tmp;
} else } else