devdraw, libdraw: handle keyboard runes > U+FFFF

Runes in Plan 9 were limited to the 16-bit BMP when I drew up
the RPC protocol between graphical programs and devdraw
a long time ago. Now that they can be 32-bit, use a 32-bit wire
encoding too. A new message number to avoid problems with
other clients (like 9fans.net/go).

Add keyboard shortcut alt : , for U+1F602, face with tears of joy,
to test that it all works.
This commit is contained in:
Russ Cox 2020-05-18 23:45:03 -04:00
parent b4cc38f943
commit d25d0ca1a3
7 changed files with 34 additions and 8 deletions

View file

@ -191,7 +191,7 @@ readfile(char *fname)
r = strtol(line, nil, 16);
p = strchr(line, ' ');
if(r == 0 || p != line+4 || p[0] != ' ' || p[1] != ' ') {
if(r == 0 || (p != line+4 && p != line+5) || p[0] != ' ' || (p == line+4 && p[1] != ' ')) {
fprint(2, "%s:%d: cannot parse line\n", fname, lineno);
continue;
}

View file

@ -229,6 +229,7 @@ runmsg(Client *c, Wsysmsg *m)
break;
case Trdkbd:
case Trdkbd4:
qlock(&c->eventlk);
if((c->kbdtags.wi+1)%nelem(c->kbdtags.t) == c->kbdtags.ri) {
qunlock(&c->eventlk);
@ -236,7 +237,7 @@ runmsg(Client *c, Wsysmsg *m)
replyerror(c, m);
break;
}
c->kbdtags.t[c->kbdtags.wi++] = m->tag;
c->kbdtags.t[c->kbdtags.wi++] = (m->tag<<1) | (m->type==Trdkbd4);
if(c->kbdtags.wi == nelem(c->kbdtags.t))
c->kbdtags.wi = 0;
c->kbd.stall = 0;
@ -357,13 +358,17 @@ replymsg(Client *c, Wsysmsg *m)
static void
matchkbd(Client *c)
{
int tag;
Wsysmsg m;
if(c->kbd.stall)
return;
while(c->kbd.ri != c->kbd.wi && c->kbdtags.ri != c->kbdtags.wi){
tag = c->kbdtags.t[c->kbdtags.ri++];
m.type = Rrdkbd;
m.tag = c->kbdtags.t[c->kbdtags.ri++];
if(tag&1)
m.type = Rrdkbd4;
m.tag = tag>>1;
if(c->kbdtags.ri == nelem(c->kbdtags.t))
c->kbdtags.ri = 0;
m.rune = c->kbd.r[c->kbd.ri++];