summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-04 16:55:36 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-04 16:59:39 -0400
commit97a1b5a9ad52f1d706b02ab6c7cd019da9a124b9 (patch)
tree2f407ff91aaa6595626e1904430fb0ba44f6d630 /src
parentfd4bd6f79ec8051c91f69543fc20d5e8d6607f13 (diff)
change pub fields to private and rename structs to io
Diffstat (limited to 'src')
-rw-r--r--src/commands/command_line.rs8
-rw-r--r--src/commands/file_operations.rs2
-rw-r--r--src/commands/open_file.rs4
-rw-r--r--src/commands/paste_files.rs2
-rw-r--r--src/commands/reload_dir.rs2
-rw-r--r--src/commands/rename_file.rs6
-rw-r--r--src/commands/search.rs4
-rw-r--r--src/commands/selection.rs8
-rw-r--r--src/commands/set_mode.rs4
-rw-r--r--src/history.rs4
-rw-r--r--src/io/dirlist.rs (renamed from src/structs/dirlist.rs)11
-rw-r--r--src/io/entry.rs (renamed from src/structs/entry.rs)42
-rw-r--r--src/io/metadata.rs (renamed from src/structs/metadata.rs)0
-rw-r--r--src/io/mod.rs (renamed from src/structs/mod.rs)0
-rw-r--r--src/main.rs2
-rw-r--r--src/preview.rs13
-rw-r--r--src/sort.rs46
-rw-r--r--src/tab.rs4
-rw-r--r--src/ui.rs50
19 files changed, 114 insertions, 98 deletions
diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs
index 6589fb4..036ad55 100644
--- a/src/commands/command_line.rs
+++ b/src/commands/command_line.rs
@@ -63,14 +63,6 @@ impl CommandLine {
Ok(())
}
}
- pub fn readline_with(
- context: &mut JoshutoContext,
- view: &JoshutoView,
- textfield: JoshutoTextField,
- ) -> Result<(), JoshutoError> {
- drop(textfield);
- Ok(())
- }
}
impl JoshutoCommand for CommandLine {}
diff --git a/src/commands/file_operations.rs b/src/commands/file_operations.rs
index cb5a818..71bd30b 100644
--- a/src/commands/file_operations.rs
+++ b/src/commands/file_operations.rs
@@ -7,7 +7,7 @@ use std::time;
use crate::commands::{JoshutoCommand, JoshutoRunnable, ProgressInfo};
use crate::context::JoshutoContext;
use crate::error::JoshutoError;
-use crate::structs::JoshutoDirList;
+use crate::io::JoshutoDirList;
use crate::window::JoshutoView;
lazy_static! {
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index 3e17978..b733255 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -42,8 +42,8 @@ impl OpenFile {
{
let curr_list = &context.tabs[context.curr_tab_index].curr_list;
if let Some(entry) = curr_list.get_curr_ref() {
- if entry.path.is_dir() {
- path = Some(entry.path.clone());
+ if entry.file_path().is_dir() {
+ path = Some(entry.file_path().clone());
}
}
}
diff --git a/src/commands/paste_files.rs b/src/commands/paste_files.rs
index 667023c..e46ed44 100644
--- a/src/commands/paste_files.rs
+++ b/src/commands/paste_files.rs
@@ -6,7 +6,7 @@ use std::time;
use crate::commands::{self, JoshutoCommand, JoshutoRunnable, ProgressInfo};
use crate::context::JoshutoContext;
-use crate::structs::JoshutoDirList;
+use crate::io::JoshutoDirList;
use crate::window::JoshutoView;
pub struct PasteFiles {
diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs
index eb13d34..b36878d 100644
--- a/src/commands/reload_dir.rs
+++ b/src/commands/reload_dir.rs
@@ -1,7 +1,7 @@
use crate::commands::{JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
use crate::error::JoshutoError;
-use crate::structs::JoshutoDirList;
+use crate::io::JoshutoDirList;
use crate::window::JoshutoView;
use std::collections::hash_map::Entry;
diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs
index c4166f3..cca52a2 100644
--- a/src/commands/rename_file.rs
+++ b/src/commands/rename_file.rs
@@ -69,7 +69,7 @@ impl JoshutoRunnable for RenameFile {
let curr_list = &context.tabs[context.curr_tab_index].curr_list;
if let Some(s) = curr_list.get_curr_ref() {
- path = Some(s.path.clone());
+ path = Some(s.file_path().clone());
}
if let Some(path) = path {
@@ -133,7 +133,7 @@ impl JoshutoRunnable for RenameFileAppend {
let file_name = match curr_list.get_curr_ref() {
Some(s) => {
let escaped = escape(
- s.file_name.clone(),
+ String::from(s.file_name()),
ESCAPE_CHAR,
&DEFAULT_BREAK_CHARS,
Quote::None,
@@ -194,7 +194,7 @@ impl JoshutoRunnable for RenameFilePrepend {
let file_name = match curr_list.get_curr_ref() {
Some(s) => {
let escaped = escape(
- s.file_name.clone(),
+ String::from(s.file_name()),
ESCAPE_CHAR,
&DEFAULT_BREAK_CHARS,
Quote::None,
diff --git a/src/commands/search.rs b/src/commands/search.rs
index 6d74990..86a3329 100644
--- a/src/commands/search.rs
+++ b/src/commands/search.rs
@@ -33,7 +33,7 @@ impl Search {
let contents_len = curr_list.contents.len();
for i in 0..contents_len {
let file_name_lower = curr_list.contents[(offset + i) % contents_len]
- .file_name
+ .file_name()
.to_lowercase();
if file_name_lower.contains(pattern) {
return Some((offset + i) % contents_len);
@@ -51,7 +51,7 @@ impl Search {
let contents_len = curr_list.contents.len();
for i in (0..contents_len).rev() {
let file_name_lower = curr_list.contents[(offset + i) % contents_len]
- .file_name
+ .file_name()
.to_lowercase();
if file_name_lower.contains(pattern) {
return Some((offset + i) % contents_len);
diff --git a/src/commands/selection.rs b/src/commands/selection.rs
index bbeafcb..4064faa 100644
--- a/src/commands/selection.rs
+++ b/src/commands/selection.rs
@@ -44,13 +44,13 @@ impl JoshutoRunnable for SelectFiles {
if !self.all {
let curr_list = &mut curr_tab.curr_list;
if let Some(s) = curr_list.get_curr_mut() {
- s.selected = !s.selected;
+ s.set_selected(!s.is_selected());
return CursorMoveDown::new(1).execute(context, view);
}
} else {
let curr_list = &mut curr_tab.curr_list;
for curr in &mut curr_list.contents {
- curr.selected = !curr.selected;
+ curr.set_selected(!curr.is_selected());
}
curr_tab.refresh_curr(&view.mid_win, &context.config_t);
ncurses::doupdate();
@@ -59,13 +59,13 @@ impl JoshutoRunnable for SelectFiles {
if !self.all {
let curr_list = &mut curr_tab.curr_list;
if let Some(s) = curr_list.get_curr_mut() {
- s.selected = true;
+ s.set_selected(true);
return CursorMoveDown::new(1).execute(context, view);
}
} else {
let curr_list = &mut curr_tab.curr_list;
for curr in &mut curr_list.contents {
- curr.selected = true;
+ curr.set_selected(true);
}
curr_tab.refresh_curr(&view.mid_win, &context.config_t);
ncurses::doupdate();
diff --git a/src/commands/set_mode.rs b/src/commands/set_mode.rs
index f330e71..8da3bfa 100644
--- a/src/commands/set_mode.rs
+++ b/src/commands/set_mode.rs
@@ -1,7 +1,7 @@
use crate::commands::{CursorMoveDown, JoshutoCommand, JoshutoRunnable};
use crate::context::JoshutoContext;
use crate::error::JoshutoError;
-use crate::structs::JoshutoDirEntry;
+use crate::io::JoshutoDirEntry;
use crate::textfield::JoshutoTextField;
use crate::ui;
use crate::unix;
@@ -58,7 +58,7 @@ impl SetMode {
mode |= val;
}
}
- unix::set_mode(entry.path.as_path(), mode);
+ unix::set_mode(entry.file_path().as_path(), mode);
entry.metadata.permissions.set_mode(mode + (1 << 15));
true
}
diff --git a/src/history.rs b/src/history.rs
index cccb396..38974d1 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -1,8 +1,8 @@
use std::collections::{hash_map::Entry, HashMap};
use std::path::{Path, PathBuf};
+use crate::io::JoshutoDirList;
use crate::sort;
-use crate::structs::JoshutoDirList;
pub trait DirectoryHistory {
fn populate_to_root(&mut self, pathbuf: &PathBuf, sort_option: &sort::SortOption);
@@ -31,7 +31,7 @@ impl DirectoryHistory for JoshutoHistory {
match JoshutoDirList::new(curr.to_path_buf().clone(), sort_option) {
Ok(mut s) => {
let index = s.contents.iter().enumerate().find_map(|(i, dir)| {
- if dir.path == ancestor {
+ if dir.file_path() == ancestor {
Some(i)
} else {
None
diff --git a/src/structs/dirlist.rs b/src/io/dirlist.rs
index 470177f..8ed8939 100644
--- a/src/structs/dirlist.rs
+++ b/src/io/dirlist.rs
@@ -1,7 +1,7 @@
use std::{fs, path};
+use crate::io::{JoshutoDirEntry, JoshutoMetadata};
use crate::sort;
-use crate::structs::{JoshutoDirEntry, JoshutoMetadata};
use crate::window::JoshutoPageState;
#[derive(Debug)]
@@ -78,13 +78,16 @@ impl JoshutoDirList {
}
pub fn selected_entries(&self) -> impl Iterator<Item = &JoshutoDirEntry> {
- self.contents.iter().filter(|entry| entry.selected)
+ self.contents.iter().filter(|entry| entry.is_selected())
}
pub fn get_selected_paths(&self) -> Option<Vec<path::PathBuf>> {
- let vec: Vec<path::PathBuf> = self.selected_entries().map(|e| e.path.clone()).collect();
+ let vec: Vec<path::PathBuf> = self
+ .selected_entries()
+ .map(|e| e.file_path().clone())
+ .collect();
if vec.is_empty() {
- Some(vec![self.get_curr_ref()?.path.clone()])
+ Some(vec![self.get_curr_ref()?.file_path().clone()])
} else {
Some(vec)
}
diff --git a/src/structs/entry.rs b/src/io/entry.rs
index 86c7209..4c692dd 100644
--- a/src/structs/entry.rs
+++ b/src/io/entry.rs
@@ -1,19 +1,19 @@
use std::{fs, io, path};
-use crate::structs::JoshutoMetadata;
+use crate::io::JoshutoMetadata;
#[derive(Clone)]
pub struct JoshutoDirEntry {
- pub file_name: String,
- pub path: path::PathBuf,
+ name: String,
+ path: path::PathBuf,
pub metadata: JoshutoMetadata,
- pub selected: bool,
- pub marked: bool,
+ selected: bool,
+ marked: bool,
}
impl JoshutoDirEntry {
pub fn from(direntry: &fs::DirEntry) -> Result<Self, io::Error> {
- let file_name = match direntry.file_name().into_string() {
+ let name = match direntry.file_name().into_string() {
Ok(s) => s,
Err(_) => {
return Err(std::io::Error::new(
@@ -27,7 +27,7 @@ impl JoshutoDirEntry {
let metadata = JoshutoMetadata::from(&path)?;
let dir_entry = JoshutoDirEntry {
- file_name,
+ name,
path,
metadata,
selected: false,
@@ -35,6 +35,32 @@ impl JoshutoDirEntry {
};
Ok(dir_entry)
}
+
+ pub fn file_name(&self) -> &str {
+ self.name.as_str()
+ }
+
+ pub fn file_path(&self) -> &path::PathBuf {
+ &self.path
+ }
+
+ /*
+ pub fn is_marked(&self) -> bool {
+ self.marked
+ }
+
+ pub fn set_marked(&mut self, marked: bool) {
+ self.marked = marked;
+ }
+ */
+
+ pub fn is_selected(&self) -> bool {
+ self.selected
+ }
+
+ pub fn set_selected(&mut self, selected: bool) {
+ self.selected = selected;
+ }
}
impl std::fmt::Debug for JoshutoDirEntry {
@@ -42,7 +68,7 @@ impl std::fmt::Debug for JoshutoDirEntry {
write!(
f,
"JoshutoDirEntry {{\n\tfile_name: {:?}, \n\tpath: {:?} \n}}",
- self.file_name, self.path
+ self.name, self.path
)
}
}
diff --git a/src/structs/metadata.rs b/src/io/metadata.rs
index 5405512..5405512 100644
--- a/src/structs/metadata.rs
+++ b/src/io/metadata.rs
diff --git a/src/structs/mod.rs b/src/io/mod.rs
index 632c2ff..632c2ff 100644
--- a/src/structs/mod.rs
+++ b/src/io/mod.rs
diff --git a/src/main.rs b/src/main.rs
index edfa4ee..9bf9f68 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,10 +3,10 @@ mod config;
mod context;
mod error;
mod history;
+mod io;
mod preview;
mod run;
mod sort;
-mod structs;
mod tab;
mod textfield;
mod ui;
diff --git a/src/preview.rs b/src/preview.rs
index 982dcf8..ede388d 100644
--- a/src/preview.rs
+++ b/src/preview.rs
@@ -4,7 +4,7 @@ use std::path;
use std::process;
use crate::config::{JoshutoConfig, JoshutoPreviewEntry};
-use crate::structs::{JoshutoDirEntry, JoshutoDirList};
+use crate::io::{JoshutoDirEntry, JoshutoDirList};
use crate::tab::JoshutoTab;
use crate::ui;
use crate::window::panel::JoshutoPanel;
@@ -22,8 +22,13 @@ pub fn preview_parent(curr_tab: &mut JoshutoTab, win: &JoshutoPanel, config_t: &
pub fn preview_entry(curr_tab: &mut JoshutoTab, win: &JoshutoPanel, config_t: &JoshutoConfig) {
ncurses::werase(win.win);
if let Some(s) = curr_tab.curr_list.get_curr_ref() {
- if s.path.is_dir() {
- preview_directory(&mut curr_tab.history, s.path.as_path(), win, config_t);
+ if s.file_path().is_dir() {
+ preview_directory(
+ &mut curr_tab.history,
+ s.file_path().as_path(),
+ win,
+ config_t,
+ );
} else if s.metadata.file_type.is_file() {
if s.metadata.len <= config_t.max_preview_size {
// preview_file(s, win);
@@ -67,7 +72,7 @@ fn preview_directory(
}
fn preview_file(entry: &JoshutoDirEntry, win: &JoshutoPanel) {
- let path = &entry.path;
+ let path = entry.file_path();
match path.extension() {
Some(file_ext) => match PREVIEW_T.extension.get(file_ext.to_str().unwrap()) {
Some(s) => preview_with(path, win, &s),
diff --git a/src/sort.rs b/src/sort.rs
index 3e7826d..9985eef 100644
--- a/src/sort.rs
+++ b/src/sort.rs
@@ -2,7 +2,7 @@ use std::cmp;
use std::fs;
use std::time;
-use crate::structs;
+use crate::io::JoshutoDirEntry;
use alphanumeric_sort::compare_str;
use serde_derive::Deserialize;
@@ -35,9 +35,7 @@ pub struct SortOption {
}
impl SortOption {
- pub fn compare_func(
- &self,
- ) -> impl Fn(&structs::JoshutoDirEntry, &structs::JoshutoDirEntry) -> std::cmp::Ordering {
+ pub fn compare_func(&self) -> impl Fn(&JoshutoDirEntry, &JoshutoDirEntry) -> cmp::Ordering {
let base_cmp = match self.sort_method {
SortType::Natural => {
if self.case_sensitive {
@@ -109,11 +107,9 @@ fn filter_hidden(result: &Result<fs::DirEntry, std::io::Error>) -> bool {
}
}
-pub fn map_entry_default(
- result: Result<fs::DirEntry, std::io::Error>,
-) -> Option<structs::JoshutoDirEntry> {
+pub fn map_entry_default(result: Result<fs::DirEntry, std::io::Error>) -> Option<JoshutoDirEntry> {
match result {
- Ok(direntry) => match structs::JoshutoDirEntry::from(&direntry) {
+ Ok(direntry) => match JoshutoDirEntry::from(&direntry) {
Ok(s) => Some(s),
Err(_) => None,
},
@@ -121,16 +117,13 @@ pub fn map_entry_default(
}
}
-const fn dummy_dir_first(
- _: &structs::JoshutoDirEntry,
- _: &structs::JoshutoDirEntry,
-) -> cmp::Ordering {
+const fn dummy_dir_first(_: &JoshutoDirEntry, _: &JoshutoDirEntry) -> cmp::Ordering {
cmp::Ordering::Equal
}
-fn dir_first(f1: &structs::JoshutoDirEntry, f2: &structs::JoshutoDirEntry) -> cmp::Ordering {
- let f1_isdir = f1.path.is_dir();
- let f2_isdir = f2.path.is_dir();
+fn dir_first(f1: &JoshutoDirEntry, f2: &JoshutoDirEntry) -> cmp::Ordering {
+ let f1_isdir = f1.file_path().is_dir();
+ let f2_isdir = f2.file_path().is_dir();
if f1_isdir && !f2_isdir {
cmp::Ordering::Less
@@ -149,26 +142,23 @@ fn reverse_ordering(c: cmp::Ordering) -> cmp::Ordering {
c.reverse()
}
-fn natural_sort_case_insensitive(
- f1: &structs::JoshutoDirEntry,
- f2: &structs::JoshutoDirEntry,
-) -> cmp::Ordering {
- let f1_name = f1.file_name.to_lowercase();
- let f2_name = f2.file_name.to_lowercase();
+fn natural_sort_case_insensitive(f1: &JoshutoDirEntry, f2: &JoshutoDirEntry) -> cmp::Ordering {
+ let f1_name = f1.file_name().to_lowercase();
+ let f2_name = f2.file_name().to_lowercase();
compare_str(&f1_name, &f2_name)
}
-fn natural_sort(f1: &structs::JoshutoDirEntry, f2: &structs::JoshutoDirEntry) -> cmp::Ordering {
- compare_str(&f1.file_name, &f2.file_name)
+fn natural_sort(f1: &JoshutoDirEntry, f2: &JoshutoDirEntry) -> cmp::Ordering {
+ compare_str(f1.file_name(), f2.file_name())
}
-fn mtime_sort(file1: &structs::JoshutoDirEntry, file2: &structs::JoshutoDirEntry) -> cmp::Ordering {
+fn mtime_sort(file1: &JoshutoDirEntry, file2: &JoshutoDirEntry) -> cmp::Ordering {
fn compare(
- file1: &structs::JoshutoDirEntry,
- file2: &structs::JoshutoDirEntry,
+ file1: &JoshutoDirEntry,
+ file2: &JoshutoDirEntry,
) -> Result<cmp::Ordering, std::io::Error> {
- let f1_meta: fs::Metadata = std::fs::metadata(&file1.path)?;
- let f2_meta: fs::Metadata = std::fs::metadata(&file2.path)?;
+ let f1_meta: fs::Metadata = std::fs::metadata(file1.file_path())?;
+ let f2_meta: fs::Metadata = std::fs::metadata(file2.file_path())?;
let f1_mtime: time::SystemTime = f1_meta.modified()?;
let f2_mtime: time::SystemTime = f2_meta.modified()?;
diff --git a/src/tab.rs b/src/tab.rs
index 105a800..dd84ebc 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -1,9 +1,9 @@
use std::path::PathBuf;
use crate::history::{DirectoryHistory, JoshutoHistory};
+use crate::io::JoshutoDirList;
use crate::preview;
use crate::sort;
-use crate::structs::JoshutoDirList;
use crate::ui;
use crate::window::{JoshutoPanel, JoshutoView};
use crate::JoshutoConfig;
@@ -100,7 +100,7 @@ impl JoshutoTab {
ncurses::waddstr(win.win, "/");
ncurses::wattroff(win.win, ncurses::COLOR_PAIR(THEME_T.directory.colorpair));
if let Some(entry) = self.curr_list.get_curr_ref() {
- ncurses::waddstr(win.win, &entry.file_name);
+ ncurses::waddstr(win.win, &entry.file_name());
}
ncurses::wattroff(win.win, ncurses::A_BOLD());
win.queue_for_refresh();
diff --git a/src/ui.rs b/src/ui.rs
index d4e899a..54b1c92 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -3,7 +3,7 @@ use std::time;
use crate::config::{JoshutoColorTheme, JoshutoConfig};
use crate::context::JoshutoContext;
-use crate::structs;
+use crate::io::{JoshutoDirEntry, JoshutoDirList};
use crate::unix;
use crate::window;
@@ -15,7 +15,7 @@ pub const EMPTY_COLOR: i16 = 241;
const MIN_WIN_WIDTH: usize = 4;
pub struct DisplayOptions {
- detailed: bool,
+ pub detailed: bool,
}
pub const PRIMARY_DISPLAY_OPTION: DisplayOptions = DisplayOptions { detailed: true };
@@ -32,12 +32,11 @@ pub fn init_ncurses() {
ncurses::use_default_colors();
ncurses::noecho();
ncurses::set_escdelay(0);
+ ncurses::curs_set(ncurses::CURSOR_VISIBILITY::CURSOR_INVISIBLE);
process_theme();
ncurses::addstr("Loading...");
- ncurses::curs_set(ncurses::CURSOR_VISIBILITY::CURSOR_INVISIBLE);
-
ncurses::refresh();
}
@@ -81,12 +80,14 @@ pub fn wprint_msg(win: &window::JoshutoPanel, msg: &str) {
}
pub fn wprint_err(win: &window::JoshutoPanel, msg: &str) {
+ let attr = ncurses::A_BOLD() | ncurses::COLOR_PAIR(ERR_COLOR);
+
ncurses::werase(win.win);
- ncurses::wattron(win.win, ncurses::A_BOLD());
- ncurses::wattron(win.win, ncurses::COLOR_PAIR(ERR_COLOR));
+ ncurses::wattron(win.win, attr);
+
ncurses::mvwaddstr(win.win, 0, 0, msg);
- ncurses::wattroff(win.win, ncurses::COLOR_PAIR(ERR_COLOR));
- ncurses::wattroff(win.win, ncurses::A_BOLD());
+
+ ncurses::wattroff(win.win, attr);
ncurses::wnoutrefresh(win.win);
}
@@ -141,7 +142,7 @@ fn wprint_file_name(
fn wprint_entry(
win: &window::JoshutoPanel,
- file: &structs::JoshutoDirEntry,
+ file: &JoshutoDirEntry,
prefix: (usize, &str),
coord: (i32, i32),
) {
@@ -153,7 +154,7 @@ fn wprint_entry(
wprint_file_name(
&win,
- &file.file_name,
+ file.file_name(),
(coord.0, coord.1 + prefix.0 as i32),
space_avail,
);
@@ -161,7 +162,7 @@ fn wprint_entry(
fn wprint_entry_detailed(
win: &window::JoshutoPanel,
- file: &structs::JoshutoDirEntry,
+ file: &JoshutoDirEntry,
prefix: (usize, &str),
coord: (i32, i32),
) {
@@ -173,7 +174,7 @@ fn wprint_entry_detailed(
let coord = (coord.0, coord.1 + prefix.0 as i32);
- if file.path.is_dir() {
+ if file.file_path().is_dir() {
} else {
let file_size_string = file_size_to_string(file.metadata.len as f64);
if space_avail > file_size_string.len() {
@@ -181,12 +182,12 @@ fn wprint_entry_detailed(
ncurses::mvwaddstr(win.win, coord.0, space_avail as i32, &file_size_string);
}
}
- wprint_file_name(win, &file.file_name, coord, space_avail);
+ wprint_file_name(win, file.file_name(), coord, space_avail);
}
pub fn display_contents(
win: &window::JoshutoPanel,
- dirlist: &mut structs::JoshutoDirList,
+ dirlist: &mut JoshutoDirList,
config_t: &JoshutoConfig,
options: &DisplayOptions,
) {
@@ -236,7 +237,7 @@ pub fn display_contents(
win.queue_for_refresh();
}
-pub fn wprint_file_mode(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) {
+pub fn wprint_file_mode(win: ncurses::WINDOW, file: &JoshutoDirEntry) {
use std::os::unix::fs::PermissionsExt;
let mode = file.metadata.permissions.mode();
@@ -246,7 +247,7 @@ pub fn wprint_file_mode(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) {
ncurses::wattroff(win, ncurses::COLOR_PAIR(6));
}
-pub fn wprint_file_info(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) {
+pub fn wprint_file_info(win: ncurses::WINDOW, file: &JoshutoDirEntry) {
use std::os::unix::fs::PermissionsExt;
let mode = file.metadata.permissions.mode();
@@ -255,10 +256,10 @@ pub fn wprint_file_info(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) {
ncurses::waddstr(win, &mtime_string);
ncurses::waddch(win, ' ' as ncurses::chtype);
- if file.path.is_dir() {
+ if file.file_path().is_dir() {
let is_link: u32 = libc::S_IFLNK as u32;
if mode >> 9 & is_link >> 9 == mode >> 9 {
- if let Ok(path) = fs::read_link(&file.path) {
+ if let Ok(path) = fs::read_link(&file.file_path()) {
ncurses::waddstr(win, " -> ");
ncurses::waddstr(win, path.to_str().unwrap());
}
@@ -270,7 +271,7 @@ pub fn wprint_file_info(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) {
/*
ncurses::waddstr(win, " ");
- if let Some(s) = tree_magic::from_filepath(&file.path) {
+ if let Some(s) = tree_magic::from_filepath(&file.file_path()) {
ncurses::waddstr(win, &s);
}
*/
@@ -282,8 +283,7 @@ pub fn redraw_tab_view(win: &window::JoshutoPanel, context: &JoshutoContext) {
if tab_len == 1 {
} else if tab_len >= 6 {
ncurses::wmove(win.win, 0, 0);
- ncurses::wattron(win.win, ncurses::A_BOLD());
- ncurses::wattron(win.win, ncurses::A_STANDOUT());
+ ncurses::wattron(win.win, ncurses::A_BOLD() | ncurses::A_STANDOUT());
ncurses::waddstr(win.win, &format!("{}", context.curr_tab_index + 1));
ncurses::wattroff(win.win, ncurses::A_STANDOUT());
ncurses::waddstr(win.win, &format!(" {}", tab_len));
@@ -319,7 +319,7 @@ pub fn draw_progress_bar(win: &window::JoshutoPanel, percentage: f32) {
pub fn get_theme_attr(
mut attr: ncurses::attr_t,
- entry: &structs::JoshutoDirEntry,
+ entry: &JoshutoDirEntry,
) -> ((usize, &str), ncurses::attr_t, i16) {
use std::os::unix::fs::FileTypeExt;
use std::os::unix::fs::PermissionsExt;
@@ -328,7 +328,7 @@ pub fn get_theme_attr(
let colorpair: i16;
let file_type = &entry.metadata.file_type;
- if entry.selected {
+ if entry.is_selected() {
theme = &THEME_T.selection;
colorpair = THEME_T.selection.colorpair;
} else if file_type.is_dir() {
@@ -349,8 +349,8 @@ pub fn get_theme_attr(
if unix::is_executable(mode) {
theme = &THEME_T.executable;
colorpair = THEME_T.executable.colorpair;
- } else if let Some(ext) = entry.file_name.rfind('.') {
- let extension: &str = &entry.file_name[ext + 1..];
+ } else if let Some(ext) = entry.file_name().rfind('.') {
+ let extension: &str = &entry.file_name()[ext + 1..];
if let Some(s) = THEME_T.ext.get(extension) {
theme = &s;
colorpair = theme.colorpair;