diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-11 04:26:36 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-11 04:26:36 -0500 |
commit | 619cd19e91c7a1ae176a706f0e1f47887cd7a1ec (patch) | |
tree | f1d922ff835e1cc412f0101dcba44fe29aeecc6a /src/state.rs | |
parent | cf04fbb6427eb10332c5bc143cc453aa2906e84c (diff) | |
download | nbsh-619cd19e91c7a1ae176a706f0e1f47887cd7a1ec.tar.gz nbsh-619cd19e91c7a1ae176a706f0e1f47887cd7a1ec.zip |
avoid unnecessary rerenders and focus changes
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 17 |
1 files changed, 5 insertions, 12 deletions
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<Action>, + actions: async_std::channel::Sender<crate::action::Action>, 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), -} |