From c43137b8f6cbe2b20a06b860b828c3af3179f02a Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sat, 30 Jul 2022 00:05:44 +0200 Subject: [PATCH] fixed #194 - added hotkeys to scroll the terminal --- tabby-terminal/src/api/baseTerminalTab.component.ts | 9 +++++++++ tabby-terminal/src/config.ts | 13 ++++++++++++- tabby-terminal/src/frontends/frontend.ts | 3 +++ tabby-terminal/src/frontends/xtermFrontend.ts | 8 ++++++++ tabby-terminal/src/hotkeys.ts | 12 ++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index 526860ca63..10665ee19e 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -279,6 +279,15 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit case 'copy-current-path': this.copyCurrentPath() 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': this.frontend?.scrollToBottom() break diff --git a/tabby-terminal/src/config.ts b/tabby-terminal/src/config.ts index a865597462..e2b78584db 100644 --- a/tabby-terminal/src/config.ts +++ b/tabby-terminal/src/config.ts @@ -5,7 +5,6 @@ export class TerminalConfigProvider extends ConfigProvider { defaults = { hotkeys: { 'copy-current-path': [], - 'scroll-to-bottom': [], }, terminal: { frontend: 'xterm', @@ -113,6 +112,10 @@ export class TerminalConfigProvider extends ConfigProvider { 'pane-focus-all': [ '⌘-Shift-I', ], + 'scroll-to-top': ['Shift-PageUp'], + 'scroll-up': ['PageUp'], + 'scroll-down': ['PageDown'], + 'scroll-to-bottom': ['Shift-PageDown'], }, }, [Platform.Windows]: { @@ -157,6 +160,10 @@ export class TerminalConfigProvider extends ConfigProvider { 'pane-focus-all': [ 'Ctrl-Shift-I', ], + 'scroll-to-top': ['Ctrl-PageUp'], + 'scroll-up': ['PageUp'], + 'scroll-down': ['PageDown'], + 'scroll-to-bottom': ['Ctrl-PageDown'], }, }, [Platform.Linux]: { @@ -199,6 +206,10 @@ export class TerminalConfigProvider extends ConfigProvider { 'pane-focus-all': [ 'Ctrl-Shift-I', ], + 'scroll-to-top': ['Ctrl-PageUp'], + 'scroll-up': ['PageUp'], + 'scroll-down': ['PageDown'], + 'scroll-to-bottom': ['Ctrl-PageDown'], }, }, } diff --git a/tabby-terminal/src/frontends/frontend.ts b/tabby-terminal/src/frontends/frontend.ts index 54056b7268..72a08ac919 100644 --- a/tabby-terminal/src/frontends/frontend.ts +++ b/tabby-terminal/src/frontends/frontend.ts @@ -75,6 +75,9 @@ export abstract class Frontend { abstract write (data: string): Promise abstract clear (): void abstract visualBell (): void + + abstract scrollToTop (): void + abstract scrollPages (pages: number): void abstract scrollToBottom (): void abstract configure (): void diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index 076606ec3e..532920d6e4 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -328,6 +328,14 @@ export class XTermFrontend extends Frontend { } } + scrollToTop (): void { + this.xterm.scrollToTop() + } + + scrollPages (pages: number): void { + this.xterm.scrollPages(pages) + } + scrollToBottom (): void { this.xtermCore._scrollToBottom() } diff --git a/tabby-terminal/src/hotkeys.ts b/tabby-terminal/src/hotkeys.ts index 878cd2fa34..3346af456b 100644 --- a/tabby-terminal/src/hotkeys.ts +++ b/tabby-terminal/src/hotkeys.ts @@ -73,6 +73,18 @@ export class TerminalHotkeyProvider extends HotkeyProvider { id: 'pane-focus-all', 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', name: this.translate.instant('Scroll terminal to bottom'),