A solution for multiline entry

I don't really like this...
This commit is contained in:
greg 2019-02-02 01:00:09 -08:00
parent 3256935946
commit 16fdf37ba3

View File

@ -99,6 +99,7 @@ impl Repl {
} }
fn input_loop(&mut self, input: String) { fn input_loop(&mut self, input: String) {
use linefeed::ReadResult;
if input == "" { if input == "" {
return; return;
} }
@ -110,8 +111,26 @@ impl Repl {
return; return;
} }
let output = self.input_handler(&input); let mut lines = input;
self.line_reader.add_history_unique(input.clone()); self.line_reader.set_prompt("> ").unwrap();
loop {
match self.line_reader.read_line() {
Err(e) => {
println!("Terminal read error: {}", e);
return;
},
Ok(ReadResult::Eof) => break,
Ok(ReadResult::Signal(_)) => break,
Ok(ReadResult::Input(input)) => {
lines.push('\n'); //TODO not sure if this is needed?
lines.push_str(&input);
}
}
}
self.line_reader.add_history_unique(lines.clone());
let output = self.input_handler(&lines);
println!("=> {}", output); println!("=> {}", output);
} }