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 name | Description |
---|---|
abort | Enables Event::Abort (C-\ ), which triggers a coredump |
suspend | Enables Event::Suspend (C-z ), which sends SIGTSTP (Unix only) |
Re-exports§
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
tocrate::Prompt