1 /* ******************************************** 2 * * 3 * Copyright, (C) Honeywell Bull Inc., 1988 * 4 * * 5 ******************************************** */ 6 7 /* HISTORY COMMENTS: 8 1) change(88-06-13,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 /*^L 26 ********************************************************************** 27 28 Routine: INIT_KB_SCREEN 29 30 Function: 31 This routine initializes a structure used by the edit mode 32 editing routines which specifies the size of the display screen. 33 34 Parameters: 35 (input) rows - specifies the height of the screen in 36 rows 37 (input) cols - specifies the width of the screen in 38 columns 39 40 Returns: NONE 41 42 **********************************************************************/ 43 44 init_kb_screen(rows,cols) 45 int rows; /* screen height in rows */ 46 int cols; /* screen width in columns */ 47 { 48 ss.top = CURSOR_HOME_ROW; /* top screen edge coordinate */ 49 ss.left = CURSOR_HOME_COL; /* left screen edge coordinate */ 50 ss.bottom = rows-1; /* bottom screen edge coordinate */ 51 /* (subtract 1 to get coordinate value) */ 52 ss.right = cols-2; /* right screen edge coordinate */ 53 /* (subtract 1 to get coordinate value */ 54 /* and another to prevent last screen */ 55 /* column to be written since it may */ 56 /* automatic cursor advancement or */ 57 /* scrolling which is not desirable) */ 58 } 59 60 61 /*^L 62 ********************************************************************** 63 64 Routine: INIT_LINE 65 66 Function: 67 This routine initializes the structure containing the line 68 being edited and information about the line in edit mode. The 69 values that are used for initializing will indicate an empty line 70 being edited. 71 72 Parameters: 73 (input/output) line - a pointer to the structure which 74 contains the line and information about the 75 line being edited 76 77 Returns: NONE 78 79 **********************************************************************/ 80 81 init_line(line) 82 EDIT_LINE *line; 83 { 84 85 line->mode = KB_REPLACE_MODE; /* insert/replace mode is replace */ 86 line->orig_row = CURSOR_HOME_ROW; /* assume starting at top row */ 87 line->orig_col = CURSOR_HOME_COL; /* assume starting at leftmost column */ 88 line->length = 0; /* line length is 0 (empty line) */ 89 line->index = 0; /* logical cursor position is 0 */ 90 line->literal_dex = 0; /* count of numeric digits for escape arg */ 91 line->line[0] = NUL_TERMINATOR; /* NUL terminate keyboard buffer */ 92 line->escape_arg = NO_ESC_ARG; /* initialize escape argument counter */ 93 line->escape_flag = NO_ESC_FUNC; /* initialize escape/literal key flag */ 94 } 95 96 97 /*^L 98 ********************************************************************** 99 100 Routine: INIT_CURPOS 101 102 Function: 103 This routine initializes the cursor position fields of the 104 structure containing the edit mode line. The position is obtained 105 by fetching the current location of the physical cursor. 106 107 Parameters: 108 (input/output) line - pointer to the structure containing the 109 line being edited in edit mode 110 111 Returns: NONE 112 113 **********************************************************************/ 114 115 init_curpos(line) 116 EDIT_LINE *line; 117 { 118 /* get cursor position as starting cursor coordinates */ 119 cursor_pos(&(line->orig_row),&(line->orig_col)); 120 121 /* assume empty line, finishing coordinates same as current 122 coordinates same as starting coordinates 123 */ 124 line->cur_row = line->max_row = line->orig_row; 125 line->cur_col = line->max_col = line->orig_col; 126 127 /* empty line, keyboard display did not scroll */ 128 line->scrolled_flag = FALSE; 129 130 /* empty line, nothing in keyboard buffer beyond what is displayed 131 at bottom of screen 132 */ 133 line->off_screen = FALSE; 134 } 135 136 137 /*^L 138 ********************************************************************** 139 140 Routine: INIT_TEMP_CURPOS 141 142 Function: 143 This routine initializes a structure used for temporarily 144 keeping track of cursor positioning. The values used for 145 initialization are taken from the structure containing the edit 146 mode line and line information. 147 148 Parameters: 149 (input/output) pos - pointer to the structure for temporarily 150 keeping track of cursor position 151 (input) line - pointer to the structure containing the 152 line and line information for the edit mode 153 line 154 155 Returns: NONE 156 157 **********************************************************************/ 158 159 init_temp_curpos(pos,line) 160 CURPOS *pos; 161 EDIT_LINE *line; 162 { 163 pos->orig_row = line->orig_row; /* get starting coordinates */ 164 pos->orig_col = line->orig_col; 165 166 pos->cur_row = line->cur_row; /* get current coordinates */ 167 pos->cur_col = line->cur_col; 168 169 pos->max_row = line->max_row; /* get ending coordinates */ 170 pos->max_col = line->max_col; 171 172 pos->scroll_flag = FALSE; 173 } 174