summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-11 02:14:03 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-11 02:14:03 -0500
commitb96b4a50d7f38ac0d884f677d4e1c4172c3f19ae (patch)
tree7f5e5bc5773f07c21b4c62b5bed9130769bed532 /src/state.rs
parent86bedf54342eda4e3f10dc34523612209a9f2685 (diff)
downloadnbsh-b96b4a50d7f38ac0d884f677d4e1c4172c3f19ae.tar.gz
nbsh-b96b4a50d7f38ac0d884f677d4e1c4172c3f19ae.zip
simplify
also avoid releasing and reacquiring the entry lock multiple times within a single handler, to avoid time of check to time of use issues
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/state.rs b/src/state.rs
index c030e2a..28f76ac 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -71,7 +71,7 @@ impl State {
textmode::Key::Ctrl(b'm') => {
let idx = self.focus_idx();
let focus = if let Some(idx) = idx {
- self.history.running(idx).await
+ self.history.entry(idx).await.running()
} else {
true
};
@@ -87,7 +87,7 @@ impl State {
textmode::Key::Char(' ') => {
if let Some(idx) = self.focus_idx() {
self.readline
- .set_input(&self.history.history_cmd(idx).await);
+ .set_input(&self.history.entry(idx).await.cmd());
self.set_focus(crate::action::Focus::Readline).await;
}
}
@@ -100,14 +100,13 @@ impl State {
}
textmode::Key::Char('f') => {
if let Some(idx) = self.focus_idx() {
+ let mut entry = self.history.entry(idx).await;
let mut focus = crate::action::Focus::History(idx);
if let crate::action::Focus::Scrolling(_) = self.focus {
- self.history.set_fullscreen(idx, true).await;
+ entry.set_fullscreen(true);
} else {
- self.history.toggle_fullscreen(idx).await;
- if !self.history.should_fullscreen(idx).await
- && !self.history.running(idx).await
- {
+ entry.toggle_fullscreen();
+ if !entry.should_fullscreen() && !entry.running() {
focus =
crate::action::Focus::Scrolling(Some(idx));
}
@@ -259,7 +258,7 @@ impl State {
crate::action::Scene::Readline
}
crate::action::Focus::History(idx) => {
- if self.history.should_fullscreen(idx).await {
+ if self.history.entry(idx).await.should_fullscreen() {
crate::action::Scene::Fullscreen
} else {
crate::action::Scene::Readline