ref: 627806e4de1f01a670ab6a3ebb960609cbda7a06
dir: /eenter.c/
#include <u.h> #include <libc.h> #include <draw.h> #include <event.h> void eresized(int) { draw(screen, screen->r, display->white, nil, ZP); } void main(int argc, char **argv) { USED(argc, argv); int e; Event ev; char buf[512]; if (initdraw(nil, nil, "eenter") < 0) sysfatal("error: %r"); einit(Emouse|Ekeyboard); for (;;) { e = event(&ev); switch (e) { case Emouse: if (ev.mouse.buttons == 0) break; snprint(buf, sizeof(buf), "hello world"); if (eenter("Ask:", buf, sizeof(buf), &ev.mouse) > 0) fprint(2, "entered: %s\n", buf); break; case Ekeyboard: if (ev.kbdc == 'q') exits(nil); } } }