From f947fe3f0f20db1e601ddba63b829079e9daed7a Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Fri, 30 Mar 2018 23:33:46 +0200 Subject: [PATCH] paste as a configurable hotkey (fixes #260) --- .../src/components/terminalTab.component.ts | 13 +++++++++---- terminus-terminal/src/config.ts | 9 +++++++++ terminus-terminal/src/hotkeys.ts | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index f4da64e6..88432268 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -93,6 +93,9 @@ export class TerminalTabComponent extends BaseTabComponent { case 'copy': this.hterm.copySelectionToClipboard() break + case 'paste': + this.paste() + break case 'clear': this.clear() break @@ -231,10 +234,7 @@ export class TerminalTabComponent extends BaseTabComponent { hterm.primaryScreen_.terminal = hterm hterm.alternateScreen_.terminal = hterm - const _onPaste = hterm.scrollPort_.onPaste_.bind(hterm.scrollPort_) hterm.scrollPort_.onPaste_ = (event) => { - hterm.scrollPort_.pasteTarget_.value = event.clipboardData.getData('text/plain').trim() - _onPaste() event.preventDefault() } @@ -336,7 +336,12 @@ export class TerminalTabComponent extends BaseTabComponent { } paste () { - this.sendInput(this.electron.clipboard.readText()) + let data = this.electron.clipboard.readText() + data = this.hterm.keyboard.encode(data) + if (this.hterm.options_.bracketedPaste) { + data = '\x1b[200~' + data + '\x1b[201~' + } + this.sendInput(data) } clear () { diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index 5afe183b..74970cdf 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -56,6 +56,9 @@ export class TerminalConfigProvider extends ConfigProvider { 'copy': [ '⌘-C', ], + 'paste': [ + '⌘-V', + ], 'clear': [ '⌘-K', ], @@ -96,6 +99,9 @@ export class TerminalConfigProvider extends ConfigProvider { 'copy': [ 'Ctrl-Shift-C', ], + 'paste': [ + 'Ctrl-Shift-V', + ], 'clear': [ 'Ctrl-L', ], @@ -133,6 +139,9 @@ export class TerminalConfigProvider extends ConfigProvider { 'copy': [ 'Ctrl-Shift-C', ], + 'paste': [ + 'Ctrl-Shift-V', + ], 'clear': [ 'Ctrl-L', ], diff --git a/terminus-terminal/src/hotkeys.ts b/terminus-terminal/src/hotkeys.ts index 53e01ead..39e5b579 100644 --- a/terminus-terminal/src/hotkeys.ts +++ b/terminus-terminal/src/hotkeys.ts @@ -8,6 +8,10 @@ export class TerminalHotkeyProvider extends HotkeyProvider { id: 'copy', name: 'Copy to clipboard', }, + { + id: 'paste', + name: 'Paste from clipboard', + }, { id: 'home', name: 'Beginning of the line', -- GitLab