diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-11-28 20:49:23 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-11-28 20:49:23 +0100 |
commit | 722ae6836ef6067805d03614c67ed80feb435267 (patch) | |
tree | f968baca2b6c8dc68191c99442a0916c3fb02c18 /src | |
parent | ddb96583a72dc8dd03e72fabaac629900e201fd1 (diff) |
renamed tab.selected into tab.current_file
Diffstat (limited to 'src')
-rw-r--r-- | src/app/status.rs | 12 | ||||
-rw-r--r-- | src/app/tab.rs | 12 | ||||
-rw-r--r-- | src/event/event_exec.rs | 10 | ||||
-rw-r--r-- | src/io/display.rs | 6 | ||||
-rw-r--r-- | src/modes/edit/line_display.rs | 2 | ||||
-rw-r--r-- | src/modes/edit/shell_parser.rs | 4 |
6 files changed, 25 insertions, 21 deletions
diff --git a/src/app/status.rs b/src/app/status.rs index 8b5ca28..7cbb105 100644 --- a/src/app/status.rs +++ b/src/app/status.rs @@ -163,7 +163,7 @@ impl Status { let tab = self.current_tab_non_mut(); if matches!(tab.edit_mode, Edit::Nothing) && !matches!(tab.display_mode, Display::Preview) { - let Ok(file) = tab.selected() else { + let Ok(file) = tab.current_file() else { return; }; self.menu.flagged.toggle(&file.path); @@ -436,7 +436,7 @@ impl Status { if self.current_tab_non_mut().path_content.is_empty() { return Ok(()); } - let Ok(file_info) = self.current_tab_non_mut().selected() else { + let Ok(file_info) = self.current_tab_non_mut().current_file() else { return Ok(()); }; match file_info.file_kind { @@ -488,7 +488,7 @@ impl Status { self.tabs[1].set_display_mode(Display::Preview); self.tabs[1].set_edit_mode(Edit::Nothing); let fileinfo = self.tabs[0] - .selected() + .current_file() .context("force preview: No file to select")?; let preview = match fileinfo.file_kind { FileKind::Directory => Preview::directory(&fileinfo, &self.tabs[0].users), @@ -525,7 +525,7 @@ impl Status { /// Open a the selected file with its opener pub fn open_selected_file(&mut self) -> Result<()> { - let path = self.current_tab_non_mut().selected()?.path; + let path = self.current_tab_non_mut().current_file()?.path; match self.opener.kind(&path) { Some(Kind::Internal(Internal::NotSupported)) => { let _ = self.mount_iso_drive(); @@ -545,7 +545,7 @@ impl Status { fn ensure_iso_device_is_some(&mut self) -> Result<()> { if self.menu.iso_device.is_none() { - let path = path_to_string(&self.current_tab_non_mut().selected()?.path); + let path = path_to_string(&self.current_tab_non_mut().current_file()?.path); self.menu.iso_device = Some(IsoDevice::from_path(path)); } Ok(()) @@ -936,7 +936,7 @@ impl Status { /// If the selected file is the root path (.) or its parent (..), /// it exits immediatly, doing nothing. pub fn rename(&mut self) -> Result<()> { - let selected = self.current_tab_non_mut().selected()?; + let selected = self.current_tab_non_mut().current_file()?; if selected.path == self.current_tab_non_mut().path_content.path { return Ok(()); } diff --git a/src/app/tab.rs b/src/app/tab.rs index 236201c..e978b99 100644 --- a/src/app/tab.rs +++ b/src/app/tab.rs @@ -158,7 +158,11 @@ impl Tab { /// Refresh the folder, reselect the last selected file, move the window to it. pub fn refresh_and_reselect_file(&mut self) -> Result<()> { - let selected_path = self.selected().context("no selected file")?.path.clone(); + let selected_path = self + .current_file() + .context("no selected file")? + .path + .clone(); self.refresh_view()?; match self.display_mode { Display::Preview => (), @@ -381,7 +385,7 @@ impl Tab { } /// Fileinfo of the selected element. - pub fn selected(&self) -> Result<FileInfo> { + pub fn current_file(&self) -> Result<FileInfo> { match self.display_mode { Display::Tree => { let node = self.tree.selected_node().context("no selected node")?; @@ -481,7 +485,7 @@ impl Tab { /// Copy the selected filename to the clipboard. Only the filename. pub fn filename_to_clipboard(&self) { - let Ok(file) = self.selected() else { + let Ok(file) = self.current_file() else { return; }; set_clipboard(file.filename.clone()) @@ -489,7 +493,7 @@ impl Tab { /// Copy the selected filepath to the clipboard. The absolute path. pub fn filepath_to_clipboard(&self) { - let Ok(file) = self.selected() else { + let Ok(file) = self.current_file() else { return; }; let Some(path_str) = file.path.to_str() else { diff --git a/src/event/event_exec.rs b/src/event/event_exec.rs index d5e834b..cea7d0a 100644 --- a/src/event/event_exec.rs +++ b/src/event/event_exec.rs @@ -306,7 +306,7 @@ impl EventAction { /// When we enter rename from a "tree" mode, we'll need to rename the selected file in the tree, /// not the selected file in the pathcontent. pub fn rename(status: &mut Status) -> Result<()> { - let selected = status.current_tab_non_mut().selected()?; + let selected = status.current_tab_non_mut().current_file()?; if selected.path == status.current_tab_non_mut().path_content.path { return Ok(()); } @@ -391,7 +391,7 @@ impl EventAction { }; let nvim_server = status.nvim_server.clone(); if status.menu.flagged.is_empty() { - let Ok(fileinfo) = status.current_tab_non_mut().selected() else { + let Ok(fileinfo) = status.current_tab_non_mut().current_file() else { return Ok(()); }; open_in_current_neovim(&fileinfo.path, &nvim_server); @@ -449,7 +449,7 @@ impl EventAction { log_line!("{DEFAULT_DRAGNDROP} must be installed."); return Ok(()); } - let Ok(file) = status.current_tab_non_mut().selected() else { + let Ok(file) = status.current_tab_non_mut().current_file() else { return Ok(()); }; let path_str = file @@ -832,7 +832,7 @@ impl EventAction { return Ok(()); } if let Display::Normal | Display::Tree = tab.display_mode { - let Ok(file_info) = tab.selected() else { + let Ok(file_info) = tab.current_file() else { return Ok(()); }; log_info!("selected {:?}", file_info); @@ -1420,7 +1420,7 @@ impl LeaveMode { /// Execute the selected node if it's a file else enter the directory. pub fn tree(status: &mut Status) -> Result<()> { - let path = status.current_tab_non_mut().selected()?.path; + let path = status.current_tab_non_mut().current_file()?.path; let is_dir = path.is_dir(); if is_dir { status.current_tab().cd(&path)?; diff --git a/src/io/display.rs b/src/io/display.rs index c8c3c88..51573ab 100644 --- a/src/io/display.rs +++ b/src/io/display.rs @@ -497,9 +497,9 @@ impl PreviewFirstLine { fn _pick_previewed_fileinfo(status: &Status) -> Result<FileInfo> { if status.settings.dual && status.settings.preview { - status.tabs[0].selected() + status.tabs[0].current_file() } else { - status.current_tab_non_mut().selected() + status.current_tab_non_mut().current_file() } } @@ -541,7 +541,7 @@ impl WinMainSecondLine { let (content, attr) = match tab.display_mode { DisplayMode::Normal | DisplayMode::Tree => { if !status.settings.metadata { - if let Ok(file) = tab.selected() { + if let Ok(file) = tab.current_file() { Self::second_line_detailed(&file) } else { (None, None) diff --git a/src/modes/edit/line_display.rs b/src/modes/edit/line_display.rs index 1800a13..b0e7952 100644 --- a/src/modes/edit/line_display.rs +++ b/src/modes/edit/line_display.rs @@ -55,7 +55,7 @@ impl LineDisplay for InputCompleted { completion_strings.push(completion.to_owned()); } if matches!(*self, Self::Exec) { - if let Ok(selected) = tab.selected() { + if let Ok(selected) = tab.current_file() { completion_strings.push(format!(" {}", selected.path.display())); } } diff --git a/src/modes/edit/shell_parser.rs b/src/modes/edit/shell_parser.rs index 27c7998..59130b5 100644 --- a/src/modes/edit/shell_parser.rs +++ b/src/modes/edit/shell_parser.rs @@ -102,7 +102,7 @@ impl ShellCommandParser { fn filename(status: &Status) -> Result<String> { Ok(status .current_tab_non_mut() - .selected() + .current_file() .context("Empty directory")? .filename) } @@ -110,7 +110,7 @@ impl ShellCommandParser { fn extension(status: &Status) -> Result<String> { Ok(status .current_tab_non_mut() - .selected() + .current_file() .context("Empty directory")? .extension) } |