added a select-all shortcut - fixes #3081

This commit is contained in:
Eugene Pankov 2021-04-05 11:10:27 +02:00
parent 797265abb1
commit 247cf6f93e
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
5 changed files with 17 additions and 0 deletions

View File

@ -162,6 +162,9 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
case 'paste': case 'paste':
this.paste() this.paste()
break break
case 'select-all':
this.frontend?.selectAll()
break
case 'clear': case 'clear':
this.frontend?.clear() this.frontend?.clear()
break break

View File

@ -97,6 +97,7 @@ export class TerminalConfigProvider extends ConfigProvider {
clear: [ clear: [
'⌘-K', '⌘-K',
], ],
'select-all': ['⌘-A'],
'zoom-in': [ 'zoom-in': [
'⌘-=', '⌘-=',
'⌘-Shift-=', '⌘-Shift-=',
@ -142,6 +143,7 @@ export class TerminalConfigProvider extends ConfigProvider {
paste: [ paste: [
'Ctrl-Shift-V', 'Ctrl-Shift-V',
], ],
'select-all': ['Ctrl-Shift-A'],
clear: [], clear: [],
'zoom-in': [ 'zoom-in': [
'Ctrl-=', 'Ctrl-=',
@ -185,6 +187,7 @@ export class TerminalConfigProvider extends ConfigProvider {
paste: [ paste: [
'Ctrl-Shift-V', 'Ctrl-Shift-V',
], ],
'select-all': ['Ctrl-Shift-A'],
clear: [], clear: [],
'zoom-in': [ 'zoom-in': [
'Ctrl-=', 'Ctrl-=',

View File

@ -62,6 +62,7 @@ export abstract class Frontend {
abstract getSelection (): string abstract getSelection (): string
abstract copySelection (): void abstract copySelection (): void
abstract selectAll (): void
abstract clearSelection (): void abstract clearSelection (): void
abstract focus (): void abstract focus (): void
abstract write (data: string): void abstract write (data: string): void

View File

@ -33,6 +33,12 @@ export class HTermFrontend extends Frontend {
this.term.copySelectionToClipboard() 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 { clearSelection (): void {
this.term.getDocument().getSelection().removeAllRanges() this.term.getDocument().getSelection().removeAllRanges()
} }

View File

@ -186,6 +186,10 @@ export class XTermFrontend extends Frontend {
} }
} }
selectAll (): void {
this.xterm.selectAll()
}
clearSelection (): void { clearSelection (): void {
this.xterm.clearSelection() this.xterm.clearSelection()
} }