[−][src]Module termwiz::lineedit
The LineEditor
struct provides line editing facilities similar
to those in the unix shell.
use termwiz::lineedit::{line_editor_terminal, NopLineEditorHost, LineEditor}; fn main() -> anyhow::Result<()> { let mut terminal = line_editor_terminal()?; let mut editor = LineEditor::new(&mut terminal); let mut host = NopLineEditorHost::default(); let line = editor.read_line(&mut host)?; println!("read line: {:?}", line); Ok(()) }
Key Bindings
The following key bindings are supported:
Keystroke | Action |
---|---|
Ctrl-A, Home | Move cursor to the beginning of the line |
Ctrl-E, End | Move cursor to the end of the line |
Ctrl-B, Left | Move cursor one grapheme to the left |
Ctrl-C | Cancel the line editor |
Ctrl-D | Cancel the line editor with an End-of-File result |
Ctrl-F, Right | Move cursor one grapheme to the right |
Ctrl-H, Backspace | Delete the grapheme to the left of the cursor |
Ctrl-J, Ctrl-M, Enter | Finish line editing and accept the current line |
Ctrl-K | Delete from cursor to end of line |
Ctrl-L | Move the cursor to the top left, clear screen and repaint |
Ctrl-R | Incremental history search mode |
Ctrl-W | Delete word leading up to cursor |
Alt-b, Alt-Left | Move the cursor backwards one word |
Alt-f, Alt-Right | Move the cursor forwards one word |
Structs
BasicHistory | A simple history implementation that holds entries in memory. |
CompletionCandidate | A candidate for tab completion.
If the line and cursor look like "why he |
LineEditor | The |
NopLineEditorHost | A concrete implementation of |
SearchResult |
Enums
Action | |
Movement | |
OutputElement | The |
SearchDirection | Encodes the direction the search should take, relative to the current HistoryIndex. |
SearchStyle |
Traits
History | Defines the history interface for the line editor. |
LineEditorHost | The |
Functions
line_editor_terminal | Create a |
Type Definitions
HistoryIndex | Represents a position within the history. Smaller numbers are assumed to be before larger numbers, and the indices are assumed to be contiguous. |
RepeatCount |