summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/commands/change_directory.rs2
-rw-r--r--src/commands/mod.rs6
-rw-r--r--src/commands/open_file.rs2
-rw-r--r--src/commands/parent_directory.rs2
-rw-r--r--src/commands/reload_dir.rs4
-rw-r--r--src/commands/selection.rs26
-rw-r--r--src/config/keymap.rs2
-rw-r--r--src/history.rs2
-rw-r--r--src/io/dirlist.rs8
-rw-r--r--src/run.rs6
-rw-r--r--src/textfield.rs6
11 files changed, 34 insertions, 32 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs
index 5109935..6a63e7c 100644
--- a/src/commands/change_directory.rs
+++ b/src/commands/change_directory.rs
@@ -42,7 +42,7 @@ impl ChangeDirectory {
std::mem::swap(&mut curr_tab.curr_list, &mut new_curr_list);
curr_tab
.history
- .insert(new_curr_list.path.clone(), new_curr_list);
+ .insert(new_curr_list.file_path().clone(), new_curr_list);
curr_tab.refresh(view, &context.config_t);
Ok(())
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index e8d165f..93606d3 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -75,7 +75,7 @@ pub struct ProgressInfo {
pub total_bytes: u64,
}
-pub fn from_args(command: &str, args: &Vec<&str>) -> Result<Box<JoshutoCommand>, KeymapError> {
+pub fn from_args(command: &str, args: &[&str]) -> Result<Box<JoshutoCommand>, KeymapError> {
match command {
"cd" => match args.len() {
0 => match HOME_DIR.as_ref() {
@@ -140,13 +140,13 @@ pub fn from_args(command: &str, args: &Vec<&str>) -> Result<Box<JoshutoCommand>,
"delete_files" => Ok(Box::new(self::DeleteFiles::new())),
"force_quit" => Ok(Box::new(self::ForceQuit::new())),
"mkdir" => {
- if args.len() == 0 {
+ if args.is_empty() {
Err(KeymapError::new(
Some("mkdir"),
String::from("mkdir requires additional parameter"),
))
} else {
- let paths: Vec<PathBuf> = args.iter().map(|s| PathBuf::from(s)).collect();
+ let paths: Vec<PathBuf> = args.iter().map(PathBuf::from).collect();
Ok(Box::new(self::NewDirectory::new(paths)))
}
}
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index b733255..57d2892 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -91,7 +91,7 @@ impl OpenFile {
std::mem::swap(&mut curr_tab.curr_list, &mut new_curr_list);
curr_tab
.history
- .insert(new_curr_list.path.clone(), new_curr_list);
+ .insert(new_curr_list.file_path().clone(), new_curr_list);
curr_tab.curr_path = path.to_path_buf().clone();
Ok(())
diff --git a/src/commands/parent_directory.rs b/src/commands/parent_directory.rs
index 50de924..abafc21 100644
--- a/src/commands/parent_directory.rs
+++ b/src/commands/parent_directory.rs
@@ -32,7 +32,7 @@ impl ParentDirectory {
std::mem::swap(&mut curr_tab.curr_list, &mut new_curr_list);
curr_tab
.history
- .insert(new_curr_list.path.clone(), new_curr_list);
+ .insert(new_curr_list.file_path().clone(), new_curr_list);
curr_tab.refresh(view, &context.config_t);
ncurses::doupdate();
diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs
index b36878d..0584125 100644
--- a/src/commands/reload_dir.rs
+++ b/src/commands/reload_dir.rs
@@ -21,14 +21,12 @@ impl ReloadDirList {
let curr_tab = &mut context.tabs[index];
let sort_option = &context.config_t.sort_option;
curr_tab.curr_list.update_contents(sort_option)?;
- curr_tab.curr_list.outdated = false;
- if let Some(parent) = curr_tab.curr_list.path.parent() {
+ 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.update_contents(sort_option)?;
- dirlist.outdated = false;
}
Entry::Vacant(entry) => {
let s = JoshutoDirList::new(parent.to_path_buf().clone(), sort_option)?;
diff --git a/src/commands/selection.rs b/src/commands/selection.rs
index 4064faa..99d97a6 100644
--- a/src/commands/selection.rs
+++ b/src/commands/selection.rs
@@ -45,7 +45,7 @@ impl JoshutoRunnable for SelectFiles {
let curr_list = &mut curr_tab.curr_list;
if let Some(s) = curr_list.get_curr_mut() {
s.set_selected(!s.is_selected());
- return CursorMoveDown::new(1).execute(context, view);
+ CursorMoveDown::new(1).execute(context, view)?;
}
} else {
let curr_list = &mut curr_tab.curr_list;
@@ -55,21 +55,19 @@ impl JoshutoRunnable for SelectFiles {
curr_tab.refresh_curr(&view.mid_win, &context.config_t);
ncurses::doupdate();
}
+ } else if !self.all {
+ let curr_list = &mut curr_tab.curr_list;
+ if let Some(s) = curr_list.get_curr_mut() {
+ s.set_selected(true);
+ CursorMoveDown::new(1).execute(context, view)?;
+ }
} else {
- if !self.all {
- let curr_list = &mut curr_tab.curr_list;
- if let Some(s) = curr_list.get_curr_mut() {
- 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.set_selected(true);
- }
- curr_tab.refresh_curr(&view.mid_win, &context.config_t);
- ncurses::doupdate();
+ let curr_list = &mut curr_tab.curr_list;
+ for curr in &mut curr_list.contents {
+ curr.set_selected(true);
}
+ curr_tab.refresh_curr(&view.mid_win, &context.config_t);
+ ncurses::doupdate();
}
Ok(())
}
diff --git a/src/config/keymap.rs b/src/config/keymap.rs
index 4496bf3..7bce940 100644
--- a/src/config/keymap.rs
+++ b/src/config/keymap.rs
@@ -145,7 +145,7 @@ impl Flattenable<JoshutoCommandMapping> for JoshutoRawCommandMapping {
fn flatten(self) -> JoshutoCommandMapping {
let mut keymaps = JoshutoCommandMapping::new();
self.mapcommand.iter().for_each(|m| {
- let args: Vec<&str> = m.args.iter().map(|s| s.as_str()).collect();
+ let args: Vec<&str> = m.args.iter().map(String::as_str).collect();
match commands::from_args(m.command.as_str(), &args) {
Ok(command) => insert_keycommand(&mut keymaps, command, &m.keys[..]),
Err(e) => eprintln!("{}", e),
diff --git a/src/history.rs b/src/history.rs
index 38974d1..df8e458 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -60,7 +60,7 @@ impl DirectoryHistory for JoshutoHistory {
if dirlist.need_update() {
dirlist.update_contents(&sort_option)?
} else {
- let metadata = std::fs::symlink_metadata(&dirlist.path)?;
+ let metadata = std::fs::symlink_metadata(dirlist.file_path())?;
let modified = metadata.modified()?;
if modified > dirlist.metadata.modified {
diff --git a/src/io/dirlist.rs b/src/io/dirlist.rs
index 8ed8939..0ecd333 100644
--- a/src/io/dirlist.rs
+++ b/src/io/dirlist.rs
@@ -7,8 +7,8 @@ use crate::window::JoshutoPageState;
#[derive(Debug)]
pub struct JoshutoDirList {
pub index: Option<usize>,
- pub path: path::PathBuf,
- pub outdated: bool,
+ path: path::PathBuf,
+ outdated: bool,
pub metadata: JoshutoMetadata,
pub contents: Vec<JoshutoDirEntry>,
pub pagestate: JoshutoPageState,
@@ -45,6 +45,10 @@ impl JoshutoDirList {
self.outdated
}
+ pub fn file_path(&self) -> &path::PathBuf {
+ &self.path
+ }
+
pub fn update_contents(
&mut self,
sort_option: &sort::SortOption,
diff --git a/src/run.rs b/src/run.rs
index 83634f0..4d09092 100644
--- a/src/run.rs
+++ b/src/run.rs
@@ -10,7 +10,7 @@ use crate::ui;
use crate::window::JoshutoPanel;
use crate::window::JoshutoView;
-fn recurse_get_keycommand(keymap: &JoshutoCommandMapping) -> Option<&Box<JoshutoCommand>> {
+fn recurse_get_keycommand(keymap: &JoshutoCommandMapping) -> Option<&JoshutoCommand> {
let (term_rows, term_cols) = ui::getmaxyx();
ncurses::timeout(-1);
@@ -41,7 +41,7 @@ fn recurse_get_keycommand(keymap: &JoshutoCommandMapping) -> Option<&Box<Joshuto
} else {
match keymap.get(&ch) {
Some(CommandKeybind::CompositeKeybind(m)) => recurse_get_keycommand(&m),
- Some(CommandKeybind::SimpleKeybind(s)) => Some(s),
+ Some(CommandKeybind::SimpleKeybind(s)) => Some(s.as_ref()),
_ => None,
}
}
@@ -183,7 +183,7 @@ pub fn run(config_t: JoshutoConfig, keymap_t: JoshutoCommandMapping) {
None => continue,
},
Some(CommandKeybind::SimpleKeybind(s)) => {
- keycommand = s;
+ keycommand = s.as_ref();
}
None => {
ui::wprint_err(&view.bot_win, &format!("Unknown keycode: {}", ch));
diff --git a/src/textfield.rs b/src/textfield.rs
index ba20176..e521f3c 100644
--- a/src/textfield.rs
+++ b/src/textfield.rs
@@ -1,6 +1,8 @@
use crate::window;
use crate::KEYMAP_T;
+use std::unimplemented;
+
use rustyline::completion::{Candidate, Completer, FilenameCompleter, Pair};
use rustyline::line_buffer;
@@ -156,9 +158,9 @@ impl<'a> JoshutoTextField<'a> {
&line_buffer.as_str()[..line_buffer.pos()],
);
} else if ch == KEYMAP_T.up {
- completion_tracker.take();
+ unimplemented!();
} else if ch == KEYMAP_T.down {
- completion_tracker.take();
+ unimplemented!();
} else if let Some(ch) = std::char::from_u32(ch as u32) {
if line_buffer.insert(ch, 1).is_some() {
curr_pos += unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1);