This trap edits a line of characters (CON channel only).
|Call Parameters||Return Parameters
|D1.L||line: position/length||D1.L||line: position/length.
|D2.W||Length of buffer ||D2.L||Preserved.
|A0.L||Channel ID ||A0.L||Preserved.
|A1.L||Pointer to end of line||A1.L||Updated.
|ERR_NO||Channel not open.
All registers not shown above are not used on entry and are preserved on exit.
This trap allows a line of characters situated in a buffer to be edited.
On entry D1.W must contain the length of the line to be edited (L).
Before the trap is called, some or all of the characters from the start of the line can be printed. The number printed N, say, (from 0 to the line length) must be set in the top word of D1.
IO_EDLIN/IOB_ELIN prints the remaining L - N characters of the line before editing starts. The cursor on the line to be edited is positioned on the first character so printed, or just after the end of the line if no characters are printed.
A1 is the address, in the buffer, of the character just after end of the line to be edited. This value, plus the line length in D1.W (L), defines exactly where the line to be edited is.
When the call is made there must be no terminating character, but the terminating character will be included in the character count on return.
ENTER, UP and DOWN arrows are acceptable terminators. In SMSQ/E the terminator ESC is also allowed.
On return D1.W contains the length of the line which includes the terminating character.
Note that this trap operates by keeping the position of the current character in the line in the msw of D1. This position is mirrored on the screen. Thus, if you move the cursor to the start of the line to be edited, the value of the msw of D1 becomes zero. For example, if the line length is 8 and the msw of D1 is set as 7, the last character of the line in the buffer will be printed to the screen at the current cursor position. The trap will assume that there are 7 previous positions on the screen (for the first part of the line). It is up to the user to see that this is so.
The example below shows the use of this trap call to obtain a filename.
The filename is held in PROMPT(A6) as a QDOS string, length followed by characters.
The code below shows how to get IO_EDLIN to print the current value of the filename and then allow it to be edited.
This code allows the terminator ESC to be used. If the code runs under SMSQ/E this terminator is recognised and is used to abandon editing. Of course if the program is not running under SMSQ/E the editing will not be terminated by ESC so this facility cannot be used.
It is assumed that A0 contains the window's ID.
MOVEQ #SD_NL,D0 ; $12
MOVEQ #-1,D3 ; Timeout
TRAP #3 ; New line
LEA ASK,A1 ; Request string
MOVEA.W UT_MTEXT,A2 ; Print the request
MOVEQ #0,D1 ; Get EDLIN to print all the line
MOVE.W PROMPT(A6),D1 ; Length of current filename
MOVE.W #40,D2 ; Buffer length
LEA PROMPT+2(A6),A1 ; Point to . .
ADDA.W D1,A1 ; . . end of name
MOVEQ #IO_EDLIN,D0 ; $04
TRAP #3 ; Edit the name
CMPI.B #$1B,-1(A1) ; ESC? . .
BEQ REP4 ; . . yes - abandon file
SUBQ.W #1,D1 ; Length of filename
MOVE.W D1,PROMPT(A6) ; . . set this in the string
ASK DC.W 10
DC.B "Filename: "