From 8ee1d0076b359f9fb5ed133d64f39934111195c7 Mon Sep 17 00:00:00 2001 From: Atte Timonen Date: Thu, 19 May 2022 18:04:40 +0200 Subject: [PATCH] Implement hotkeys for navigating to a specific pane --- .../src/components/splitTab.component.ts | 36 +++++++++++++++++++ tabby-core/src/configDefaults.linux.yaml | 9 +++++ tabby-core/src/configDefaults.macos.yaml | 9 +++++ tabby-core/src/configDefaults.windows.yaml | 9 +++++ tabby-core/src/hotkeys.ts | 36 +++++++++++++++++++ 5 files changed, 99 insertions(+) diff --git a/tabby-core/src/components/splitTab.component.ts b/tabby-core/src/components/splitTab.component.ts index 065011a5..54f223ca 100644 --- a/tabby-core/src/components/splitTab.component.ts +++ b/tabby-core/src/components/splitTab.component.ts @@ -311,6 +311,33 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit case 'pane-nav-next': this.navigateLinear(1) break + case 'pane-nav-1': + this.navigateSpecific(0) + break + case 'pane-nav-2': + this.navigateSpecific(1) + break + case 'pane-nav-3': + this.navigateSpecific(2) + break + case 'pane-nav-4': + this.navigateSpecific(3) + break + case 'pane-nav-5': + this.navigateSpecific(4) + break + case 'pane-nav-6': + this.navigateSpecific(5) + break + case 'pane-nav-7': + this.navigateSpecific(6) + break + case 'pane-nav-8': + this.navigateSpecific(7) + break + case 'pane-nav-9': + this.navigateSpecific(8) + break case 'pane-maximize': if (this.maximizedTab) { this.maximize(null) @@ -644,6 +671,15 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit this.focus(target) } + navigateSpecific (target: number): void { + const all = this.getAllTabs() + if (target >= all.length) { + return + } + + this.focus(all[target]) + } + async splitTab (tab: BaseTabComponent, dir: SplitDirection): Promise { const newTab = await this.tabsService.duplicate(tab) if (newTab) { diff --git a/tabby-core/src/configDefaults.linux.yaml b/tabby-core/src/configDefaults.linux.yaml index 1cd5ef7b..cadb4160 100644 --- a/tabby-core/src/configDefaults.linux.yaml +++ b/tabby-core/src/configDefaults.linux.yaml @@ -73,6 +73,15 @@ hotkeys: - 'Ctrl-Alt-[' pane-nav-next: - 'Ctrl-Alt-]' + pane-nav-1: [] + pane-nav-2: [] + pane-nav-3: [] + pane-nav-4: [] + pane-nav-5: [] + pane-nav-6: [] + pane-nav-7: [] + pane-nav-8: [] + pane-nav-9: [] pane-maximize: - 'Ctrl-Alt-Enter' pane-increase-vertical: [] diff --git a/tabby-core/src/configDefaults.macos.yaml b/tabby-core/src/configDefaults.macos.yaml index c4bf2867..620471df 100644 --- a/tabby-core/src/configDefaults.macos.yaml +++ b/tabby-core/src/configDefaults.macos.yaml @@ -71,6 +71,15 @@ hotkeys: - '⌘-⌥-[' pane-nav-next: - '⌘-⌥-]' + pane-nav-1: [] + pane-nav-2: [] + pane-nav-3: [] + pane-nav-4: [] + pane-nav-5: [] + pane-nav-6: [] + pane-nav-7: [] + pane-nav-8: [] + pane-nav-9: [] pane-maximize: - '⌘-⌥-Enter' close-pane: diff --git a/tabby-core/src/configDefaults.windows.yaml b/tabby-core/src/configDefaults.windows.yaml index 1f334e0c..19293b87 100644 --- a/tabby-core/src/configDefaults.windows.yaml +++ b/tabby-core/src/configDefaults.windows.yaml @@ -74,6 +74,15 @@ hotkeys: - 'Ctrl-Alt-[' pane-nav-next: - 'Ctrl-Alt-]' + pane-nav-1: [] + pane-nav-2: [] + pane-nav-3: [] + pane-nav-4: [] + pane-nav-5: [] + pane-nav-6: [] + pane-nav-7: [] + pane-nav-8: [] + pane-nav-9: [] pane-maximize: - 'Ctrl-Alt-Enter' close-pane: [] diff --git a/tabby-core/src/hotkeys.ts b/tabby-core/src/hotkeys.ts index 9d73272b..e35f662f 100644 --- a/tabby-core/src/hotkeys.ts +++ b/tabby-core/src/hotkeys.ts @@ -188,6 +188,42 @@ export class AppHotkeyProvider extends HotkeyProvider { id: 'pane-nav-next', name: this.translate.instant('Focus next pane'), }, + { + id: 'pane-nav-1', + name: this.translate.instant('Focus pane {number}', { number: 1 }), + }, + { + id: 'pane-nav-2', + name: this.translate.instant('Focus pane {number}', { number: 2 }), + }, + { + id: 'pane-nav-3', + name: this.translate.instant('Focus pane {number}', { number: 3 }), + }, + { + id: 'pane-nav-4', + name: this.translate.instant('Focus pane {number}', { number: 4 }), + }, + { + id: 'pane-nav-5', + name: this.translate.instant('Focus pane {number}', { number: 5 }), + }, + { + id: 'pane-nav-6', + name: this.translate.instant('Focus pane {number}', { number: 6 }), + }, + { + id: 'pane-nav-7', + name: this.translate.instant('Focus pane {number}', { number: 7 }), + }, + { + id: 'pane-nav-8', + name: this.translate.instant('Focus pane {number}', { number: 8 }), + }, + { + id: 'pane-nav-9', + name: this.translate.instant('Focus pane {number}', { number: 9 }), + }, { id: 'switch-profile', name: this.translate.instant('Switch profile in the active pane'),