ref: f664f9d3a8d305e088f259a23cb6e86e664a7b36
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); } } }