add option to copy path when pressing down shift
This commit is contained in:
parent
f1a8e4ea19
commit
4e77e398f2
4 changed files with 22 additions and 2 deletions
|
|
@ -354,6 +354,7 @@ quit = Quit
|
|||
edit = Edit
|
||||
cut = Cut
|
||||
copy = Copy
|
||||
copy-path = Copy path
|
||||
paste = Paste
|
||||
select-all = Select all
|
||||
|
||||
|
|
|
|||
10
src/app.rs
10
src/app.rs
|
|
@ -146,6 +146,7 @@ pub enum Action {
|
|||
AddToSidebar,
|
||||
Compress,
|
||||
Copy,
|
||||
CopyPath,
|
||||
CopyTo,
|
||||
Cut,
|
||||
CosmicSettingsDesktop,
|
||||
|
|
@ -215,6 +216,7 @@ impl Action {
|
|||
Self::AddToSidebar => Message::AddToSidebar(entity_opt),
|
||||
Self::Compress => Message::Compress(entity_opt),
|
||||
Self::Copy => Message::Copy(entity_opt),
|
||||
Self::CopyPath => Message::CopyPath(entity_opt),
|
||||
Self::CopyTo => Message::CopyTo(entity_opt),
|
||||
Self::Cut => Message::Cut(entity_opt),
|
||||
Self::CosmicSettingsDesktop => Message::CosmicSettings("desktop"),
|
||||
|
|
@ -340,6 +342,7 @@ pub enum Message {
|
|||
Compress(Option<Entity>),
|
||||
Config(Config),
|
||||
Copy(Option<Entity>),
|
||||
CopyPath(Option<Entity>),
|
||||
CopyTo(Option<Entity>),
|
||||
CopyToResult(DialogResult),
|
||||
CosmicSettings(&'static str),
|
||||
|
|
@ -2744,6 +2747,13 @@ impl Application for App {
|
|||
let contents = ClipboardCopy::new(ClipboardKind::Copy, paths);
|
||||
return clipboard::write_data(contents);
|
||||
}
|
||||
Message::CopyPath(entity_opt) => {
|
||||
let paths = self.selected_paths(entity_opt);
|
||||
let path_strings: Vec<String> =
|
||||
paths.into_iter().map(|p| p.display().to_string()).collect();
|
||||
let text = path_strings.join("\n");
|
||||
return clipboard::write(text);
|
||||
}
|
||||
Message::CopyTo(entity_opt) => {
|
||||
let selected_paths: Box<[_]> = self.selected_paths(entity_opt).collect();
|
||||
return self.copy_to(&selected_paths);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ pub fn key_binds(mode: &tab::Mode) -> HashMap<KeyBind, Action> {
|
|||
// App and desktop only keys
|
||||
if matches!(mode, tab::Mode::App | tab::Mode::Desktop) {
|
||||
bind!([Ctrl], Key::Character("c".into()), Copy);
|
||||
bind!([Ctrl, Shift], Key::Character("c".into()), CopyPath);
|
||||
bind!([Ctrl], Key::Character("x".into()), Cut);
|
||||
bind!([], Key::Named(Named::Delete), Delete);
|
||||
bind!([Shift], Key::Named(Named::Delete), PermanentlyDelete);
|
||||
|
|
|
|||
12
src/menu.rs
12
src/menu.rs
|
|
@ -174,7 +174,11 @@ pub fn context_menu<'a>(
|
|||
children.push(divider::horizontal::light().into());
|
||||
children.push(menu_item(fl!("rename"), Action::Rename).into());
|
||||
children.push(menu_item(fl!("cut"), Action::Cut).into());
|
||||
children.push(menu_item(fl!("copy"), Action::Copy).into());
|
||||
if modifiers.shift() && !modifiers.control() {
|
||||
children.push(menu_item(fl!("copy-path"), Action::CopyPath).into());
|
||||
} else {
|
||||
children.push(menu_item(fl!("copy"), Action::Copy).into());
|
||||
}
|
||||
// Should this simply bypass trash and remove the shortcut?
|
||||
children.push(menu_item(fl!("move-to-trash"), Action::Delete).into());
|
||||
} else if selected > 0 {
|
||||
|
|
@ -204,7 +208,11 @@ pub fn context_menu<'a>(
|
|||
children.push(menu_item(fl!("rename"), Action::Rename).into());
|
||||
children.push(menu_item(fl!("cut"), Action::Cut).into());
|
||||
}
|
||||
children.push(menu_item(fl!("copy"), Action::Copy).into());
|
||||
if modifiers.shift() && !modifiers.control() {
|
||||
children.push(menu_item(fl!("copy-path"), Action::CopyPath).into());
|
||||
} else {
|
||||
children.push(menu_item(fl!("copy"), Action::Copy).into());
|
||||
}
|
||||
if selected_mount_point == 0 {
|
||||
children.push(menu_item(fl!("move-to"), Action::MoveTo).into());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue