mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Add CopyPrimary keybinding action on Linux/BSD
This commit is contained in:
parent
a2875454b1
commit
c9c5fbbe2b
4 changed files with 27 additions and 16 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue