> But I was surprised it doesn't do what I want.
> The rio(1) man page says, in the 'Raw text windows' section that
> '... no typed keyboard characters are special, ... and all are passed
> to a program immediately upon reading'.
> However, it seems rio still interprets ^u, ^a, ^e, ^w, BS, arrows,
> page up/down,... (although not DEL, e.g.)
> Can anybody explain to me what is wrong?

if you open the mouse, you will supress rio's terminal from using these
keys for navigation.

> (Also I don't quite understand why pressing ^d results in drawing EOT,

you're reading ctl-d (0x04) and then printing it.  since there
is a character in your font at that position that looks like EOT, that's
what you see.

> pressing F1 does nothing as well as pressing alt-whatever [e.g.
> alt-AE]...; Also, what must I do to see the codes (like ^a=0x01)
> instead of the characters?)

a Rune is >1 byte.  you're only reading one byte.

- erik

---

#include <u.h>
#include <libc.h>

void
main(void)
{
        char buf[UTFmax + 1];
        int cfd, mfd, n, i, l;
        Rune r;

        cfd = open("/dev/consctl", OWRITE);
        if(cfd == -1 || write(cfd, "rawon", 5) != 5)
                sysfatal("consctl: %r");
        mfd = open("/dev/mouse", OREAD);
        if(mfd == -1)
                sysfatal("mouse: %r");
        i = 0;
        for(;;){
                for(;;){
                        n = read(0, buf + i, 1);
                        if(n <= 0)
                                goto done;
                        i += n;
                        if(fullrune(buf, i))
                                break;
                }
                buf[i] = 0;
                l = chartorune(&r, buf);
                if(r == 0xfff7)
                        break;
                if(r < 0x20)
                        print("ctl-%c\n", '@' + r);
                else if(r == 0x7f)
                        print("del\n");
                else
                        print("%C\n", r);
                memmove(buf, buf + l, i - l);
                i = i - l;
        }
done:
        close(cfd);
        close(mfd);
        exits(nil);
}

Reply via email to