summaryrefslogtreecommitdiffstats
path: root/src/action.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-17 22:29:05 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-17 22:29:05 -0500
commit70f48c3ef7dde34546b6d646818333505d0e4777 (patch)
treedb5d3fd7a2f4cfd168a73e03c8c8272ac375ecc1 /src/action.rs
parent96f335c58f9b9b9035a43f106f2dfddbe62777e7 (diff)
downloadnbsh-70f48c3ef7dde34546b6d646818333505d0e4777.tar.gz
nbsh-70f48c3ef7dde34546b6d646818333505d0e4777.zip
refactor
Diffstat (limited to 'src/action.rs')
-rw-r--r--src/action.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/action.rs b/src/action.rs
index c7f437c..22f088e 100644
--- a/src/action.rs
+++ b/src/action.rs
@@ -4,6 +4,7 @@ pub enum Action {
ForceRedraw,
Run(String),
UpdateFocus(crate::state::Focus),
+ ToggleFullscreen(usize),
Resize((u16, u16)),
Quit,
}
@@ -37,6 +38,7 @@ struct Pending {
force_redraw: Option<()>,
run: std::collections::VecDeque<String>,
focus: Option<crate::state::Focus>,
+ fullscreen: std::collections::VecDeque<usize>,
size: Option<(u16, u16)>,
done: bool,
}
@@ -52,6 +54,7 @@ impl Pending {
|| self.force_redraw.is_some()
|| !self.run.is_empty()
|| self.focus.is_some()
+ || !self.fullscreen.is_empty()
|| self.size.is_some()
}
@@ -65,6 +68,11 @@ impl Pending {
if self.focus.is_some() {
return Some(Action::UpdateFocus(self.focus.take().unwrap()));
}
+ if !self.fullscreen.is_empty() {
+ return Some(Action::ToggleFullscreen(
+ self.fullscreen.pop_front().unwrap(),
+ ));
+ }
if self.force_redraw.is_some() {
self.force_redraw.take();
self.render.take();
@@ -86,6 +94,9 @@ impl Pending {
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::ToggleFullscreen(idx)) => {
+ self.fullscreen.push_back(*idx);
+ }
Some(Action::Resize(size)) => self.size = Some(*size),
Some(Action::Quit) | None => self.done = true,
}