Expand description
This is a library that interfaces with the linenoise library. Linenoise is a library implemented by Antirez, the Redis creator as a replacement for readline.
This library is just a binding to this library.
extern crate linenoise;
fn callback(input: &str) -> Vec<String> {
let mut ret : Vec<&str>;
if input.starts_with("s") {
ret = vec!["suggestion", "suggestion2", "suggestion-three"];
} else {
ret = vec!["wot"];
}
return ret.iter().map(|s| s.to_string()).collect();
}
fn main() {
linenoise::set_callback(callback);
loop {
let val = linenoise::input("hello > ");
match val {
None => { break }
Some(input) => {
println!("> {}", input);
linenoise::history_add(input.as_slice());
if input.as_slice() == "clear" {
linenoise::clear_screen();
}
}
}
}
}
Modules§
Functions§
- add_
completion - Add a completion to the current list of completions.
- clear_
screen - Clears the screen
- history_
add - Add this string to the history
- history_
line - Get a line from the history by (zero-based) index
- history_
load - Load the history on disk
- history_
save - Save the history on disk
- history_
set_ max_ len - Set max length history
- input
- Shows the prompt with your prompt as prefix Retuns the typed string or None is nothing or EOF
- print_
key_ codes - set_
callback - Sets the callback when tab is pressed
- set_
multiline