| 21 |
|
|
| 22 |
|
char *progname; /* global argv[0] */ |
| 23 |
|
|
| 24 |
< |
#define SERV_READY 01 |
| 25 |
< |
#define DEV_READY 02 |
| 24 |
> |
#define RDY_SRV 01 |
| 25 |
> |
#define RDY_DEV 02 |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
main(argc, argv) |
| 29 |
|
int argc; |
| 30 |
|
char *argv[]; |
| 31 |
|
{ |
| 32 |
< |
int rdy, inp, res = 0; |
| 32 |
> |
int rdy, inp, res = 0, pause = 0; |
| 33 |
|
|
| 34 |
|
progname = argv[0]; |
| 35 |
|
if (argc != 2) |
| 39 |
|
/* enter main loop */ |
| 40 |
|
do { |
| 41 |
|
rdy = disp_wait(); |
| 42 |
< |
while (rdy & DEV_READY) { |
| 43 |
< |
inp = dev_input(); /* take residual action here */ |
| 42 |
> |
if (rdy & RDY_DEV) { /* get user input */ |
| 43 |
> |
inp = dev_input(); |
| 44 |
|
if (inp & DEV_NEWVIEW) |
| 45 |
|
new_view(&odev.v); |
| 46 |
|
if (inp & DEV_SHUTDOWN) |
| 47 |
|
serv_request(DR_SHUTDOWN, 0, NULL); |
| 48 |
+ |
if (inp & DEV_REDRAW) { |
| 49 |
+ |
imm_mode = 1; /* preempt updates */ |
| 50 |
+ |
beam_sync(); |
| 51 |
+ |
} |
| 52 |
|
if (inp & DEV_WAIT) |
| 53 |
< |
serv_request(DR_ATTEN, 0, NULL); |
| 54 |
< |
else |
| 51 |
< |
rdy &= ~DEV_READY; |
| 52 |
< |
} |
| 53 |
< |
if (rdy & SERV_READY) { |
| 54 |
< |
res = serv_result(); /* processes result, also */ |
| 55 |
< |
if (res == DS_ACKNOW) |
| 53 |
> |
pause = 1; |
| 54 |
> |
if (inp & DEV_RESUME) { |
| 55 |
|
serv_request(DR_NOOP, 0, NULL); |
| 56 |
+ |
pause = 0; |
| 57 |
+ |
} |
| 58 |
|
} |
| 59 |
+ |
if (rdy & RDY_SRV) { /* get server result */ |
| 60 |
+ |
res = serv_result(); |
| 61 |
+ |
if (pause && res != DS_SHUTDOWN) { |
| 62 |
+ |
serv_request(DR_ATTEN, 0, NULL); |
| 63 |
+ |
while ((res = serv_result()) != DS_ACKNOW && |
| 64 |
+ |
res != DS_SHUTDOWN) |
| 65 |
+ |
; |
| 66 |
+ |
} |
| 67 |
+ |
} |
| 68 |
|
} while (res != DS_SHUTDOWN); |
| 69 |
|
/* all done */ |
| 70 |
|
quit(0); |
| 80 |
|
register int i; |
| 81 |
|
/* see if we can avoid select call */ |
| 82 |
|
if (imm_mode || stdin->_cnt > 0) |
| 83 |
< |
return(SERV_READY); |
| 83 |
> |
return(RDY_SRV); |
| 84 |
|
if (dev_flush()) |
| 85 |
< |
return(DEV_READY); |
| 85 |
> |
return(RDY_DEV); |
| 86 |
|
/* make the call */ |
| 87 |
|
FD_ZERO(&readset); FD_ZERO(&errset); |
| 88 |
|
FD_SET(0, &readset); |
| 98 |
|
} |
| 99 |
|
flgs = 0; /* flag what's ready */ |
| 100 |
|
if (FD_ISSET(0, &readset) || FD_ISSET(0, &errset)) |
| 101 |
< |
flgs |= SERV_READY; |
| 101 |
> |
flgs |= RDY_SRV; |
| 102 |
|
if (FD_ISSET(odev.ifd, &readset) || FD_ISSET(odev.ifd, &errset)) |
| 103 |
< |
flgs |= DEV_READY; |
| 103 |
> |
flgs |= RDY_DEV; |
| 104 |
|
return(flgs); |
| 105 |
|
} |
| 106 |
|
|