2023-06-26 01:29:50 -08:00
|
|
|
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
|
2019-12-20 08:55:03 -09:00
|
|
|
|
2023-07-25 08:11:02 -08:00
|
|
|
const shellMenu = (
|
2019-12-20 08:55:03 -09:00
|
|
|
commandKeys: Record<string, string>,
|
2023-06-30 11:04:45 -08:00
|
|
|
execCommand: (command: string, focusedWindow?: BrowserWindow) => void,
|
|
|
|
|
profiles: string[]
|
2019-12-20 08:55:03 -09:00
|
|
|
): MenuItemConstructorOptions => {
|
2017-05-25 22:59:02 -08:00
|
|
|
const isMac = process.platform === 'darwin';
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
label: isMac ? 'Shell' : 'File',
|
|
|
|
|
submenu: [
|
|
|
|
|
{
|
2017-11-06 05:22:40 -09:00
|
|
|
label: 'New Tab',
|
|
|
|
|
accelerator: commandKeys['tab:new'],
|
2017-11-02 18:51:18 -08:00
|
|
|
click(item, focusedWindow) {
|
2017-11-06 05:22:40 -09:00
|
|
|
execCommand('tab:new', focusedWindow);
|
2017-05-25 22:59:02 -08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2017-11-06 05:22:40 -09:00
|
|
|
label: 'New Window',
|
|
|
|
|
accelerator: commandKeys['window:new'],
|
2017-05-25 22:59:02 -08:00
|
|
|
click(item, focusedWindow) {
|
2017-11-06 05:22:40 -09:00
|
|
|
execCommand('window:new', focusedWindow);
|
2017-05-25 22:59:02 -08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'separator'
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-07-30 14:03:33 -08:00
|
|
|
label: 'Split Down',
|
|
|
|
|
accelerator: commandKeys['pane:splitDown'],
|
2017-05-25 22:59:02 -08:00
|
|
|
click(item, focusedWindow) {
|
2019-07-30 14:03:33 -08:00
|
|
|
execCommand('pane:splitDown', focusedWindow);
|
2017-05-25 22:59:02 -08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-07-30 14:03:33 -08:00
|
|
|
label: 'Split Right',
|
|
|
|
|
accelerator: commandKeys['pane:splitRight'],
|
2017-05-25 22:59:02 -08:00
|
|
|
click(item, focusedWindow) {
|
2019-07-30 14:03:33 -08:00
|
|
|
execCommand('pane:splitRight', focusedWindow);
|
2017-05-25 22:59:02 -08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'separator'
|
|
|
|
|
},
|
2023-06-30 11:04:45 -08:00
|
|
|
...profiles.map(
|
|
|
|
|
(profile): MenuItemConstructorOptions => ({
|
|
|
|
|
label: profile,
|
|
|
|
|
submenu: [
|
|
|
|
|
{
|
|
|
|
|
label: 'New Tab',
|
2023-06-30 22:17:16 -08:00
|
|
|
accelerator: commandKeys[`tab:new:${profile}`],
|
2023-06-30 11:04:45 -08:00
|
|
|
click(item, focusedWindow) {
|
|
|
|
|
execCommand(`tab:new:${profile}`, focusedWindow);
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-30 11:07:04 -08:00
|
|
|
{
|
|
|
|
|
label: 'New Window',
|
2023-06-30 22:17:16 -08:00
|
|
|
accelerator: commandKeys[`window:new:${profile}`],
|
2023-06-30 11:07:04 -08:00
|
|
|
click(item, focusedWindow) {
|
|
|
|
|
execCommand(`window:new:${profile}`, focusedWindow);
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-30 11:04:45 -08:00
|
|
|
{
|
|
|
|
|
type: 'separator'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Split Down',
|
2023-06-30 22:17:16 -08:00
|
|
|
accelerator: commandKeys[`pane:splitDown:${profile}`],
|
2023-06-30 11:04:45 -08:00
|
|
|
click(item, focusedWindow) {
|
|
|
|
|
execCommand(`pane:splitDown:${profile}`, focusedWindow);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Split Right',
|
2023-06-30 22:17:16 -08:00
|
|
|
accelerator: commandKeys[`pane:splitRight:${profile}`],
|
2023-06-30 11:04:45 -08:00
|
|
|
click(item, focusedWindow) {
|
|
|
|
|
execCommand(`pane:splitRight:${profile}`, focusedWindow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
),
|
|
|
|
|
{
|
|
|
|
|
type: 'separator'
|
|
|
|
|
},
|
2017-05-25 22:59:02 -08:00
|
|
|
{
|
2017-11-06 05:22:40 -09:00
|
|
|
label: 'Close',
|
2017-11-02 18:51:18 -08:00
|
|
|
accelerator: commandKeys['pane:close'],
|
2017-05-25 22:59:02 -08:00
|
|
|
click(item, focusedWindow) {
|
2017-11-02 18:51:18 -08:00
|
|
|
execCommand('pane:close', focusedWindow);
|
2017-05-25 22:59:02 -08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: isMac ? 'Close Window' : 'Quit',
|
|
|
|
|
role: 'close',
|
2017-11-02 18:51:18 -08:00
|
|
|
accelerator: commandKeys['window:close']
|
2017-05-25 22:59:02 -08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-07-25 08:11:02 -08:00
|
|
|
|
|
|
|
|
export default shellMenu;
|