1 /**** BEGIN INCLUDE FILE wstdefs.h */ 2 3 /* HISTORY COMMENTS: 4 1) change(87-03-13,Wallman), approve(87-03-13,MCR7586), 5 audit(87-07-16,Flegel), install(87-08-07,MR12.1-1072): 6 First release 7 2) change(88-08-09,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel): 8 Separated redefinitions of ctype.h defines 9 and placed them in separate include file "wsttype.h"; added 10 miscellaneous defines used. 11 END HISTORY COMMENTS */ 12 13 /* Function: 14 This include file defines constants and structures used in WSTERM. 15 */ 16 17 #ifndef WSTDEFS 18 /* Constant definitions and structure skeletons for WSTERM */ 19 20 /* ASCII characters and definitions */ 21 22 #define BEL '\007' /* ASCII BEL */ 23 #define BSP '\010' /* ASCII BS */ 24 #define CR '\015' /* ASCII CR */ 25 #define DEL '\177' /* ASCII DEL - Default char erase */ 26 #define ESC '\033' /* ASCII ESC */ 27 #define HT '\011' /* ASCII HT */ 28 #define KILL '\100' /* ASCII AT - Default line kill */ 29 #define LF '\012' /* ASCII LF */ 30 #define LNC '\134' /* ASCII \ - Default literal next char */ 31 #define NL '\012' /* ASCII NL */ 32 #define NUL '\000' /* ASCII NUL */ 33 #define ASCII_DEL 127 /* ASCII value for DEL */ 34 #define ASCII_NUL 0 35 36 #define CTRL_A 1 /* ASCII value for CTRL A */ 37 #define CTRL_B 2 /* ASCII value for CTRL B */ 38 #define CTRL_D 4 /* ASCII value for CTRL D */ 39 #define CTRL_E 5 /* ASCII value for CTRL E */ 40 #define CTRL_F 6 /* ASCII value for CTRL F */ 41 #define CTRL_K 11 /* ASCII value for CTRL K */ 42 #define CTRL_N 14 /* ASCII value for CTRL N */ 43 #define CTRL_P 16 /* ASCII value for CTRL P */ 44 #define CTRL_T 20 /* ASCII value for CTRL T */ 45 #define CTRL_Y 25 /* ASCII value for CTRL Y */ 46 47 #define RETURN_KEY 13 /* ASCII value for RETURN key */ 48 #define BACKSPACE 8 /* ASCII value for BACKSPACE */ 49 #define TAB 9 /* ASCII value for TAB */ 50 #define LINEFEED 10 /* ASCII value for line feed character */ 51 52 #define MIN_PRINTABLE_ASCII ' ' /* lowest printable ascii char */ 53 #define MAX_PRINTABLE_ASCII 126 /* maximum printable ascii char */ 54 #define MAX_CNTRL_CHAR 31 /* highest ASCII control character */ 55 56 /* Keyboard key codes */ 57 #define DEL_KEY 339 /* unique key code for DEL key */ 58 #define CTRL_2 259 /* unique key code for ^2 */ 59 #define NULL_KEY 259 /* another name for ^2 */ 60 #define ALT_D 288 /* unique key code for ALT-D */ 61 #define ALT_M 306 /* unique key code for ALT-M */ 62 #define ALT_H 291 /* unique key code for ALT-H */ 63 #define ALT_B 304 /* unique key code for ALT-B */ 64 #define ALT_S 287 /* unique key code for ALT_S */ 65 #define ALT_I 279 /* unique key code for ALT_I */ 66 #define BREAK_KEY 512 /* unique key code for ^BREAK */ 67 68 /* define values for keypad characters */ 69 70 #define CTRL_LEFT_ARROW_KEY 371 /* control left arrow key */ 71 #define CTRL_RIGHT_ARROW_KEY 372 /* control right arrow key */ 72 #define DOWN_ARROW_KEY 336 /* the down arrow key */ 73 #define END_KEY 335 /* the End key */ 74 #define HOME_KEY 327 /* Home key */ 75 #define INS_KEY 338 /* the Ins key */ 76 #define LEFT_ARROW_KEY 331 /* the left arrow key */ 77 #define PAGE_DOWN_KEY 337 /* the PgDn key */ 78 #define RIGHT_ARROW_KEY 333 /* the right arrow key */ 79 #define UP_ARROW_KEY 328 /* the up arrow key */ 80 81 82 /* ANSI functions */ 83 84 #define ED "\033[2J" /* Erase display */ 85 #define EL "\033[K" /* Erase line */ 86 #define RCP "\033[u" /* Restore cursor position */ 87 #define SCP "\033[s" /* Save cursor position */ 88 89 90 /* DOS/BIOS constants */ 91 92 #define BIOS_KB 0x16 /* BIOS keyboard request */ 93 #define BIOS_KB_READ 0 /* Keyboard read function */ 94 #define BIOS_KB_SHIFTS 2 /* Keyboard shift status function */ 95 #define BIOS_KB_STATUS 1 /* Keyboard status function */ 96 #define BIOS_PRT 0x17 /* BIOS printer interrupt request */ 97 #define BIOS_PRT_PRINT 0 /* BIOS print character function */ 98 #define BIOS_PRT_STATUS 2 /* BIOS printer status function */ 99 #define BIOS_SEGMENT 0x40 /* segment location of BIOS variables */ 100 #define BIOS_VIDEO 0x10 /* BIOS video request */ 101 #define BLINK_ATTRIBUTE 0x80 /* bit that enables blink attribute */ 102 #define CUP 2 /* BIOS cursor position function */ 103 #define DOS_CTRL_C_DISABLE 0 /* ctrl-c checking disabled */ 104 #define DOS_CTRL_C_ENABLE 1 /* ctrl-c checking enabled */ 105 #define DOS_CTRL_C_EXCHANGE 2 /* ctrl-c exchange function */ 106 #define DOS_CTRL_C_FUNCTION 0x33 /* DOS set/check ctrl-c function */ 107 #define DOS_CTRL_C_SET 1 /* ctrl-c set function */ 108 #define DOS_GET_DATE 0x2a /* DOS get date function */ 109 #define DOS_GET_TIME 0x2c /* DOS get time function */ 110 #define DOS_INT 0x21 /* DOS function interrupt */ 111 #define HIDE_CURSOR_COL 0 /* hide cursor column coordinate */ 112 #define HIDE_CURSOR_ROW 25 /* hide cursor row coordinate */ 113 #define LINE24_COL0 0x1700 /* Start of blank scroll line */ 114 #define N_BG_ATTR_BITS 4 /* number of background video attribute bits */ 115 #define N_FG_ATTR_BITS 4 /* number of foreground video attribute bits */ 116 #define PRT_NO_PAPER_MODE 070 /* bit pattern for printer no paper */ 117 #define PRT_OFF_LINE_MODE 030 /* bit pattern for printer off line */ 118 #define PRT_OFF_MODE 0210 /* bit pattern for printer off */ 119 #define PRT_READY_MODE 0220 /* bit pattern for printer ready */ 120 #define PRT_TIMEOUT_BASE 0x78 121 #define RD_SCREEN 0x8 /* Read screen char and attributes */ 122 #define SCROLL_LINE_ATTRS 0x700 /* Attributes for blank scroll line */ 123 #define SCROLL_UP_1_LINE 0x601 /* BIOS scroll up function */ 124 #define SCROLL_WINDOW_END 0x174F /* End of scrolling window */ 125 #define SCROLL_WINDOW_START 0 /* Start of scrolling window */ 126 #define SET_CURSOR_POS 2 /* BIOS set cursor position function */ 127 #define SYSTEM_TIME 0x2C /* BIOS system time function */ 128 #define VIDEO_CURSOR_MOVE_FUNC 0x2 /* video cursor move function */ 129 #define VIDEO_CURSOR_READ_FUNC 0x3 /* video read cursor function */ 130 #define VIDEO_SCROLL_UP_FUNC 0x6 /* video scroll up function */ 131 #define WRT_SCREEN 0x9 /* Write screen char and attributes */ 132 133 134 /* Keystroke status bits */ 135 136 #define ALT 0x8 /* ALT key status bit */ 137 #define CAPSLCK 0x40 /* Caps lock */ 138 #define CTRL 0x4 /* CTRL key status bit */ 139 #define INSACT 0x80 /* Insert mode active */ 140 #define LSHIFT 0x2 /* LEFT SHIFT key status bit */ 141 #define NUMLCK 0x20 /* Numeric lock */ 142 #define RSHIFT 0x1 /* RIGHT SHIFT key status bit */ 143 #define SCRLLCK 0x10 /* Scroll lock */ 144 145 146 /* Keyboard scan codes */ 147 148 #define B_KEY_CODE 48 /* keyboard scan code for B key */ 149 #define C_KEY_CODE 46 /* keyboard scan code for C key */ 150 #define D_KEY_CODE 32 /* keyboard scan code for D key */ 151 #define E_KEY_CODE 18 /* keyboard scan code for E */ 152 #define F11_KEY_CODE 84 /* keyboard scan code, F11 func key */ 153 #define F1_KEY_CODE 59 /* keyboard scan code, F1 func key */ 154 #define F_KEY_CODE 33 /* keyboard scan code for F */ 155 #define H_KEY_CODE 35 /* keyboard scan code for H */ 156 #define M_KEY_CODE 50 /* keyboard scan code for M key */ 157 #define N_KEY_CODE 49 /* keyboard scan code for N key */ 158 #define O_KEY_CODE 24 /* keyboard scan code for O */ 159 #define P_KEY_CODE 25 /* keyboard scan code for P */ 160 #define Q_KEY_CODE 16 /* keyboard scan code for Q key */ 161 #define S_KEY_CODE 31 /* keyboard scan code for S */ 162 #define V_KEY_CODE 47 /* keyboard scan code for V */ 163 #define zero_KEY_CODE 11 /* keyboard scan code for 0 key */ 164 165 166 /* Other constants */ 167 168 #define ASCII_EXTEND_CODE 256 /* assigns unique key codes */ 169 #define ASCII_ZERO_BASE '0' /* to convert binary to ascii digit */ 170 #define BLINK -1 /* Blinking attribute for chars */ 171 #define BLOCK -1 /* Wait for function completion */ 172 #define CURSOR_BLOCK 2 /* WSTERM block cursor type */ 173 #define CURSOR_HOME_COL 0 /* cursor coordinates for home col */ 174 #define CURSOR_HOME_ROW 0 /* cursor coordinates for home row */ 175 #define CURSOR_UNDERSCORE 1 /* WSTERM underscore cursor type */ 176 #define DEFAULT_ACTIVE_PAGE 0 /* default active page */ 177 #define DEFAULT_AUDIT_FILE "wsterm.log" /* default audit file name */ 178 #define DEFAULT_LINES_TO_SCROLL 1 /* normally only 1 line scrolled */ 179 #define DEFAULT_PRINTER_CARD 0 /* default printer card value */ 180 #define DS_LCT 8 /* Display map size */ 181 #define FALSE 0 /* logical false */ 182 #define FG_MSG_SIZE 3000 /* Size of foreground message buffer */ 183 #define FORCE -1 /* Switch value to force stuff */ 184 #define F_AUDIT_BUFF_SIZE 1024 /* size of file audit buffer */ 185 #define HIDE -1 /* Switch value to hide stuff */ 186 #define HI_BYTE_VALUE 0x100 /* Value of high byte in size field */ 187 #define KB_CAPITALIZED 3 /* flag for capitalize conversion */ 188 #define KB_HANDLING_ESC_ARG 2 /* handling numeric escape argument */ 189 #define KB_INSERT_MODE 1 /* input chars are inserted */ 190 #define KB_LITERAL_ESC 4 /* handling literal character escape */ 191 #define KB_LOWER_CASE 2 /* flag for lower case conversion */ 192 #define KB_NO_BLOCK 0 /* no block flag for edit mode keyboard read */ 193 #define KB_PREV_KEY_ESC 1 /* previous key hit was escape key */ 194 #define KB_REPLACE_MODE 0 /* input chars overstrike/replace */ 195 #define KB_UPPER_CASE 1 /* flag for upper case conversion */ 196 #define LARGEST_DECI_DIGIT '9' /* largest ascii decimal digit */ 197 #define LARGEST_OCTAL_DIGIT '7' /* largest ascii octal digit */ 198 #define LOW_7_BITS 0177 /* mask for lowest 7 bits */ 199 #define LOW_8_BITS 0xff /* mask for lowest 8 bits */ 200 #define LO_BYTE_MASK 0xFF /* Mask for low order bytes */ 201 #define MAXINT 0x7FFF /* Maximum integer value */ 202 #define MAXMSG 650 /* Length of message buffers */ 203 #define MAX_7_BIT_VAL 128 /* maximum value for 7 bits */ 204 #define MAX_8_BIT_VALUE 256 /* maximum value for 8 bits */ 205 #define MAX_ARG_LIMIT 3266 /* max signed int value / 10 */ 206 #define MAX_BG_MESS_LENGTH 256 /* maximum background message length */ 207 #define MAX_DATE_TIME_STR_LENGTH 32 /* max. length for date/time string */ 208 #define MAX_DISPLAY_CHAR_SIZE 10 /* maximum length of char displayed */ 209 #define MAX_LINE_SIZE 512 /* size of edit mode line buffer */ 210 #define MAX_OCTAL_SEQ_DIGITS 3 /* max. digits in octal sequence */ 211 #define MAX_PRINTER_CARD_VAL 2 /* highest printer card value */ 212 #define MAX_SCREEN_COL 79 /* Dimensions for 80x24 screen */ 213 #define MAX_SCREEN_LINE 23 214 #define MINI -1 /* Mini switch setting */ 215 #define MINI_LIN 24 /* The minibuffer line */ 216 #define MIN_PRINTER_CARD_VAL 0 /* lowest printer card value */ 217 #define NONE 0 /* descriptive define for 0 */ 218 #define NO_BLOCK -1 /* Dont block for keyboard input */ 219 #define NO_BLOCK_MASK 0x80 /* No block flag for sync reads */ 220 #define NO_ESC_ARG -1 /* no numeric arguments */ 221 #define NO_ESC_FUNC 0 /* not handling special escaping */ 222 #define NUL_TERMINATOR 0 /* descriptive, string terminator */ 223 #define N_SIZE_SPEC_BYTES 2 /* size specifier word bytes */ 224 #define OCTAL_BASE_VALUE 8 /* multiplier for octal base */ 225 #define OFF 0 /* Switch OFF value */ 226 #define ON -1 /* Switch ON value */ 227 #define ONE_BYTE 1 /* descriptive define for 1 byte */ 228 #define PEL_OFF_LINE 0 /* printer error list OFF LINE */ 229 #define PEL_NOT_READY 2 /* printer error list NOT READY */ 230 #define PEL_NO_PAPER 1 /* printer error list NO PAPER */ 231 #define PSTR -1 /* Switch value for prompt strings */ 232 #define P_AUDIT_BUFF_SIZE 256 /* size of printer audit buffer */ 233 #define QUIT 'Q' /* Quit emulator & return to DOS */ 234 #define SCREEN_COLS 80 /* number of screen columns */ 235 #define SCREEN_LINES 24 /* number of screen rows or lines */ 236 #define SET_MARK "\000" /* Emacs "set-the-mark" */ 237 #define SMALLEST_DECI_DIGIT '0' /* smallest ascii decimal digit */ 238 #define SMALLEST_OCTAL_DIGIT '0' /* smallest ascii octal digit */ 239 #define STATUS -1 /* Argument value for rd_key */ 240 #define TAB_SIZE 10 /* size (in columns) of a tab */ 241 #define TOTAL_SIZE_SPEC_BYTES 4 /* total bytes for size specifier */ 242 #define TRO -1 /* Delay timer has run out */ 243 #define TRUE 1 /* logical true */ 244 #define TXMT_MSG -1 /* Transmit a message */ 245 #define WST_ASYNC_MODE 2 /* asynchronous packet mode */ 246 #define WST_BACKGROUND_SCREEN 1 247 #define WST_FOREGROUND_SCREEN 2 248 #define WST_GLASS_TTY_MODE 1 /* glass tty mode */ 249 #define WST_SYNC_MODE 3 /* synchronous packet mode */ 250 #define WST_UNKNOWN_MODE 0 /* unknown wsterm protocol mode */ 251 #define ZERO_BYTES 0 /* descriptive define for 0 bytes */ 252 #define ZERO_INDEX_VALUE 0 /* descriptive define for index 0 */ 253 #define Z_FLAG_MASK 0100 /* mask for the CPU Z bit */ 254 255 #define KILLBUFF_SAVE TRUE /* enabled saving to kill buffer */ 256 #define NO_KILLBUFF_SAVE FALSE /* disable saving to kill buffer */ 257 258 /* total number of characters on the screen */ 259 #define SCREEN_CHARS (SCREEN_LINES*SCREEN_COLS) 260 261 /* total number of characters in each screen buffer */ 262 #define SCREEN_BUFFER_BYTES (SCREEN_LINES*SCREEN_COLS*2) 263 264 /* constants which define help topics */ 265 266 #define BG_HELP 1 /* background screen help */ 267 #define GENERAL_HELP 0 /* general help */ 268 #define HISTORY_HELP 2 /* history screen help */ 269 #define N_HELP_TOPICS 3 /* number of help topics */ 270 #define N_HELP_PAGE_LINES 24 /* number of lines per help screen */ 271 272 #define FIRST_TOPIC_INDEX 0 /* descriptive define for index 0 */ 273 #define SECOND_TOPIC_INDEX 1 /* descriptive define for index 1 */ 274 #define THIRD_TOPIC_INDEX 2 /* descriptive define for index 2 */ 275 276 #define LAST_HELP_TOPIC_INDEX (N_HELP_TOPICS-1) /* last help topic index */ 277 278 279 /* FANSI-CONSOLE escape sequences */ 280 #define FCON_RESET_SCROLL_STR "\033[0;0r" /* default scroll region */ 281 #define FCON_SET_SCROLL_24 "\033[1;24r" /* scroll region rows 1 to 24 */ 282 283 #define beep() putch('\007') /* sound a beep */ 284 285 286 /* Structures */ 287 288 struct ctl_msg_hdr /* Control message header */ 289 { char id [3]; /* Message ID */ 290 byte msb_size, lsb_size; /* Message size */ 291 }; 292 293 294 struct ds_struct /* Keyboard display data */ 295 { int ccol, /* Current column position */ 296 do_col, do_ctl, /* For ANSI control sequences */ 297 lct, /* Number of ds_map lines */ 298 lndx, /* Current display map line index */ 299 pstrl, /* Prompt string length */ 300 spill [DS_LCT], /* Last ds.dlin char spills */ 301 splct [DS_LCT]; /* Char spill from previous line */ 302 char dlin [SCREEN_COLS+1], /* Current display line */ 303 map [DS_LCT] [SCREEN_COLS+1], /* Display line map */ 304 pstr [SCREEN_COLS+1]; /* The prompt string */ 305 }; 306 307 struct kb_struct /* Keyboard input data */ 308 { int echo, /* Effective echo switch */ 309 cndx, /* Next kb.klin character index */ 310 endx, /* First kb.klin unechoed character */ 311 fkey, /* Function key switch */ 312 key_ndx, /* Keyboard scan index */ 313 key_status, /* Keyboard status */ 314 insert_mode, /* Insert mode switch */ 315 pos [MAXMSG]; /* Display position of each char */ 316 char chr [10], /* A keyboard "character" */ 317 klin [MAXMSG+1], /* Keyboard input line */ 318 dstr [12]; /* Display string for kb.chr */ 319 }; 320 321 struct screen_struct /* Screen display data */ 322 { int curcol, curlin, /* Current cursor position */ 323 EOP_ct, /* EOP line counter */ 324 maxcol, maxlin; /* Screen size from tty_ modes */ 325 char mini_buf [MAX_SCREEN_COL+1]; /* 25th line minibuffer */ 326 }; 327 328 union regs_struct 329 { struct HREG hreg; 330 struct XREG xreg; 331 }; 332 333 struct snd_msg_struct 334 { struct ctl_msg_hdr hdr; 335 char data [MAXMSG + 1]; 336 }; 337 338 struct stm_data /* Data for STM message */ 339 { byte modes, /* '00000'|lfecho|crecho|sync */ 340 kill, 341 erase, 342 lnc, 343 maxcol, 344 maxlin; 345 }; 346 347 union fg_msg_struct 348 { char text [FG_MSG_SIZE]; 349 struct { struct ctl_msg_hdr hdr; 350 union { byte rd_ct [2]; 351 char break_table [96]; 352 struct stm_data stm; 353 } data; 354 } ctl; 355 }; 356 357 358 /* screen buffer for saving contents of screen; screen characters 359 and attributes are saved 360 */ 361 typedef struct wst_screen_struct { 362 int cursor_row; /* cursor row coordinate to save */ 363 int cursor_col; /* cursor column coordinate to save */ 364 int attr; /* default attribute to use */ 365 char screen[SCREEN_BUFFER_BYTES]; /* buffer to hold screen contents */ 366 } SCREEN; 367 368 369 /* structure which defines the screen dimensions for edit mode 370 keyboard display 371 */ 372 typedef struct screen_size_struct { 373 int left; /* left coordinate of keyboard window */ 374 int right; /* right coordinate of keyboard window */ 375 int top; /* top coordinate of keyboard window */ 376 int bottom; /* bottom coordinate of keyboard window */ 377 } SCREEN_SIZE; 378 379 /* structure for keeping temporary track of cursor positioning 380 information 381 */ 382 typedef struct curpos_struct { 383 int orig_row; /* row coordinates where displaying first begins */ 384 int orig_col; /* col coordinates where displaying first begins */ 385 int cur_row; /* row coordinates of where cursor currently is */ 386 int cur_col; /* col coordinates of where cursor currently is */ 387 int max_row; /* maximum row coordinates of characters displayed */ 388 int max_col; /* maximum col coordinates of characters displayed */ 389 int scroll_flag; /* indicates screen has scrolled */ 390 } CURPOS; 391 392 393 /* structure containing the line and information about the line 394 being edited in edit mode 395 */ 396 typedef struct line_struct { 397 int mode; /* flag indicating replace/insert */ 398 int orig_row; /* row coordinate where displaying originates */ 399 int orig_col; /* col coordinate where displaying originates */ 400 int cur_row; /* row coordinate of current cursor position */ 401 int cur_col; /* col coordinate of current cursor position */ 402 int max_row; /* maximum row coordinates of characters displayed */ 403 int max_col; /* maximum col coordinates of characters displayed */ 404 int scrolled_flag; /* flag indicating screen has scrolled */ 405 int off_screen; /* flag indicating text beyond what is displayed */ 406 int escape_flag; /* flag indicating whether doing escape handling */ 407 int escape_arg; /* flag containing numeric escape argument */ 408 409 char line[MAX_LINE_SIZE+2]; /* command line, extra bytes for LF and '\0' */ 410 char size[MAX_LINE_SIZE+2]; /* command line, extra bytes for LF and '\0' */ 411 char literal_buff[4]; /* for holding literal character strings */ 412 int index; /* index representing cursor location in line */ 413 int length; /* line length */ 414 int literal_dex; /* length of literal character string */ 415 } EDIT_LINE; 416 417 #define WSTDEFS 418 #endif 419 420 /* END INCLUDE FILE: wstdefs.h */