14 |
|
#include "selcall.h" |
15 |
|
#include <ctype.h> |
16 |
|
|
17 |
+ |
#ifndef VIEWHISTLEN |
18 |
+ |
#define VIEWHISTLEN 2 /* number of remembered views */ |
19 |
+ |
#endif |
20 |
+ |
|
21 |
|
HOLO *hdlist[HDMAX+1]; /* global holodeck list */ |
22 |
|
|
23 |
|
char cmdlist[DC_NCMDS][8] = DC_INIT; |
58 |
|
rdy = disp_wait(); |
59 |
|
if (rdy & RDY_DEV) { /* user input from driver */ |
60 |
|
inp = dev_input(); |
61 |
< |
if (inp & DEV_PUTVIEW) |
58 |
< |
printview(); |
59 |
< |
if (inp & DEV_NEWVIEW) |
61 |
> |
if (inp & DFL(DC_SETVIEW)) |
62 |
|
new_view(&odev.v); |
63 |
< |
if (inp & DEV_SHUTDOWN) |
64 |
< |
serv_request(DR_SHUTDOWN, 0, NULL); |
65 |
< |
if (inp & DEV_REDRAW) { |
66 |
< |
imm_mode = 1; /* preempt updates */ |
67 |
< |
beam_sync(); |
66 |
< |
} |
67 |
< |
if (inp & DEV_WAIT) |
63 |
> |
if (inp & DFL(DC_GETVIEW)) |
64 |
> |
printview(); |
65 |
> |
if (inp & DFL(DC_LASTVIEW)) |
66 |
> |
new_view(NULL); |
67 |
> |
if (inp & DFL(DC_PAUSE)) |
68 |
|
pause = 1; |
69 |
< |
if (inp & DEV_RESUME) { |
69 |
> |
if (inp & DFL(DC_RESUME)) { |
70 |
|
serv_request(DR_NOOP, 0, NULL); |
71 |
|
pause = 0; |
72 |
|
} |
73 |
+ |
if (inp & DFL(DC_REDRAW)) |
74 |
+ |
imm_mode = beam_sync() > 0; |
75 |
+ |
if (inp & DFL(DC_QUIT)) |
76 |
+ |
serv_request(DR_SHUTDOWN, 0, NULL); |
77 |
|
} |
78 |
|
if (rdy & RDY_SIN) /* user input from sstdin */ |
79 |
|
switch (usr_input()) { |
194 |
|
|
195 |
|
|
196 |
|
new_view(v) /* change view parameters */ |
197 |
< |
VIEW *v; |
197 |
> |
register VIEW *v; |
198 |
|
{ |
199 |
+ |
static VIEW viewhist[VIEWHISTLEN]; |
200 |
+ |
static unsigned nhist; |
201 |
|
char *err; |
202 |
< |
|
203 |
< |
do { |
204 |
< |
if ((err = setview(v)) != NULL) { |
205 |
< |
error(COMMAND, err); |
202 |
> |
/* restore previous view? */ |
203 |
> |
if (v == NULL) { |
204 |
> |
if (nhist < 2) { |
205 |
> |
error(COMMAND, "no previous view"); |
206 |
|
return; |
207 |
|
} |
208 |
< |
if (v->type == VT_PAR) { |
209 |
< |
error(COMMAND, "cannot handle parallel views"); |
210 |
< |
return; |
211 |
< |
} |
212 |
< |
dev_view(v); /* update display driver */ |
213 |
< |
dev_flush(); /* update screen */ |
214 |
< |
} while (!beam_view(v)); /* update beam list */ |
208 |
> |
nhist--; /* get one before last setting */ |
209 |
> |
v = viewhist + ((nhist-1)%VIEWHISTLEN); |
210 |
> |
} else if ((err = setview(v)) != NULL) { |
211 |
> |
error(COMMAND, err); |
212 |
> |
return; |
213 |
> |
} |
214 |
> |
again: |
215 |
> |
if (v->type == VT_PAR) { |
216 |
> |
error(COMMAND, "cannot handle parallel views"); |
217 |
> |
return; |
218 |
> |
} |
219 |
> |
if (!dev_view(v)) /* update display driver */ |
220 |
> |
goto again; |
221 |
> |
dev_flush(); /* update screen */ |
222 |
> |
if (!beam_view(v)) /* update beam list */ |
223 |
> |
goto again; |
224 |
> |
/* record new view */ |
225 |
> |
if (v < viewhist || v >= viewhist+VIEWHISTLEN) { |
226 |
> |
copystruct(viewhist + (nhist%VIEWHISTLEN), v); |
227 |
> |
nhist++; |
228 |
> |
} |
229 |
|
} |
230 |
|
|
231 |
|
|
266 |
|
case DC_GETVIEW: /* print the current view */ |
267 |
|
printview(); |
268 |
|
break; |
269 |
+ |
case DC_LASTVIEW: /* restore previous view */ |
270 |
+ |
new_view(NULL); |
271 |
+ |
break; |
272 |
|
case DC_PAUSE: /* pause the current calculation */ |
273 |
|
case DC_RESUME: /* resume the calculation */ |
274 |
|
/* handled in main() */ |
275 |
+ |
break; |
276 |
+ |
case DC_REDRAW: /* redraw from server */ |
277 |
+ |
imm_mode = beam_sync() > 0; |
278 |
|
break; |
279 |
|
case DC_QUIT: /* quit request */ |
280 |
|
serv_request(DR_SHUTDOWN, 0, NULL); |