From ff4daa7e93f4ea09506276ecdb69fa1cca19a7a7 Mon Sep 17 00:00:00 2001 From: mischief Date: Sat, 13 Dec 2014 11:28:16 -0800 Subject: stats: handle 'q' to close a side effect of this is keys typed other than q/Del no longer get drawn on top of the window. --- sys/src/cmd/stats.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/sys/src/cmd/stats.c b/sys/src/cmd/stats.c index 7f2e4508d..3572f7ec1 100644 --- a/sys/src/cmd/stats.c +++ b/sys/src/cmd/stats.c @@ -5,6 +5,7 @@ #include #include #include +#include #define MAXNUM 10 /* maximum number of numbers on data line */ @@ -85,7 +86,7 @@ struct Machine enum { Mainproc, - Mouseproc, + Inputproc, NPROC, }; @@ -204,7 +205,7 @@ int ylabels = 0; int oldsystem = 0; int sleeptime = 1000; -char *procnames[NPROC] = {"main", "mouse"}; +char *procnames[NPROC] = {"main", "input"}; void killall(char *s) @@ -1238,29 +1239,36 @@ eresized(int new) } void -mouseproc(void) +inputproc(void) { - Mouse mouse; + Event e; int i; for(;;){ - mouse = emouse(); - if(mouse.buttons == 4){ - lockdisplay(display); - for(i=0; i= 0){ - if(!present[i]) - addgraph(i); - else if(ngraph > 1) - dropgraph(i); - resize(); + switch(eread(Emouse|Ekeyboard, &e)){ + case Emouse: + if(e.mouse.buttons == 4){ + lockdisplay(display); + for(i=0; i= 0){ + if(!present[i]) + addgraph(i); + else if(ngraph > 1) + dropgraph(i); + resize(); + } + unlockdisplay(display); } - unlockdisplay(display); + break; + case Ekeyboard: + if(e.kbdc==Kdel || e.kbdc=='q') + killall(nil); + break; } } } @@ -1413,8 +1421,8 @@ main(int argc, char *argv[]) exits("initdraw"); } colinit(); - einit(Emouse); - startproc(mouseproc, Mouseproc); + einit(Emouse|Ekeyboard); + startproc(inputproc, Inputproc); pids[Mainproc] = getpid(); display->locking = 1; /* tell library we're using the display lock */ -- cgit v1.2.3