mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-09 06:20:22 +08:00
hotkeys to move tabs around (fixes #2079)
This commit is contained in:
parent
9ca091e592
commit
4a50c84cfe
@ -107,6 +107,12 @@ export class AppRootComponent {
|
||||
if (hotkey === 'previous-tab') {
|
||||
this.app.previousTab()
|
||||
}
|
||||
if (hotkey === 'move-tab-left') {
|
||||
this.app.moveSelectedTabLeft()
|
||||
}
|
||||
if (hotkey === 'move-tab-right') {
|
||||
this.app.moveSelectedTabRight()
|
||||
}
|
||||
}
|
||||
if (hotkey === 'toggle-fullscreen') {
|
||||
this.hostApp.toggleFullscreen()
|
||||
|
@ -16,6 +16,10 @@ hotkeys:
|
||||
previous-tab:
|
||||
- 'Ctrl-Shift-Left'
|
||||
- 'Ctrl-Shift-Tab'
|
||||
move-tab-left:
|
||||
- 'Ctrl-Shift-PageUp'
|
||||
move-tab-right:
|
||||
- 'Ctrl-Shift-PageDown'
|
||||
tab-1:
|
||||
- 'Alt-1'
|
||||
tab-2:
|
||||
|
@ -14,6 +14,10 @@ hotkeys:
|
||||
- 'Ctrl-Tab'
|
||||
previous-tab:
|
||||
- 'Ctrl-Shift-Tab'
|
||||
move-tab-left:
|
||||
- '⌘-Shift-Left'
|
||||
move-tab-right:
|
||||
- '⌘-Shift-Right'
|
||||
tab-1:
|
||||
- '⌘-1'
|
||||
tab-2:
|
||||
|
@ -17,6 +17,10 @@ hotkeys:
|
||||
previous-tab:
|
||||
- 'Ctrl-Shift-Left'
|
||||
- 'Ctrl-Shift-Tab'
|
||||
move-tab-left:
|
||||
- 'Ctrl-Shift-PageUp'
|
||||
move-tab-right:
|
||||
- 'Ctrl-Shift-PageDown'
|
||||
tab-1:
|
||||
- 'Alt-1'
|
||||
tab-2:
|
||||
|
@ -37,6 +37,14 @@ export class AppHotkeyProvider extends HotkeyProvider {
|
||||
id: 'previous-tab',
|
||||
name: 'Previous tab',
|
||||
},
|
||||
{
|
||||
id: 'move-tab-left',
|
||||
name: 'Move tab to the left',
|
||||
},
|
||||
{
|
||||
id: 'move-tab-right',
|
||||
name: 'Move tab to the right',
|
||||
},
|
||||
{
|
||||
id: 'tab-1',
|
||||
name: 'Tab 1',
|
||||
|
@ -224,6 +224,35 @@ export class AppService {
|
||||
}
|
||||
}
|
||||
|
||||
moveSelectedTabLeft () {
|
||||
if (this.tabs.length > 1) {
|
||||
const tabIndex = this.tabs.indexOf(this._activeTab)
|
||||
if (tabIndex > 0) {
|
||||
this.swapTabs(this._activeTab, this.tabs[tabIndex - 1])
|
||||
} else if (this.config.store.appearance.cycleTabs) {
|
||||
this.swapTabs(this._activeTab, this.tabs[this.tabs.length - 1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
moveSelectedTabRight () {
|
||||
if (this.tabs.length > 1) {
|
||||
const tabIndex = this.tabs.indexOf(this._activeTab)
|
||||
if (tabIndex < this.tabs.length - 1) {
|
||||
this.swapTabs(this._activeTab, this.tabs[tabIndex + 1])
|
||||
} else if (this.config.store.appearance.cycleTabs) {
|
||||
this.swapTabs(this._activeTab, this.tabs[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
swapTabs (a: BaseTabComponent, b: BaseTabComponent) {
|
||||
const i1 = this.tabs.indexOf(a)
|
||||
const i2 = this.tabs.indexOf(b)
|
||||
this.tabs[i1] = b
|
||||
this.tabs[i2] = a
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
emitTabsChanged () {
|
||||
this.tabsChanged.next()
|
||||
|
Loading…
Reference in New Issue
Block a user