[][src]Module termwiz::lineedit

The LineEditor struct provides line editing facilities similar to those in the unix shell.

use failure::Fallible;
use termwiz::lineedit::{line_editor, NopLineEditorHost};

fn main() -> Fallible<()> {
    let mut editor = line_editor()?;
    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-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" and if "hello" is a valid completion of "he" in that context, then the corresponding CompletionCandidate would have its range set to [4..6] (the "he" slice range) and its text set to "hello".

LineEditor

The LineEditor struct provides line editing facilities similar to those in the unix shell.

NopLineEditorHost

A concrete implementation of LineEditorHost that uses the default behaviors.

Enums

Action
Movement
OutputElement

The OutputElement type allows returning graphic attribute changes as well as textual output.

Traits

History

Defines the history interface for the line editor.

LineEditorHost

The LineEditorHost trait allows an embedding application to influence how the line editor functions. A concrete implementation of the host with neutral defaults is provided as NopLineEditorHost.

Functions

line_editor

Create a Terminal with the recommended settings, and use that to create a LineEditor instance.

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