From c087a969d6310784a5f0893fba71711ccd8f05e1 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 5 Jul 2017 19:31:58 +0200 Subject: [PATCH] cmd-k to clear the terminal (fixes #39) --- .../src/components/terminalTab.component.ts | 8 ++++++++ terminus-terminal/src/config.ts | 9 +++++++++ terminus-terminal/src/hotkeys.ts | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 619e2df4..d2286f08 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -75,6 +75,9 @@ export class TerminalTabComponent extends BaseTabComponent { if (hotkey === 'copy') { this.hterm.copySelectionToClipboard() } + if (hotkey === 'clear') { + this.clear() + } if (hotkey === 'zoom-in') { this.zoomIn() } @@ -234,6 +237,11 @@ export class TerminalTabComponent extends BaseTabComponent { this.io.writeUTF8(data) } + clear () { + this.hterm.wipeContents() + this.hterm.onVTKeystroke('\f') + } + async configure (): Promise { let config = this.config.store preferenceManager.set('font-family', config.terminal.font) diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index 03da5eba..f36103bb 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -47,6 +47,9 @@ export class TerminalConfigProvider extends ConfigProvider { 'copy': [ '⌘-C', ], + 'clear': [ + '⌘-K', + ], 'zoom-in': [ '⌘-=', '⌘-Shift-+', @@ -75,6 +78,9 @@ export class TerminalConfigProvider extends ConfigProvider { 'copy': [ 'Ctrl-Shift-C', ], + 'clear': [ + 'Ctrl-L', + ], 'zoom-in': [ 'Ctrl-=', 'Ctrl-Shift-+', @@ -102,6 +108,9 @@ export class TerminalConfigProvider extends ConfigProvider { 'copy': [ 'Ctrl-Shift-C', ], + 'clear': [ + 'Ctrl-L', + ], 'zoom-in': [ 'Ctrl-=', 'Ctrl-Shift-+', diff --git a/terminus-terminal/src/hotkeys.ts b/terminus-terminal/src/hotkeys.ts index da8faa1d..dc19d04c 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: 'clear', + name: 'Clear terminal', + }, { id: 'zoom-in', name: 'Zoom in',