summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-28 21:37:35 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-28 21:37:35 -0400
commit8867e4e11d2649cb8459c792fa4b316bb5e97647 (patch)
treedbbc2ba745adda04903d35042871f3e36795c692
parent3a5deb92d5c0dd519146e2fd66f06255842660a3 (diff)
cargo fmt
-rw-r--r--src/commands/cursor_move.rs5
-rw-r--r--src/fs/entry.rs5
-rw-r--r--src/history.rs12
-rw-r--r--src/tab.rs6
-rw-r--r--src/ui.rs2
5 files changed, 17 insertions, 13 deletions
diff --git a/src/commands/cursor_move.rs b/src/commands/cursor_move.rs
index 2409a9e..f401703 100644
--- a/src/commands/cursor_move.rs
+++ b/src/commands/cursor_move.rs
@@ -22,10 +22,7 @@ pub fn cursor_move(mut new_index: usize, context: &mut JoshutoContext, view: &Jo
}
}
- curr_tab.refresh_curr(&view.mid_win, &context.config_t);
- curr_tab.refresh_path_status(&view.top_win, context.config_t.tilde_in_titlebar);
- curr_tab.refresh_file_status(&view.bot_win);
- curr_tab.refresh_preview(&view.right_win, &context.config_t);
+ curr_tab.refresh(&view, &context.config_t);
ncurses::doupdate();
}
diff --git a/src/fs/entry.rs b/src/fs/entry.rs
index d88c0a5..a4e2672 100644
--- a/src/fs/entry.rs
+++ b/src/fs/entry.rs
@@ -26,14 +26,13 @@ impl JoshutoDirEntry {
let path = direntry.path();
let metadata = JoshutoMetadata::from(&path)?;
- let dir_entry = JoshutoDirEntry {
+ Ok(JoshutoDirEntry {
name,
path,
metadata,
selected: false,
marked: false,
- };
- Ok(dir_entry)
+ })
}
pub fn file_name(&self) -> &str {
diff --git a/src/history.rs b/src/history.rs
index 3dc6687..5ae8ee2 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -5,7 +5,11 @@ use crate::fs::JoshutoDirList;
use crate::sort;
pub trait DirectoryHistory {
- fn populate_to_root(&mut self, pathbuf: &PathBuf, sort_option: &sort::SortOption) -> std::io::Result<()>;
+ fn populate_to_root(
+ &mut self,
+ pathbuf: &PathBuf,
+ sort_option: &sort::SortOption,
+ ) -> std::io::Result<()>;
fn pop_or_create(
&mut self,
path: &Path,
@@ -22,7 +26,11 @@ pub trait DirectoryHistory {
pub type JoshutoHistory = HashMap<PathBuf, JoshutoDirList>;
impl DirectoryHistory for JoshutoHistory {
- fn populate_to_root(&mut self, pathbuf: &PathBuf, sort_option: &sort::SortOption) -> std::io::Result<()> {
+ fn populate_to_root(
+ &mut self,
+ pathbuf: &PathBuf,
+ sort_option: &sort::SortOption,
+ ) -> std::io::Result<()> {
let mut ancestors = pathbuf.ancestors();
match ancestors.next() {
None => {}
diff --git a/src/tab.rs b/src/tab.rs
index 9f57ab3..9c7cafc 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -39,7 +39,7 @@ impl JoshutoTab {
if config_t.show_preview {
self.refresh_preview(&views.right_win, config_t);
}
- self.refresh_path_status(&views.top_win, config_t.tilde_in_titlebar);
+ self.refresh_path_status(&views.top_win, config_t);
self.refresh_file_status(&views.bot_win);
}
@@ -70,7 +70,7 @@ impl JoshutoTab {
}
}
- pub fn refresh_path_status(&self, win: &JoshutoPanel, tilde_in_titlebar: bool) {
+ pub fn refresh_path_status(&self, win: &JoshutoPanel, config_t: &JoshutoConfig) {
let path_str: &str = self.curr_path.to_str().unwrap();
ncurses::werase(win.win);
@@ -83,7 +83,7 @@ impl JoshutoTab {
ncurses::wattron(win.win, ncurses::COLOR_PAIR(THEME_T.directory.colorpair));
/* shorten $HOME to ~/ */
- if tilde_in_titlebar {
+ if config_t.tilde_in_titlebar {
if let Some(s) = (*HOME_DIR).as_ref() {
if let Some(s) = s.as_os_str().to_str() {
let path_str = &path_str.replace(s, "~");
diff --git a/src/ui.rs b/src/ui.rs
index 578be47..fe21378 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -250,7 +250,7 @@ pub fn wprint_file_status(
wprint_file_mode(win.win, entry);
ncurses::waddch(win.win, ' ' as ncurses::chtype);
- ncurses::waddstr(win.win, format!("{}/{} ", index + 1, len).as_str());
+ ncurses::waddstr(win.win, &format!("{}/{} ", index + 1, len));
let usercache: UsersCache = UsersCache::new();
match usercache.get_user_by_uid(entry.metadata.uid) {