1 procedure $STD_CON_STRING_INPUT
,NEAR ;System call 10
2 ASSUME
DS:NOTHING
,ES:NOTHING
5 ; DS:DX Point to an input buffer
7 ; Fill buffer from console input until CR
17 retz
;Buffer is 0 length!!?
18 MOV BL,AH ;Init template counter
19 MOV BH,CH ;Init template counter
21 JBE NOEDIT
;If length of buffer inconsistent with contents
22 CMP BYTE PTR [BX+SI],c_CR
23 JZ EDITON
;If CR correctly placed EDIT is OK
25 MOV BL,CH ;Reset buffer
28 DEC DX ;DL is # of bytes we can put in the buffer
31 MOV [STARTPOS
],AL ;Remember position in raw buffer
33 MOV DI,OFFSET DOSGROUP
:INBUF
;Build the new line here
34 MOV [INSMODE
],CH ;Insert mode off
35 MOV BH,CH ;No chars from template yet
36 MOV DH,CH ;No chars to new line yet
37 invoke $STD_CON_INPUT_NO_ECHO
;Get first char
39 JNZ GOTCH
;Filter out LF so < works
41 invoke $STD_CON_INPUT_NO_ECHO
43 CMP AL,"F"-"@" ;Ignore ^F
62 invoke BUFOUT
;Print control chars nicely
63 CMP BYTE PTR [INSMODE
],0
64 JNZ GETCH
;In insert mode, get more chars
66 JAE GETCH
;We are out of chars in template
67 INC SI ;Skip to next char in template
71 BACKSPJ: JMP SHORT BACKSP
79 transfer OEMFunctionKey
82 STOSB ;Put the CR in the buffer
84 POP DI ;Get start of buffer
85 MOV [DI-1],DH ;Tell user how many bytes
86 INC DH ;DH is length including CR
92 MOV SI,OFFSET DOSGROUP
:INBUF
94 REP MOVSB ;Copy final line to user buffer
104 ;Output a CRLF which is not terminate buffer
109 ;Zap the line without zapping the template
112 invoke OUT ;Print the CANCEL indicator
113 POP SI ;Remember start of edit buffer
115 invoke CRLF ;Go to next line on screen
118 JMP NEWLIN ;Start over again
123 JZ OLDBAK ;No chars in line, do nothing to line
124 CALL BACKUP ;Do the backup
125 MOV AL,ES:[DI] ;Get the deleted char
127 JAE OLDBAK ;Was a normal char
129 JZ BAKTAB ;Was a tab, fix up users display
130 CALL BACKMES ;Was a control char, zap the '^'
132 CMP BYTE PTR [INSMODE],0
133 JNZ GETCH1 ;In insert mode, get more chars
135 JZ GETCH1 ;Not advanced in template, stay where we are
136 DEC BH ;Go back in template
143 DEC DI ;Back up one char
145 MOV CL,DH ;Number of chars currently in line
149 JCXZ FIGTAB ;At start, do nothing
153 CMP BYTE PTR ES:[DI+1],9
154 JZ HAVTAB ;Found a tab
155 DEC BL ;Back one char if non tab control char
163 AND CL,7 ;CX has correct number to erase
167 JZ OLDBAK ;Nothing to erase
170 LOOP TABBAK ;Erase correct number of chars
174 DEC DH ;Back up in line
177 MOV AL,c_BS ;Backspace
181 MOV AL,c_BS ;Backspace
184 ;User really wants an ESC character in his line
189 ;Copy the rest of the template
191 MOV CL,BL ;Total size of template
192 SUB CL,BH ;Minus position in template, is number to move
196 invoke FINDOLD ;Find the char
197 JMP SHORT COPYEACH ;Copy up to it
199 ;Copy one char from template to line
202 ;Copy CX chars from template to line
204 MOV BYTE PTR [INSMODE],0 ;All copies turn off insert mode
206 JZ GETCH2 ;At end of line, can't do anything
208 JZ GETCH2 ;At end of template, can't do anything
212 INC BH ;Ahead in template
213 INC DH ;Ahead in line
218 ;Skip one char in template
221 JZ GETCH2 ;At end of template
222 INC BH ;Ahead in template
227 invoke FINDOLD ;Find out how far to go
232 ;Get the next user char, and look ahead in template for a match
233 ;CX indicates how many chars to skip to get there on output
234 ;NOTE: WARNING: If the operation cannot be done, the return
235 ; address is popped off and a jump to GETCH is taken.
236 ; Make sure nothing extra on stack when this routine
237 ; is called!!! (no PUSHes before calling it).
239 invoke $STD_CON_INPUT_NO_ECHO
240 CMP AL,[ESCCHAR] ; did he type a function key?
241 JNZ FindSetup ; no, set up for scan
242 invoke $STD_CON_INPUT_NO_ECHO ; eat next char
243 JMP NotFnd ; go try again
246 SUB CL,BH ;CX is number of chars to end of template
247 JZ NOTFND ;At end of template
248 DEC CX ;Cannot point past end, limit search
249 JZ NOTFND ;If only one char in template, forget it
254 MOV DI,SI ;Template to ES:DI
259 JNZ NOTFND ;Didn't find the char
260 NOT CL ;Turn how far to go into how far we went
261 ADD CL,BL ;Add size of template
262 SUB CL,BH ;Subtract current pos, result distance to skip
266 POP BP ;Chuck return address
270 MOV AL,"@
" ;Output re-edit character
276 invoke COPYNEW ;Copy current line into template
280 MOV BL,DH ;Size of line is new size template
281 JMP PUTNEW ;Start over again
285 NOT BYTE PTR [INSMODE]
288 ;Put a real live ^Z in the buffer (embedded)
292 $STD_CON_STRING_INPUT ENDP