From 0452f42c41a7ac557b6010eb777cfc1d6ac18215 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 28 Jun 2021 22:41:08 +0200 Subject: [PATCH] added hotkeys to loop through panes - fixes #3417 --- .../src/components/splitTab.component.ts | 17 +++++++++++++++++ terminus-core/src/configDefaults.linux.yaml | 4 ++++ terminus-core/src/configDefaults.macos.yaml | 4 ++++ terminus-core/src/configDefaults.windows.yaml | 4 ++++ terminus-core/src/hotkeys.ts | 8 ++++++++ 5 files changed, 37 insertions(+) diff --git a/terminus-core/src/components/splitTab.component.ts b/terminus-core/src/components/splitTab.component.ts index 9a292656..10e8239a 100644 --- a/terminus-core/src/components/splitTab.component.ts +++ b/terminus-core/src/components/splitTab.component.ts @@ -238,6 +238,12 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit case 'pane-nav-down': this.navigate('b') break + case 'pane-nav-previous': + this.navigateLinear(-1) + break + case 'pane-nav-next': + this.navigateLinear(1) + break case 'pane-maximize': if (this.maximizedTab) { this.maximize(null) @@ -433,6 +439,17 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit } } + navigateLinear (delta: number): void { + if (!this.focusedTab) { + return + } + + const relativeTo: BaseTabComponent = this.focusedTab + const all = this.getAllTabs() + const target = all[(all.indexOf(relativeTo) + delta + all.length) % all.length] + this.focus(target) + } + async splitTab (tab: BaseTabComponent, dir: SplitDirection): Promise { const newTab = await this.tabsService.duplicate(tab) if (newTab) { diff --git a/terminus-core/src/configDefaults.linux.yaml b/terminus-core/src/configDefaults.linux.yaml index e8939c30..62e9f6db 100644 --- a/terminus-core/src/configDefaults.linux.yaml +++ b/terminus-core/src/configDefaults.linux.yaml @@ -62,6 +62,10 @@ hotkeys: - 'Ctrl-Alt-Up' pane-nav-left: - 'Ctrl-Alt-Left' + pane-nav-previous: + - 'Ctrl-Alt-[' + pane-nav-next: + - 'Ctrl-Alt-]' pane-maximize: - 'Ctrl-Alt-Enter' close-pane: [] diff --git a/terminus-core/src/configDefaults.macos.yaml b/terminus-core/src/configDefaults.macos.yaml index 970d6fbb..db91a013 100644 --- a/terminus-core/src/configDefaults.macos.yaml +++ b/terminus-core/src/configDefaults.macos.yaml @@ -60,6 +60,10 @@ hotkeys: - '⌘-⌥-Up' pane-nav-left: - '⌘-⌥-Left' + pane-nav-previous: + - '⌘-⌥-[' + pane-nav-next: + - '⌘-⌥-]' pane-maximize: - '⌘-⌥-Enter' close-pane: diff --git a/terminus-core/src/configDefaults.windows.yaml b/terminus-core/src/configDefaults.windows.yaml index e03c6776..5ddee4e2 100644 --- a/terminus-core/src/configDefaults.windows.yaml +++ b/terminus-core/src/configDefaults.windows.yaml @@ -63,6 +63,10 @@ hotkeys: - 'Ctrl-Alt-Up' pane-nav-left: - 'Ctrl-Alt-Left' + pane-nav-previous: + - 'Ctrl-Alt-[' + pane-nav-next: + - 'Ctrl-Alt-]' pane-maximize: - 'Ctrl-Alt-Enter' close-pane: [] diff --git a/terminus-core/src/hotkeys.ts b/terminus-core/src/hotkeys.ts index aaec3cb4..437f0a62 100644 --- a/terminus-core/src/hotkeys.ts +++ b/terminus-core/src/hotkeys.ts @@ -157,6 +157,14 @@ export class AppHotkeyProvider extends HotkeyProvider { id: 'pane-nav-right', name: 'Focus the pane on the right', }, + { + id: 'pane-nav-previous', + name: 'Focus previous pane', + }, + { + id: 'pane-nav-next', + name: 'Focus next pane', + }, { id: 'close-pane', name: 'Close focused pane',