From 247cf6f93e49bb2c50390507eb1feb434a648895 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 5 Apr 2021 11:10:27 +0200 Subject: [PATCH] added a select-all shortcut - fixes #3081 --- terminus-terminal/src/api/baseTerminalTab.component.ts | 3 +++ terminus-terminal/src/config.ts | 3 +++ terminus-terminal/src/frontends/frontend.ts | 1 + terminus-terminal/src/frontends/htermFrontend.ts | 6 ++++++ terminus-terminal/src/frontends/xtermFrontend.ts | 4 ++++ 5 files changed, 17 insertions(+) diff --git a/terminus-terminal/src/api/baseTerminalTab.component.ts b/terminus-terminal/src/api/baseTerminalTab.component.ts index 11fbffa9..b75adb8e 100644 --- a/terminus-terminal/src/api/baseTerminalTab.component.ts +++ b/terminus-terminal/src/api/baseTerminalTab.component.ts @@ -162,6 +162,9 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit case 'paste': this.paste() break + case 'select-all': + this.frontend?.selectAll() + break case 'clear': this.frontend?.clear() break diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index ee7a205b..ec570c09 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -97,6 +97,7 @@ export class TerminalConfigProvider extends ConfigProvider { clear: [ '⌘-K', ], + 'select-all': ['⌘-A'], 'zoom-in': [ '⌘-=', '⌘-Shift-=', @@ -142,6 +143,7 @@ export class TerminalConfigProvider extends ConfigProvider { paste: [ 'Ctrl-Shift-V', ], + 'select-all': ['Ctrl-Shift-A'], clear: [], 'zoom-in': [ 'Ctrl-=', @@ -185,6 +187,7 @@ export class TerminalConfigProvider extends ConfigProvider { paste: [ 'Ctrl-Shift-V', ], + 'select-all': ['Ctrl-Shift-A'], clear: [], 'zoom-in': [ 'Ctrl-=', diff --git a/terminus-terminal/src/frontends/frontend.ts b/terminus-terminal/src/frontends/frontend.ts index 1a80e0eb..06c08a30 100644 --- a/terminus-terminal/src/frontends/frontend.ts +++ b/terminus-terminal/src/frontends/frontend.ts @@ -62,6 +62,7 @@ export abstract class Frontend { abstract getSelection (): string abstract copySelection (): void + abstract selectAll (): void abstract clearSelection (): void abstract focus (): void abstract write (data: string): void diff --git a/terminus-terminal/src/frontends/htermFrontend.ts b/terminus-terminal/src/frontends/htermFrontend.ts index 13973d35..efd77a96 100644 --- a/terminus-terminal/src/frontends/htermFrontend.ts +++ b/terminus-terminal/src/frontends/htermFrontend.ts @@ -33,6 +33,12 @@ export class HTermFrontend extends Frontend { this.term.copySelectionToClipboard() } + selectAll (): void { + const content = this.term.getDocument().body.children[0] + const selection = content.ownerDocument.defaultView.getSelection() + selection.setBaseAndExtent(content, 0, content, 1) + } + clearSelection (): void { this.term.getDocument().getSelection().removeAllRanges() } diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index 7b0e2c06..5b6a8ae2 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -186,6 +186,10 @@ export class XTermFrontend extends Frontend { } } + selectAll (): void { + this.xterm.selectAll() + } + clearSelection (): void { this.xterm.clearSelection() }