Start adding tab completion API

This commit is contained in:
greg 2018-05-06 21:29:27 -07:00
parent 012c50b7c3
commit 670833185b

View File

@ -123,19 +123,28 @@ fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInte
} }
} }
struct TabCompleteHandler { }
impl rustyline::completion::Completer for TabCompleteHandler {
fn complete(&self, line: &str, pos: usize) -> rustyline::Result<(usize, Vec<String>)> {
Ok((pos, vec!(format!("tab-completion-no-done"), format!("tab-completion-still-not-done"))))
}
}
struct Repl { struct Repl {
options: EvalOptions, options: EvalOptions,
languages: Vec<Box<ProgrammingLanguageInterface>>, languages: Vec<Box<ProgrammingLanguageInterface>>,
current_language_index: usize, current_language_index: usize,
interpreter_directive_sigil: char, interpreter_directive_sigil: char,
console: rustyline::Editor<()>, console: rustyline::Editor<TabCompleteHandler>,
} }
impl Repl { impl Repl {
fn new(languages: Vec<Box<ProgrammingLanguageInterface>>, initial_index: usize) -> Repl { fn new(languages: Vec<Box<ProgrammingLanguageInterface>>, initial_index: usize) -> Repl {
let i = if initial_index < languages.len() { initial_index } else { 0 }; let i = if initial_index < languages.len() { initial_index } else { 0 };
let console = Editor::<()>::new(); let mut console = Editor::<TabCompleteHandler>::new();
console.set_completer(Some(TabCompleteHandler {}));
Repl { Repl {
options: Repl::get_options(), options: Repl::get_options(),