1 /* ********************************************
  2    *                                          *
  3    * Copyright, (C) Honeywell Bull Inc., 1988 *
  4    *                                          *
  5    ******************************************** */
  6 
  7 /* HISTORY COMMENTS:
  8   1) change(88-04-26,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   4) change(89-01-18,Lee), approve(89-01-02,MCR8043), audit(89-03-14,Flegel),
 20      install(89-04-24,MR12.3-1033):
 21      Separated input and output parameters to int86() to avoid confusion
 22      when parameters are used.
 23                                                    END HISTORY COMMENTS */
 24 
 25 #include <stdio.h>
 26 #include <dos.h>
 27 #include "wstdefs.h"
 28 #include "wstglob.h"
 29 
 30 /* status line should look like:
 31 A  Edit Replace Audit(FILE,PRINTER) Paging No-Scroll [Background] [Foreground]
 32 */
 33 
 34 
 35 /*^L
 36 **********************************************************************
 37 
 38   Routine:            UPDATE_STATUS
 39 
 40   Function:
 41       This routine updates the status line to reflect the current
 42   mode settings. The current mode settings are obtained by examining
 43   global flags.
 44 
 45   Parameters:         NONE
 46 
 47   Returns:            NONE
 48 
 49   Note 1 - This routine should only be called while in the foreground
 50       screen as the status line is used to display other information
 51       while in other screens.
 52 **********************************************************************/
 53 
 54 update_status()
 55 {
 56     char *wsterm_mode_str;
 57     char *edit_mode_str;
 58     char *kb_mode_str;
 59     char audit_str[32];  /* enough to hold "Audit(FILE,PRINTER)" */
 60     char *page_str;
 61     char *scroll_str;
 62     char printbuff[SCREEN_COLS+1];
 63 
 64     /* determine WSTERM's mode */
 65     if (~mowse_active)           /* GLASS TTY MODE */
 66         wsterm_mode_str = "G";
 67     else if (sync)
 68         wsterm_mode_str = "S";   /* SYNC MODE */
 69     else
 70         wsterm_mode_str = "A";   /* ASYNC MODE */
 71 
 72     kb_mode_str = "";
 73 
 74     /* edit mode disabled in synchronous packet mode */
 75     if (mowse_active && sync)
 76         edit_mode_str = "";
 77 
 78     /* if edit mode is otherwise enabled */
 79     else if (wst_edit_mode) {
 80         edit_mode_str = "Edit";
 81         /* update kb ins/repl mode here as well */
 82         if (edlin.mode)
 83             kb_mode_str = "Insert";
 84         else
 85             kb_mode_str = "Replace";
 86     }
 87 
 88     /* edit mode is disabled */
 89     else
 90         edit_mode_str = "";
 91 
 92     /* determine audit mode modes */
 93     *audit_str = 0;
 94     if (wst_f_audit) {
 95         strcpy(audit_str,"Audit(FILE");
 96         if (wst_p_audit)
 97             strcat(audit_str,",PRINTER)");
 98         else
 99             strcat(audit_str,")");
100     }
101     else if (wst_p_audit) {
102         strcpy(audit_str,"Audit(PRINTER)");
103     }
104 
105     /* determine no-scroll and paging modes */
106     scroll_str = wst_freeze ? "No-Scroll" : "";
107     page_str = wst_paging ? "Page" : "";
108 
109     /* format to a string for displaying */
110     sprintf(printbuff,
111         "%1.1s %-4.4s %-7.7s %-19.19s %-6.6s %-9.9s",
112             wsterm_mode_str,
113             edit_mode_str,
114             kb_mode_str,
115             audit_str,
116             page_str,
117             scroll_str);
118 
119     /* display the string on the status line */
120     status_line(printbuff);
121 
122     /* check for foreground message signal */
123     if (fg_msg_showing)
124         signal_fg(ON);
125 
126     /* check for background message signal */
127     if (bk_msg_showing)
128         signal_bg(ON);
129 }
130 
131 
132 
133 /*^L
134 **********************************************************************
135 
136   Routine:            STATUS_LINE
137 
138   Function:
139       This routine displays a string on the status line. The cursor
140   position is preserved.
141 
142   Parameters:
143      (input)          str - pointer to the string to display
144 
145   Returns:            NONE
146 
147 **********************************************************************/
148 
149 status_line(str)
150 char *str;
151 {
152     union REGS reg, outreg;
153     int row, col;
154     int i, j;
155     int attribute;
156 
157     /* save current cursor position */
158     cursor_pos(&row,&col);
159 
160     /* get default foreground screen attributes for status line */
161     attribute = wst_fg_screen.attr;
162 
163     reg.h.ah = WRT_SCREEN;   /* select function to write a character */
164     reg.h.bh = get_active_page();   /* write to current active page */
165     reg.x.cx = 1;            /* write 1 character at a time */
166 
167     /* invert the foreground and background attributes for reverse video */
168     reg.h.bl = ((attribute << N_FG_ATTR_BITS) |
169         (attribute >> N_BG_ATTR_BITS)) & LOW_7_BITS;
170 
171     /* display until last screen column or end of string */
172     for (i = 0; i <= MAX_SCREEN_COL && *str; i++, str++) {
173         cursor_move(SCREEN_LINES,i);     /* position cursor */
174         reg.h.al = *str;                  /* get character to write */
175         int86(BIOS_VIDEO,&reg,&outreg);          /* write the character out */
176     }
177 
178     /* blank pad the rest of the line */
179     reg.h.al = ' ';
180     for (j = i; j <= MAX_SCREEN_COL; j++) {
181         cursor_move(SCREEN_LINES,j);     /* position cursor */
182         int86(BIOS_VIDEO,&reg,&outreg);        /* write the blank */
183     }
184 
185     /* restore original cursor position */
186     cursor_move(row,col);
187 }
188 
189 
190 
191 /*^L
192 **********************************************************************
193 
194   Routine:            SIGNAL_BG
195 
196   Function:
197       This routine turns on or off the background message signal on
198   the status line.
199 
200   Parameters:
201      (input)          sw - if this value is TRUE, the background
202                           signal is turned on; if FALSE, the signal
203                           is turned OFF
204 
205   Returns:            NONE
206 
207 **********************************************************************/
208 
209 signal_bg(sw)
210 int sw;
211 {
212     int row, col;
213     union REGS reg, outreg;
214     int i;
215     char *str;
216     int attribute;
217 
218     /* save original position of cursor */
219     cursor_pos(&row,&col);
220 
221     /* get default background screen attributes */
222     attribute = wst_bg_screen.attr;
223 
224     reg.h.ah = WRT_SCREEN;   /* select function to write a character */
225     reg.h.bh = get_active_page();  /* write to current active page */
226     reg.x.cx = 1;            /* write only one character */
227 
228     /* invert the foreground and background attributes for reverse video */
229     reg.h.bl = ((attribute << N_FG_ATTR_BITS) |
230         (attribute >> N_BG_ATTR_BITS)) & LOW_7_BITS;
231 
232     /* if turning signal ON */
233     if (sw) {
234 
235         /* set hi bit for blinking */
236         reg.h.bl |= BLINK_ATTRIBUTE;
237 
238         /* initialize the message string pointer */
239         str = "[Background]";
240 
241     }
242 
243     /* else turning the signal OFF, overwrite with blanks */
244     else
245         str = "            ";
246 
247     /* write the string out at the status line background message position; */
248     /* starting coordinates on screen for background message is 24,53 */
249     for (i = 53; *str; i++, str++) {
250         cursor_move(SCREEN_LINES,i);
251         reg.h.al = *str;
252         int86(BIOS_VIDEO,&reg,&outreg);
253     }
254 
255     /* restore the original cursor position */
256     cursor_move(row,col);
257 }
258 
259 
260 
261 /*^L
262 **********************************************************************
263 
264   Routine:            SIGNAL_FG
265 
266   Function:
267       This routine turns the foreground message signal on the status
268   line on or off.
269 
270   Parameters:
271      (input)          sw - if this value is TRUE, the foreground
272                           signal is turned ON, otherwise the signal
273                           is turned OFF.
274 
275   Returns:            NONE
276 
277 **********************************************************************/
278 
279 signal_fg(sw)
280 int sw;
281 {
282     int row, col;
283     union REGS reg, outreg;
284     int i;
285     char *str;
286     int attribute;
287 
288     /* save the original cursor position */
289     cursor_pos(&row,&col);
290 
291     /* get default foreground screen attributes */
292     attribute = wst_fg_screen.attr;
293 
294     reg.h.ah = WRT_SCREEN;   /* select function to write a character */
295     reg.h.bh = get_active_page();  /* write to current active page */
296     reg.x.cx = 1;            /* write only one character */
297 
298     /* invert the foreground and background attributes for reverse video */
299     reg.h.bl = ((attribute << N_FG_ATTR_BITS) |
300         (attribute >> N_BG_ATTR_BITS)) & LOW_7_BITS;
301 
302     /* if turning signal ON */
303     if (sw) {
304 
305         /* set hi bit for blinking */
306         reg.h.bl |= BLINK_ATTRIBUTE;
307 
308         /* initialize the message string pointer */
309         str = "[Foreground]";
310     }
311 
312     /* else turning the signal OFF, overwrite with blanks */
313     else
314         str = "            ";
315 
316     /* write the string out at the status line foreground message position */
317     /* starting coordinates on screen for foreground message is 24,66 */
318     for (i = 66; *str; i++, str++) {
319         cursor_move(SCREEN_LINES,i);
320         reg.h.al = *str;
321         int86(BIOS_VIDEO,&reg,&outreg);
322     }
323 
324     /* restore the original cursor position */
325     cursor_move(row,col);
326 }