From 0f73a4484744cb2e8cd6d7ada5c0b01c9570e7f1 Mon Sep 17 00:00:00 2001 From: Sinkerine Date: Tue, 24 Oct 2023 00:13:48 -0700 Subject: [PATCH 1/2] feat: Support unyank There are two options to put the unyank ability: - Option 1: Register a new command like in this CL - Option 2: Add the unyank to the escape sequence, maybe after the escape_select. I chose option 1 because the yank function is its own module but the escape sequence belongs to the tab class. Option 2 is infeasible without touching the module structure. I just randomly choose a meaninful and unoccuped key binding for the `unyank` function. Feel free to modify or remove it from the preset. I personally remap the yank related functions to dance keys such as ["y" "y"]. --- yazi-config/preset/keymap.toml | 1 + yazi-core/src/manager/commands/yank.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 52021f803..64e35c75a 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -63,6 +63,7 @@ keymap = [ { on = [ "" ], exec = "open", desc = "Open the selected files" }, { on = [ "" ], exec = "open --interactive", desc = "Open the selected files interactively" }, { on = [ "y" ], exec = [ "yank", "escape --visual --select" ], desc = "Copy the selected files" }, + { on = [ "Y" ], exec = [ "unyank", "escape --visual --select" ], desc = "Remove the files from the yank clipboard" }, { on = [ "x" ], exec = [ "yank --cut", "escape --visual --select" ], desc = "Cut the selected files" }, { on = [ "p" ], exec = "paste", desc = "Paste the files" }, { on = [ "P" ], exec = "paste --force", desc = "Paste the files (overwrite if the destination exists)" }, diff --git a/yazi-core/src/manager/commands/yank.rs b/yazi-core/src/manager/commands/yank.rs index 7f1209a58..41605ed9b 100644 --- a/yazi-core/src/manager/commands/yank.rs +++ b/yazi-core/src/manager/commands/yank.rs @@ -18,4 +18,9 @@ impl Manager { self.yanked.1 = self.selected().into_iter().map(|f| f.url()).collect(); render!(); } + + pub fn unyank(&mut self) -> bool { + self.yanked = Default::default(); + true + } } From 2c52f282279a6c52a612e601eb9b693bc6b0063c Mon Sep 17 00:00:00 2001 From: sxyazi Date: Wed, 31 Jan 2024 21:51:31 +0800 Subject: [PATCH 2/2] Rebase --- cspell.json | 2 +- yazi-config/preset/keymap.toml | 2 +- yazi-core/src/manager/commands/mod.rs | 1 + yazi-core/src/manager/commands/unyank.rs | 10 ++++++++++ yazi-core/src/manager/commands/yank.rs | 5 ----- yazi-fm/src/executor.rs | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 yazi-core/src/manager/commands/unyank.rs diff --git a/cspell.json b/cspell.json index c089cb893..46d992b6b 100644 --- a/cspell.json +++ b/cspell.json @@ -1 +1 @@ -{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds"],"language":"en","version":"0.2"} \ No newline at end of file +{"version":"0.2","language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank"]} \ No newline at end of file diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 64e35c75a..af622e9ed 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -63,7 +63,7 @@ keymap = [ { on = [ "" ], exec = "open", desc = "Open the selected files" }, { on = [ "" ], exec = "open --interactive", desc = "Open the selected files interactively" }, { on = [ "y" ], exec = [ "yank", "escape --visual --select" ], desc = "Copy the selected files" }, - { on = [ "Y" ], exec = [ "unyank", "escape --visual --select" ], desc = "Remove the files from the yank clipboard" }, + { on = [ "Y" ], exec = [ "unyank", "escape --visual --select" ], desc = "Cancel the yank status of files" }, { on = [ "x" ], exec = [ "yank --cut", "escape --visual --select" ], desc = "Cut the selected files" }, { on = [ "p" ], exec = "paste", desc = "Paste the files" }, { on = [ "P" ], exec = "paste --force", desc = "Paste the files (overwrite if the destination exists)" }, diff --git a/yazi-core/src/manager/commands/mod.rs b/yazi-core/src/manager/commands/mod.rs index e6e4c0933..cc4e4ceff 100644 --- a/yazi-core/src/manager/commands/mod.rs +++ b/yazi-core/src/manager/commands/mod.rs @@ -15,6 +15,7 @@ mod tab_close; mod tab_create; mod tab_swap; mod tab_switch; +mod unyank; mod update_files; mod update_mimetype; mod update_paged; diff --git a/yazi-core/src/manager/commands/unyank.rs b/yazi-core/src/manager/commands/unyank.rs new file mode 100644 index 000000000..8eaa81f9c --- /dev/null +++ b/yazi-core/src/manager/commands/unyank.rs @@ -0,0 +1,10 @@ +use yazi_shared::{event::Cmd, render}; + +use crate::manager::Manager; + +impl Manager { + pub fn unyank(&mut self, _: Cmd) { + self.yanked = Default::default(); + render!(); + } +} diff --git a/yazi-core/src/manager/commands/yank.rs b/yazi-core/src/manager/commands/yank.rs index 41605ed9b..7f1209a58 100644 --- a/yazi-core/src/manager/commands/yank.rs +++ b/yazi-core/src/manager/commands/yank.rs @@ -18,9 +18,4 @@ impl Manager { self.yanked.1 = self.selected().into_iter().map(|f| f.url()).collect(); render!(); } - - pub fn unyank(&mut self) -> bool { - self.yanked = Default::default(); - true - } } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 532258a0e..6f434094e 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -92,6 +92,7 @@ impl<'a> Executor<'a> { on!(MANAGER, open, &self.app.cx.tasks); on!(MANAGER, open_do, &self.app.cx.tasks); on!(MANAGER, yank); + on!(MANAGER, unyank); on!(MANAGER, paste, &self.app.cx.tasks); on!(MANAGER, link, &self.app.cx.tasks); on!(MANAGER, remove, &self.app.cx.tasks);