1 /* ********************************************
  2    *                                          *
  3    * Copyright, (C) Honeywell Bull Inc., 1988 *
  4    *                                          *
  5    ******************************************** */
  6 
  7 /* HISTORY COMMENTS:
  8   1) change(88-04-21,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel),
  9      install(88-10-12,MR12.2-1160):
 10      Created.
 11   2) change(88-07-25,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel),
 12      install(88-10-12,MR12.2-1160):
 13      Documentation additions only. Added header comments to all routines.
 14   3) change(88-08-09,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel),
 15      install(88-10-12,MR12.2-1160):
 16      Fix references to include files; "wstdefs.h" was split into
 17      "wstdefs.h" and "wsttype.h" to avoid declaration clash; also,
 18      various constants defined to descriptive names.
 19                                                    END HISTORY COMMENTS */
 20 
 21 #include <dos.h>
 22 #include "wstdefs.h"
 23 #include "wstglob.h"
 24 
 25 char *general_help_lines[] = {
 26 "-------------------------- WSTERM FUNCTIONS ----------------------------------",
 27 "ALT-0  Send an ASCII NUL             |  ALT-D  Display pending foreground",
 28 "ALT-B  Send a break to host          |         message",
 29 "^BREAK Send a break if /B control    |  ALT-H  Enter help screen",
 30 "       argument specified            |  ALT-M  Enter background screen",
 31 "ALT-C  Clear the display             |  ALT-Q  Exit (quit) wsterm",
 32 "                                     |  ALT-S  No scroll (any key resumes)",
 33 "",
 34 "",
 35 "------------------------- WSTERM MODES (toggles) -----------------------------",
 36 "ALT-I,<INS> keyboard insert/replace -|  ALT-E      edit mode ON/OFF",
 37 "            (in edit mode only)      |  ALT-O      local paging ON/OFF",
 38 "ALT-F       file audit ON/OFF        |  ALT-P      line printer audit ON/OFF",
 39 "",
 40 "",
 41 "",
 42 
 43 "-------------------------------- EDIT MODE -----------------------------------",
 44 "A variety of editing and history functions are available in edit mode. While",
 45 "in edit mode, all keyboard input is buffered and echoed, allowing various",
 46 "editing to take place until the <RETURN> key is hit, sending the line to the",
 47 "host. Note that before the attach_mowse/atm command is invoked, the host",
 48 "also echoes input, resulting in a \"double echo\". Thus it may be desirable",
 49 "to turn off echoing by the host (e.g. stty -modes ^echoplex) in this case.",
 50 "",
 51 "---------------------- Edit Mode cursor movement keys ------------------------",
 52 "^A,<HOME> cursor to beginning of line|  ^E,<END>  move cursor to end of line",
 53 "^F,->     move cursor forward a char |  ^B,->     move cursor backward a char",
 54 "^->,esc F move cursor forward a word |  ^<-,esc B move cursor backward a word",
 55 "",
 56 "-------------------------- Edit Mode editing keys ----------------------------",
 57 "Backspace erase (previous char)      |  @          kill (to beginning of line)",
 58 "<DEL>   delete previous char         |  esc <DEL>  delete to previous word",
 59 "^D      delete current char          |  esc D      delete to end of word",
 60 "^K      kill to end of line          |  \\          literal escape character",
 61 "",
 62 "*   cursor movement and edit keys may be repeated N times by entering",
 63 "    <ESC> N before the key. N is some unsigned integer value.",
 64 "",
 65 "----------------------- Edit Mode History Functions --------------------------",
 66 "ALT-V    enter history screen        |   ^P     recall previous command",
 67 "NN ^P    select the NNth previous    |   ^N     recall the next command",
 68 "         command",
 69 "",
 70 "",
 71 "",
 72 "",
 73 "",
 74 "",
 75 "----------------------------- Status Line ------------------------------------",
 76 "The bottom line of the screen is the status line. It is displayed in reverse",
 77 "video and is used to display local messages to the user. In the foreground",
 78 "screen, WSTERM's current mode settings are displayed as follows:",
 79 "",
 80 "G Edit Replace Audit(FILE,PRINTER) Page No-Scroll [background] [foreground]",
 81 "1  2     3              4            5      6           7            8",
 82 "",
 83 "1) G=Glass tty (before atm); A=Async (after atm); S=Sync (atm & video)",
 84 "2) Edit=Edit mode enabled; <BLANK>=Edit mode disabled",
 85 "3) Replace=text overstrikes; Insert=text inserts; <BLANK>=not in Edit mode",
 86 "4) <BLANK>=No audit; Audit(FILE)=File audit; Audit(PRINTER)=Printer audit;",
 87 "   Audit(FILE,PRINTER)=File and Printer audit",
 88 "5) Page=local paging after atm; <BLANK>=no local page after atm",
 89 "6) <BLANK>=scrolling; No-Scroll=local stopping of scrolling",
 90 "7) <BLANK>-no background messages; [background]=background message(s) pending,",
 91 "   enter background screen to examine messages.",
 92 "8) <BLANK>-no foreground messages; [foreground]=foreground message(s) pending",
 93 "   while entering input, hit ALT-D to display message, then resume input",
 94 "",
 95 "Note: The status line is also used to temporarily display error messages.",
 96 "      Status line information is also different in other screens. See help",
 97 "      for other screens."
 98 };
 99 
