term.input

index · term

Overview

Full-featured line input with multi-line editing, history, completion, and Kitty keyboard protocol support.

Submodules

ModuleDescription
term.input.completionCompletion engine with pluggable sources and candidate management.
term.input.historyCommand history with persistent storage, navigation, and duplicate filtering.
term.input.promptInput prompt display with optional configurable blocks.
term.input.rendererCompletion renderer interface and built-in inline ghost renderer.

Functions

NameSignature
input:eventinput:event() -> action, combo
input:newlineinput:newline() -> redraw
input:clear_allinput:clear_all()
input:clear_from_promptinput:clear_from_prompt()
input:full_redrawinput:full_redraw() -> redraw
input:move_rightinput:move_right() -> redraw
input:move_leftinput:move_left() -> redraw
input:move_to_previous_spaceinput:move_to_previous_space() -> redraw
input:move_to_next_spaceinput:move_to_next_space() -> redraw
input:insertinput:insert(char) -> redraw
input:backspaceinput:backspace() -> redraw
input:scroll_completioninput:scroll_completion(direction) -> redraw
input:promote_completion_fullinput:promote_completion_full() -> redraw
input:promote_completioninput:promote_completion() -> redraw
input:search_completioninput:search_completion() -> redraw
input:external_editorinput:external_editor()
input:insert_last_arginput:insert_last_arg() -> redraw
input:copy_to_clipboardinput:copy_to_clipboard() -> success
input:displayinput:display(force)
input:buffer_emptyinput:buffer_empty() -> empty
input:prompt_leninput:prompt_len() -> len, prompt
input:max_widthinput:max_width() -> width
newnew(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: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

new(config) -> input

Create a new input instance

The config table may contain: