shithub: riscv

Download patch

ref: 1015ae8ea86cc4cdcea7ab6048440b9e5f58da26
parent: c501fe69366175312b39f7eead949f9b27c03ef6
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Oct 17 14:39:44 EDT 2013

kbdfs: implement <compoxe>x to enter variable length unicode as suggested by erik quanstro

from: http://9fans.net/archive/2013/04/327

since <compose>x is not yet entrenched, i have a suggestion for ease of
input.  suppose <compose>x were redefined so the syntax were
"<compose>x[0-9a-f]+;".  in the case that 6 hex digits are entered, then
the ";" is not necessary.

not only would this allow for entering 21-bit runes, it would also allow for
short sequences to be entered more easily.

- erik

--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -514,22 +514,22 @@
 		if(nextrune(rawchan, &r))
 			continue;
 
-		if(r == 'X'){
+		if(r == 'x' || r == 'X'){
+			i = (r == 'X') ? 4 : 6;
 			r = 0;
-			for(i = 0; i<4; i++){
+			do {
 				if(nextrune(rawchan, &rr))
 					break;
-				r <<= 4;
 				if(rr >= '0' && rr <= '9')
-					r |= (rr - '0');
+					r = (r << 4) | (rr - '0');
 				else if(rr >= 'a' && rr <= 'f')
-					r |= 10 + (rr - 'a');
+					r = (r << 4) | (10 + (rr - 'a'));
 				else if(rr >= 'A' && rr <= 'F')
-					r |= 10 + (rr - 'A');
+					r = (r << 4) | (10 + (rr - 'A'));
 				else
 					break;
-			}
-			if(i == 4 && r)
+			} while(--i > 0);
+			if((i == 0 || rr == ';') && r != 0 && r < Runemax)
 				goto Forward;
 		} else {
 			if(nextrune(rawchan, &rr))
--