1Dh ED$EPOS invoke line editor
Input
A register -  Bit 0 clear for single-line editing.
Bit 0 set for multi-line editing.
Bit 1 set for up/down to exit editor in single-line editing. LZ only.
Bit 7 clear for exit on MODE key.
Bit 7 set for no exit on MODE key.
B register - Maximum input length.
UTW_S0 -  Position within line to start editing.
Output B register - Terminating key.
Description

This is the standard input line-editor. The OPL EDIT command uses this service.

A maximum of B characters may be edited. There are two modes of operation, multi-line and single-line editing. With multi-line editing the down arrow key starts a new line of text, while with single-line editing the up and down arrow keys send the cursor to the beginning and end of the editable text respectively. A new line is represented in the editor buffer by a TAB character (ASCII value 9). Bit 0 of register A is cleared for single-line and set for multi-line editing. The MODE key causes the editor to exit only if bit 7 of register A is clear.

In single-line mode, TABs in the default string will still be treated as new-line markers but will not be handled predictably.

The characters displayed prior to calling the editor are treated as a prompt. Any characters in the editor buffer RTT_BF are used as the default string for editing. Since a TAB in the editor buffer represents a new line, including any in the default string in single-line mode produces unpredictable results. The default string is displayed directly after the prompt. The cursor is initially positioned UTW_S0 characters beyond the end of the prompt in the first line (UTW_S0 is 0 for the first editable character). If UTW_S0 is greater than the length of the editable line, the cursor goes to the end of the line. After editing, the input is returned in the editor buffer. The terminating character is returned in the B register.

The editor is exited when the EXE key is pressed, or when the ON/CLEAR key is pressed with an empty editor buffer. When the editor buffer is not not empty, the ON/CLEAR key clears it and does not cause an exit. As explained above, the programmer can also choose whether to allow exit from the editor when the user presses the MODE key.

If the coursor is to be positionned on the first editable character, ED$EDIT may also be used.

Example Displays the prompt "Code: " and inputs the code number in single-line mode, preventing an exit on pressing MODE. The default code number is "0235". The cursor is positioned at the end of the default string (as one extra character is expected to be input by the user).
; Display the prompt
        OS      UT$DISP         ; Display the prompt
        DB      #12             ; Clear screen
        ASCIZ   "Code: "
; Set up editor buffer RTT_BF of length RTB_BL with default string
        LDD     #3032h          ; A='0' and B='2'
        STD     RTT_BF
        LDD     #3335h          ; A='3' and B='5'
        STD     RTT_BF+2
        LDAB    #4              ; Length of default
        STAB    RTB_BL
;
        INCB                    ; Maximum input of 5 characters
        CLRA
        STD     UTW_S0:         ; Cursor at end of line initially
        LDAA    #80             ; Single-line edit, with no exit on MODE
        OS      ED$EPOS
Errors - none -