From 619cd19e91c7a1ae176a706f0e1f47887cd7a1ec Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 11 Nov 2021 04:26:36 -0500 Subject: avoid unnecessary rerenders and focus changes --- src/state.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 6051329..5a1e1bd 100644 --- a/src/state.rs +++ b/src/state.rs @@ -9,7 +9,7 @@ pub struct State { impl State { pub fn new( - actions: async_std::channel::Sender, + actions: async_std::channel::Sender, output: textmode::Output, ) -> Self { let readline = crate::readline::Readline::new(actions.clone()); @@ -37,15 +37,15 @@ impl State { Ok(()) } - pub async fn handle_action(&mut self, action: Action) { + pub async fn handle_action(&mut self, action: crate::action::Action) { match action { - Action::Render => { + crate::action::Action::Render => { self.render().await.unwrap(); } - Action::Run(ref cmd) => { + crate::action::Action::Run(ref cmd) => { self.history.run(cmd).await.unwrap(); } - Action::UpdateFocus(new_focus) => { + crate::action::Action::UpdateFocus(new_focus) => { self.focus = new_focus; self.render().await.unwrap(); } @@ -65,10 +65,3 @@ pub enum Focus { Readline, History(usize), } - -#[derive(Debug)] -pub enum Action { - Render, - Run(String), - UpdateFocus(Focus), -} -- cgit v1.2.3-54-g00ecf