diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-16 14:10:24 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-16 14:10:24 -0500 |
commit | 9edb92d2715a7d0bd67a977454f1c648367dad40 (patch) | |
tree | a70d8851de516e81da696991a865e4de2f72d7b7 /src/action.rs | |
parent | 0e102f53da61de230de8b4c4879c046b8c6baf4d (diff) | |
download | nbsh-9edb92d2715a7d0bd67a977454f1c648367dad40.tar.gz nbsh-9edb92d2715a7d0bd67a977454f1c648367dad40.zip |
add ^L (or ^E^L) to force-redraw the screen
Diffstat (limited to 'src/action.rs')
-rw-r--r-- | src/action.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/action.rs b/src/action.rs index 81f83bb..2e27393 100644 --- a/src/action.rs +++ b/src/action.rs @@ -1,6 +1,7 @@ #[derive(Debug)] pub enum Action { Render, + ForceRedraw, Run(String), UpdateFocus(crate::state::Focus), Resize((u16, u16)), @@ -32,6 +33,7 @@ impl Debouncer { #[derive(Default)] struct Pending { render: Option<()>, + force_redraw: Option<()>, run: std::collections::VecDeque<String>, focus: Option<crate::state::Focus>, size: Option<(u16, u16)>, @@ -45,6 +47,7 @@ impl Pending { fn has_event(&self) -> bool { self.render.is_some() + || self.force_redraw.is_some() || !self.run.is_empty() || self.focus.is_some() || self.size.is_some() @@ -60,6 +63,11 @@ impl Pending { if self.focus.is_some() { return Some(Action::UpdateFocus(self.focus.take().unwrap())); } + if self.force_redraw.is_some() { + self.force_redraw.take(); + self.render.take(); + return Some(Action::ForceRedraw); + } if self.render.is_some() { self.render.take(); return Some(Action::Render); @@ -72,9 +80,10 @@ impl Pending { fn new_event(&mut self, action: &Option<Action>) { match action { + Some(Action::Render) => self.render = Some(()), + Some(Action::ForceRedraw) => self.force_redraw = Some(()), Some(Action::Run(cmd)) => self.run.push_back(cmd.to_string()), Some(Action::UpdateFocus(focus)) => self.focus = Some(*focus), - Some(Action::Render) => self.render = Some(()), Some(Action::Resize(size)) => self.size = Some(*size), None => self.done = true, } |