mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
viewer UTF-8: Correctly position cursor for ACT_EDIT_LEFT in text input field.
To reproduce the bug before this patch: Enable CONFIG_UTF_8, UTF-8 I/O, and UTF-8 charset. Go to www.google.com and type "abc" in the text input field. Then press Left. The cursor jumps to "a" when it should go to "c".
This commit is contained in:
parent
5fd284d6a2
commit
7dcc6c9a19
@ -1312,15 +1312,17 @@ field_op(struct session *ses, struct document_view *doc_view,
|
||||
if (utf8) {
|
||||
int old_state = fs->state;
|
||||
unsigned char *new_value;
|
||||
int cells;
|
||||
|
||||
new_value = utf8_prevchar(fs->value + fs->state, 1, fs->value);
|
||||
fs->state = new_value - fs->value;
|
||||
|
||||
if (old_state != fs->state) {
|
||||
if (fc->type == FC_PASSWORD)
|
||||
fs->state_cell = int_max(fs->state_cell - 1, 0);
|
||||
cells = 1;
|
||||
else
|
||||
fs->state_cell = int_max(utf8_char2cells(new_value, NULL) - 1, 0);
|
||||
cells = utf8_char2cells(new_value, NULL);
|
||||
fs->state_cell = int_max(fs->state_cell - cells, 0);
|
||||
}
|
||||
} else
|
||||
#endif /* CONFIG_UTF_8 */
|
||||
|
Loading…
Reference in New Issue
Block a user