summaryrefslogtreecommitdiffstats
path: root/src/context
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-08-30 15:20:03 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-08-30 15:20:03 -0400
commite7218c81d90ae07d7f56dce0c3032db15b11d118 (patch)
tree63c3b63345ec73031b26c1b900957ad06b69aec6 /src/context
parenta592bfe51c0cbb7744f14586520827cb06da8c8d (diff)
rework and fix issues
- fixed bug where io tasks would not run when user is in a textfield or prompt - fixed bug where cut doesn't work - rework structs to have private fields and public functions - move IOWorkerObserver into seperate file - move code from TuiView to TuiFolderView
Diffstat (limited to 'src/context')
-rw-r--r--src/context/context.rs19
-rw-r--r--src/context/local_state.rs4
2 files changed, 14 insertions, 9 deletions
diff --git a/src/context/context.rs b/src/context/context.rs
index c39bd8e..6c65695 100644
--- a/src/context/context.rs
+++ b/src/context/context.rs
@@ -10,10 +10,10 @@ use crate::util::event::{Event, Events};
pub struct JoshutoContext {
pub exit: bool,
pub config_t: config::JoshutoConfig,
- local_state: Option<LocalStateContext>,
+ events: Events,
tab_context: TabContext,
- pub events: Events,
- pub message_queue: VecDeque<String>,
+ local_state: Option<LocalStateContext>,
+ message_queue: VecDeque<String>,
worker_queue: VecDeque<IOWorkerThread>,
worker: Option<IOWorkerObserver>,
}
@@ -22,10 +22,10 @@ impl JoshutoContext {
pub fn new(config_t: config::JoshutoConfig) -> Self {
Self {
exit: false,
+ events: Events::new(),
+ tab_context: TabContext::new(),
local_state: None,
- tab_context: TabContext::default(),
message_queue: VecDeque::with_capacity(4),
- events: Events::new(),
worker_queue: VecDeque::new(),
worker: None,
config_t,
@@ -39,9 +39,15 @@ impl JoshutoContext {
&mut self.tab_context
}
+ pub fn message_queue_ref(&self) -> &VecDeque<String> {
+ &self.message_queue
+ }
pub fn push_msg(&mut self, msg: String) {
self.message_queue.push_back(msg);
}
+ pub fn pop_msg(&mut self) -> Option<String> {
+ self.message_queue.pop_front()
+ }
// event related
pub fn poll_event(&self) -> Result<Event, mpsc::RecvError> {
@@ -108,8 +114,7 @@ impl JoshutoContext {
let _ = tx.send(Event::IOWorkerResult((file_op, res)));
}
Err(e) => {
- let err = std::io::Error::new(std::io::ErrorKind::Other,
- "Sending Error");
+ let err = std::io::Error::new(std::io::ErrorKind::Other, "Sending Error");
let _ = tx.send(Event::IOWorkerResult((file_op, Err(err))));
}
}
diff --git a/src/context/local_state.rs b/src/context/local_state.rs
index 6bb8d00..c48660f 100644
--- a/src/context/local_state.rs
+++ b/src/context/local_state.rs
@@ -22,8 +22,8 @@ impl LocalStateContext {
pub fn set_paths<'a, I>(&mut self, vals: I)
where
- I: Iterator<Item = &'a path::Path>,
+ I: Iterator<Item = path::PathBuf>,
{
- self.paths = vals.map(|p| p.to_path_buf()).collect();
+ self.paths = vals.collect();
}
}