diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index bb09531..f18bac5 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -99,6 +99,7 @@ impl Repl { } fn input_loop(&mut self, input: String) { + use linefeed::ReadResult; if input == "" { return; } @@ -110,8 +111,26 @@ impl Repl { return; } - let output = self.input_handler(&input); - self.line_reader.add_history_unique(input.clone()); + let mut lines = input; + 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); }