mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-08 21:40:03 +00:00
added tab explore/combine hotkeys - fixes #5703
This commit is contained in:
parent
fdca83ff27
commit
177a988292
@ -112,6 +112,12 @@ export class AppRootComponent {
|
|||||||
if (hotkey === 'duplicate-tab') {
|
if (hotkey === 'duplicate-tab') {
|
||||||
this.app.duplicateTab(this.app.activeTab)
|
this.app.duplicateTab(this.app.activeTab)
|
||||||
}
|
}
|
||||||
|
if (hotkey === 'explode-tab' && this.app.activeTab instanceof SplitTabComponent) {
|
||||||
|
this.app.explodeTab(this.app.activeTab)
|
||||||
|
}
|
||||||
|
if (hotkey === 'combine-tabs' && this.app.activeTab instanceof SplitTabComponent) {
|
||||||
|
this.app.combineTabsInto(this.app.activeTab)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (hotkey === 'reopen-tab') {
|
if (hotkey === 'reopen-tab') {
|
||||||
this.app.reopenLastTab()
|
this.app.reopenLastTab()
|
||||||
|
@ -82,6 +82,18 @@ export class SplitContainer {
|
|||||||
this.ratios = this.ratios.map(x => x / s)
|
this.ratios = this.ratios.map(x => x / s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes all tabs have the same size
|
||||||
|
*/
|
||||||
|
equalize (): void {
|
||||||
|
for (const child of this.children) {
|
||||||
|
if (child instanceof SplitContainer) {
|
||||||
|
child.equalize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.ratios.fill(1 / this.ratios.length)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the left/top side offset for the given element index (between 0 and 1)
|
* Gets the left/top side offset for the given element index (between 0 and 1)
|
||||||
*/
|
*/
|
||||||
@ -449,6 +461,8 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
|
|||||||
this.attachTabView(tab)
|
this.attachTabView(tab)
|
||||||
this.onAfterTabAdded(tab)
|
this.onAfterTabAdded(tab)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.root.normalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTab (tab: BaseTabComponent): void {
|
removeTab (tab: BaseTabComponent): void {
|
||||||
@ -644,6 +658,11 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
equalize (): void {
|
||||||
|
this.root.normalize()
|
||||||
|
this.root.equalize()
|
||||||
|
}
|
||||||
|
|
||||||
private updateTitle (): void {
|
private updateTitle (): void {
|
||||||
this.setTitle([...new Set(this.getAllTabs().map(x => x.title))].join(' | '))
|
this.setTitle([...new Set(this.getAllTabs().map(x => x.title))].join(' | '))
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
div {
|
div {
|
||||||
background: rgba(0, 0, 0, .7);
|
background: rgba(0, 0, 0, .7);
|
||||||
padding: 20px 30px;
|
padding: 20px 30px;
|
||||||
font-size: 18px;
|
margin: 20px;
|
||||||
|
font-size: 16px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -21,6 +21,10 @@ hotkeys:
|
|||||||
rearrange-panes:
|
rearrange-panes:
|
||||||
- 'Ctrl-Shift'
|
- 'Ctrl-Shift'
|
||||||
duplicate-tab: []
|
duplicate-tab: []
|
||||||
|
explode-tab:
|
||||||
|
- 'Ctrl-Shift-.'
|
||||||
|
combine-tabs:
|
||||||
|
- 'Ctrl-Shift-,'
|
||||||
tab-1:
|
tab-1:
|
||||||
- 'Alt-1'
|
- 'Alt-1'
|
||||||
tab-2:
|
tab-2:
|
||||||
|
@ -39,6 +39,10 @@ hotkeys:
|
|||||||
tab-10:
|
tab-10:
|
||||||
- '⌘-0'
|
- '⌘-0'
|
||||||
duplicate-tab: []
|
duplicate-tab: []
|
||||||
|
explode-tab:
|
||||||
|
- '⌘-Shift-.'
|
||||||
|
combine-tabs:
|
||||||
|
- '⌘-Shift-,'
|
||||||
tab-11: []
|
tab-11: []
|
||||||
tab-12: []
|
tab-12: []
|
||||||
tab-13: []
|
tab-13: []
|
||||||
|
@ -22,6 +22,10 @@ hotkeys:
|
|||||||
rearrange-panes:
|
rearrange-panes:
|
||||||
- 'Ctrl-Shift'
|
- 'Ctrl-Shift'
|
||||||
duplicate-tab: []
|
duplicate-tab: []
|
||||||
|
explode-tab:
|
||||||
|
- 'Ctrl-Shift-.'
|
||||||
|
combine-tab:
|
||||||
|
- 'Ctrl-Shift-,'
|
||||||
tab-1:
|
tab-1:
|
||||||
- 'Alt-1'
|
- 'Alt-1'
|
||||||
tab-2:
|
tab-2:
|
||||||
|
@ -56,6 +56,14 @@ export class AppHotkeyProvider extends HotkeyProvider {
|
|||||||
id: 'duplicate-tab',
|
id: 'duplicate-tab',
|
||||||
name: this.translate.instant('Duplicate tab'),
|
name: this.translate.instant('Duplicate tab'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'explode-tab',
|
||||||
|
name: this.translate.instant('Turn current tab\'s panes into separate tabs'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'combine-tabs',
|
||||||
|
name: this.translate.instant('Combine all tabs into the current tab'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'tab-1',
|
id: 'tab-1',
|
||||||
name: this.translate.instant('Tab {number}', { number: 1 }),
|
name: this.translate.instant('Tab {number}', { number: 1 }),
|
||||||
|
@ -399,4 +399,40 @@ export class AppService {
|
|||||||
showSelector <T> (name: string, options: SelectorOption<T>[]): Promise<T> {
|
showSelector <T> (name: string, options: SelectorOption<T>[]): Promise<T> {
|
||||||
return this.selector.show(name, options)
|
return this.selector.show(name, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explodeTab (tab: SplitTabComponent): SplitTabComponent[] {
|
||||||
|
const result: SplitTabComponent[] = []
|
||||||
|
for (const child of tab.getAllTabs().slice(1)) {
|
||||||
|
tab.removeTab(child)
|
||||||
|
result.push(this.wrapAndAddTab(child))
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
combineTabsInto (into: SplitTabComponent): void {
|
||||||
|
this.explodeTab(into)
|
||||||
|
|
||||||
|
let allChildren: BaseTabComponent[] = []
|
||||||
|
for (const tab of this.tabs) {
|
||||||
|
if (into === tab) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let children = [tab]
|
||||||
|
if (tab instanceof SplitTabComponent) {
|
||||||
|
children = tab.getAllTabs()
|
||||||
|
}
|
||||||
|
allChildren = allChildren.concat(children)
|
||||||
|
}
|
||||||
|
|
||||||
|
let x = 1
|
||||||
|
let previous: BaseTabComponent|null = null
|
||||||
|
const stride = Math.ceil(Math.sqrt(allChildren.length + 1))
|
||||||
|
for (const child of allChildren) {
|
||||||
|
into.add(child, x ? previous : null, x ? 'r' : 'b')
|
||||||
|
previous = child
|
||||||
|
x = (x + 1) % stride
|
||||||
|
}
|
||||||
|
|
||||||
|
into.equalize()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user