A solution for multiline entry
I don't really like this...
This commit is contained in:
parent
3256935946
commit
16fdf37ba3
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user