Commit Diff


commit - 2c70acc3ab751ab1ccb1999f1d22310ad8c35b27
commit + 3850e6e177677885074c8896ef24534894726ad5
blob - bc7cb5afb507137175c26c4639d37447643c8feb
blob + 07bfb96028eabc70a9aaa07d243ceb7614cd341e
--- man/man7/keyboard.7
+++ man/man7/keyboard.7
@@ -58,7 +58,7 @@ The up arrow scrolls backward.
 .PP
 Characters in Plan 9 are runes (see
 .IR utf (7)).
-Any 16-bit rune can be typed using a compose key followed by several
+Any rune can be typed using a compose key followed by several
 other keys.
 The compose key is also generally near the lower right of the main key area:
 the
@@ -72,14 +72,21 @@ key on the SLC, the
 key on the Magnum, and either
 .B Alt
 key on the PC.
-After typing the compose key, type a capital
-.L X
-and exactly four hexadecimal characters (digits and
+To type a single rune with the value specified by
+a given four-digit hexadecimal number,
+type the compose key,
+then a capital
+.LR X ,
+and then the four hexadecimal digits (decimal digits and
 .L a
 to
-.LR f )
-to type a single rune with the value represented by
-the typed number.
+.LR f ).
+For a longer rune, type
+.L X
+twice followed by five digits,
+or type
+.L X
+three times followed by six digits.
 There are shorthands for many characters, comprising
 the compose key followed by a two- or three-character sequence.
 The full list is too long to repeat here, but is contained in the file
blob - a3d13a088614807c4c742261dff5aa58a7b94319
blob + 87c0be458445fb2b5fcc7b7a8d58535e203f8b46
--- src/cmd/devdraw/latin1.c
+++ src/cmd/devdraw/latin1.c
@@ -17,16 +17,15 @@ static struct cvlist
 };
 
 /*
- * Given 5 characters k[0]..k[4], find the rune or return -1 for failure.
+ * Given 5 characters k[0]..k[n], find the rune or return -1 for failure.
  */
 static long
-unicode(Rune *k)
+unicode(Rune *k, int n)
 {
 	long i, c;
 
-	k++;	/* skip 'X' */
 	c = 0;
-	for(i=0; i<4; i++,k++){
+	for(i=0; i<n; i++,k++){
 		c <<= 4;
 		if('0'<=*k && *k<='9')
 			c += *k-'0';
@@ -36,6 +35,8 @@ unicode(Rune *k)
 			c += 10 + *k-'A';
 		else
 			return -1;
+		if(c > Runemax)
+			return -1;
 	}
 	return c;
 }
@@ -53,10 +54,32 @@ latin1(Rune *k, int n)
 	char* p;
 
 	if(k[0] == 'X'){
-		if(n>=5)
-			return unicode(k);
-		else
-			return -5;
+		if(n < 2)
+			return -2;
+		if(k[1] == 'X') {
+			if(n < 3)
+				return -3;
+			if(k[2] == 'X') {
+				if(n < 9) {
+					if(unicode(k+3, n-3) < 0)
+						return -1;
+					return -(n+1);
+				}
+				return unicode(k+3, 6);
+			}
+			if(n < 7) {
+				if(unicode(k+2, n-2) < 0)
+					return -1;
+				return -(n+1);
+			}
+			return unicode(k+2, 5);
+		}
+		if(n < 5) {
+			if(unicode(k+1, n-1) < 0)
+				return -1;
+			return -(n+1);
+		}
+		return unicode(k+1, 4);
 	}
 
 	for(l=latintab; l->ld!=0; l++)