7 unstable releases (3 breaking)

0.5.3 Mar 9, 2024
0.5.2 Mar 9, 2024
0.4.0 Oct 10, 2023
0.3.0 Oct 7, 2023
0.2.0 Oct 6, 2023

#409 in Command-line interface

35 downloads per month
Used in faye

Apache-2.0

26KB
474 lines

Pomprt

crates.io docs.rs

A tiny and extensible readline implementation built from scratch

Pomprt is a small yet feature-rich multi-line editor that supports syntax highlighting, hints and completion.

  • UTF-8 support
  • Line history
  • Familiar keybinds: most of readline implemented
  • Highly compatible: only simple VT100 sequences are used, which should be supported by most terminals
  • Small footprint: ~580 sloc, only depending on libc/winapi
for input in pomprt::new(">> ") {
    println!("{input}");
}

License

Apache-2.0


lib.rs:

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][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.

Dependencies

~215KB