diff --git a/src/app/app.rs b/src/app/app.rs index 1729fac..0796b77 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -82,7 +82,7 @@ pub fn update(state: &mut State, message: Message) -> Task { if let Some(value) = pick_directory("Choose scratch folder") { interpreter::INTERPRETER_WORKER .interp_sender - .send_blocking(interpreter::Message::SetScratchDir(value)) + .send_blocking(interpreter::Message::SendCmd(format!("apdir x {value}"))) .expect("the channel is unbound"); } } @@ -173,6 +173,8 @@ pub fn update(state: &mut State, message: Message) -> Task { interpreter::Message::Error(output) | interpreter::Message::PythonError(output) => { state.answer = "".to_owned(); state.output.push(Output::Error(output)); + + return text_input::focus(state.input_id.clone()); } interpreter::Message::Ask(prompt) => { state.answer = "".to_owned(); diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index e8a4c90..39585f0 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -54,9 +54,6 @@ impl InterpreterWorker { Message::GetScratchDir => { interpreter.scratch_dir().map(Message::ScratchDir) } - Message::SetScratchDir(value) => interpreter - .set_scratch_dir(&value) - .map(|_| Message::ScratchDir(value)), _ => continue, } .into(); @@ -96,8 +93,6 @@ pub enum Message { LoadMidi(String), /// Get scratch dir. GetScratchDir, - /// Set scratch dir. - SetScratchDir(String), /// The result of `Self::GetScratchDir`. ScratchDir(String), } @@ -173,18 +168,6 @@ interp"# }) } - fn set_scratch_dir(&self, path: &str) -> InterpreterResult<()> { - self.py_interpreter.enter(|vm| -> InterpreterResult<()> { - let external = vm - .get_attribute_opt(self.ath_object.clone(), "external") - .try_py()? - .expect("external attribute is always available on AthenaObject"); - vm.call_method(&external, "writePref", ("athena", "fpScratchDir", path)) - .try_py()?; - Ok(()) - }) - } - fn scratch_dir(&self) -> InterpreterResult { self.py_interpreter .enter(|vm| -> InterpreterResult {