diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-30 15:20:03 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-30 15:20:03 -0400 |
commit | e7218c81d90ae07d7f56dce0c3032db15b11d118 (patch) | |
tree | 63c3b63345ec73031b26c1b900957ad06b69aec6 /src/io | |
parent | a592bfe51c0cbb7744f14586520827cb06da8c8d (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/io')
-rw-r--r-- | src/io/io_observer.rs | 40 | ||||
-rw-r--r-- | src/io/io_worker.rs | 38 | ||||
-rw-r--r-- | src/io/mod.rs | 4 |
3 files changed, 43 insertions, 39 deletions
diff --git a/src/io/io_observer.rs b/src/io/io_observer.rs new file mode 100644 index 0000000..c31b94d --- /dev/null +++ b/src/io/io_observer.rs @@ -0,0 +1,40 @@ +use std::path; +use std::thread; + +#[derive(Debug)] +pub struct IOWorkerObserver { + pub handle: thread::JoinHandle<()>, + msg: Option<String>, + src: path::PathBuf, + dest: path::PathBuf, +} + +impl IOWorkerObserver { + pub fn new(handle: thread::JoinHandle<()>, src: path::PathBuf, dest: path::PathBuf) -> Self { + Self { + handle, + src, + dest, + msg: None, + } + } + + pub fn join(self) { + self.handle.join(); + } + pub fn set_msg(&mut self, msg: String) { + self.msg = Some(msg) + } + pub fn get_msg(&self) -> Option<&String> { + self.msg.as_ref() + } + pub fn clear_msg(&mut self) { + self.msg = None + } + pub fn get_src_path(&self) -> &path::Path { + self.src.as_path() + } + pub fn get_dest_path(&self) -> &path::Path { + self.dest.as_path() + } +} diff --git a/src/io/io_worker.rs b/src/io/io_worker.rs index 58ac181..cd96929 100644 --- a/src/io/io_worker.rs +++ b/src/io/io_worker.rs @@ -29,44 +29,6 @@ impl std::default::Default for IOWorkerOptions { } #[derive(Debug)] -pub struct IOWorkerObserver { - msg: Option<String>, - pub handle: thread::JoinHandle<()>, - src: path::PathBuf, - dest: path::PathBuf, -} - -impl IOWorkerObserver { - pub fn new(handle: thread::JoinHandle<()>, src: path::PathBuf, dest: path::PathBuf) -> Self { - Self { - handle, - src, - dest, - msg: None, - } - } - - pub fn join(self) { - self.handle.join(); - } - pub fn set_msg(&mut self, msg: String) { - self.msg = Some(msg) - } - pub fn get_msg(&self) -> Option<&String> { - self.msg.as_ref() - } - pub fn clear_msg(&mut self) { - self.msg = None - } - pub fn get_src_path(&self) -> &path::Path { - self.src.as_path() - } - pub fn get_dest_path(&self) -> &path::Path { - self.dest.as_path() - } -} - -#[derive(Debug)] pub struct IOWorkerThread { pub options: IOWorkerOptions, pub paths: Vec<path::PathBuf>, diff --git a/src/io/mod.rs b/src/io/mod.rs index dd97f69..43c70d7 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -1,5 +1,7 @@ +mod io_observer; mod io_worker; mod name_resolution; -pub use io_worker::{FileOp, IOWorkerObserver, IOWorkerOptions, IOWorkerThread}; +pub use io_observer::IOWorkerObserver; +pub use io_worker::{FileOp, IOWorkerOptions, IOWorkerThread}; pub use name_resolution::rename_filename_conflict; |