2 /* Copyright (c) 1995 by Arkkra Enterprises */
3 /* All rights reserved */
5 /* command processing function for Mup/Ghostscript display program.
6 * Given a input input character, does the appropriate command */
9 /* The user interface commands are:
10 * + or <space> or ^e or ^f scroll forwards 1/8"
11 * - or <backsp> or ^y or ^b scroll backwards 1/8"
12 * f or <enter> or ^d scroll forwards 1"
13 * b or ^u scroll backwards 1"
15 * m toggle between full page and scrolled mode
16 * n go to top of next page
17 * p go to top of previous page
19 * r repaint current page
20 * Num\n go to page Num
21 * Upper case versions work too.
22 * ZZ is synonym for quit
27 /* bitmap for the help screen. Have to manually make sure this is smaller
28 * than the minimum screen/window size */
32 /* command processing function for Mup/Ghostscript display program.
33 * Given a input input character, does the appropriate command */
38 int c
; /* character read from user */
41 static int line
= 0; /* current line on page that
42 * is at top of screen */
43 static int got1z
= 0; /* if got one Z for vi-like ZZ exit */
44 static int pgnum
= -1; /* page number */
45 static int count
= 0; /* how many times called */
46 static int lasterr
= 0; /* value of count for last error */
47 static int goofs
= 0; /* how many consecutive user errors */
50 /* count of times called, to implement auto-help if user goofs too
51 * many times in a row */
63 /* gathering page number for specific page */
65 /* first digit, so initialize page number */
68 pgnum
= (pgnum
* 10) + c
- '0';
73 case '\5': /* control-E for vi users */
74 case '\6': /* control-F for emacs users */
75 /* scroll forward a little bit */
77 ( *(Conf_info_p
->error
) ) ("command invalid in full page mode");
80 line
= scroll(line
, 9);
86 case '\31': /* control-Y for vi users */
87 case '\2': /* control-B for emacs users */
88 /* backward a little bit */
90 ( *(Conf_info_p
->error
) ) ("command invalid in full page mode");
93 line
= scroll(line
, -9);
100 /* ending page number command */
101 if (getpginfo(pgnum
) == YES
) {
102 ( *(Conf_info_p
->draw
) ) (0, Fullpgmode
);
106 ( *(Conf_info_p
->error
) ) ("invalid page number");
111 /* else fall through to moving forward on page*/
115 case '\4': /* control-D */
116 case '\16': /* control-N */
117 /* forward an inch */
119 ( *(Conf_info_p
->error
) ) ("command invalid in full page mode");
122 line
= scroll(line
, 72);
127 case '\25': /* control-U */
128 case '\20': /* control-P */
131 ( *(Conf_info_p
->error
) ) ("command invalid in full page mode");
134 line
= scroll(line
, -72);
140 /* display help screen */
141 ( *(Conf_info_p
->bitmap
) ) (Help_bitmap
, Help_width
, Help_height
);
145 /* go to next page */
146 if (Currpage_p
->next
!= (struct Pginfo
*) 0) {
147 Currpage_p
= Currpage_p
->next
;
149 ( *(Conf_info_p
->draw
) ) (line
, Fullpgmode
);
152 ( *(Conf_info_p
->error
) ) ("already at last page");
157 /* go to previous page */
158 if (Currpage_p
->prev
!= (struct Pginfo
*) 0) {
159 Currpage_p
= Currpage_p
->prev
;
161 ( *(Conf_info_p
->draw
) ) (line
, Fullpgmode
);
164 ( *(Conf_info_p
->error
) ) ("already at first page");
170 ( *(Conf_info_p
->cleanup
) ) (0);
174 /* repaint current screen */
175 /* if redraw is because window was resized, make sure we don't
176 * run off the bottom */
177 if (line
+ Conf_info_p
->vlines
> LINES_PER_PAGE
* Conf_info_p
->adjust
) {
178 line
= LINES_PER_PAGE
* Conf_info_p
->adjust
- Conf_info_p
->vlines
;
180 ( *(Conf_info_p
->draw
) ) (line
, Fullpgmode
);
184 /* 2 Z's is symonym for quit, to match with common
187 ( *(Conf_info_p
->cleanup
) ) (0);
192 /* switch between full page and scrolled modes */
193 Fullpgmode
= (Fullpgmode
== YES ? NO
: YES
);
195 ( *(Conf_info_p
->draw
) ) (line
, Fullpgmode
);
199 ( *(Conf_info_p
->error
) ) ("unknown command");
200 /* auto-help feature:
201 * if user puts in something illegal too many times in a row,
202 * figure they're confused and desperate, so give them the
204 if (lasterr
== count
- 1) {
207 ( *(Conf_info_p
->bitmap
) ) (Help_bitmap
,
208 Help_width
, Help_height
);
219 /* set flag if got Z, so can check for Z consecutive Z's for
221 got1z
= (c
== 'Z' || c
== 'z');