summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qkzk@users.noreply.github.com>2024-01-10 20:37:07 +0100
committerGitHub <noreply@github.com>2024-01-10 20:37:07 +0100
commit0c669840cac86bdf59074d643d56a6ff3554c3cd (patch)
treee27577b68401036af6f12418d4381d9f232fd99d
parent1df94a5fe4fb781b6d207bc35759348b3d8ad86a (diff)
parentfa7fae1fbd318988f75d97a45d49a5228254007b (diff)
Merge pull request #87 from qkzk/v0.1.25-devv0.1.25
V0.1.25 dev
-rw-r--r--Cargo.lock6
-rw-r--r--Cargo.toml4
-rw-r--r--config_files/fm/cli.yaml38
-rw-r--r--config_files/fm/config.yaml46
-rw-r--r--config_files/fm/tuis.yaml10
-rw-r--r--development.md214
-rw-r--r--readme.md38
-rw-r--r--src/app/application.rs135
-rw-r--r--src/app/displayer.rs54
-rw-r--r--src/app/header_footer.rs181
-rw-r--r--src/app/mod.rs4
-rw-r--r--src/app/status.rs362
-rw-r--r--src/app/tab.rs196
-rw-r--r--src/common/constant_strings_paths.rs39
-rw-r--r--src/common/utils.rs62
-rw-r--r--src/config/configuration.rs103
-rw-r--r--src/config/keybindings.rs8
-rw-r--r--src/config/mod.rs2
-rw-r--r--src/event/action_map.rs54
-rw-r--r--src/event/event_dispatch.rs7
-rw-r--r--src/event/event_exec.rs584
-rw-r--r--src/event/event_poller.rs7
-rw-r--r--src/io/args.rs4
-rw-r--r--src/io/commands.rs45
-rw-r--r--src/io/display.rs447
-rw-r--r--src/io/log.rs27
-rw-r--r--src/io/mod.rs2
-rw-r--r--src/io/opener.rs33
-rw-r--r--src/main.rs14
-rw-r--r--src/modes/display/content_window.rs2
-rw-r--r--src/modes/display/directory.rs34
-rw-r--r--src/modes/display/fileinfo.rs77
-rw-r--r--src/modes/display/mod.rs2
-rw-r--r--src/modes/display/preview.rs28
-rw-r--r--src/modes/display/tree.rs391
-rw-r--r--src/modes/edit/bulkrename.rs246
-rw-r--r--src/modes/edit/cli_menu.rs124
-rw-r--r--src/modes/edit/completion.rs40
-rw-r--r--src/modes/edit/compress.rs9
-rw-r--r--src/modes/edit/context.rs7
-rw-r--r--src/modes/edit/copy_move.rs12
-rw-r--r--src/modes/edit/cryptsetup.rs8
-rw-r--r--src/modes/edit/flagged.rs158
-rw-r--r--src/modes/edit/help.rs23
-rw-r--r--src/modes/edit/history.rs7
-rw-r--r--src/modes/edit/leave_mode.rs263
-rw-r--r--src/modes/edit/line_display.rs4
-rw-r--r--src/modes/edit/marks.rs29
-rw-r--r--src/modes/edit/menu.rs254
-rw-r--r--src/modes/edit/mod.rs7
-rw-r--r--src/modes/edit/mount_help.rs8
-rw-r--r--src/modes/edit/permissions.rs1
-rw-r--r--src/modes/edit/regex.rs4
-rw-r--r--src/modes/edit/removable_devices.rs23
-rw-r--r--src/modes/edit/second_line.rs71
-rw-r--r--src/modes/edit/selectable_content.rs73
-rw-r--r--src/modes/edit/shortcut.rs23
-rw-r--r--src/modes/edit/trash.rs58
-rw-r--r--src/modes/edit/tui_menu.rs153
-rw-r--r--src/modes/mod.rs2
-rw-r--r--src/modes/mode.rs91
61 files changed, 3401 insertions, 1557 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c087f56..be79440 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -797,7 +797,7 @@ dependencies = [
[[package]]
name = "fm-tui"
-version = "0.1.24"
+version = "0.1.25"
dependencies = [
"anyhow",
"cairo-rs",
@@ -2174,9 +2174,9 @@ dependencies = [
[[package]]
name = "skim-qkzk"
-version = "0.9.12"
+version = "0.9.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca4c3bcd3a72b5925fa30dae1e8ac51f8cf02f94c3dcb63e7f6136023c403374"
+checksum = "960c890424e7df1058598aa89e0e8d3fb6ccc57421d315aa6b667bd287ff17c7"
dependencies = [
"atty",
"beef",
diff --git a/Cargo.toml b/Cargo.toml
index 91291f4..89a8fbb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "fm-tui"
-version = "0.1.24"
+version = "0.1.25"
authors = ["Quentin Konieczko <qu3nt1n@gmail.com>"]
edition = "2021"
license-file = "LICENSE.txt"
@@ -52,7 +52,7 @@ sanitize-filename = "0.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9.13"
shellexpand = "2.1.2"
-skim-qkzk = "0.9.12"
+skim-qkzk = "0.9.14"
strfmt = "0.2.2"
strum = {version = "0.24.1", features = ["derive"]}
strum_macros = "0.24.3"
diff --git a/config_files/fm/cli.yaml b/config_files/fm/cli.yaml
new file mode 100644
index 0000000..3be00f0
--- /dev/null
+++ b/config_files/fm/cli.yaml
@@ -0,0 +1,38 @@
+# A list of commands which output a displayble text.
+# No interaction with the user is provided.
+# When the user picks a command, it will be run and its output displayed in Preview mode.
+#
+# Don't use space in the description, use `_` instead.
+# Don't use a sudo command as it's not possible to ask for a password (yet ?).
+#
+# Some basic shell expansion are made :
+# - %s: the full path of the currently selected file or folder,
+# - %f: the list of the full paths of the flagged files.
+# - %e: the extension of the file.
+# - %n: the filename only.
+# - %p: the full path of the current directory.
+#
+# Example :
+#
+#
+# drag_and_drop:
+# command: "dragon-drop %s"
+#
+drag_and_drop:
+ command: "dragon-drop %s"
+set_wallpaper:
+ command: "nitrogen --set-zoom-fill --save %s"
+man_page:
+ command: "man %s"
+space_used:
+ command: "duf"
+full_system_info:
+ command: "inxi -S -I -D -i -J -M --color"
+simple_system_info:
+ command: "neofetch"
+list_usb:
+ command: "lsusb"
+media_tags:
+ command: "mediainfo %s"
+diff_2_files:
+ command: "diff %f"
diff --git a/config_files/fm/config.yaml b/config_files/fm/config.yaml
index 8560b1c..0f41ead 100644
--- a/config_files/fm/config.yaml
+++ b/config_files/fm/config.yaml
@@ -28,6 +28,22 @@ colors:
symlink: magenta
broken: light_magenta
+# Colors for menus, headers, footers etc.
+menu_colors:
+ # first color
+ first: rgb(45, 250, 209)
+ # second color
+ second: rgb(230, 189, 87)
+ # selected tab border
+ selected_border: rgb(45, 250, 209)
+ # non selected tab border
+ inert_border: rgb(120, 120, 120)
+ # palette of 4 elements, used in menus (second window) and header
+ palette_1: rgb(45, 250, 209)
+ palette_2: rgb(230, 189, 87)
+ palette_3: rgb(230, 167, 255)
+ palette_4: rgb(59, 204, 255)
+
# keybindings
#
# You can bind any key to any action.
@@ -79,7 +95,7 @@ keys:
'alt-d': ToggleDualPane
'alt-e': EncryptedDrive
'alt-f': Filter
- 'alt-g': Goto
+ 'alt-g': Cd
'alt-m': Chmod
'alt-p': TogglePreviewSecond
'ctrl-c': CopyFilename
@@ -114,4 +130,30 @@ custom:
'alt-u': "/usr/bin/google-chrome-stable %s"
'shift-d': "/usr/bin/dragon-drop %s"
-
+# DO NOT EDIT UNLESS YOU WANT TO ADD AN UNKNOWN TERMINAL EMULATOR
+#
+# The flag is used to open a terminal application (TUI, CLI etc.) like bat or htop.
+# We need to execute the terminal itself and pass it a new command as an argument
+# It requires a flag which is often, but not always "-e".
+# See the documentation of your emulator and add the correct argument like below.
+terminal_emulator_flags:
+ alacritty: "-e"
+ st: "-e"
+ terminology: "-e"
+ kitty: "--"
+ sakura: "-e"
+ lilyterm: "-e"
+ coo: "-r"
+ termite: "-x"
+ yakuake: "-e"
+ guake: "-n"
+ tilda: "-c"
+ terminator: "-x"
+ urxvt: "-e"
+ pantheo: "-t"
+ lxterminal: "-e"
+ mat: "-t"
+ xfce: "-t"
+ konsole: "-e"
+ gnom: "-t"
+ xterm: "-e"
diff --git a/config_files/fm/tuis.yaml b/config_files/fm/tuis.yaml
index b471223..28ff881 100644
--- a/config_files/fm/tuis.yaml
+++ b/config_files/fm/tuis.yaml
@@ -1,19 +1,9 @@
# Here you can configure which Terminal User Interface application you want to
# be able to load from the application itself.
# Each application should be reachable from your `$PATH`.
-# The `cwd` boolean, which is required must be set to true
-# if the application requires a working directory, like `lazygit`.
-# It can be set to false for applications that don't care about where
-# they're started from, like `htop`.
lazygit:
- cwd: true
ncdu:
- cwd: true
htop:
- cwd: false
btop:
- cwd: false
glances:
- cwd: false
mocp:
- cwd: true
diff --git a/development.md b/development.md
index fe266b6..e106377 100644
--- a/development.md
+++ b/development.md
@@ -623,8 +623,6 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [x] refactor
- [x] document
-## Current dev
-
### Version 0.1.24
#### Summary
@@ -706,27 +704,181 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- [x] make every session element private, ensure we read the correct setting for dual.
- [x] FIX: opening help or fuzzyfindhelp crashes if a listed action has no keybind (aka. the user overwritten a keybind without creating one for old action).
- [x] !command & cli_application print the command run and the output
-- [ ] Pre release
+- [x] Pre release
- [x] Fix last missing items
- [x] check installation (remove config, cargo build)
- [x] readme
- [x] describe what was done succintly
- [x] test every mode
- - [ ] merge into v0.1.24-dev branch
+
+## Current dev
+
+### Version 0.1.25
+
+#### Summary
+
+- Improve scrolling in tree mode.
+- Bulk & normal rename: create intermediate folders when renaming.
+- Bulk now asks a confirmation before execution.
+- Scroll to selection when opening a menu. Selected file should alway be displayed in top window.
+- Scroll completion & navigation menus.
+- Configurable cli applications. See `~/fm/cli.yaml`
+- Simplify tui config files. Remove `cwd` boolean parameter. Doesn't break old config files.
+- Display the number of entries as the size of a directory instead of '-'. Might affect performance for very large directories.
+- Enable logging with `-l` or `--log`. **Nothing is logged anywhere without this flag.**
+- FIX: Tree mode. Unfolding a directory unfold its children
+- BREAKING: Use specific argument read from config file to run a command at startup for most common terminal emulators.
+ It allows the user to setup a specific terminal unknown to me and use it with fm.
+ To make this work, it will require the user to update its config file by copying the last part: "terminal_emulator_flags:..."
+- FIX: entering an inaccessible dir or writing in any way to a readonly dir shouldn't crash the app anymore...
+- Display & Update separation. Use a thread for display, allowing 30 fps. It uses more CPU :(
+ This feature is subject to change in future versions.
+- Flagged display mode. Enter with <F> and show all your flagged files. You can rename, open, trash, delete, bulk rename, open, open with etc.
+ Custom and simple search (filename containing input).
+ Jump to the file with <return>
+ ATM both "edit::jump" and "display::flagged" show the same content. The former may be removed soon.
+- Configurable menu colors. Every color used on screen is now configurable like file colors.
+
+#### Changelog
+
+- [x] move navigate movement to menu file.
+- [x] Tree scrolling
+ - [x] attach full content to tree
+ - [x] update content when tree necessary (???)
+ - [x] attach window to content
+ - [x] FIX: smoothscrolling. Last tree line isn't displayed
+ - [x] jump to next sibling
+ - [x] compare memory usage
+ - [x] scrolling in tree mode should start 1 line earlier since we use 1 line at the bottom
+ - [x] FIX: Tree mode: search forward doesn't scroll
+- [x] make navigable content scrollable
+- [x] leaving second pane as preview should set second pane to normal
+- [x] FIX: in tree mode, refresh also refresh the window. Incorrect number of file displayed
+- [x] FIX: while second window is opened, if the selection is below half screen, it's not shown anymore.
+- [x] exec multiple flagged files
+- [x] confirm before bulkaction
+- [x] allow bulk rename and normal rename to move files + bulk refactoring
+- [x] nohup, nix, setsid ???
+ - [x] replace nohup by setsid
+ - [x] check for setsid in path and use normal child if it's not.
+- [x] cli info is configurable
+- [x] refactor menus. split selectable content trait into 2 traits. Use closure to impl methods
+- [x] refactor cli & tui applications using common traits. Simplify tui config file
+- [x] rename Action::Command to Action::Action since it's what it does
+- [x] use number of files for dir size
+- [x] rename Goto Mode to cd to allow `:` then `cd`
+- [x] optionable logging
+- [x] FIX: Filter isn't shown and does nothing in tree mode
+- [x] FIX: unfold shouldn't unfold every child
+- [x] don't use -e for every terminal. See [rifle.conf](https://github.com/ranger/ranger/blob/136416c7e2ecc27315fe2354ecadfe09202df7dd/ranger/config/rifle.conf#L244)
+- [x] FIX: preview a symlink crashes the app
+- [x] FIX: opening an inaccessible dir crashes the app
+ - [x] check std set env crashes before
+ - [x] check all writes
+ - [x] Rename,
+ - [x] Copy, Move,
+ - [x] Delete,
+ - [x] Trash, Untrash,
+ - [x] Compress,
+ - [x] Decompress
+- [x] separate display from update
+ May be removed in future version.
+ It uses a lot of cpu to just display and doesn't do much else
+ - [x] make status sync: replace Rc by Arc
+ - [x] update status every event
+ - [x] display 30 fps
+ - [x] move display into a thread
+ - [x] test everything
+- [x] flagged as content
+
+ - [x] remove jump completely ??? not yet
+ - [x] fuzzy find flags all
+ - [x] display metadata of selected file
+ - [x] simplest possible holding struct
+ - [x] another display mode, displayable
+ - [x] display flagged like in dir
+ - [x] clickable header & Footer
+ - [x] enter: from skim files or lines, from jump, from folder, from tree (flatten)
+ - [x] flag everything in tree mode
+ - [x] FIX: window is off for big content
+ - [x] action on all files
+ - [x] disable filter. Filtering is easy, navigating in filtered files isn't. Require to keep a "filtered" files somewhere and use it everywhere.
+ - [x] preview & dual pane preview
+ - [x] open single or all flagged
+ - [x] renaming
+ - [x] disable copy, move
+ - [x] delete, trash
+ - [x] jump with enter
+ - [x] ctrl+o open all fuzzy files
+ - [x] unflag all (v)
+ - [x] <spc> remove file from flagged
+ - [x] bulk update flagged with new names
+ - [x] custom search with completion
+ - [x] disable regex match in flagged. Should it only keep the flagged files ? Would require to save the files before entering...
+ - [x] chmod
+ - [x] disable new nodes (file, dir)
+ - [x] disable all cd since we can't see the directory
+ - [x] copy filename & filepath
+ - [x] FIX: jump does nothing
+
+- [x] trashmode should display which shortcut erase all trash.
+- [x] add left tab current dir to right shortcut and vice versa
+- [x] refactor status.set_second_pane_preview
+- [x] FIX: leave sort does nothing
+- [x] FIX: incomplete regex crashes
+- [x] key which enter a mode should allow to leave it also.
+- [x] second line for every mod, use default color
+- [x] in marks new, backspace (since del is annoying...) should erase a mark.
+- [x] improve marks help.
+- [x] sort marks at read & update
+- [x] FIX: display flagged symbol in tree mode. Better alignment
+- [x] FIX: xdg-open pollutes the top border if opening a file fails
+- [x] update skim to 0.9.14
+- [x] FIX: in tree, moving while in "second pane as preview" unfolds.
+ "status.set_edit_mode..." does too much.
+- [x] FIX: running a command line application with "-d" doesn't work on alacritty
+- [x] display flagged files 1 char right like default ranger
+- [x] toggle flag move down in tree mode
+- [x] FIX: move back is buggy.
+- [x] Move back & leave_mode history should use the same status method
+- [x] toggling tree selects the current file if possible
+- [x] FIX: next_sibling doesn't wrap
+- [x] configurable menu colors
+- [x] allow more videos format to be previewed
+- [x] FIX ueberzug in dual tab.
+ Use different name per ueberzug tab, allowing multiple previews
+- [ ] pre release
+ - [x] Fix last missing items
+ - [x] check installation (remove config, cargo build)
+ - [x] readme
+ - [x] describe what was done succintly
+ - [ ] test every mode
+
+## Version 0.1.26
+
+- [ ] display all specific binds for every mode with a key ?
+- [ ] merge sort & regex, display nb of matches, completion + flag on the fly
+ - [ ] display number of matches while searching
+ - [ ] Sort refactoring
+ - [ ] entering
+ - [ ] setting
+ - [ ] leaving aka reseting
+- [ ] remove MOCP control from fm ???
+- [ ] focusable windows
+ - [ ] move display to status ? it would be easier to know where I clicked
+ - [ ] allow to change focus, only color the focused window border.
+ - [ ] Change focus with ctrl+hjkl or ctrl+arrow
+ - [ ] When a menu is opened, it should still be possible to navigate in files and preview or whatever
+ - [ ] Clicking an unfocused window should only give the focus, not execute anything
## TODO
-- [ ] refactor & unify all shell commands. Better names : Action::Action instead of command, Action::Command instead of shellwhatever
+- [ ] open a shell while hiding fm, restore after leaving
+- [ ] refactor & unify all shell commands
- [ ] config loading : https://www.reddit.com/r/rust/comments/17v65j8/implement_configuration_files_without_reading_the/
-- [ ] Only store one Selectable thing in status
-- [ ] use `Rc<str>` instead of string to avoid copying
- [ ] mount usb key - should be merged with mtp
- [ ] document filepicking (from my config etc.).
- [ ] avoid multiple refreshs if we edit files ourself
-- [ ] FIX: tab.selected() should return Option<&FileInfo>
-- [ ] use widget for every drawable element. First line should be a collection of widget which are drawned
-- [ ] while second window is opened, if the selection is below half screen, it's not shown anymore.
- Scroll to second element if needed
- [ ] remote control
- [ ] listen to stdin (rcv etc.)
@@ -736,53 +888,23 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally.
- https://github.com/KillTheMule/nvim-rs/blob/master/examples/basic.rs
- https://neovim.io/doc/user/api.html
-- [ ] display / event separation. use async and message passing between coroutines
-
- [ ] zoxide support
-- [ ] make navigable content scrollable
- [ ] temporary marks
- [ ] context switch
- [ ] read events from stdin ? can't be done from tuikit. Would require another thread ?
- [ ] pushbullet ?
- [ ] update the animation
-- [ ] exec multiple flagged files
-- [ ] shell menu
-
- - [ ] allow non tui like wttr, diff, bat, tail -n etc.
- - [ ] more options like "use flagged files" for diff
- [ ] build option to force reset of config file, warn the user at first start
-- [ ] optionable "plugin" started from config file. Would require every option to be `Option<Plugin>` and may cause problems with the borrow checker.
- [ ] edit folder like a buffer [oil like](https://github.com/stevearc/oil.nvim)
- [ ] allow pipe in execution
-- [ ] refactor cryptdevice and iso_file
-
- - [ ] mode to handle those mounts. ATM it's all over the place...
- - [ ] allow mounting some other devices
- - [ ] list non mounted devices, list all mount points
- - [ ] act on them
-
-- [ ] Version 0.1.50 : safety & memory usage
-
- - [ ] there's a memory leak somewhere
- - [ ] preview of big files (or whatever file) should only read chunk of the file,
- not the whole thing. Previewing a 5gB iso file uses up to 15gB of ram, which will crash any system.
- or should it ?
- Simple solutions:
-
- - only reads a buffer
- - limit to xxx filesize
-
-- [ ] Version 0.2.0 : tests
-
- - [ ] tests
- - [ ] remove references to local thing
- - [ ] translations i18n
-
-- [ ] Version 0.3.0 : dark/light theme, transparency etc.
-- [ ] Version 0.4.0 : plugins
+- [ ] tests
+- [ ] remove references to local thing
+- [ ] translations i18n
+- [ ] dark/light theme, transparency etc.
+- [ ] plugins
- which language ?
- what for ?
diff --git a/readme.md b/readme.md
index 5152aa4..9779a4b 100644
--- a/readme.md
+++ b/readme.md
@@ -9,7 +9,7 @@
[docrs]: https://docs.rs/fm-tui/0.1.24
```
-A TUI file manager inspired by dired and ranger
+ A TUI file manager inspired by dired and ranger
Usage: fm [OPTIONS]
@@ -17,6 +17,7 @@ Options:
-p, --path <PATH> Starting path. directory or file [default: .]
-s, --server <SERVER> Nvim server [default: ]
-A, --all Display all files (hidden)
+ -l, --log Enable logging
-h, --help Print help
-V, --version Print version
```
@@ -170,6 +171,15 @@ Expansions :
- %n : selected filename
- %d : current directory
+### Logging
+
+With `-l` or `--log`, logs are enabled. They are disabled by default.
+
+Critical actions will be logged to `~/.config/fm/log/fm.log` and actions affecting the file tree will be logged to `~/.config/fm/log/action_logger.log`.
+
+The last action is displayed at the bottom of the screen and can be read with `Alt+l` like a preview.
+Those logs can be seen even if logging is disabled, it just won't be up to date.
+
### More
- Copy a filename/filepath to clipboard with Ctrl+n, Ctrl+p
@@ -195,13 +205,13 @@ Ctrl('h') : help
- Navigation -
Left : cd to parent directory
-Right : cd to child directory
+Char('l') : cd to child directory
Up : one line up
-Down : one line down
+Char('j') : one line down
Home : go to first line
Char('G') : go to last line
PageUp : 10 lines up
-PageDown : 10 lines down
+Char('J') : 10 lines down
Tab : cycle tab
- Actions -
@