keyboard(7): document X compose sequences
Add -x flag to mklatinkbd to generate file for $HOME/.XCompose. Thanks to Anthony Martin, Tony Lainson, and Kris Maglione for legwork. R=rsc http://codereview.appspot.com/3811043
This commit is contained in:
parent
4f52e8afe9
commit
b567422f98
4 changed files with 162 additions and 23 deletions
|
|
@ -171,6 +171,57 @@ yields £.
|
||||||
.PP
|
.PP
|
||||||
Note the difference between ß (ss) and µ (micron) and
|
Note the difference between ß (ss) and µ (micron) and
|
||||||
the Greek β and μ.
|
the Greek β and μ.
|
||||||
|
.SS "X WINDOWS
|
||||||
|
Under X Windows, both the Alt key and the ``Multi key''
|
||||||
|
can begin a compose sequence in a Plan 9 program.
|
||||||
|
.PP
|
||||||
|
It is also possible to configure X Windows to use the
|
||||||
|
same keystroke mappings as the Plan 9 programs.
|
||||||
|
First, generate an XCompose sequence list by using
|
||||||
|
.IR mklatinkbd :
|
||||||
|
.IP
|
||||||
|
.EX
|
||||||
|
mklatinkbd -x $PLAN9/lib/keyboard >$HOME/.XCompose
|
||||||
|
.EE
|
||||||
|
.LP
|
||||||
|
Second, configure a ``Multi key'' by running
|
||||||
|
.IP
|
||||||
|
.EX
|
||||||
|
xmodmap -e 'keysym Super_L = Multi_key'
|
||||||
|
.EE
|
||||||
|
.LP
|
||||||
|
(The name
|
||||||
|
.L Super_L
|
||||||
|
typically denotes the Windows key on recent keyboards.)
|
||||||
|
.PP
|
||||||
|
Third, set these environment variables so that GTK- and QT-based programs
|
||||||
|
will use the compose sequences:
|
||||||
|
.IP
|
||||||
|
.EX
|
||||||
|
export GTK_IM_MODULE=xim
|
||||||
|
export QT_IM_MODULE=xim
|
||||||
|
.EE
|
||||||
|
.LP
|
||||||
|
Finally, start a new GTK- or QT-based program:
|
||||||
|
.IP
|
||||||
|
.EX
|
||||||
|
gnome-terminal &
|
||||||
|
.EE
|
||||||
|
.LP
|
||||||
|
In that terminal, typing the key sequence
|
||||||
|
.RB ` Windows
|
||||||
|
.B *
|
||||||
|
.BR a '
|
||||||
|
should be interpreted as the Greek letter
|
||||||
|
.LR α .
|
||||||
|
.PP
|
||||||
|
If using the GNOME Window Manager, put the
|
||||||
|
.B xmodmap
|
||||||
|
and
|
||||||
|
.B export
|
||||||
|
commands into the file
|
||||||
|
.B $HOME/.gnomerc
|
||||||
|
to run them automatically at startup.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.TP
|
.TP
|
||||||
.B \*9/lib/keyboard
|
.B \*9/lib/keyboard
|
||||||
|
|
|
||||||
|
|
@ -48,3 +48,4 @@ $O.macargv: macargv.$O
|
||||||
$LD -o $target $prereq
|
$LD -o $target $prereq
|
||||||
|
|
||||||
install: $MACARGV
|
install: $MACARGV
|
||||||
|
install: mklatinkbd.install
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
int rflag;
|
int rflag;
|
||||||
|
int xflag;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAXLD = 2, /* latin1.c assumes this is 2 */
|
MAXLD = 2, /* latin1.c assumes this is 2 */
|
||||||
|
|
@ -115,39 +116,56 @@ cprints(Biobuf *b, char *p)
|
||||||
cprintchar(b, *p++);
|
cprintchar(b, *p++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xprint(Biobuf *b, int c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printtrie(Biobuf *b, Trie *t)
|
printtrie(Biobuf *b, Trie *t)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
char *p;
|
||||||
|
|
||||||
for(i=0; i<256; i++)
|
for(i=0; i<256; i++)
|
||||||
if(t->link[i])
|
if(t->link[i])
|
||||||
printtrie(b, t->link[i]);
|
printtrie(b, t->link[i]);
|
||||||
|
if(t->n == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if(t->n > 0) {
|
if(xflag) {
|
||||||
Bprint(b, "\t\"");
|
for(i=0; i<256; i++) {
|
||||||
cprints(b, t->seq);
|
if(t->r[i] == 0)
|
||||||
Bprint(b, "\", \"");
|
continue;
|
||||||
|
Bprint(b, "<Multi_key>");
|
||||||
|
for(p=t->seq; *p; p++)
|
||||||
|
Bprint(b, " %k", *p);
|
||||||
|
Bprint(b, " %k : \"%C\" U%04X\n", i, t->r[i], t->r[i]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bprint(b, "\t\"");
|
||||||
|
cprints(b, t->seq);
|
||||||
|
Bprint(b, "\", \"");
|
||||||
|
for(i=0; i<256; i++)
|
||||||
|
if(t->r[i])
|
||||||
|
cprintchar(b, i);
|
||||||
|
Bprint(b, "\",\t");
|
||||||
|
if(rflag) {
|
||||||
|
Bprint(b, "{");
|
||||||
for(i=0; i<256; i++)
|
for(i=0; i<256; i++)
|
||||||
if(t->r[i])
|
if(t->r[i])
|
||||||
cprintchar(b, i);
|
Bprint(b, " 0x%.4ux,", t->r[i]);
|
||||||
Bprint(b, "\",\t");
|
Bprint(b, " }");
|
||||||
if(rflag) {
|
} else {
|
||||||
Bprint(b, "{");
|
Bprint(b, "L\"");
|
||||||
for(i=0; i<256; i++)
|
for(i=0; i<256; i++)
|
||||||
if(t->r[i])
|
if(t->r[i])
|
||||||
Bprint(b, " 0x%.4ux,", t->r[i]);
|
Bprint(b, "%C", t->r[i]);
|
||||||
Bprint(b, " }");
|
Bprint(b, "\"");
|
||||||
} else {
|
|
||||||
Bprint(b, "L\"");
|
|
||||||
for(i=0; i<256; i++)
|
|
||||||
if(t->r[i])
|
|
||||||
Bprint(b, "%C", t->r[i]);
|
|
||||||
Bprint(b, "\"");
|
|
||||||
}
|
|
||||||
Bprint(b, ",\n");
|
|
||||||
}
|
}
|
||||||
|
Bprint(b, ",\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -207,15 +225,21 @@ usage(void)
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int kfmt(Fmt*);
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Biobuf bout;
|
Biobuf bout;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'r': /* print rune values */
|
case 'r': /* print rune values */
|
||||||
rflag = 1;
|
rflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'x':
|
||||||
|
xflag = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}ARGEND
|
}ARGEND
|
||||||
|
|
@ -223,10 +247,72 @@ main(int argc, char **argv)
|
||||||
if(argc > 1)
|
if(argc > 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
readfile(argc == 1 ? argv[0] : "/fd/0");
|
fmtinstall('k', kfmt);
|
||||||
|
readfile(argc == 1 ? argv[0] : "/dev/stdin");
|
||||||
|
|
||||||
Binit(&bout, 1, OWRITE);
|
Binit(&bout, 1, OWRITE);
|
||||||
|
if(xflag) {
|
||||||
|
Bprint(&bout, "# Generated by mklatinkbd -x; do not edit.\n");
|
||||||
|
for(i=0x20; i<0x10000; i++)
|
||||||
|
Bprint(&bout, "<Multi_key> <X> <%x> <%x> <%x> <%x> : \"%C\" U%04X\n",
|
||||||
|
(i>>12)&0xf, (i>>8)&0xf, (i>>4)&0xf, i&0xf, i, i);
|
||||||
|
}
|
||||||
if(root)
|
if(root)
|
||||||
printtrie(&bout, root);
|
printtrie(&bout, root);
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X11 key names
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int c;
|
||||||
|
char *s;
|
||||||
|
} xkey[] = {
|
||||||
|
' ', "space",
|
||||||
|
'!', "exclam",
|
||||||
|
'"', "quotedbl",
|
||||||
|
'#', "numbersign",
|
||||||
|
'$', "dollar",
|
||||||
|
'%', "percent",
|
||||||
|
'&', "ampersand",
|
||||||
|
'\'', "apostrophe",
|
||||||
|
'(', "parenleft",
|
||||||
|
')', "parenright",
|
||||||
|
'*', "asterisk",
|
||||||
|
'+', "plus",
|
||||||
|
',', "comma",
|
||||||
|
'-', "minus",
|
||||||
|
'.', "period",
|
||||||
|
'/', "slash",
|
||||||
|
':', "colon",
|
||||||
|
';', "semicolon",
|
||||||
|
'<', "less",
|
||||||
|
'=', "equal",
|
||||||
|
'>', "greater",
|
||||||
|
'?', "question",
|
||||||
|
'@', "at",
|
||||||
|
'[', "bracketleft",
|
||||||
|
'\\', "backslash",
|
||||||
|
',', "bracketright",
|
||||||
|
'^', "asciicircum",
|
||||||
|
'_', "underscore",
|
||||||
|
'`', "grave",
|
||||||
|
'{', "braceleft",
|
||||||
|
'|', "bar",
|
||||||
|
'}', "braceright",
|
||||||
|
'~', "asciitilde",
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
kfmt(Fmt *f)
|
||||||
|
{
|
||||||
|
int i, c;
|
||||||
|
|
||||||
|
c = va_arg(f->args, int);
|
||||||
|
for(i=0; xkey[i].s; i++)
|
||||||
|
if(xkey[i].c == c)
|
||||||
|
return fmtprint(f, "<%s>", xkey[i].s);
|
||||||
|
return fmtprint(f, "<%c>", c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ __xtoplan9kbd(XEvent *e)
|
||||||
needstack(64*1024); /* X has some *huge* buffers in openobject */
|
needstack(64*1024); /* X has some *huge* buffers in openobject */
|
||||||
/* and they're even bigger on SuSE */
|
/* and they're even bigger on SuSE */
|
||||||
XLookupString((XKeyEvent*)e,NULL,0,&k,NULL);
|
XLookupString((XKeyEvent*)e,NULL,0,&k,NULL);
|
||||||
if(k == XK_Multi_key || k == NoSymbol)
|
if(k == k == NoSymbol)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(k&0xFF00){
|
if(k&0xFF00){
|
||||||
|
|
@ -113,6 +113,7 @@ __xtoplan9kbd(XEvent *e)
|
||||||
case XK_Meta_L: /* Shift Alt on PCs */
|
case XK_Meta_L: /* Shift Alt on PCs */
|
||||||
case XK_Alt_R:
|
case XK_Alt_R:
|
||||||
case XK_Meta_R: /* Shift Alt on PCs */
|
case XK_Meta_R: /* Shift Alt on PCs */
|
||||||
|
case XK_Multi_key:
|
||||||
k = Kalt;
|
k = Kalt;
|
||||||
break;
|
break;
|
||||||
default: /* not ISO-1 or tty control */
|
default: /* not ISO-1 or tty control */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue