summaryrefslogtreecommitdiffstats
path: root/src/commands
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2020-02-16 11:59:33 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2020-02-16 12:01:23 -0500
commitd788f8d740be85bb014ddfa005156723f0a31e99 (patch)
tree1cd74c86358b70f78dffe25da5e0bfe4bd9b1abf /src/commands
parent726a7a424f7ddec97478490a0f3a25005dde45ac (diff)
rework rendering system to use tui-rs widgets
- move files around - delete some old ncurses code - integrate tui-rs styles and colors
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/change_directory.rs3
-rw-r--r--src/commands/command_line.rs2
-rw-r--r--src/commands/load_child.rs31
-rw-r--r--src/commands/mod.rs2
-rw-r--r--src/commands/open_file.rs5
-rw-r--r--src/commands/reload_dir.rs13
-rw-r--r--src/commands/set_mode.rs2
7 files changed, 7 insertions, 51 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs
index cd761c9..5f30c36 100644
--- a/src/commands/change_directory.rs
+++ b/src/commands/change_directory.rs
@@ -1,10 +1,11 @@
use std::path;
-use crate::commands::{JoshutoCommand, JoshutoRunnable, LoadChild};
+use crate::commands::{JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
use crate::history::DirectoryHistory;
use crate::ui::TuiBackend;
+use crate::util::load_child::LoadChild;
#[derive(Clone, Debug)]
pub struct ChangeDirectory {
diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs
index ff3c694..1ca2c14 100644
--- a/src/commands/command_line.rs
+++ b/src/commands/command_line.rs
@@ -1,8 +1,8 @@
use crate::commands::{self, JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
-use crate::util::textfield::TextField;
use crate::ui::TuiBackend;
+use crate::util::textfield::TextField;
#[derive(Clone, Debug)]
pub struct CommandLine {
diff --git a/src/commands/load_child.rs b/src/commands/load_child.rs
deleted file mode 100644
index 693e339..0000000
--- a/src/commands/load_child.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-use std::path::PathBuf;
-
-use crate::context::JoshutoContext;
-use crate::error::JoshutoResult;
-use crate::history::DirectoryHistory;
-use crate::ui::TuiBackend;
-
-pub struct LoadChild {}
-
-impl LoadChild {
- pub fn load_child(context: &mut JoshutoContext, backend: &mut TuiBackend) {
- let curr_tab = &mut context.tabs[context.curr_tab_index];
- let mut path: Option<PathBuf> = None;
-
- if let Some(curr_list) = curr_tab.curr_list_ref() {
- if let Some(index) = curr_list.index {
- let entry = &curr_list.contents[index];
- path = Some(entry.file_path().clone())
- }
- }
-
- // get preview
- if let Some(path) = path {
- if path.is_dir() {
- curr_tab
- .history
- .create_or_update(path.as_path(), &context.config_t.sort_option);
- }
- }
- }
-}
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 0c395e6..724b5ad 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -4,7 +4,6 @@ mod command_line;
mod cursor_move;
mod delete_files;
mod file_ops;
-mod load_child;
mod new_directory;
mod open_file;
mod parent_directory;
@@ -27,7 +26,6 @@ pub use self::cursor_move::{
};
pub use self::delete_files::DeleteFiles;
pub use self::file_ops::{CopyFiles, CutFiles, PasteFiles};
-pub use self::load_child::LoadChild;
pub use self::new_directory::NewDirectory;
pub use self::open_file::OpenFile; //, OpenFileWith};
pub use self::parent_directory::ParentDirectory;
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index b1b46d1..501eb67 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -1,12 +1,13 @@
use std::path::{Path, PathBuf};
-use crate::commands::{ChangeDirectory, JoshutoCommand, JoshutoRunnable, LoadChild};
+use crate::commands::{ChangeDirectory, JoshutoCommand, JoshutoRunnable};
use crate::config::mimetype::JoshutoMimetypeEntry;
use crate::context::JoshutoContext;
use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult};
use crate::history::DirectoryHistory;
-use crate::util::textfield::TextField;
use crate::ui::TuiBackend;
+use crate::util::load_child::LoadChild;
+use crate::util::textfield::TextField;
use crate::MIMETYPE_T;
diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs
index d1d6f5f..20d415b 100644
--- a/src/commands/reload_dir.rs
+++ b/src/commands/reload_dir.rs
@@ -22,19 +22,6 @@ impl ReloadDirList {
let sort_option = &context.config_t.sort_option;
curr_tab.curr_list.reload_contents(sort_option)?;
- if let Some(parent) = curr_tab.curr_list.file_path().parent() {
- match curr_tab.history.entry(parent.to_path_buf().clone()) {
- Entry::Occupied(mut entry) => {
- let dirlist = entry.get_mut();
- dirlist.reload_contents(sort_option)?;
- }
- Entry::Vacant(entry) => {
- let mut s = JoshutoDirList::new(parent.to_path_buf().clone(), &sort_option)?;
- s.sort(sort_option.compare_func());
- entry.insert(s);
- }
- }
- }
Ok(())
}
}
diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs
index a84cc80..6a5896f 100644
--- a/src/commands/set_mode.rs
+++ b/src/commands/set_mode.rs
@@ -2,9 +2,9 @@ use crate::commands::{CursorMoveDown, JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
use crate::fs::JoshutoDirEntry;
-use crate::util::textfield::TextField;
use crate::ui::TuiBackend;
use crate::unix;
+use crate::util::textfield::TextField;
#[derive(Clone, Debug)]
pub struct SetMode;