Crate pomprt

Source
Expand description

A tiny and extensible readline implementation built from scratch

Pomprt is a multi-line editor with support for things like syntax highlighting, hints and completion.

§Usage

For starters, you can create a prompt with prompt::new, and read input via Prompt::read, or by iterating through it:

for input in pomprt::new(">> ") {
    println!("{input}");
}

§Custom editors

For more complex applications, extra features can be added by implementing an Editor:

impl pomprt::Editor for MyEditor {
    // Make the prompt cyan
    fn highlight_prompt(&self, prompt: &str, _multiline: bool) -> String {
        format!("\x1b[36m{prompt}")
    }
}

let mut cmd = pomprt::with(MyEditor, "><> ");
// ...

That’s it! More complete examples can be found in the examples folder.

§Crate features

Feature nameDescription
abortEnables Event::Abort (C-\), which triggers a coredump
suspendEnables Event::Suspend (C-z), which sends SIGTSTP (Unix only)

Re-exports§

pub use Error::Eof;
pub use Error::Interrupt;

Modules§

ansi
Helper module for reading and parsing ANSI sequences

Structs§

Basic
A basic editor with no extra features.
Completion
Completion result returned by Editor::complete
Prompt
The pomprt prompt

Enums§

Error
Error returned by Prompt::read
Event
Edit event emitted by Editor::next_event to crate::Prompt

Traits§

Editor
Custom editor behaviour for a Prompt

Functions§

new
Construct a new Prompt with the default editor
with
Construct a new Prompt with a custom editor
with_multiline
Construct a new Prompt with a custom editor and multiline prompt