Re: [patch] terminal: Read modifiers from the first UTF-8 byte, not the last.

Kalle Olavi Niemitalo <[email protected]>
Newsgroups gmane.comp.web.links
Message-ID <[email protected]>
This revised patch can be applied on top of the
"UTF-8: Use UCS-4 in struct term_event_keyboard." series
<mid:[email protected]>.

_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev
(unnamed) (text/x-patch, 2.1 KB)
terminal: Read modifiers from the first UTF-8 byte, not the last.

Previously, ELinks used to silently discard the Alt modifier from
Alt-ö keystrokes when UTF-8 I/O was enabled.  Now, separate actions
can be bound to ö and Alt-ö.

However, if CONFIG_UTF_8 is defined, then actions cannot be bound to
non-ASCII characters, regardless of modifiers.  This is because the
code that handles names of keystrokes assumes a character can only be
a single byte.  This commit does not change that.

---
commit 9ab7c62ecd4faa4a31ca6b263378221e28f7a1b6
tree a46e62d66f08d81050d6229a2866c33f89c015bd
parent 9a946700365149cb7421cfa4381cddf15efe5b56
author Kalle Olavi Niemitalo <[email protected]> Sun, 06 Aug 2006 14:09:20 +0300
committer Kalle Olavi Niemitalo <[email protected]> Sun, 06 Aug 2006 14:09:20 +0300

 src/terminal/event.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/terminal/event.c b/src/terminal/event.c
index 260e915..bea8882 100644
--- a/src/terminal/event.c
+++ b/src/terminal/event.c
@@ -44,6 +44,12 @@ struct terminal_interlink {
 		unicode_val_T ucs;
 		int len;
 		int min;
+		/* Modifier keys from the key event that carried the
+		 * first byte of the character.  We need this because
+		 * ELinks sees e.g. ESC U+00F6 as 0x1B 0xC3 0xB6 and
+		 * converts it to Alt-0xC3 0xB6, attaching the
+		 * modifier to the first byte only.  */
+		int modifier;
 	} utf_8;
 
 	/* This is the queue of events as coming from the other ELinks instance
@@ -321,14 +327,15 @@ #endif /* CONFIG_UTF_8 */
 
 					if (u < interlink->utf_8.min)
 						u = UCS_REPLACEMENT_CHARACTER;
-					term_send_ucs(term, u, modifier);
+					term_send_ucs(term, u,
+						      term->interlink->utf_8.modifier);
 				}
 				break;
 
 			} else {
 				interlink->utf_8.len = 0;
 				term_send_ucs(term, UCS_REPLACEMENT_CHARACTER,
-					      modifier);
+					      term->interlink->utf_8.modifier);
 			}
 		}
 
@@ -358,6 +365,7 @@ #endif /* !CONFIG_UTF_8 */
 
 			interlink->utf_8.len = len - 1;
 			interlink->utf_8.ucs = key & (mask - 1);
+			interlink->utf_8.modifier = modifier;
 			break;
 		}
signature.asc (application/pgp-signature, 188 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFE1c9EHm9IGt60eMgRAg61AKC/SpWZXU26ISfpiGCrEVhvFlNBkgCg2eks
btLduuhGR+lnsTbEtz4S6l4=
=KSzt
-----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.