1 /* *********************************************************** 2 * * 3 * Copyright, (C) Honeywell Bull Inc., 1988 * 4 * * 5 * Copyright, (C) Honeywell Information Systems Inc., 1987 * 6 * * 7 *********************************************************** */ 8 9 10 /* HISTORY COMMENTS: 11 1) change(87-03-21,Wallman), approve(87-03-21,MCR7586), 12 audit(87-07-13,Flegel), install(87-08-07,MR12.1-1072): 13 First release. 14 2) change(88-06-06,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 15 install(88-10-12,MR12.2-1160): 16 Return error code instead of exiting when MOWSE not yet invoked 17 for cleanup by main(). 18 3) change(88-07-12,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 19 install(88-10-12,MR12.2-1160): 20 Replaced calls to redundant move_abs() with calls to cursor_move(). 21 4) change(88-07-20,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 22 install(88-10-12,MR12.2-1160): 23 Made edit mode default after atm. 24 5) change(88-07-25,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 25 install(88-10-12,MR12.2-1160): 26 Documentation only, added header comment. 27 6) change(88-08-09,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 28 install(88-10-12,MR12.2-1160): 29 Fix references to include files; "wstdefs.h" was split into 30 "wstdefs.h" and "wsttype.h" to avoid declaration clash; also, 31 various constants defined to descriptive names. 32 7) change(88-08-23,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 33 install(88-10-12,MR12.2-1160): 34 Added WSTERM edit mode and other mode initialization routines. 35 8) change(88-08-30,Lee), approve(88-09-12,MCR7986), audit(88-09-19,Flegel), 36 install(88-10-12,MR12.2-1160): 37 Removed non-edit async mode and references to non-edit async mode 38 line editing routines. 39 9) change(89-01-18,Lee), approve(89-01-02,MCR8043), audit(89-03-14,Flegel), 40 install(89-04-24,MR12.3-1033): 41 phx21233 - Modified to initialize default glass_edit_mode value; 42 separated input and output parameters to int86() to avoid confusion 43 when parameters are used. 44 END HISTORY COMMENTS */ 45 46 /* WSTINIT - Initialization module for WSTERM */ 47 48 /* This module prepares the execution evironment for a WSTERM session */ 49 50 #include <stdio.h> 51 #include <dos.h> 52 #include <alloc.h> 53 #include <ws_error.h> 54 #include <wsmincap.h> 55 #include "wstdefs.h" 56 #include "wstglob.h" 57 58 /*^L 59 ********************************************************************** 60 61 Routine: WSTINIT 62 63 Function: 64 This routine initializes the screen and the execution 65 environment variables which are used by WSTERM. 66 67 Parameters: NONE 68 69 Returns: -1 if an error occurs during initialization; in 70 particular, if MOWSE has not been invoked 71 on the PC 72 0 if no errors 73 74 **********************************************************************/ 75 76 wstinit () 77 { 78 79 /* Clear the screen and display version id */ 80 81 clear_screen (); 82 cursor_move (CURSOR_HOME_ROW, 60); 83 printf ("WSTERM Vers %s", version); 84 cursor_move (CURSOR_HOME_ROW, CURSOR_HOME_COL); 85 86 /* Initialize static structures with defaults */ 87 88 setmem (&screen, sizeof (screen), 0); 89 screen.maxcol = MAX_SCREEN_COL; 90 screen.maxlin = MAX_SCREEN_LINE; 91 92 setmem (&kb, sizeof (kb), 0); 93 kb.key_status = -1; 94 setmem (&ds, sizeof (ds), 0); 95 setmem (&tdata_arg, sizeof (tdata_arg), 0); 96 97 tdata_arg.local_buffer_pointer = (char *) fg_msg.text; 98 tdata_arg.local_buffer_size = FG_MSG_SIZE; 99 100 setmem (&fg_msg, sizeof (fg_msg), 0); 101 setmem (brk_table, sizeof (brk_table), 0); 102 103 /* Tell mowse we're here */ 104 mowse_active = cretinst ("WSTERM", /* capability name */ 105 NULL, /* NULL entry function */ 106 0, /* zero inbuff length */ 107 0, /* zero outbuff length */ 108 NULL, /* NULL data block ptr */ 109 &wst_mcb); /* MCB pointer */ 110 111 if (mowse_active == WSNOTRES) { 112 printf ("MOWSE has not been invoked.\n"); 113 return(-1); 114 } 115 116 /**************** WSNOTPKT goes here */ 117 118 mowse_active = -(mowse_active == 0); 119 120 /* is mowse active? */ 121 if (~mowse_active) { 122 123 kb.echo = OFF; 124 glass_edit_mode = FALSE; /* phx21233 R.L. - initialize mode flags */ 125 wst_edit_mode = FALSE; 126 127 } 128 else { 129 kb.echo = ON; 130 131 /* edit mode is always enabled in async packet mode */ 132 wst_edit_mode = TRUE; 133 } 134 135 return(0); 136 } /* End of wstinit */ 137 138 139 140 /*^L 141 ********************************************************************** 142 143 Routine: WST_INIT_MODES 144 145 Function: 146 This routine initializes structures and variables associated 147 with WSTERM's various modes. 148 149 Parameters: NONE 150 151 Returns: NONE 152 153 **********************************************************************/ 154 155 wst_init_modes() 156 { 157 int attr; 158 159 wst_paging = ON; /* display EOP after screenful */ 160 wst_freeze = OFF; /* allow scrolling */ 161 wst_f_audit = OFF; /* file audit off */ 162 wst_p_audit = OFF; /* line printer audit off */ 163 wst_edit_mode = OFF; /* disable line edit mode */ 164 break_flag = FALSE; /* no break hit */ 165 wst_status = WST_UNKNOWN_MODE; /* mode to be determined */ 166 clr_index = 0; /* not currently in escape sequence */ 167 cursor_type = CURSOR_UNDERSCORE; /* assume underscore cursor */ 168 169 wst_fansi_flag = FALSE; /* assume FANSI-CONSOLE not used */ 170 171 init_fconsole(); /* set scroll region and wst_fansi_flag */ 172 /* if device driver is FANSI-CONSOLE */ 173 174 printf(ED); /* (EraseDisplay) clear screen and home cursor */ 175 getattr(&attr); /* get character attributes */ 176 wst_screens_init(' ',attr); /* initialize the screen variables */ 177 init_wst_scroll(attr); /* initialize structure for scrolling display */ 178 p_aud_init(); 179 f_aud_init(); 180 init_histbuff(); 181 init_killbuff(); 182 save_printer_timeout(); 183 set_printer_timeout(1); 184 } 185 186 187 188 /*^L 189 ********************************************************************** 190 191 Routine: GETATTR 192 193 Function: 194 This routine gets the current screen attributes. The screen 195 attributes read can then be used to determine what color and 196 intensity is to be used for subsequent displaying. 197 198 Parameters: 199 (output) attr - pointer to the integer variable for 200 passing back the current attributes 201 202 Returns: NONE 203 204 **********************************************************************/ 205 206 getattr(attr) 207 int *attr; 208 { 209 union REGS reg, outreg; 210 211 cursor_move(CURSOR_HOME_ROW,CURSOR_HOME_COL); /* home cursor */ 212 reg.h.ah = RD_SCREEN; /* read character and attributes */ 213 reg.h.bh = get_active_page(); /* from current active page */ 214 int86(BIOS_VIDEO,®,&outreg); /* call BIOS to get character attributes */ 215 *attr = (int)outreg.h.ah; /* set attribute parameter with attributes */ 216 } 217 218 219 220 /*^L 221 ********************************************************************** 222 223 Routine: INIT_FCONSOLE 224 225 Function: 226 This routine determines if FANSI-CONSOLE is being used as the 227 screen driver. If so, the global flag "wst_fansi_flag" is set and 228 an escape sequence is sent to initialize the first 24 lines of the 229 screen as the scrolling region. 230 231 Parameters: NONE 232 233 Returns: NONE 234 235 **********************************************************************/ 236 237 init_fconsole() 238 { 239 int fd; 240 241 /* if device driver for FANSI-CONSOLE exists */ 242 if ((fd = open("fcon",0)) >= 0) { 243 close(fd); /* we don't need file descriptor any more */ 244 245 wst_fansi_flag = TRUE; /* set to indicate fansi-console installed */ 246 247 /* print sequence to set the scroll region from lines 1 to 24 */ 248 put_screen_str(FCON_SET_SCROLL_24); 249 } 250 } 251 252 253 254 /*^L 255 ********************************************************************** 256 257 Routine: RESET_SCROLL 258 259 Function: 260 This routine checks to see if the global flag "wst_fansi_flag" 261 has been set and if so, will send an escape sequence to the screen 262 driver to reset the scrolling region. 263 264 Parameters: NONE 265 266 Returns: NONE 267 268 **********************************************************************/ 269 270 reset_scroll() 271 { 272 /* if fansi console installed */ 273 if (wst_fansi_flag) 274 /* print the escape sequence to set the scroll 275 region to the default (the entire screen) 276 */ 277 put_screen_str(FCON_RESET_SCROLL_STR); 278 } 279 280 281 /* End of WSTINIT */ 282