[patch] viewer UTF-8: Correctly position cursor for ACT_EDIT_LEFT in text input field.

Kalle Olavi Niemitalo <[email protected]>
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
(unnamed) (text/x-patch, 1.5 KB)
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 */
signature.asc (application/pgp-signature, 188 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFEzeAeHm9IGt60eMgRAoFYAJ9IrcRDbqXCBna/Qu7/AB3UJ3st8QCg2YRJ
bsFli3/GZzcq1+OHlalGhWM=
=DSrt
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.