A Rust library offering readline-like functionality.
This was forked from https://gitlab.redox-os.org/redox-os/liner. It has some changes to history (non-duplicating and context sensitive by default) and it supports Windows (10 with an ansi escape capable console).
- Autosuggestions
- Emacs and Vi keybindings
- Multi-line editing
- History
- Basic and filename completions
- Reverse search
- Remappable keybindings
In Cargo.toml
:
[dependencies]
sl_liner = "https://github.com/sl-sh-dev/sl-liner"
...
In src/main.rs
:
extern crate liner;
use liner::{Context, Completer};
struct EmptyCompleter;
impl<W: std::io::Write> Completer<W> for EmptyCompleter {
fn completions(&mut self, _start: &str) -> Vec<String> {
Vec::new()
}
}
fn main() {
let mut con = Context::new();
loop {
let res = con.read_line("[prompt]$ ", &mut EmptyCompleter).unwrap();
if res.is_empty() {
break;
}
con.history.push(res.into());
}
}
See src/main.rs for a more sophisticated example.
MIT licensed. See the LICENSE
file.