#include #include #include #include Image *what, *back; char *fontname = "/lib/font/bit/lucidasans/unicode.13.font"; Font *font; char but[512]; void redraw(Image *screen) { draw(screen, screen->r, back, nil, ZP); string(screen, screen->r.min, what, ZP, font, but); flushimage(display, 1); } void eresized(int new) { if(new && getwindow(display, Refnone) < 0) fprint(2,"can't reattach to window"); redraw(screen); } void main(int, char**) { Event e; Mouse m; int key, timer; int t; int text; int desk; char *deskname = "/srv/desk"; /* gosh I wish this worked -- it would be cool you would have soft keys. But there's all this junk in there. text = open("/dev/text", OREAD); */ text = open("/dev/label", OREAD); if (text < 0) exits(smprint("/dev/label: %r")); if (pread(text, but, sizeof(but), 0LL) < 0) exits("read label"); desk = open(deskname, OWRITE); if (desk < 0) exits(smprint("%s: %r", deskname)); initdraw(0,0,but); drawsetdebug(1); if((font = openfont(display, fontname)) == nil) sysfatal("font '%s' not found", fontname); back = allocimagemix(display, DPalebluegreen, DWhite); what = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DBlue); redraw(screen); einit(Emouse); t = (30*1000); timer = etimer(0, t); for(;;) { key = event(&e); if(key == Emouse) { m = e.mouse; if(m.buttons & 4) { int amt; /* why do we re read this? So you can have soft keys */ memset(but, 0, sizeof(but)); amt = pread(text, but, sizeof(but), 0LL); if (amt < 0) exits("read text: %r"); amt = write(desk, but, amt); if (amt < 0) exits("write desk: %r"); } } else if(key == timer) { redraw(screen); } } }