Input line editing

In “line-editing mode” most keystrokes add to or modify an editing area in the DomTerm window, but are not sent to the application until you type Enter. This enables editing of input lines similar to Emacs shell mode or GNU readline.

The input area

images/dt-lineedit1

The area affected by insertions and edits during line-edit mode is called the input area, and it is by default high-lighted using a dashed brown border. Normally, the input area is a single line (or the part of a line following a prompt) but it can be multiple lines.

If output arrives while the input area is active the output buffer is updated as if the input area is not there: The input area is removed, the output with escape sequence is processed, and then the input area is re-inserted at the position of the output caret.

A mouse click on a match move the base position to the start of the match, and selects the match. A click not on a match sets the base position to the clicked location, and selects the first following match. (Id the search direction is backwards ....)

Enter (accept-line)

Send the contents of the input area to the application, along with a final newline. Also, if the input area is non-empty, add it to the history list.

If you want to send the contents of the input area without a final newline, you can switch the input mode to character mode (using either the menu or one-or-more Ctrl+Shift+L commands). This removes the text of the input area, but echo from the application will normally replace it. You can then optionally switch back to line mode.

Alt+Enter (insert-newline)

Insert a literal newline. Splits the current line at the current position, creating two new lines out of one old line, with the caret after the new break.

Using the mouse

A mouse click in the input area moves the caret, as you would expect. For convenience, clicking outside the input area but on an input line also works, moving the mouse to the beginning or end of that line. Clicking on a line that does not contain part of the input area has no effect (except to make the window active).

Swiping the mouse (mouse-down followed by moving the muse followed by mouse-up) selects the region of text swiped, as expected. However, unlike many text editors, the input caret is not moved: The selection and the input caret are independent. A reason for difference is that the input caret is restricted to the input area, while the selection can be any part of the buffer.

Note that the end of the swept area (correspondiong to mouse-up) is indicated with a special marker (by default a brown I-beam) called the focus caret. More on that later.

Clicking while the shift key is pressed extends the selection as if you swept the mouse from the orginal end-point to the new click position.

Keyboard editing commands

The following special keys are supported. The word “caret” refers to the text cursor (as opposed to the mouse cursor). The names in parentheses are the corresponding action names that can be used if changing the key-bindings.

Repeat count

Many of the following keyboard commands can be modified by previously-typed repeat count.

Alt+digit
Alt+Minus
Alt+.

Set or extend a repeat count. For example Alt+1 Alt+2 Left moves 12 characters left, while Alt+Minus Alt+2 Ctrl+Left moves 2 words right (because of the minus).

You can also repeat self-inserting characters: Alt+2 Alt+0 * inserts 20 asterisks.

Commands that are affected by a repeat count contain count in the description. By default the count is one, and it is reset after each command.

Moving the editing position

Left (backward-char)
Right (forward-char)

Move caret count characters left or right.

Ctrl+Left (except macOS) (backward-word)
Alt+Left (only macOS)
Ctrl+Right (except macOS) (forward-word)
Alt+Right (only macOS)

Move caret count words left or right.

Home (beginning-of-line)
End (end-of-line)

Move caret to start/end of line.

Alt+Home (beginning-of-input)
Alt+End (end-of-input)

Move caret to start/end of the input area. (Different from start/end of line if there are multiple lines in the input area.)

Deleting text

You can also delete using the selection; see later.

Backspace (backward-delete-char)
Delete (forward-delete-char)

Delete count characters to the left or right of the caret.

Ctrl+Backspace (backward-delete-word)
Ctrl+Delete (forward-delete-word)

Delete count words to the left or right of the caret.

Special characters

The keystrokes Ctrl+C, Ctrl+Z, Ctrl+Z are handled specially, because of traditional Unix shell functionality. They are passed to the process - but only under certain conditions, because of other compatibility issues.

Ctrl+C (copy-text-or-interrupt) (except macOS)
Ctrl+C (client-action) (only macOS)

