diff options
-rw-r--r-- | config/joshuto.toml | 3 | ||||
-rw-r--r-- | src/config/config.rs | 5 | ||||
-rw-r--r-- | src/preview.rs | 9 | ||||
-rw-r--r-- | src/tab.rs | 4 |
4 files changed, 15 insertions, 6 deletions
diff --git a/config/joshuto.toml b/config/joshuto.toml index 4c5c6c5..0b3aae1 100644 --- a/config/joshuto.toml +++ b/config/joshuto.toml @@ -10,6 +10,9 @@ scroll_offset = 6 sort_type = "natural" +show_preview = true +max_preview_size = 2097152 # 2MB + [sort_option] show_hidden = false case_sensitive = false diff --git a/src/config/config.rs b/src/config/config.rs index bacb6aa..ab1e56f 100644 --- a/src/config/config.rs +++ b/src/config/config.rs @@ -17,6 +17,7 @@ pub struct SortRawOption { pub struct JoshutoRawConfig { scroll_offset: Option<usize>, tilde_in_titlebar: Option<bool>, + show_preview: Option<bool>, max_preview_size: Option<u64>, sort_method: Option<String>, sort_option: Option<SortRawOption>, @@ -32,6 +33,7 @@ impl Flattenable<JoshutoConfig> for JoshutoRawConfig { let scroll_offset: usize = self.scroll_offset.unwrap_or(6); let tilde_in_titlebar: bool = self.tilde_in_titlebar.unwrap_or(true); + let show_preview: bool = self.show_preview.unwrap_or(true); let max_preview_size: u64 = self.max_preview_size.unwrap_or(2 * 1024 * 1024); let sort_method: sort::SortType = match self.sort_method { @@ -73,6 +75,7 @@ impl Flattenable<JoshutoConfig> for JoshutoRawConfig { JoshutoConfig { scroll_offset, tilde_in_titlebar, + show_preview, max_preview_size, column_ratio, sort_option, @@ -84,6 +87,7 @@ impl Flattenable<JoshutoConfig> for JoshutoRawConfig { pub struct JoshutoConfig { pub scroll_offset: usize, pub tilde_in_titlebar: bool, + pub show_preview: bool, pub max_preview_size: u64, pub sort_option: sort::SortOption, pub column_ratio: (usize, usize, usize), @@ -109,6 +113,7 @@ impl std::default::Default for JoshutoConfig { JoshutoConfig { scroll_offset: 6, tilde_in_titlebar: true, + show_preview: true, max_preview_size: 2 * 1024 * 1024, sort_option, column_ratio: (1, 3, 4), diff --git a/src/preview.rs b/src/preview.rs index c207463..917fad7 100644 --- a/src/preview.rs +++ b/src/preview.rs @@ -1,11 +1,10 @@ use std::collections::{hash_map::Entry, HashMap}; -use std::ffi::OsStr; use std::io::BufRead; use std::path; use std::process; use crate::config::JoshutoConfig; -use crate::structs::{JoshutoDirEntry, JoshutoDirList}; +use crate::structs::JoshutoDirList; use crate::tab::JoshutoTab; use crate::ui; use crate::window::panel::JoshutoPanel; @@ -55,10 +54,10 @@ fn preview_directory( fn preview_file(path: &path::Path, win: &JoshutoPanel) { match path.extension() { - Some(file_ext) => { + Some(_file_ext) => { let mimetype_str = tree_magic::from_filepath(&path); /* mime subtype have second priority */ - if let Some(s) = MIMETYPE_T.mimetype.get(&mimetype_str) {} + if let Some(_s) = MIMETYPE_T.mimetype.get(&mimetype_str) {} /* generic mime type have last priority */ if let Some(s) = mimetype_str.find('/') { @@ -71,7 +70,7 @@ fn preview_file(path: &path::Path, win: &JoshutoPanel) { None => { let mimetype_str = tree_magic::from_filepath(&path); /* mime subtype have second priority */ - if let Some(s) = MIMETYPE_T.mimetype.get(&mimetype_str) {} + if let Some(_s) = MIMETYPE_T.mimetype.get(&mimetype_str) {} /* generic mime type have last priority */ if let Some(s) = mimetype_str.find('/') { @@ -71,7 +71,9 @@ impl JoshutoTab { } pub fn refresh_preview(&mut self, win: &JoshutoPanel, config_t: &config::JoshutoConfig) { - preview::preview_entry(self, win, config_t); + if config_t.show_preview { + preview::preview_entry(self, win, config_t); + } } pub fn refresh_file_status(&self, win: &JoshutoPanel) { |