diff options
author | qkzk <qkzk@users.noreply.github.com> | 2024-10-14 18:01:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 18:01:47 +0200 |
commit | 340ffc7c9e4bc9bdc9901e7e940a9015d4a46420 (patch) | |
tree | 164de75c770cbf727c05519384b42da8e515c506 | |
parent | 1fe495994993b616d25c97f89f0afb6f5690ff39 (diff) | |
parent | 267a89ed8ccda455c3f4eaab35bfb880ea3dfa67 (diff) |
Merge pull request #100 from qkzk/v0.1.30-previwer-non-blokingv0.1.30
V0.1.30 previwer non bloking
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | development.md | 124 | ||||
-rw-r--r-- | readme.md | 14 | ||||
-rw-r--r-- | src/app/application.rs | 107 | ||||
-rw-r--r-- | src/app/displayer.rs | 4 | ||||
-rw-r--r-- | src/app/header_footer.rs | 28 | ||||
-rw-r--r-- | src/app/internal_settings.rs | 7 | ||||
-rw-r--r-- | src/app/mod.rs | 2 | ||||
-rw-r--r-- | src/app/previewer.rs | 66 | ||||
-rw-r--r-- | src/app/refresher.rs | 24 | ||||
-rw-r--r-- | src/app/status.rs | 723 | ||||
-rw-r--r-- | src/app/tab.rs | 160 | ||||
-rw-r--r-- | src/common/utils.rs | 2 | ||||
-rw-r--r-- | src/config/colors.rs | 3 | ||||
-rw-r--r-- | src/config/configuration.rs | 5 | ||||
-rw-r--r-- | src/config/keybindings.rs | 3 | ||||
-rw-r--r-- | src/event/action_map.rs | 25 | ||||
-rw-r--r-- | src/event/event_action.rs (renamed from src/event/event_exec.rs) | 496 | ||||
-rw-r--r-- | src/event/event_dispatch.rs | 125 | ||||
-rw-r--r-- | src/event/event_poller.rs | 12 | ||||
-rw-r--r-- | src/event/fm_events.rs | 8 | ||||
-rw-r--r-- | src/event/mod.rs | 4 | ||||
-rw-r--r-- | src/io/display.rs | 1055 | ||||
-rw-r--r-- | src/io/draw_menu.rs | 90 | ||||
-rw-r--r-- | src/io/git.rs | 4 | ||||
-rw-r--r-- | src/io/input_history.rs | 94 | ||||
-rw-r--r-- | src/io/log.rs | 11 | ||||
-rw-r--r-- | src/io/mod.rs | 2 | ||||
-rw-r--r-- | src/io/opendal.rs | 35 | ||||
-rw-r--r-- | src/modes/display/directory.rs | 14 | ||||
-rw-r--r-- | src/modes/display/mod.rs | 12 | ||||
-rw-r--r-- | src/modes/display/preview.rs | 44 | ||||
-rw-r--r-- | src/modes/display/skim.rs | 12 | ||||
-rw-r--r-- | src/modes/display/tree.rs | 796 | ||||
-rw-r--r-- | src/modes/display/uber.rs | 3 | ||||
-rw-r--r-- | src/modes/edit/flagged.rs | 224 | ||||
-rw-r--r-- | src/modes/fs/fileinfo.rs (renamed from src/modes/display/fileinfo.rs) | 8 | ||||
-rw-r--r-- | src/modes/fs/mod.rs | 8 | ||||
-rw-r--r-- | src/modes/fs/users.rs (renamed from src/modes/display/users.rs) | 29 | ||||
-rw-r--r-- | src/modes/menu/bulkrename.rs (renamed from src/modes/edit/bulkrename.rs) | 14 | ||||
-rw-r--r-- | src/modes/menu/cli_menu.rs (renamed from src/modes/edit/cli_menu.rs) | 19 | ||||
-rw-r--r-- | src/modes/menu/completion.rs (renamed from src/modes/edit/completion.rs) | 138 | ||||
-rw-r--r-- | src/modes/menu/compress.rs (renamed from src/modes/edit/compress.rs) | 29 | ||||
-rw-r--r-- | src/modes/menu/context.rs (renamed from src/modes/edit/context.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/copy_move.rs (renamed from src/modes/edit/copy_move.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/cryptsetup.rs (renamed from src/modes/edit/cryptsetup.rs) | 14 | ||||
-rw-r--r-- | src/modes/menu/decompress.rs (renamed from src/modes/edit/decompress.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/filter.rs (renamed from src/modes/edit/filter.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/flagged.rs | 121 | ||||
-rw-r--r-- | src/modes/menu/help.rs (renamed from src/modes/edit/help.rs) | 3 | ||||
-rw-r--r-- | src/modes/menu/history.rs (renamed from src/modes/edit/history.rs) | 3 | ||||
-rw-r--r-- | src/modes/menu/input.rs (renamed from src/modes/edit/input.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/iso.rs (renamed from src/modes/edit/iso.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/marks.rs (renamed from src/modes/edit/marks.rs) | 11 | ||||
-rw-r--r-- | src/modes/menu/mod.rs (renamed from src/modes/edit/mod.rs) | 28 | ||||
-rw-r--r-- | src/modes/menu/node_creation.rs (renamed from src/modes/edit/node_creation.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/nvim.rs (renamed from src/modes/edit/nvim.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/password.rs (renamed from src/modes/edit/password.rs) | 4 | ||||
-rw-r--r-- | src/modes/menu/permissions.rs (renamed from src/modes/edit/permissions.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/picker.rs (renamed from src/modes/edit/picker.rs) | 3 | ||||
-rw-r--r-- | src/modes/menu/regex.rs (renamed from src/modes/edit/regex.rs) | 2 | ||||
-rw-r--r-- | src/modes/menu/remote.rs | 82 | ||||
-rw-r--r-- | src/modes/menu/removable_devices.rs (renamed from src/modes/edit/removable_devices.rs) | 11 | ||||
-rw-r--r-- | src/modes/menu/search.rs (renamed from src/modes/edit/search.rs) | 166 | ||||
-rw-r--r-- | src/modes/menu/shortcut.rs (renamed from src/modes/edit/shortcut.rs) | 41 | ||||
-rw-r--r-- | src/modes/menu/sort.rs (renamed from src/modes/edit/sort.rs) | 0 | ||||
-rw-r--r-- | src/modes/menu/trash.rs (renamed from src/modes/edit/trash.rs) | 12 | ||||
-rw-r--r-- | src/modes/menu/tui_menu.rs (renamed from src/modes/edit/tui_menu.rs) | 6 | ||||
-rw-r--r-- | src/modes/mod.rs | 10 | ||||
-rw-r--r-- | src/modes/mode.rs | 51 | ||||
-rw-r--r-- | src/modes/utils/content_window.rs (renamed from src/modes/display/content_window.rs) | 15 | ||||
-rw-r--r-- | src/modes/utils/leave_menu.rs (renamed from src/modes/edit/leave_mode.rs) | 237 | ||||
-rw-r--r-- | src/modes/utils/line_display.rs (renamed from src/modes/edit/line_display.rs) | 12 | ||||
-rw-r--r-- | src/modes/utils/menu_holder.rs (renamed from src/modes/edit/menu.rs) | 213 | ||||
-rw-r--r-- | src/modes/utils/mod.rs | 17 | ||||
-rw-r--r-- | src/modes/utils/mount_help.rs (renamed from src/modes/edit/mount_help.rs) | 0 | ||||
-rw-r--r-- | src/modes/utils/second_line.rs (renamed from src/modes/edit/second_line.rs) | 4 | ||||
-rw-r--r-- | src/modes/utils/selectable_content.rs (renamed from src/modes/edit/selectable_content.rs) | 43 | ||||
-rw-r--r-- | src/modes/utils/shell_parser.rs (renamed from src/modes/edit/shell_parser.rs) | 10 |
80 files changed, 3101 insertions, 2605 deletions
@@ -932,7 +932,7 @@ dependencies = [ [[package]] name = "fm-tui" -version = "0.1.29" +version = "0.1.30" dependencies = [ "anyhow", "chrono", @@ -1,6 +1,6 @@ [package] name = "fm-tui" -version = "0.1.29" +version = "0.1.30" authors = ["Quentin Konieczko <qu3nt1n@gmail.com>"] edition = "2021" license-file = "LICENSE.txt" diff --git a/development.md b/development.md index 4c73a137..4dc41c8e 100644 --- a/development.md +++ b/development.md @@ -1100,11 +1100,8 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - [x] Fix: opening tree mode with selection on "." doesn't display "." as selected - [x] refactor draw tree line - [x] Fix: Crash when quiting. "sending on a closed channel". From quit -> refresher::quit -- [ ] - [ ] Badges to latest version -## Current dev - ### Version 0.1.29 #### Summary @@ -1153,28 +1150,127 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - [x] only one "colors" map in yaml file - [x] migration of config file : detailed in release +## Current dev + +### Version 0.1.30 + +#### Summary + +- shell & exec menu allow %t as terminal expansion. It allows you to open a file in a new terminal. + `! %t nvim %s` will open the selected file with neovim in a new terminal. +- cd command (Alt+g) includes children of a path (detected as soon as you type a /) +- double clic on a menu item to execute it. Same as a clic then press enter. +- Fixed a bug where search completion would be made before the char is inserted, displaying wrong results +- Fixed a bug where preview were built for second pane even if it wasn't visible, wasting ressources +- Move as you type. In Cd menu (Alt+g), the display and preview is updated as you type. + Pressing Esc (leave mode) go back to where you started from. + You need to validate with enter. +- Sync left tab from right path shift+left. shift+right go the other way. +- A lot of refactoring: + - flagged files, + - input history, + - application start, main loop & quit, + - display + - menus +- Fixed a bug where leaving a menu while a tree is displayed resets the index. + +#### Changelog + +- [x] Refactor flagged files + - [x] Fix: can't clic flagged. Display is offset by something + - [x] Fix: can't flag files when flagged menu is opened + - [x] Fix: removing flagged files can crash. + - [x] removed window from flagged + - [x] Fix: Too much flags + scroll = crash +- [x] menus refactor + - [x] Fix: closing left menu shouldn't clear right + - [x] refactor menu.remote_mount into a separate module with parser & executer +- [x] DrawMenu used to display most of navigable elements. +- [x] refactor display. + - [x] renamed most methods + - [x] separated by mode + - [x] common interface using `draw` method from tuikit +- [x] cd: after typing '/' extend with children +- [x] exec: allow %t in first param to be expanded to $TERM + flags + + - [x] %t + TAB -> /usr/bin/alacritty -e + - [x] Fix after ! command, empty preview is displayed + - [x] documentation, help + +- [x] Fix: :Preview does nothing. Had to create a new kind of event +- [ ] revisit cloud configuration make it permanent + - [ ] something is wrong, IDK what +- [x] double clic on menu items +- [x] FIX: search completion is made before the char is inserted in input string. Should be done afterward. +- [x] FIX: previewer is called even when preview can't be seen +- [x] FIX: Refresher is sending its quit message trought a closed channel +- [x] tree: separate builder for nodes and for treelines +- [x] non bloking previews, "simple" way. + - [x] struct with a thread and 2 mpsc: one to ask for previews, one to send them back. The first is also used to break the loop. + - [x] refresher send more events, also asking for previews to be checked + - [x] check if a preview should be asked in app every event received + - [x] don't display obsoletes previews + - [ ] tests, perf, memory usage... +- [x] refactor app: + - [x] simplify update loop + - [x] simplify build + - [x] simplify early exit +- [x] don't pass users to preview, build them if needed in tree +- [x] Move as you type in Alt+g, esc go back to previous + - [x] hold origin in tab + - [x] cd there as you type + - [x] reset when pressing Esc + - [x] Fix: preview doesn't update every time + - [x] cd should be called from status or parent not menu + - [x] request a preview + - [x] preview is updated when input is a directory + - [x] preview is updated when input is an existing file + - [x] NOT A BUG, a kernel feature: + multiple //// are allowed in pathes, kernel collapses them into a single separator. + [See StackOverflow](https://stackoverflow.com/questions/16840916/what-is-path-how-is-it-different-from) + - [x] can't use history. Every cd is recorded, so when need to remember where we started... +- [x] refactor input history calls +- [x] sync left to right or right left with shift+arrow +- [x] removed unused struct +- [ ] search refactor + - [x] common trait to impl iter from index to index in tree & directory. + - [x] macro like impl_selectable + - [x] move search execution to status + - [x] refactor status.search & status.search_again + - [x] use reference to files, avoiding a clone + - [x] FIX: tree search doesn't find first match + - [x] FIX: search doesn't update if tab +- [x] Refactor completion +- [x] leavemode small refactor +- [x] Use custom command for ncdu & lazygit shouldn't be actions by themselves +- [x] removed backtab action +- [x] FIX: leaving a menu while in tree resets the index. +- [x] Massive renaming and moving. +- [x] Simplify display mode comparison with a few methods. Should make the code more readable +- [ ] directory preview should just be a "directory" ? + ## TODO -- [ ] google drive should be a display ? -- [ ] status, tab, event exec refactor. What should go where ? status is too big and should be splitted -- [ ] menus refactor - - [ ] open 2 menus at once - - [ ] maybe use the same system as preview, create them on the fly - - [ ] attach menus to tab, where they belong - - [ ] leaving left menu shouldn't reset right menu +### Next version + - [ ] replace tuikit by ratatui + crossterm + - [ ] [step by step migration](https://chatgpt.com/c/670cf276-9540-800f-94c8-eaa4ae1e05ea) + - [ ] [nucleo](https://github.com/helix-editor/nucleo) as a skim replacement + - [ ] [nucleo-picker](https://github.com/autobib/nucleo-picker) uses crossterm +- [ ] common trait to validate a data : input string, config, args... +- [ ] google drive should be a display ? +- [ ] previews: find a way to stop + +### Other ideas + - [ ] Focus & mouseover. Mousemove require raw terminal mode.. Requires to rewrite every event (Mousepress, mouse release etc.) Another motivation to switch to ratatui + crossterm. - [ ] ideas from broot : https://dystroy.org/broot/#apply-commands-on-several-files - [ ] floating windows ? - [ ] rclone -- [ ] FIX: leaving flagged file should reset the window correctly. Can't reproduce... -- [ ] move as you type in Alt+g - [ ] use the new mpsc event parser to read commands from stdin or RPC - [ ] [opener file kind](./src/io/opener.rs): move associations to a config file - [ ] 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/ - [ ] document filepicking (from my config etc.). - [ ] avoid multiple refreshs if we edit files ourself - [ ] remote control @@ -232,7 +232,6 @@ Only developpers of fm should be concerned. - Detect removable disks automatically and jump to them in a few keystrokes (Ctrl+g, up, enter) - Drag and drop files (requires dragon-drop installed) with D - Open and mount encrypted devices. Open the menu with Shift+e, mount with m, unmount with u. -- Contol MOCP with Ctrl+arrows. Ctrl+Left, Ctrl+Right: previous or next song. Ctrl+Down: Toggle pause. Ctrl+Up: add current folder to playlist - Set the selected image as wallpaper with W. - Enter "command mode" with ':'. Type the name of a command and it will be executed. - Mount a remote filesystem using ssfhs with Alt-r. @@ -352,21 +351,13 @@ Alt('f') : FILTER (by name "n name", by ext "e ext", "d only directories" or "a all" for reset) Enter : Execute mode then NORMAL -- MOC - -Control MOC from your TUI -CtrlUp : MOCP: Add selected file or folder to the playlist -CtrlLeft : MOCP: Previous song -CtrlDown : MOCP: Toggle play/pause. -CtrlRight : MOCP: Next song -AltEnter : MOCP: Go to currently playing song -Ctrl('x') : MOCP: Clear the playlist - - CUSTOM ACTIONS - %s: the selected file, %f: the flagged files, %e: the extension of the file, %n: the filename only, %p: the full path of the current directory. +%t: the currently set terminal & its flags. Alt('u'): /usr/bin/google-chrome-stable %s Char('D'): /usr/bin/dragon-drop %s ``` @@ -397,7 +388,7 @@ You can configure : - **Colors** of files. Non standard files (directory, char devices, block devices, symlinks, sockets, fifo) have their own configurable colors. You can use ansi colors or rgb values. - Standard files are colored by their extension and you can use 3 differents palettes (red-green, red-blue or green-blue). + Standard files are colored by their extension and you can use any gradient between two colors Every extension has its own random color. ## External dependencies @@ -408,7 +399,6 @@ Most of the openers and tui applications are configurable from config files. Som - [faillock](https://linux.die.net/man/8/faillock): reset failed sudo attempts - [Cryptsetup](https://gitlab.com/cryptsetup/cryptsetup): decrypt & mount encrypted devices - [Nitrogen](https://github.com/l3ib/nitrogen/): set up a wallpaper -- [MOC](https://moc.daper.net/) Music On Console allows you to play music from your terminal - [Dragon-Drop](https://github.com/mwh/dragon) drag-and-drop a file from a terminal to a GUI application. - [Ueberzug](https://github.com/LalleSX/ueberzug) display images in your terminal. Used to preview images. This one may be tricky to install from source since the original maintener nuked his project. It's still available in many package managers. - [isoinfo](https://command-not-found.com/isoinfo) allow the content preview of an iso file diff --git a/src/app/application.rs b/src/app/application.rs index fbfe7f19..ccf93ec8 100644 --- a/src/app/application.rs +++ b/src/app/application.rs @@ -1,13 +1,12 @@ use std::process::exit; -use std::sync::Arc; -use std::sync::Mutex; +use std::sync::{mpsc, Arc, Mutex}; -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, bail, Result}; use clap::Parser; use crate::app::{Displayer, Refresher, Status}; use crate::common::{clear_tmp_files, init_term, print_on_quit, CONFIG_PATH}; -use crate::config::{cloud_config, load_config, set_configurable_static, Config, START_FOLDER}; +use crate::config::{cloud_config, load_config, set_configurable_static, Config}; use crate::event::{EventDispatcher, EventReader, FmEvents}; use crate::io::{set_loggers, Args, Opener}; use crate::log_info; @@ -46,41 +45,28 @@ impl FM { /// /// May fail if the [`tuikit::term`] can't be started or crashes pub fn start() -> Result<Self> { - set_loggers()?; - let Ok(config) = load_config(CONFIG_PATH) else { - Self::exit_wrong_config() - }; - - let args = Args::parse(); - - if args.keybinds { - Self::exit_with_binds(&config); - } - - if args.cloudconfig { |