summaryrefslogtreecommitdiffstats
path: root/src/history.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-11-10 13:14:44 -0500
committerJesse Luehrs <doy@tozt.net>2021-11-10 13:14:44 -0500
commit747da41fd3f192038c2e3194b4de041f7969f7a8 (patch)
tree5436c8b77a9bfcbefc90885513ea4ed0ec5b5d51 /src/history.rs
parent847f8834ae051c1c6177e9166cac855ccff113f0 (diff)
downloadnbsh-747da41fd3f192038c2e3194b4de041f7969f7a8.tar.gz
nbsh-747da41fd3f192038c2e3194b4de041f7969f7a8.zip
simplify
Diffstat (limited to 'src/history.rs')
-rw-r--r--src/history.rs33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/history.rs b/src/history.rs
index 00ad39a..bf46693 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -3,13 +3,13 @@ use pty_process::Command as _;
use textmode::Textmode as _;
pub struct History {
- entries: Vec<async_std::sync::Arc<async_std::sync::Mutex<HistoryEntry>>>,
- action: async_std::channel::Sender<crate::nbsh::Action>,
+ entries: Vec<crate::util::Mutex<HistoryEntry>>,
+ action: async_std::channel::Sender<crate::state::Action>,
}
impl History {
pub fn new(
- action: async_std::channel::Sender<crate::nbsh::Action>,
+ action: async_std::channel::Sender<crate::state::Action>,
) -> Self {
Self {
entries: vec![],
@@ -24,8 +24,9 @@ impl History {
let child = process
.spawn_pty(Some(&pty_process::Size::new(24, 80)))
.unwrap();
- let entry = async_std::sync::Arc::new(async_std::sync::Mutex::new(
- HistoryEntry::new(cmd, child.id().try_into().unwrap()),
+ let entry = crate::util::mutex(HistoryEntry::new(
+ cmd,
+ child.id().try_into().unwrap(),
));
let task_entry = async_std::sync::Arc::clone(&entry);
let task_action = self.action.clone();
@@ -42,29 +43,27 @@ impl History {
}
task_entry.lock_arc().await.running = false;
task_action
- .send(crate::nbsh::Action::UpdateFocus(
- crate::nbsh::InputSource::Repl,
+ .send(crate::state::Action::UpdateFocus(
+ crate::state::Focus::Readline,
))
.await
.unwrap();
- task_action
- .send(crate::nbsh::Action::Render)
- .await
- .unwrap();
break;
}
}
- task_action.send(crate::nbsh::Action::Render).await.unwrap();
+ task_action
+ .send(crate::state::Action::Render)
+ .await
+ .unwrap();
}
});
self.entries.push(entry);
self.action
- .send(crate::nbsh::Action::UpdateFocus(
- crate::nbsh::InputSource::History(self.entries.len() - 1),
+ .send(crate::state::Action::UpdateFocus(
+ crate::state::Focus::History(self.entries.len() - 1),
))
.await
.unwrap();
- self.action.send(crate::nbsh::Action::Render).await.unwrap();
Ok(self.entries.len() - 1)
}
@@ -81,8 +80,8 @@ impl History {
}
textmode::Key::Ctrl(b'z') => {
self.action
- .send(crate::nbsh::Action::UpdateFocus(
- crate::nbsh::InputSource::Repl,
+ .send(crate::state::Action::UpdateFocus(
+ crate::state::Focus::Readline,
))
.await
.unwrap();