From deb4b963cdb5c0dbcd6a9a75fda98fc653988d6c Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 5 Jul 2017 18:46:16 +0200 Subject: [PATCH] copy hotkey for macOS (fixes #61) --- .../src/components/terminalTab.component.ts | 6 ++++++ terminus-terminal/src/config.ts | 9 +++++++++ terminus-terminal/src/hotkeys.ts | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 311b7848..619e2df4 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -69,6 +69,12 @@ export class TerminalTabComponent extends BaseTabComponent { this.session.releaseInitialDataBuffer() }) this.hotkeysSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => { + if (!this.hasFocus) { + return + } + if (hotkey === 'copy') { + this.hterm.copySelectionToClipboard() + } if (hotkey === 'zoom-in') { this.zoomIn() } diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index 914a8224..03da5eba 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -44,6 +44,9 @@ export class TerminalConfigProvider extends ConfigProvider { shell: '~default-shell~', }, hotkeys: { + 'copy': [ + '⌘-C', + ], 'zoom-in': [ '⌘-=', '⌘-Shift-+', @@ -69,6 +72,9 @@ export class TerminalConfigProvider extends ConfigProvider { shell: '~clink~', }, hotkeys: { + 'copy': [ + 'Ctrl-Shift-C', + ], 'zoom-in': [ 'Ctrl-=', 'Ctrl-Shift-+', @@ -93,6 +99,9 @@ export class TerminalConfigProvider extends ConfigProvider { shell: '~default-shell~', }, hotkeys: { + 'copy': [ + 'Ctrl-Shift-C', + ], 'zoom-in': [ 'Ctrl-=', 'Ctrl-Shift-+', diff --git a/terminus-terminal/src/hotkeys.ts b/terminus-terminal/src/hotkeys.ts index 0d30ffe5..da8faa1d 100644 --- a/terminus-terminal/src/hotkeys.ts +++ b/terminus-terminal/src/hotkeys.ts @@ -4,6 +4,10 @@ import { IHotkeyDescription, HotkeyProvider } from 'terminus-core' @Injectable() export class TerminalHotkeyProvider extends HotkeyProvider { hotkeys: IHotkeyDescription[] = [ + { + id: 'copy', + name: 'Copy to clipboard', + }, { id: 'zoom-in', name: 'Zoom in',