If there is a non-empty selection and this is not macOS, copy the selection to the clipboard. Otherwise, send Ctrl+C literally to the process (which traditionally interrupts it).

Ctrl+D (delete-char-or-eof)

Send Ctrl+D literally to the process (which on Unix system traditionally treats it as end-of-file), but only if the input area is empty. Otherwise (for Emacs/readline compatibility), delete the character following the caret.

Ctrl+Z (client-action)

Send a literal Ctrl+Z (traditionally used in Unix to suspend the current job) to the process (following any existing text in the input area).

Scrolling

You can use the general scrolling shortcuts available in all modes, but in line-edit mode you don’t need to press Shift, and you can use a repeat count.

Ctrl+PageUp (scroll-page-up)
Ctrl+PageDown (scroll-page-down)

Scroll count pages up or down, respectively.

Ctrl+Up (scroll-line-up)
Ctrl+Down (scroll-line-down)

Scroll count lines up or down, respectively.

Ctrl+Home (scroll-top)
Ctrl+End (scroll-bottom)

Scroll to top or bottom, respectively.

Emacs-style keybindings

Ctrl+A (beginning-of-line)
Ctrl+B (backward-char)
Ctrl+E (end-of-line)
Ctrl+F (forward-char)
Ctrl+N (down-line-or-history)
Ctrl+P (up-line-or-history)
Alt+B (backward-word)
Alt+F (forward-word)

Emacs-style alternate keybindings.

Ctrl+D (delete-char-or-eof)

If the input area is empty, send the character literally (usually interpreted as end-of-file on Unix-like system). Otherwise, delete the character following.

Not implemented yet, but planned: Emacs-style key-bindings should be controlled by a separate option; some bindings are missing, such as Ctrl+T, and the ones prefixed by Esc. Command-completion, using some protocol to be defined. A plug-in replacement for GNU readline using LD_PRELOAD would be nice. (The idea is for an enhanced readline to detect it is running under DomTerm, in which case it would delegate most editing to DomTerm. This would allow using bash completion logic.) Auto-completion (completion as you type).

History

The “history” is the list of previously entered input lines.

Up (up-line-or-history)
Down (down-line-or-history)

Move up/down in history. If the current command is multi-line, first moves within the current command before moving to commands in the history.

Ctrl+R (backward-search-history)

Enter history-search-mode.

Searching in history

The Ctrl+R key enters history-search mode. As you type characters, a search string is created, which is matched against the items in the history list.

printable-char

Append (or insert) printable-char to the search string, which may update the selected history item.

Left
Right

Move caret within search string.

Backspace
Delete

Delete character from search string. This may change the selected history item.

Ctrl+R
Ctrl+S

Search for previous/next history item matching the current search string. If the search string is empty, use previous search string. For example Ctrl+R Ctrl+R repeats previous search.

Enter

Exit search mode, accept current item, and send it to the application.

Up
Down

Exit search mode, and move to previous/next history item.

Tab

Exit search mode, accept current item, but continue editing it.

Password fields

A “password field” is an input area where the typed characters are hidden or obscured. DomTerm will display each character as a black circle instead of the actual character. (The replacement character is the password-hide-char setting.) The most recently typed character is displayed briefly (depending on the password-show-char-timeout setting) before it too is replaced by a black circle. On Enter, all circles are removed.

Using these circles makes it easier see how many characters you’ve typed, and to move around using the mouse or cursor keys.

A password field is automatically created when we’re in line-editing mode and echoing is turned off by the program reading the input.

Changing keybindings

You can override the keymap (map from keystrokes to action) used for input line editing. The keymap.line-edit is a list (separated by commas or newlines), where each item is a quoted keystroke string, followed by a colon, followed by an action name. An action name is a string, but quotes are optional. The following example disables the binding for Ctrl+A and adds a binding that maps Ctrl+H to the beginning-of-line action.

keymap.line-edit =
 | "Ctrl+A": ignore-action
 | 'Ctrl+H': beginning-of-line