100 
101 #define N_GENERAL_HELP_LINES    (sizeof(general_help_lines)/sizeof(char *))
102 
103 char *bg_help_lines[] = {
104 "----------------------------BACKGROUND SCREEN---------------------------------",
105 "This screen displays the number of pending background messages and displays",
106 "the next background message whenever <ALT-M> or <ALT-D> is hit. The user",
107 "may also enter this screen just to look at background messages which were",
108 "previously displayed but have not been scrolled off.",
109 "",
110 "    ALT-M,ALT-D - display next background messages if it exists",
111 "    Q           - quit from background screen",
112 "    P           - enter background polling mode",
113 "",
114 "----------------------------BACKGROUND POLLING--------------------------------",
115 "This screen displays all pending background messages and sits in a polling",
116 "loop, displaying any background message whenever it is received.",
117 "",
118 "    Q           - quit from background screen",
119 "    <other>     - toggle between scroll and no scroll",
120 "",
121 "-------------------- Replying to background query messages -------------------",
122 "When the message \"Enter Reply:\" appears on the status line, the most recent",
123 "background message displayed is a background query message. Any text until",
124 "a <RETURN> is hit will then be sent as a reply to this query.",
125 "",
126 "NOTE: Acceptable keys are listed between \"[\" and \"]\" on the status line"
127 };
128 
129 
130 #define N_BG_HELP_LINES    (sizeof(bg_help_lines)/sizeof(char *))
131 
132 char *history_help_lines[] = {
133 "---------------- HISTORY SCREEN FUNCTIONS (in edit mode only) ----------------",
134 "This screen allows previously entered lines of input to be examined and/or",
135 "selected. Selecting an input line copies that line as current input, just",
136 "as if entered from the keyboard. Further editing may take place before",
137 "sending the line to the host by hitting the <RETURN> key.",
138 "",
139 " NN <RETURN> - exit the history screen and select the specified history",
140 "               line (beeps if invalid selection)",
141 " NN <L>      - shift screen left NN columns; NN defaults to 1",
142 " NN <R>      - shift screen right NN columns; NN defaults to 1",
143 " <P>         - display previous history page (beeps if no previous page)",
144 " <N>         - display next history page (beeps if no next page)",
145 " <Q>         - quit from the history screen",
146 "",
147 "",
148 "NOTE 1: NN refers to an unsigned integer value and is specified by entering",
149 "        any of the digit keys (0 thru 9).",
150 "NOTE 2: The status line will display the current screen offset.",
151 "NOTE 3: Recognized command keys are listed between \"[\" and \"]\" on the",
152 "        status line."
153 };
154 
155 #define N_HISTORY_HELP_LINES    (sizeof(history_help_lines)/sizeof(char *))
156 
157 /* help - this routine displays the help screen in a manner
158           transparent to the caller. The parameter "cur_scr"
159           specifies the screen to save the current screen
160           contents to before displaying the help information.
161 */
162 
163 
164 /*^L
165 **********************************************************************
166 
167   Routine:            HELP
168 
169   Function:
170       This routine saves the contents of the current screen and
171   invokes the help screen. The status line provides further
172   instructions to allow more help pages to be displayed or quitting
173   from the help screen. The original screen contents are restored on
174   quitting from help, making the invokation of help transparent to
175   the caller.
176 
177   Parameters:
178      (input)          order - flag to specify in what order the help
179                           topics should be displayed
180 
181   Returns:            NONE
182 
183 **********************************************************************/
184 
185 help(order)
186 int order;
187 {
188     int i;
189     int cnt;
190     int ch;
191     char **hlp[N_HELP_TOPICS];
192     int  hlp_cnt[N_HELP_TOPICS];
193     int  help_index;
194 
195     /* determine what order the topics are to be displayed */
196     if (order == BG_HELP) {
197         hlp[FIRST_TOPIC_INDEX] = bg_help_lines;
198         hlp_cnt[FIRST_TOPIC_INDEX] = N_BG_HELP_LINES;
199         hlp[SECOND_TOPIC_INDEX] = general_help_lines;
200         hlp_cnt[SECOND_TOPIC_INDEX] = N_GENERAL_HELP_LINES;
201         hlp[THIRD_TOPIC_INDEX] = history_help_lines;
202         hlp_cnt[THIRD_TOPIC_INDEX] = N_HISTORY_HELP_LINES;
203     }
204 
205     else if (order == HISTORY_HELP) {
206         hlp[FIRST_TOPIC_INDEX] = history_help_lines;
207         hlp_cnt[FIRST_TOPIC_INDEX] = N_HISTORY_HELP_LINES;
208         hlp[SECOND_TOPIC_INDEX] = general_help_lines;
209         hlp_cnt[SECOND_TOPIC_INDEX] = N_GENERAL_HELP_LINES;
210         hlp[THIRD_TOPIC_INDEX] = bg_help_lines;
211         hlp_cnt[THIRD_TOPIC_INDEX] = N_BG_HELP_LINES;
212     }
213 
214     else {
215         hlp[FIRST_TOPIC_INDEX] = general_help_lines;
216         hlp_cnt[FIRST_TOPIC_INDEX] = N_GENERAL_HELP_LINES;
217         hlp[SECOND_TOPIC_INDEX] = bg_help_lines;
218         hlp_cnt[SECOND_TOPIC_INDEX] = N_BG_HELP_LINES;
219         hlp[THIRD_TOPIC_INDEX] = history_help_lines;
220         hlp_cnt[THIRD_TOPIC_INDEX] = N_HISTORY_HELP_LINES;
221     }
222 
223     /* save the contents of the screen to the user specified buffer */
224     save_wst_screen(&wst_tmp_screen);
225 
226     /* hide the cursor */
227     cursor_move(HIDE_CURSOR_ROW,HIDE_CURSOR_COL);
228 
229     /* initialize input char, working index and line counter */
230     ch = 0;
231     i = 0;
232     cnt = 0;
233 
234     /* initialize topic index */
235     help_index = 0;
236 
237     /* clear the temporary screen buffer */
238     wst_screen_clear(&wst_help_screen);
239 
240     while (TRUE) {
241             if (help_index >= LAST_HELP_TOPIC_INDEX && i >= hlp_cnt[help_index])
242                 break;
243 
244             /* increment line counter and see if screen is full */
245             if (cnt >= N_HELP_PAGE_LINES || i >= hlp_cnt[help_index]) {
246 
247                 /* screen full, dump the contents of the temporary screen buffer */
248                 restore_wst_screen(&wst_help_screen);
249 
250                 /* hide the cursor */
251                 cursor_move(HIDE_CURSOR_ROW,HIDE_CURSOR_COL);
252 
253                 /* update the status line */
254                 status_line("HELP SCREEN: <q> - quit, <any other> - next");
255 
256                 /* wait for key press and determine whether to quit */
257                 ch = getkey(BLOCK);
258                 if (uppercase(ch) == 'Q')
259                     break;
260 
261                 /* reset line counter and clear the temporary screen buffer */
262                 cnt = 0;
263                 wst_screen_clear(&wst_help_screen);
264 
265                 if (i >= hlp_cnt[help_index]) {
266                     help_index++;
267                     i = 0;
268                     if (help_index > LAST_HELP_TOPIC_INDEX) break;
269                 }
270             }
271 
272             /* write a line of help info to the temporary screen buffer */
273             wst_screen_printline(&wst_help_screen,hlp[help_index][i]);
274             i++;
275             cnt++;
276     }
277 
278     /* if user did not hit quit to exit help screen */
279     if (uppercase(ch) != 'Q') {
280 
281         /* dump contents of temporary screen buffer */
282         restore_wst_screen(&wst_help_screen);
283 
284         /* hide the cursor */
285         cursor_move(HIDE_CURSOR_ROW,HIDE_CURSOR_COL);
286 
287         /* update status line */
288         status_line("HELP SCREEN: <any key> - quit");
289         wait_for_key();
290     }
291 
292     /* restore contents of original screen and turn cursor back on */
293     restore_wst_screen(&wst_tmp_screen);
294 }