mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: hotkeys to navigate forward or backward between tabs
This commit is contained in:
@ -556,7 +556,9 @@ export default {
|
|||||||
selectTab,
|
selectTab,
|
||||||
newTab,
|
newTab,
|
||||||
removeTab,
|
removeTab,
|
||||||
updateTabs
|
updateTabs,
|
||||||
|
selectNextTab,
|
||||||
|
selectPrevTab
|
||||||
} = workspacesStore;
|
} = workspacesStore;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -568,7 +570,9 @@ export default {
|
|||||||
selectTab,
|
selectTab,
|
||||||
newTab,
|
newTab,
|
||||||
removeTab,
|
removeTab,
|
||||||
updateTabs
|
updateTabs,
|
||||||
|
selectNextTab,
|
||||||
|
selectPrevTab
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
@ -670,6 +674,22 @@ export default {
|
|||||||
if (currentTab)
|
if (currentTab)
|
||||||
this.closeTab(currentTab);
|
this.closeTab(currentTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// select next tab
|
||||||
|
if (e.altKey && (e.ctrlKey || e.metaKey) && e.key === 'ArrowRight')
|
||||||
|
this.selectNextTab({ uid: this.connection.uid });
|
||||||
|
|
||||||
|
// select prev tab
|
||||||
|
if (e.altKey && (e.ctrlKey || e.metaKey) && e.key === 'ArrowLeft')
|
||||||
|
this.selectPrevTab({ uid: this.connection.uid });
|
||||||
|
|
||||||
|
// select tab by index (range 1-9). CTRL|CMD number
|
||||||
|
if ((e.ctrlKey || e.metaKey) && !e.altKey && e.keyCode >= 49 && e.keyCode <= 57) {
|
||||||
|
const newIndex = parseInt(e.key) - 1;
|
||||||
|
|
||||||
|
if (this.workspace.tabs[newIndex])
|
||||||
|
this.selectTab({ uid: this.connection.uid, tab: this.workspace.tabs[newIndex].uid });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
openAsPermanentTab (tab) {
|
openAsPermanentTab (tab) {
|
||||||
const permanentTabs = {
|
const permanentTabs = {
|
||||||
|
@ -609,6 +609,26 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
|||||||
: workspace
|
: workspace
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
selectNextTab ({ uid }) {
|
||||||
|
const workspace = this.workspaces.find(workspace => workspace.uid === uid);
|
||||||
|
|
||||||
|
let newIndex = workspace.tabs.findIndex(tab => tab.selected || tab.uid === workspace.selectedTab) + 1;
|
||||||
|
|
||||||
|
if (newIndex > workspace.tabs.length -1)
|
||||||
|
newIndex = 0;
|
||||||
|
|
||||||
|
this.selectTab({ uid, tab: workspace.tabs[newIndex].uid });
|
||||||
|
},
|
||||||
|
selectPrevTab ({ uid }) {
|
||||||
|
const workspace = this.workspaces.find(workspace => workspace.uid === uid);
|
||||||
|
|
||||||
|
let newIndex = workspace.tabs.findIndex(tab => tab.selected || tab.uid === workspace.selectedTab) - 1;
|
||||||
|
|
||||||
|
if (newIndex < 0)
|
||||||
|
newIndex = workspace.tabs.length -1;
|
||||||
|
|
||||||
|
this.selectTab({ uid, tab: workspace.tabs[newIndex].uid });
|
||||||
|
},
|
||||||
updateTabs ({ uid, tabs }) {
|
updateTabs ({ uid, tabs }) {
|
||||||
this.workspaces = this.workspaces.map(workspace => workspace.uid === uid
|
this.workspaces = this.workspaces.map(workspace => workspace.uid === uid
|
||||||
? { ...workspace, tabs }
|
? { ...workspace, tabs }
|
||||||
|
Reference in New Issue
Block a user