summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config_files/fm/config.yaml5
-rw-r--r--development.md2
-rw-r--r--src/common/constant_strings_paths.rs6
-rw-r--r--src/config/keybindings.rs4
-rw-r--r--src/event/action_map.rs8
-rw-r--r--src/event/event_exec.rs27
-rw-r--r--src/io/display.rs3
-rw-r--r--src/io/mod.rs2
-rw-r--r--src/io/specific_commands.rs113
-rw-r--r--src/modes/display/preview.rs39
10 files changed, 4 insertions, 205 deletions
diff --git a/config_files/fm/config.yaml b/config_files/fm/config.yaml
index 1460c4d..45fdc6e 100644
--- a/config_files/fm/config.yaml
+++ b/config_files/fm/config.yaml
@@ -76,7 +76,6 @@ keys:
'v': ReverseFlags
'w': RegexMatch
'x': DeleteFile
- 'alt-d': DragNDrop
'alt-e': ToggleDisplayFull
'alt-f': ToggleDualPane
'alt-g': Goto
@@ -96,7 +95,6 @@ keys:
'shift-m': MarksNew
'shift-o': Sort
'shift-p': Preview
- 'shift-t': MediaInfo
# display settings
# All this settings are bound to keys an can be toggled in the application itself.
@@ -112,7 +110,7 @@ settings:
preview: false
# Custom command :
-# * Use an unused keybind
+# * Use a free keybind
# * Don't use pipe or redirection, it won't be parsed correctly
# * Use full path for the command : `/usr/bin/ls` not `ls`
# * You can use expansions :
@@ -127,3 +125,4 @@ settings:
custom:
# open the selected file with chrome
'alt-u': "/usr/bin/google-chrome-stable %s"
+ 'alt-d': "/usr/bin/dragon-drop %d"
diff --git a/development.md b/development.md
index 053d44f..b1ac812 100644
--- a/development.md
+++ b/development.md
@@ -680,7 +680,7 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [ ] opening a text file should try to open in current neovim (???)
- [ ] merge specific commands & cli_info
- [x] merge
- - [ ] remove specific commands
+ - [x] remove specific commands
- [ ] ensure diff only use first 2 files (???)
## TODO
diff --git a/src/common/constant_strings_paths.rs b/src/common/constant_strings_paths.rs
index 2091583..e131c42 100644
--- a/src/common/constant_strings_paths.rs
+++ b/src/common/constant_strings_paths.rs
@@ -16,8 +16,6 @@ pub const TRASH_FOLDER_FILES: &str = "~/.local/share/Trash/files";
pub const TRASH_FOLDER_INFO: &str = "~/.local/share/Trash/info";
/// Trash info files extension. Watchout it includes the final '.'
pub const TRASH_INFO_EXTENSION: &str = ".trashinfo";
-/// Log file path. Rotating file logs are created in the same directeroy
-pub const LOG_PATH: &str = "~/.config/fm/fm{}";
/// File where marks are stored.
pub const MARKS_FILEPATH: &str = "~/.config/fm/marks.cfg";
/// Temporary folder used when bulkrenaming files
@@ -42,8 +40,6 @@ pub const OPENER_DEFAULT: (&str, bool) = ("xdg-open", false);
pub const OPENER_VECT: (&str, bool) = ("inkscape", false);
/// Program used to open videos. Does it require a terminal ?
pub const OPENER_VIDEO: (&str, bool) = ("mpv", false);
-/// Default program used to drag and drop files
-pub const DEFAULT_DRAGNDROP: &str = "dragon-drop";
/// Array of text representation of a file permissions.
/// The index of each string gives a correct representation.
pub const PERMISSIONS_STR: [&str; 8] = ["---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"];
@@ -179,8 +175,6 @@ pub const CLI_INFO: [(&str, &str); 9] = [
("media tags ", "mediainfo %s"),
("diff 2 files ", "diff %f"),
];
-/// Wallpaper executable
-pub const NITROGEN: &str = "nitrogen";
/// Mediainfo (used to preview media files) executable
pub const MEDIAINFO: &str = "mediainfo";
/// ueberzug (used to preview images, videos & fonts)
diff --git a/src/config/keybindings.rs b/src/config/keybindings.rs
index 0bbc786..40e797e 100644
--- a/src/config/keybindings.rs
+++ b/src/config/keybindings.rs
@@ -59,7 +59,6 @@ impl Bindings {
(Key::Char(':'), ActionMap::Command),
(Key::Char('B'), ActionMap::Bulk),
(Key::Char('C'), ActionMap::Compress),
- (Key::Char('D'), ActionMap::Diff),
(Key::Char('E'), ActionMap::EncryptedDrive),
(Key::Char('F'), ActionMap::Filter),
(Key::Char('G'), ActionMap::End),
@@ -72,9 +71,7 @@ impl Bindings {
(Key::Char('O'), ActionMap::Sort),
(Key::Char('P'), ActionMap::Preview),
(Key::Char('S'), ActionMap::TuiMenu),
- (Key::Char('T'), ActionMap::MediaInfo),
(Key::Char('X'), ActionMap::TrashMoveFile),
- (Key::Char('W'), ActionMap::SetWallpaper),
(Key::Char('a'), ActionMap::ToggleHidden),
(Key::Char('c'), ActionMap::CopyPaste),
(Key::Char('d'), ActionMap::NewDir),
@@ -101,7 +98,6 @@ impl Bindings {
(Key::Char('z'), ActionMap::TreeFold),
(Key::Char('Z'), ActionMap::TreeUnFoldAll),
(Key::Alt('c'), ActionMap::OpenConfig),
- (Key::Alt('d'), ActionMap::DragNDrop),
(Key::Alt('e'), ActionMap::ToggleDisplayFull),
(Key::Alt('f'), ActionMap::ToggleDualPane),
(Key::Alt('g'), ActionMap::Goto),
diff --git a/src/event/action_map.rs b/src/event/action_map.rs
index 21870a9..32abdbb 100644
--- a/src/event/action_map.rs
+++ b/src/event/action_map.rs
@@ -27,8 +27,6 @@ pub enum ActionMap {
CutPaste,
Delete,
DeleteFile,
- Diff,
- DragNDrop,
Ncdu,
EncryptedDrive,
End,
@@ -51,7 +49,6 @@ pub enum ActionMap {
Log,
MarksJump,
MarksNew,
- MediaInfo,
MocpAddToPlayList,
MocpClearPlaylist,
MocpGoToSong,
@@ -83,7 +80,6 @@ pub enum ActionMap {
ReverseFlags,
Search,
SearchNext,
- SetWallpaper,
Shell,
ShellCommand,
TuiMenu,
@@ -128,8 +124,6 @@ impl ActionMap {
Self::CutPaste => EventAction::cut_paste(status),
Self::Delete => EventAction::delete(status),
Self::DeleteFile => EventAction::delete_file(status),
- Self::Diff => EventAction::diff(status),
- Self::DragNDrop => EventAction::drag_n_drop(status),
Self::Ncdu => EventAction::ncdu(status),
Self::EncryptedDrive => EventAction::encrypted_drive(status),
Self::End => EventAction::end(status),
@@ -152,7 +146,6 @@ impl ActionMap {
Self::LazyGit => EventAction::lazygit(status),
Self::MarksJump => EventAction::marks_jump(status),
Self::MarksNew => EventAction::marks_new(current_tab),
- Self::MediaInfo => EventAction::mediainfo(current_tab),
Self::MocpAddToPlayList => EventAction::mocp_add_to_playlist(current_tab),
Self::MocpClearPlaylist => EventAction::mocp_clear_playlist(),
Self::MocpGoToSong => EventAction::mocp_go_to_song(status),
@@ -183,7 +176,6 @@ impl ActionMap {
Self::ReverseFlags => EventAction::reverse_flags(status),
Self::Search => EventAction::search(current_tab),
Self::SearchNext => EventAction::search_next(status),
- Self::SetWallpaper => EventAction::set_wallpaper(current_tab),
Self::Shell => EventAction::shell(status),
Self::ShellCommand => EventAction::shell_command(current_tab),
Self::Shortcut => EventAction::shortcut(status),
diff --git a/src/event/event_exec.rs b/src/event/event_exec.rs
index 6d26d52..85eece3 100644
--- a/src/event/event_exec.rs
+++ b/src/event/event_exec.rs
@@ -13,7 +13,6 @@ use crate::config::Bindings;
use crate::config::START_FOLDER;
use crate::io::execute_without_output_with_path;
use crate::io::read_log;
-use crate::io::SpecificCommand;
use crate::log_info;
use crate::log_line;
use crate::modes::help_string;
@@ -830,32 +829,6 @@ impl EventAction {
Ok(())
}
- /// Executes a `dragon-drop` command on the selected file.
- /// It obviously requires the `dragon-drop` command to be installed.
- pub fn drag_n_drop(status: &mut Status) -> Result<()> {
- SpecificCommand::drag_n_drop(status);
- Ok(())
- }
-
- /// Set the current selected file as wallpaper with `nitrogen`.
- /// Requires `nitrogen` to be installed.
- pub fn set_wallpaper(tab: &Tab) -> Result<()> {
- SpecificCommand::set_wallpaper(tab);
- Ok(())
- }
-
- /// Display mediainfo details of an image
- pub fn mediainfo(tab: &mut Tab) -> Result<()> {
- SpecificCommand::mediainfo(tab);
- Ok(())
- }
-
- /// Display a diff between the first 2 flagged files or dir.
- pub fn diff(status: &mut Status) -> Result<()> {
- SpecificCommand::diff(status);
- Ok(())
- }
-
/// Move flagged files to the trash directory.
/// If no file is flagged, flag the selected file.
/// More information in the trash crate itself.
diff --git a/src/io/display.rs b/src/io/display.rs
index c07a4d7..9ff57bb 100644
--- a/src/io/display.rs
+++ b/src/io/display.rs
@@ -390,9 +390,6 @@ impl<'a> WinMain<'a> {
Preview::Text(text) => {
impl_preview!(text, tab, length, canvas, line_number_width, window, height)
}
- Preview::Diff(text) => {
- impl_preview!(text, tab, length, canvas, line_number_width, window, height)
- }
Preview::Iso(text) => {
impl_preview!(text, tab, length, canvas, line_number_width, window, height)
}
diff --git a/src/io/mod.rs b/src/io/mod.rs
index eae5e1a..8c2d2ce 100644
--- a/src/io/mod.rs
+++ b/src/io/mod.rs
@@ -4,7 +4,6 @@ mod display;
mod git;
mod log;
mod opener;
-mod specific_commands;
pub use args::Args;
pub use commands::*;
@@ -12,4 +11,3 @@ pub use display::{Display, MIN_WIDTH_FOR_DUAL_PANE};
pub use git::{git, git_root};
pub use log::{read_last_log_line, read_log, set_loggers, write_log_info_once, write_log_line};
pub use opener::*;
-pub use specific_commands::*;
diff --git a/src/io/specific_commands.rs b/src/io/specific_commands.rs
deleted file mode 100644
index ce704b6..0000000
--- a/src/io/specific_commands.rs
+++ /dev/null
@@ -1,113 +0,0 @@
-use crate::app::Status;
-use crate::app::Tab;
-use crate::common::is_program_in_path;
-use crate::common::DEFAULT_DRAGNDROP;
-use crate::common::DIFF;
-use crate::common::MEDIAINFO;
-use crate::common::NITROGEN;
-use crate::io::execute;
-use crate::log_info;
-use crate::log_line;
-use crate::modes::Display;
-use crate::modes::ExtensionKind;
-use crate::modes::Preview;
-use crate::modes::SelectableContent;
-
-/// Bunch of commands which check :
-/// 1. if a program is accessible from path
-/// 2. find the selected file or group of files
-/// 3. run the program with those arguments.
-/// 4. eventually set the status & tab to display the output
-///
-/// Those commands must
-/// 1. be infaillible,
-/// 2. take only a single reference to `Status` or `Tab`,
-/// 3. returns `(())`
-/// If they can't get the expected result, they must return early, doing nothing.
-pub struct SpecificCommand {}
-
-impl SpecificCommand {
- /// Display mediainfo details of an image
- pub fn mediainfo(tab: &mut Tab) {
- if !matches!(tab.display_mode, Display::Tree | Display::Directory) {
- return;
- }
- if !is_program_in_path(MEDIAINFO) {
- log_line!("{} isn't installed", MEDIAINFO);
- return;
- }
- let Ok(file_info) = tab.current_file() else {
- return;
- };
- log_info!("selected {:?}", file_info);
- let Ok(preview) = Preview::mediainfo(&file_info.path) else {
- return;
- };
- tab.preview = preview;
- tab.window.reset(tab.preview.len());
- tab.set_display_mode(Display::Preview);
- }
-
- /// Display a diff between the first 2 flagged files or dir.
- pub fn diff(status: &mut Status) {
- if !matches!(
- status.current_tab().display_mode,
- Display::Tree | Display::Directory
- ) {
- return;
- }
- if status.menu.flagged.len() < 2 {
- return;
- };
- if !is_program_in_path(DIFF) {
- log_line!("{DIFF} isn't installed");
- return;
- }
- let Some(first_path) = &status.menu.flagged.content[0].to_str() else {
- return;
- };
- let Some(second_path) = &status.menu.flagged.content[1].to_str() else {
- return;
- };
- let Ok(preview) = Preview::diff(first_path, second_path) else {
- return;
- };
- let tab = status.current_tab_mut();
- tab.preview = preview;
- tab.window.reset(tab.preview.len());
- tab.set_display_mode(Display::Preview);
- }
-
- /// Set the current selected file as wallpaper with `nitrogen`.
- /// Requires `nitrogen` to be installed.
- pub fn set_wallpaper(tab: &Tab) {
- if !is_program_in_path(NITROGEN) {
- log_line!("nitrogen must be installed");
- return;
- }
- let Ok(fileinfo) = tab.current_file() else {
- return;
- };
- if !ExtensionKind::matcher(&fileinfo.extension).is(ExtensionKind::Image) {
- return;
- }
- let Ok(path_str) = tab.current_file_string() else {
- return;
- };
- let _ = execute(NITROGEN, &["--set-zoom-fill", "--save", &path_str]);
- }
-
- /// Executes a `dragon-drop` command on the selected file.
- /// It obviously requires the `dragon-drop` command to be installed.
- pub fn drag_n_drop(status: &mut Status) {
- if !is_program_in_path(DEFAULT_DRAGNDROP) {
- log_line!("{DEFAULT_DRAGNDROP} must be installed.");
- return;
- }
- let Ok(path_str) = status.current_tab().current_file_string() else {
- return;
- };
-
- let _ = execute(DEFAULT_DRAGNDROP, &[&path_str]);
- }
-}
diff --git a/src/modes/display/preview.rs b/src/modes/display/preview.rs
index 6aa8431..c374c22 100644
--- a/src/modes/display/preview.rs
+++ b/src/modes/display/preview.rs
@@ -15,7 +15,7 @@ use syntect::parsing::{SyntaxReference, SyntaxSet};
use tuikit::attr::{Attr, Color};
use crate::common::{
- CALC_PDF_PATH, DIFF, FFMPEG, FONTIMAGE, ISOINFO, JUPYTER, LIBREOFFICE, LSBLK, LSOF, MEDIAINFO,
+ CALC_PDF_PATH, FFMPEG, FONTIMAGE, ISOINFO, JUPYTER, LIBREOFFICE, LSBLK, LSOF, MEDIAINFO,
PANDOC, RSVG_CONVERT, SS, THUMBNAIL_PATH, UEBERZUG,
};
use crate::log_info;
@@ -99,7 +99,6 @@ pub enum Preview {
Media(MediaContent),
Tree(TreePreview),
Iso(Iso),
- Diff(Diff),
ColoredText(ColoredText),
Socket(Socket),
BlockDevice(BlockDevice),
@@ -271,15 +270,6 @@ impl Preview {
&& inspect(buffer) == ContentType::BINARY
}
- /// Returns mediainfo of a media file.
- pub fn mediainfo(path: &Path) -> Result<Self> {
- Ok(Self::Media(MediaContent::new(path)?))
- }
-
- pub fn diff(first_path: &str, second_path: &str) -> Result<Self> {
- Ok(Self::Diff(Diff::new(first_path, second_path)?))
- }
-
/// Creates the help preview as if it was a text file.
pub fn help(help: &str) -> Self {
Self::Text(TextContent::help(help))
@@ -311,7 +301,6 @@ impl Preview {
Self::Ueberzug(ueberzug) => ueberzug.len(),
Self::Media(media) => media.len(),
Self::Tree(directory) => directory.len(),
- Self::Diff(diff) => diff.len(),
Self::Iso(iso) => iso.len(),
Self::ColoredText(text) => text.len(),
Self::Socket(socket) => socket.len(),
@@ -1072,31 +1061,6 @@ impl TreePreview {
}
}
-pub struct Diff {
- pub content: Vec<String>,
- length: usize,
-}
-
-impl Diff {
- pub fn new(first_path: &str, second_path: &str) -> Result<Self> {
- let content: Vec<String> =
- execute_and_capture_output_without_check(DIFF, &[first_path, second_path])?
- .lines()
- .map(|s| s.to_owned())
- .collect();
- log_info!("{DIFF}:\n{content:?}");
-
- Ok(Self {
- length: content.len(),
- content,
- })
- }
-
- fn len(&self) -> usize {
- self.length
- }
-}
-
pub struct Iso {
pub content: Vec<String>,
length: usize,
@@ -1193,7 +1157,6 @@ impl_window!(BinaryContent, Line);
impl_window!(ArchiveContent, String);
impl_window!(MediaContent, String);
impl_window!(TreePreview, ColoredTriplet);
-impl_window!(Diff, String);
impl_window!(Iso, String);
impl_window!(ColoredText, String);
impl_window!(Socket, String);