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"].
This commit is contained in:
Sinkerine 2023-10-24 00:13:48 -07:00 committed by sxyazi
parent 9d912b07aa
commit 0f73a44847
No known key found for this signature in database
2 changed files with 6 additions and 0 deletions

View file

@ -63,6 +63,7 @@ keymap = [
{ on = [ "<Enter>" ], exec = "open", desc = "Open the selected files" },
{ on = [ "<C-Enter>" ], 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)" },

View file

@ -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
}
}