9 unstable releases (4 breaking)
0.6.1 | Nov 14, 2024 |
---|---|
0.6.0 | Jun 10, 2024 |
0.5.3 | Mar 9, 2024 |
0.4.0 | Oct 10, 2023 |
0.2.0 | Oct 6, 2023 |
#389 in Command-line interface
152 downloads per month
Used in faye
29KB
491 lines
Pomprt
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
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.
Crate features
Feature name | Description |
---|---|
abort |
Enables Event::Abort (C-\ ), which triggers a coredump |
suspend |
Enables Event::Suspend (C-z ), which sends SIGTSTP (Unix only) |
Dependencies
~215KB