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".

---
commit 8c6b696ccf182848a2c7e86aadb9b8434b4292ac
tree 19af58f4133081277903a983f9f745e4df88851f
parent 2683a6308502ebd09827e2310a8bc44455f5b41c
author Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Mon, 31 Jul 2006 13:43:41 +0300
committer Kalle Olavi Niemitalo <[EMAIL PROTECTED]> Mon, 31 Jul 2006 13:43:41 +0300

 src/viewer/text/form.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c
index 40cb5bd..43c7080 100644
--- a/src/viewer/text/form.c
+++ b/src/viewer/text/form.c
@@ -1312,15 +1312,17 @@ #ifdef CONFIG_UTF_8
 			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 */

Attachment: pgpieAGWnIkl3.pgp
Description: PGP signature

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to