From afd2b018f46d96f2f202734ba38f615b1db24bec Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 7 Dec 2017 20:08:31 -0800 Subject: [PATCH] Language name in prompt --- schala-lib/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/schala-lib/src/lib.rs b/schala-lib/src/lib.rs index 2ec384c..dd2dcfd 100644 --- a/schala-lib/src/lib.rs +++ b/schala-lib/src/lib.rs @@ -123,8 +123,7 @@ struct Repl { impl Repl { fn new(languages: Vec>, initial_index: usize) -> Repl { - let mut reader: linefeed::Reader<_> = linefeed::Reader::new("Metainterpreter").unwrap(); - reader.set_prompt(">> "); + let reader: linefeed::Reader<_> = linefeed::Reader::new("Metainterpreter").unwrap(); let i = if initial_index < languages.len() { initial_index } else { 0 }; Repl { @@ -165,8 +164,12 @@ impl Repl { fn run(&mut self) { use linefeed::ReadResult::*; println!("MetaInterpreter v 0.05"); - println!("Using language: {}", self.languages[self.current_language_index].get_language_name()); + loop { + let language_name = self.languages[self.current_language_index].get_language_name(); + let prompt_str = format!("{} >> ", language_name); + self.reader.set_prompt(&prompt_str); + match self.reader.read_line() { Err(e) => { println!("Terminal read error: {}", e);