aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2020-03-24 02:46:33 +0300
committerGitHub <noreply@github.com>2020-03-23 23:46:33 +0000
commitc9c5fbbe2bd522c55af041e84d6a222c059555b1 (patch)
tree0bff3e8a9a38dc97b9bc3a64215a19ac83f50835
parenta2875454b1c6b856ccb7f61e737ea1e090b0e054 (diff)
downloadalacritty-c9c5fbbe2bd522c55af041e84d6a222c059555b1.tar.gz
alacritty-c9c5fbbe2bd522c55af041e84d6a222c059555b1.zip
Add CopyPrimary keybinding action on Linux/BSD
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty.yml23
-rw-r--r--alacritty/src/config/bindings.rs8
-rw-r--r--alacritty/src/input.rs11
4 files changed, 27 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7a05428..f9c68516 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Default Command+N keybinding for SpawnNewInstance on macOS
- Vi mode for copying text and opening links
+- `CopySelection` action which copies into selection buffer on Linux/BSD
### Changed
diff --git a/alacritty.yml b/alacritty.yml
index eb4b4a43..f0e12747 100644
--- a/alacritty.yml
+++ b/alacritty.yml
@@ -504,6 +504,9 @@
# (macOS only):
# - ToggleSimpleFullscreen: Enters fullscreen without occupying another space
#
+# (Linux/BSD only):
+# - CopySelection: Copies into selection buffer
+#
# - `command`: Fork and execute a specified command plus arguments
#
# The `command` field must be a map containing a `program` string and an
@@ -569,6 +572,8 @@
#- { key: U, mods: Control, mode: Vi, action: ScrollHalfPageUp }
#- { key: D, mods: Control, mode: Vi, action: ScrollHalfPageDown }
#- { key: Y, mode: Vi, action: Copy }
+ #- { key: Y, mode: Vi, action: ClearSelection }
+ #- { key: Copy, mode: Vi, action: ClearSelection }
#- { key: V, mode: Vi, action: ToggleNormalSelection }
#- { key: V, mods: Shift, mode: Vi, action: ToggleLineSelection }
#- { key: V, mods: Control, mode: Vi, action: ToggleBlockSelection }
@@ -597,14 +602,15 @@
#- { key: Key5, mods: Shift, mode: Vi, action: Bracket }
# (Windows, Linux, and BSD only)
- #- { key: V, mods: Control|Shift, action: Paste }
- #- { key: C, mods: Control|Shift, action: Copy }
- #- { key: Insert, mods: Shift, action: PasteSelection }
- #- { key: Key0, mods: Control, action: ResetFontSize }
- #- { key: Equals, mods: Control, action: IncreaseFontSize }
- #- { key: Add, mods: Control, action: IncreaseFontSize }
- #- { key: Subtract, mods: Control, action: DecreaseFontSize }
- #- { key: Minus, mods: Control, action: DecreaseFontSize }
+ #- { key: V, mods: Control|Shift, action: Paste }
+ #- { key: C, mods: Control|Shift, action: Copy }
+ #- { key: C, mods: Control|Shift, mode: Vi, action: ClearSelection }
+ #- { key: Insert, mods: Shift, action: PasteSelection }
+ #- { key: Key0, mods: Control, action: ResetFontSize }
+ #- { key: Equals, mods: Control, action: IncreaseFontSize }
+ #- { key: Add, mods: Control, action: IncreaseFontSize }
+ #- { key: Subtract, mods: Control, action: DecreaseFontSize }
+ #- { key: Minus, mods: Control, action: DecreaseFontSize }
# (Windows only)
#- { key: Return, mods: Alt, action: ToggleFullscreen }
@@ -618,6 +624,7 @@
#- { key: K, mods: Command, action: ClearHistory }
#- { key: V, mods: Command, action: Paste }
#- { key: C, mods: Command, action: Copy }
+ #- { key: C, mods: Command, mode: Vi, action: ClearSelection }
#- { key: H, mods: Command, action: Hide }
#- { key: M, mods: Command, action: Minimize }
#- { key: Q, mods: Command, action: Quit }
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index 7485cd54..f9febc2a 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -111,6 +111,10 @@ pub enum Action {
/// Store current selection into clipboard.
Copy,
+ #[cfg(not(any(target_os = "macos", windows)))]
+ /// Store current selection into selection buffer.
+ CopySelection,
+
/// Paste contents of selection buffer.
PasteSelection,
@@ -297,6 +301,7 @@ pub fn default_key_bindings() -> Vec<KeyBinding> {
let mut bindings = bindings!(
KeyBinding;
Copy; Action::Copy;
+ Copy, +TermMode::VI; Action::ClearSelection;
Paste, ~TermMode::VI; Action::Paste;
L, ModifiersState::CTRL; Action::ClearLogNotice;
L, ModifiersState::CTRL, ~TermMode::VI; Action::Esc("\x0c".into());
@@ -366,6 +371,7 @@ pub fn default_key_bindings() -> Vec<KeyBinding> {
U, ModifiersState::CTRL, +TermMode::VI; Action::ScrollHalfPageUp;
D, ModifiersState::CTRL, +TermMode::VI; Action::ScrollHalfPageDown;
Y, +TermMode::VI; Action::Copy;
+ Y, +TermMode::VI; Action::ClearSelection;
V, +TermMode::VI; ViAction::ToggleNormalSelection;
V, ModifiersState::SHIFT, +TermMode::VI; ViAction::ToggleLineSelection;
V, ModifiersState::CTRL, +TermMode::VI; ViAction::ToggleBlockSelection;
@@ -472,6 +478,7 @@ fn common_keybindings() -> Vec<KeyBinding> {
KeyBinding;
V, ModifiersState::CTRL | ModifiersState::SHIFT, ~TermMode::VI; Action::Paste;
C, ModifiersState::CTRL | ModifiersState::SHIFT; Action::Copy;
+ C, ModifiersState::CTRL | ModifiersState::SHIFT, +TermMode::VI; Action::ClearSelection;
Insert, ModifiersState::SHIFT, ~TermMode::VI; Action::PasteSelection;
Key0, ModifiersState::CTRL; Action::ResetFontSize;
Equals, ModifiersState::CTRL; Action::IncreaseFontSize;
@@ -511,6 +518,7 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> {
F, ModifiersState::CTRL | ModifiersState::LOGO; Action::ToggleFullscreen;
K, ModifiersState::LOGO; Action::ClearHistory;
C, ModifiersState::LOGO; Action::Copy;
+ C, ModifiersState::LOGO, +TermMode::VI; Action::ClearSelection;
H, ModifiersState::LOGO; Action::Hide;
M, ModifiersState::LOGO; Action::Minimize;
Q, ModifiersState::LOGO; Action::Quit;
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs
index 6a2d925b..7c2a1f8b 100644
--- a/alacritty/src/input.rs
+++ b/alacritty/src/input.rs
@@ -132,14 +132,9 @@ impl<T: EventListener> Execute<T> for Action {
ctx.scroll(Scroll::Bottom);
ctx.write_to_pty(s.clone().into_bytes())
},
- Action::Copy => {
- ctx.copy_selection(ClipboardType::Clipboard);
-
- // Clear selection in vi mode for better user feedback
- if ctx.terminal().mode().contains(TermMode::VI) {
- ctx.clear_selection();
- }
- },
+ Action::Copy => ctx.copy_selection(ClipboardType::Clipboard),
+ #[cfg(not(any(target_os = "macos", windows)))]
+ Action::CopySelection => ctx.copy_selection(ClipboardType::Selection),
Action::Paste => {
let text = ctx.terminal_mut().clipboard().load(ClipboardType::Clipboard);
paste(ctx, &text);