Full-featured line input with multi-line editing, history, completion, and Kitty keyboard protocol support.
| Module | Description |
|---|---|
| term.input.completion | Completion engine with pluggable sources and candidate management. |
| term.input.history | Command history with persistent storage, navigation, and duplicate filtering. |
| term.input.prompt | Input prompt display with optional configurable blocks. |
| term.input.renderer | Completion renderer interface and built-in inline ghost renderer. |
| Name | Signature |
|---|---|
| input:event | input:event() -> action, combo |
| input:run | input:run(exit_events) -> event, combo |
| input:newline | input:newline() -> redraw |
| input:clear_all | input:clear_all() |
| input:clear_from_prompt | input:clear_from_prompt() |
| input:full_redraw | input:full_redraw() -> redraw |
| input:move_right | input:move_right() -> redraw |
| input:move_left | input:move_left() -> redraw |
| input:move_to_previous_space | input:move_to_previous_space() -> redraw |
| input:move_to_next_space | input:move_to_next_space() -> redraw |
| input:insert | input:insert(char) -> redraw |
| input:backspace | input:backspace() -> redraw |
| input:scroll_completion | input:scroll_completion(direction) -> redraw |
| input:promote_completion_full | input:promote_completion_full() -> redraw |
| input:promote_completion | input:promote_completion() -> redraw |
| input:search_completion | input:search_completion() -> redraw |
| input:external_editor | input:external_editor() |
| input:insert_last_arg | input:insert_last_arg() -> redraw |
| input:copy_to_clipboard | input:copy_to_clipboard() -> success |
| input:display | input:display(force) |
| input:buffer_empty | input:buffer_empty() -> empty |
| input:prompt_len | input:prompt_len() -> len, prompt |
| input:max_width | input:max_width() -> width |
| input:relocate | input:relocate() |
| new | new(config) -> input |
input:event() ->
action,combo
Process a single keyboard event and return the action taken
Reads one key event via KKBP, handles character insertion, cursor
movement, history navigation, and completion. Returns true when a
redraw is needed, an event string like "execute" or "exit" for
terminal events, or nil when no action was taken.
input:run(
exit_events) ->event,combo
Run the input event loop until an exit event occurs
Loops calling event() and display(), handling terminal resizes.
The exit_events table maps event names to true (defaults to
{execute = true, exit = true}). Returns the triggering event name.
input:newline() ->
redraw
Insert a new line at the cursor position
input:clear_all()
Clear the entire input area and reset cursor to start
input:clear_from_prompt()
Clear the input area from the end of the prompt onward
input:full_redraw() ->
redraw
Perform a complete redraw of the prompt and input content
input:move_right() ->
redraw
Move cursor one position to the right or to the next line
input:move_left() ->
redraw
Move cursor one position to the left or to the previous line
input:move_to_previous_space() ->
redraw
Move cursor back to the previous space character
input:move_to_next_space() ->
redraw
Move cursor forward to the next space character
input:insert(
char) ->redraw
Insert a character at the current cursor position
input:backspace() ->
redraw
Delete the character before the cursor
input:scroll_completion(
direction) ->redraw
Scroll through completion candidates in the given direction
input:promote_completion_full() ->
redraw
Accept the currently selected completion candidate in full
input:promote_completion() ->
redraw
Promote completion to common prefix or accept if single candidate
Two-phase promotion logic. With a single candidate, or when the
provider signals should_promote_full(), delegates to
promote_completion_full(). With multiple candidates, appends the
longest common prefix to the input and re-runs the completion search.
input:search_completion() ->
redraw
Trigger a completion search based on current input content
When cfg.eol_only is true (the default), only searches when the
cursor is at end-of-line and the current line does not end with
whitespace. When false, searches at any cursor position and passes
the cursor position to the provider. Delegates to
completion:search() with the current line and history object.
input:external_editor()
Open the current input content in an external editor
input:insert_last_arg() ->
redraw
Insert the last argument from the previous history command
input:copy_to_clipboard() ->
success
Copy current input content to clipboard using OSC52
input:display(
force)
Decide between full and partial redraw and render accordingly
input:buffer_empty() ->
empty
Check whether the input buffer contains no text
input:prompt_len() ->
len,prompt
Return the display length and rendered prompt string
input:max_width() ->
width
Return the maximum editable width in columns
input:relocate()
Find the input's row again after a resize, and erase from it down
For an input in the scrolling screen, the relocate config key. Call it
after update_window_size and before the redraw. A terminal that
rewraps its lines on a resize, as foot and alacritty do, moves the
input's line and carries the cursor with it. The method asks the terminal where the
cursor went (CPR), then counts back the rows the rewrap put above it.
It sets cfg.l to the line's first row and erases from there to the
screen's end. One prompt then stands, and the output above stays.
The cursor's column at the last draw says how many rows the rewrap put
above it. A terminal that cuts its lines instead, as xterm does, clamps
the cursor to the last column. When the old column is a multiple of the
new width, both answer the same column, and the method takes the
rewrap. With no answer to the query, cfg.l is clamped to the screen's
height and nothing is erased.
Kitty 0.41 does not carry the cursor on a full screen: the rewrap scrolls the line up and leaves the cursor on the bottom row. The method then finds the line's last row, and the rows above it keep the old prompt.
new(
config) ->input
Create a new input instance
The config table may contain:
l, c — starting line and column positionwidth — maximum input widthrss — raw style sheet to merge with defaultscompletion — completion object instancehistory — history object instanceprompt — prompt object instancerenderer — completion renderer (default: inline ghost)eol_only — only complete at end-of-line (default: true)relocate — the input sits in the scrolling screen, not on a fixed
row: run calls relocate on a resize (default: false). An input
inside a frame must leave it off, since relocate erases the rows
below it.