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