fixed #194 - added hotkeys to scroll the terminal

This commit is contained in:
Eugene Pankov 2022-07-30 00:05:44 +02:00
parent 5d383eea04
commit c43137b8f6
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
5 changed files with 44 additions and 1 deletions

View file

@ -279,6 +279,15 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
case 'copy-current-path': case 'copy-current-path':
this.copyCurrentPath() this.copyCurrentPath()
break break
case 'scroll-to-top':
this.frontend?.scrollToTop()
break
case 'scroll-up':
this.frontend?.scrollPages(-1)
break
case 'scroll-down':
this.frontend?.scrollPages(1)
break
case 'scroll-to-bottom': case 'scroll-to-bottom':
this.frontend?.scrollToBottom() this.frontend?.scrollToBottom()
break break

View file

@ -5,7 +5,6 @@ export class TerminalConfigProvider extends ConfigProvider {
defaults = { defaults = {
hotkeys: { hotkeys: {
'copy-current-path': [], 'copy-current-path': [],
'scroll-to-bottom': [],
}, },
terminal: { terminal: {
frontend: 'xterm', frontend: 'xterm',
@ -113,6 +112,10 @@ export class TerminalConfigProvider extends ConfigProvider {
'pane-focus-all': [ 'pane-focus-all': [
'⌘-Shift-I', '⌘-Shift-I',
], ],
'scroll-to-top': ['Shift-PageUp'],
'scroll-up': ['PageUp'],
'scroll-down': ['PageDown'],
'scroll-to-bottom': ['Shift-PageDown'],
}, },
}, },
[Platform.Windows]: { [Platform.Windows]: {
@ -157,6 +160,10 @@ export class TerminalConfigProvider extends ConfigProvider {
'pane-focus-all': [ 'pane-focus-all': [
'Ctrl-Shift-I', 'Ctrl-Shift-I',
], ],
'scroll-to-top': ['Ctrl-PageUp'],
'scroll-up': ['PageUp'],
'scroll-down': ['PageDown'],
'scroll-to-bottom': ['Ctrl-PageDown'],
}, },
}, },
[Platform.Linux]: { [Platform.Linux]: {
@ -199,6 +206,10 @@ export class TerminalConfigProvider extends ConfigProvider {
'pane-focus-all': [ 'pane-focus-all': [
'Ctrl-Shift-I', 'Ctrl-Shift-I',
], ],
'scroll-to-top': ['Ctrl-PageUp'],
'scroll-up': ['PageUp'],
'scroll-down': ['PageDown'],
'scroll-to-bottom': ['Ctrl-PageDown'],
}, },
}, },
} }

View file

@ -75,6 +75,9 @@ export abstract class Frontend {
abstract write (data: string): Promise<void> abstract write (data: string): Promise<void>
abstract clear (): void abstract clear (): void
abstract visualBell (): void abstract visualBell (): void
abstract scrollToTop (): void
abstract scrollPages (pages: number): void
abstract scrollToBottom (): void abstract scrollToBottom (): void
abstract configure (): void abstract configure (): void

View file

@ -328,6 +328,14 @@ export class XTermFrontend extends Frontend {
} }
} }
scrollToTop (): void {
this.xterm.scrollToTop()
}
scrollPages (pages: number): void {
this.xterm.scrollPages(pages)
}
scrollToBottom (): void { scrollToBottom (): void {
this.xtermCore._scrollToBottom() this.xtermCore._scrollToBottom()
} }

View file

@ -73,6 +73,18 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
id: 'pane-focus-all', id: 'pane-focus-all',
name: this.translate.instant('Focus all panes at once (broadcast)'), name: this.translate.instant('Focus all panes at once (broadcast)'),
}, },
{
id: 'scroll-to-top',
name: this.translate.instant('Scroll terminal to top'),
},
{
id: 'scroll-up',
name: this.translate.instant('Scroll terminal one page up'),
},
{
id: 'scroll-down',
name: this.translate.instant('Scroll terminal one page down'),
},
{ {
id: 'scroll-to-bottom', id: 'scroll-to-bottom',
name: this.translate.instant('Scroll terminal to bottom'), name: this.translate.instant('Scroll terminal to bottom'),