9fans archive / 1997 / 11 / 17 /    prev next

From: Tad Hunt tad@csh...
Subject: [9fans] Novice use of libg
Date: Thu, 20 Nov 1997 13:04:54 -0500

In message <swordfish.880045065@min...>, you said:
;------------------------------- cut here -----------------------
;int
;main(int argc, char **argv) {
;	Mouse mouse;
;	ulong Estdin;
;	bool done = false;
;	progname = argv[0];
;	binit(panic, 0, progname);
;	if ((Estdin = estart((ulong)0, 0, 8192)) == 0)
;		panic("Estdin = estart(0, 0, 8192) fails");
;	einit(Emouse | Estdin);
;	do {
;		struct Event e;
;		ulong key = eread(Emouse | Estdin, &e);
;		if (key == Estdin) {
;fprintf(stderr, "debug: Estdin, e.n %d\n", e.n); fflush(stderr);
;		} else if (key == Emouse) {
;fprintf(stderr, "debug: Emouse, x %d y %d\n", e.mouse.xy.x, e.mouse.xy.y);
;fflush(stderr);
;		} else
;			panic("unexpected event");
;	} while (!done);

I see two problems off the top of my head:
    eread() is only called once.
    done is never set to "true", thus the looping.