Skip to content

Commit

Permalink
fixed #194 - added hotkeys to scroll the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jul 29, 2022
1 parent 5d383ee commit c43137b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tabby-terminal/src/api/baseTerminalTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion tabby-terminal/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export class TerminalConfigProvider extends ConfigProvider {
defaults = {
hotkeys: {
'copy-current-path': [],
'scroll-to-bottom': [],
},
terminal: {
frontend: 'xterm',
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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]: {
Expand Down Expand Up @@ -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'],
},
},
}
Expand Down
3 changes: 3 additions & 0 deletions tabby-terminal/src/frontends/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export abstract class Frontend {
abstract write (data: string): Promise<void>
abstract clear (): void
abstract visualBell (): void

abstract scrollToTop (): void
abstract scrollPages (pages: number): void
abstract scrollToBottom (): void

abstract configure (): void
Expand Down
8 changes: 8 additions & 0 deletions tabby-terminal/src/frontends/xtermFrontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
12 changes: 12 additions & 0 deletions tabby-terminal/src/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit c43137b

Please sign in to comment.