Skip to content

Commit 823e061

Browse files
committedFeb 8, 2025
1 parent d4c0852 commit 823e061

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
 

‎packages/home/tabs-store.tsx

+34
Original file line numberDiff line numberDiff line change
@@ -1320,12 +1320,46 @@ export class Tabs {
13201320
tab.reloadProject();
13211321
}
13221322
}
1323+
1324+
showNextTab() {
1325+
for (let i = 0; i < this.tabs.length; i++) {
1326+
if (this.tabs[i] == this.activeTab) {
1327+
if (i + 1 < this.tabs.length) {
1328+
this.makeActive(this.tabs[i + 1]);
1329+
} else {
1330+
this.makeActive(this.tabs[0]);
1331+
}
1332+
break;
1333+
}
1334+
}
1335+
}
1336+
1337+
showPreviousTab() {
1338+
for (let i = 0; i < this.tabs.length; i++) {
1339+
if (this.tabs[i] == this.activeTab) {
1340+
if (i - 1 >= 0) {
1341+
this.makeActive(this.tabs[i - 1]);
1342+
} else {
1343+
this.makeActive(this.tabs[this.tabs.length - 1]);
1344+
}
1345+
break;
1346+
}
1347+
}
1348+
}
13231349
}
13241350

13251351
export let tabs: Tabs;
13261352

13271353
export function loadTabs() {
13281354
tabs = new Tabs();
1355+
1356+
ipcRenderer.on("show-next-tab", async () => {
1357+
tabs.showNextTab();
1358+
});
1359+
1360+
ipcRenderer.on("show-previous-tab", async () => {
1361+
tabs.showPreviousTab();
1362+
});
13291363
}
13301364

13311365
export function openProject(filePath: string, runMode: boolean) {

‎packages/main/menu.ts

+24
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,30 @@ function buildViewMenu(win: IWindow | undefined) {
772772
});
773773
}
774774

775+
viewSubmenu.push({
776+
label: "Next Tab",
777+
accelerator: "Ctrl+Tab",
778+
click: function (item) {
779+
if (win) {
780+
win.browserWindow.webContents.send("show-next-tab");
781+
}
782+
}
783+
});
784+
785+
viewSubmenu.push({
786+
label: "Previous Tab",
787+
accelerator: "Ctrl+Shift+Tab",
788+
click: function (item) {
789+
if (win) {
790+
win.browserWindow.webContents.send("show-previous-tab");
791+
}
792+
}
793+
});
794+
795+
viewSubmenu.push({
796+
type: "separator"
797+
});
798+
775799
viewSubmenu.push({
776800
label: "Reload",
777801
accelerator: "CmdOrCtrl+R",

0 commit comments

Comments
 (0)
Failed to load comments.