diff --git a/CHANGELOG.md b/CHANGELOG.md index d7a0542..f9c6851 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 eb4b4a4..f0e1274 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 7485cd5..f9febc2 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 { 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 { 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; 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 { 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 6a2d925..7c2a1f8 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -132,14 +132,9 @@ impl Execute 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);