Develop wasm support further.

This commit is contained in:
Oleksandr Kozachuk
2023-01-06 16:16:04 +01:00
parent 3416ea96ae
commit e9dba54750
5 changed files with 49 additions and 16 deletions
+14 -11
View File
@@ -47,18 +47,21 @@ impl LKRead {
()
}
}
self.cmd = match self.rl.readline(&*self.prompt) {
Ok(str) => str,
Err(LKErr::EOF) => "quit".to_string(),
Err(err) => {
return LKEval::new(
Command::Error(LKErr::ReadError(err.to_string())),
self.state.clone(),
self.read_password,
)
}
};
if self.cmd != "" {
self.cmd = match self.rl.readline(&*self.prompt) {
Ok(str) => str,
Err(LKErr::EOF) => "quit".to_string(),
Err(err) => {
return LKEval::new(
Command::Error(LKErr::ReadError(err.to_string())),
self.state.clone(),
self.read_password,
)
}
};
}
self.rl.add_history_entry(self.cmd.as_str());
self.cmd = "".to_string();
match self.rl.save_history(&history_file) {
Ok(_) => (),
Err(_) => (),
+13
View File
@@ -228,6 +228,19 @@ impl LKOut {
}
}
pub fn output(&self) -> Vec<String> {
let mut out: Vec<String> = vec![];
match &self.err {
Some(o) => for l in &*o.lock() { out.push(l.to_string()); },
_ => (),
}
match &self.out {
Some(o) => for l in &*o.lock() { out.push(l.to_string()); },
_ => (),
}
out
}
pub fn active(&self) -> bool {
self.out.is_some()
}