1 /* ******************************************** 2 * * 3 * Copyright, (C) Honeywell Bull Inc., 1987 * 4 * * 5 ******************************************** */ 6 7 /* HISTORY COMMENTS: 8 1) change(87-05-04,Wallman), approve(87-05-04,MCR7586), 9 audit(87-08-10,Flegel), install(87-08-07,MR12.1-1072): 10 First release. 11 2) change(87-09-02,Wallman), approve(87-09-02,MCR7586), 12 audit(87-08-17,Flegel), install(87-09-10,MR12.1-1103): 13 PBF to improve robustness of string handling by avoiding all str* 14 functions. 15 3) change(88-02-24,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 16 install(88-10-12,MR12.2-1160): 17 Removed debugging code and unused variables; code re-formatting. 18 4) change(88-04-25,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 19 install(88-10-12,MR12.2-1160): 20 Null-terminated temporary string "trash" in edit_HT to fix bug. 21 5) change(88-05-18,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 22 install(88-10-12,MR12.2-1160): 23 Deleted hide_sw reference to function replay(). 24 6) change(88-05-31,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 25 install(88-10-12,MR12.2-1160): 26 Added file and printer auditing support. 27 7) change(88-07-12,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 28 install(88-10-12,MR12.2-1160): 29 Replace calls to redundant move_abs() with calls to cursor_move(). 30 8) change(88-07-25,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 31 install(88-10-12,MR12.2-1160): 32 Documentation additions only. Added header comments to all routines. 33 9) change(88-08-09,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel), 34 install(88-10-12,MR12.2-1160): 35 Fix references to include files; "wstdefs.h" was split into 36 "wstdefs.h" and "wsttype.h" to avoid declaration clash; also, 37 various constants defined to descriptive names. 38 10) change(88-08-30,Lee), approve(88-09-12,MCR7986), audit(88-09-19,Flegel), 39 install(88-10-12,MR12.2-1160): 40 Removed non-edit async mode line editing routines and references 41 to those routines. 42 END HISTORY COMMENTS */ 43 44 /* WSTEDIT - Local edit module for WSTERM */ 45 46 /* Perform local edit action for async mode */ 47 48 #include <stdio.h> 49 #include <dos.h> 50 #include "wstdefs.h" 51 #include "wstglob.h" 52 #include <wsmincap.h> 53 54 /*^L 55 ********************************************************************** 56 57 Routine: REPLAY 58 59 Function: 60 This routine redisplays the input line in non-edit async mode. 61 62 Parameters: 63 (input) coli - specifies the column movement increment 64 65 Returns: NONE 66 67 **********************************************************************/ 68 69 70 replay (coli) 71 int coli; /* Column movement increment */ 72 { 73 int cndx, /* Scan index for kb.klin */ 74 dcol, /* Local column position */ 75 dend, /* Final column position */ 76 dlin, /* Local line counter */ 77 dstrt, /* Local starting column value */ 78 space_left, /* Space left in current line */ 79 spill, /* Line wrap spill character count */ 80 tab_space; /* Tabbing space needed */ 81 82 register int ilin; /* Working index */ 83 84 /* Set up boundary conditions for the display */ 85 86 cndx = kb.endx; /* Starting character */ 87 dstrt = ds.ccol; /* Starting column */ 88 dcol = ds.ccol; 89 dend = dcol + coli; /* Ending column */ 90 dlin = ds.lndx; /* Starting line index */ 91 92 if (dend > screen.maxcol) /* Adjust ending column */ 93 dend %= screen.maxcol; 94 95 if (dstrt < strlen (ds.dlin)) /* Clear needed stuff */ 96 putscr (EL, strlen (EL)); 97 98 ds.dlin [dstrt] = NUL; 99 space_left = 0; 100 spill = 0; 101 102 /* Scan kb.klin from cndx to end */ 103 104 while (cndx < strlen (kb.klin)) { 105 106 /* Loop thru display line */ 107 108 while (dcol < screen.maxcol && cndx < strlen (kb.klin)) { 109 kb.pos [cndx] = dcol; 110 111 if (kb.klin [cndx] == HT) /* Tabbing */ { 112 tab_space = next_tab (dcol); 113 space_left = screen.maxcol - dcol; 114 if ((space_left < tab_space) & (space_left > 115 0)) 116 spill = tab_space - space_left; 117 catstr (ds.dlin, spaces, tab_space, 118 "ds.dlin", sizeof (ds.dlin)); 119 120 if (spill > 0) { 121 ds.spill [dlin] = ON; 122 if (wrap_line (dlin, dcol)) /* Non-zero if line wont fit */ 123 return (ON); 124 125 catstr (ds.dlin, spaces, 126 spill, "ds.dlin", sizeof (ds.dlin)); 127 dcol = ds.splct [dlin] = spill; 128 dstrt = 0; 129 } 130 else 131 dcol = tab_space; 132 133 } /* Control characters */ 134 135 else if (iscntrl (kb.klin [cndx])) { 136 sprintf (kb.dstr, "%c%03o", lnc, (int) kb.klin [cndx]); 137 space_left = screen.maxcol - dcol; 138 if ((space_left < 4) & (space_left > 0)) 139 spill = (4 - space_left) % 4; 140 141 if (space_left >= 4) /* It fits on the line */ { 142 catstr (ds.dlin, kb.dstr, 143 strlen (kb.dstr), "ds.dlin", sizeof (ds.dlin)); 144 145 dcol += 4; 146 } 147 148 else /* It doesn't fit */ { 149 if (space_left > 0) 150 catstr (ds.dlin, 151 kb.dstr, space_left, "ds.dlin", 152 sizeof (ds.dlin)); 153 154 putscr (ds.dlin [dstrt], 155 space_left); 156 157 ds.spill [dlin] = ON; 158 if (wrap_line (dlin, dcol)) /* Error if line wont fit */ 159 return (ON); 160 161 dlin++; 162 dstrt = 0; 163 164 strcpy (ds.dlin, kb.dstr [space_left]); 165 dcol = ds.splct [dlin] = spill; 166 } 167 } /* End of control chars */ 168 169 else { /* Printing graphics */ 170 putscr (&kb.klin [cndx], 1); 171 172 ds.dlin [dcol++] = kb.klin [cndx]; 173 ds.dlin [dcol] = NUL; 174 175 } 176 177 cndx++; 178 } /* End of ds.lin loop */ 179 180 if (cndx < strlen (kb.klin)) /* Next line if there's more */ { 181 putscr (&ds.dlin [dstrt], strlen (&ds.dlin [dstrt])); 182 183 if (wrap_line (dlin, dcol)) /* Error if line wont fit */ 184 return (ON); 185 dstrt = 0; 186 dcol = 0; 187 setmem (ds.dlin, sizeof (ds.dlin), NUL); 188 dlin++; 189 } 190 191 else { /* Copy current line to ds map */ 192 strcpy (&ds.map [dlin][0], ds.dlin); 193 194 } 195 } /* End of kb.klin loop */ 196 197 if ((ilin = dlin + 1) <= ds.lct) /* Erase leftovers */ { 198 for (; ilin <= ds.lct; ilin++) 199 ; 200 { 201 cursor_move (screen.curlin + ilin, 0); 202 putscr (EL, strlen (EL)); 203 } 204 205 ds.lct = dlin; 206 cursor_move (screen.curlin + dlin, dstrt); 207 } 208 209 putscr (EL, strlen (EL)); 210 211 if (dcol != dend) 212 cursor_move (screen.curlin, dend + (dlin == 0) * ds.pstrl); 213 ds.lndx = dlin; 214 ds.ccol = dend; 215 216 return (0); 217 } /* End of replay */ 218 219 220 /* End of WSTEDIT */