From 7921e0fcdcb7188914d326d8b56e58dfd7c49377 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Fri, 28 Feb 2020 21:38:15 +0100 Subject: [PATCH] Change urxvt terminal paste shortcut to CTRL+ALT+V. Fix #166 --- native/liblinuxbridge/bridge.cpp | 8 ++++++-- native/liblinuxbridge/bridge.h | 5 +++++ src/bridge/linux.rs | 1 + src/keyboard/linux.rs | 5 +++++ src/keyboard/mod.rs | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/native/liblinuxbridge/bridge.cpp b/native/liblinuxbridge/bridge.cpp index 4fcdd58..f353eac 100644 --- a/native/liblinuxbridge/bridge.cpp +++ b/native/liblinuxbridge/bridge.cpp @@ -307,6 +307,10 @@ void trigger_alt_shift_ins_paste() { xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Shift+Alt+Insert", 8000); } +void trigger_ctrl_alt_paste() { + xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Control_L+Alt+v", 8000); +} + void trigger_copy() { // Release the other keys, for an explanation, read the 'trigger_paste' method @@ -467,8 +471,8 @@ int32_t is_current_window_special() { if (res > 0) { if (strstr(class_buffer, "terminal") != NULL) { return 1; - }else if (strstr(class_buffer, "URxvt") != NULL) { // Manjaro terminal - return 1; + }else if (strstr(class_buffer, "URxvt") != NULL) { // urxvt terminal + return 4; }else if (strstr(class_buffer, "XTerm") != NULL) { // XTerm and UXTerm return 1; }else if (strstr(class_buffer, "Termite") != NULL) { // Termite diff --git a/native/liblinuxbridge/bridge.h b/native/liblinuxbridge/bridge.h index 2389cf8..f4b857a 100644 --- a/native/liblinuxbridge/bridge.h +++ b/native/liblinuxbridge/bridge.h @@ -92,6 +92,11 @@ extern "C" void trigger_shift_ins_paste(); */ extern "C" void trigger_alt_shift_ins_paste(); +/* + * Trigger CTRL+ALT+V pasting + */ +extern "C" void trigger_ctrl_alt_paste(); + /* * Trigger copy shortcut ( Pressing CTRL+C ) */ diff --git a/src/bridge/linux.rs b/src/bridge/linux.rs index 967aa9d..08f65cc 100644 --- a/src/bridge/linux.rs +++ b/src/bridge/linux.rs @@ -44,5 +44,6 @@ extern { pub fn trigger_terminal_paste(); pub fn trigger_shift_ins_paste(); pub fn trigger_alt_shift_ins_paste(); + pub fn trigger_ctrl_alt_paste(); pub fn trigger_copy(); } \ No newline at end of file diff --git a/src/keyboard/linux.rs b/src/keyboard/linux.rs index 78e0961..04c3c3a 100644 --- a/src/keyboard/linux.rs +++ b/src/keyboard/linux.rs @@ -52,6 +52,8 @@ impl super::KeyboardManager for LinuxKeyboardManager { trigger_alt_shift_ins_paste(); }else if is_special == 3 { // Special case for Emacs trigger_shift_ins_paste(); + }else if is_special == 4 { // CTRL+ALT+V used in some terminals (urxvt) + trigger_ctrl_alt_paste(); }else{ trigger_terminal_paste(); } @@ -65,6 +67,9 @@ impl super::KeyboardManager for LinuxKeyboardManager { PasteShortcut::ShiftInsert=> { trigger_shift_ins_paste(); }, + PasteShortcut::CtrlAltV => { + trigger_ctrl_alt_paste(); + }, _ => { error!("Linux backend does not support this Paste Shortcut, please open an issue on GitHub if you need it.") } diff --git a/src/keyboard/mod.rs b/src/keyboard/mod.rs index 66ebe77..045be16 100644 --- a/src/keyboard/mod.rs +++ b/src/keyboard/mod.rs @@ -43,6 +43,7 @@ pub enum PasteShortcut { CtrlV, // Classic Ctrl+V shortcut CtrlShiftV, // Could be used to paste without formatting in many applications ShiftInsert, // Often used in Linux systems + CtrlAltV, // Used in some Linux terminals (urxvt) MetaV, // Corresponding to Win+V on Windows and Linux, CMD+V on macOS }