terminal menu

rdesktop2
filip mertens 1 year ago
parent 12c0894079
commit 35a7690591
  1. 6
      apps/remixdesktop/src/engine.ts
  2. 1
      apps/remixdesktop/src/main.ts
  3. 5
      apps/remixdesktop/src/menus/commands.ts
  4. 20
      apps/remixdesktop/src/menus/terminal.ts
  5. 40
      apps/remixdesktop/src/plugins/xtermPlugin.ts

@ -36,6 +36,12 @@ ipcMain.on('fs:openFolder', async (event) => {
fsPlugin.openFolder(event) fsPlugin.openFolder(event)
}) })
ipcMain.on('terminal:new', async (event) => {
console.log('terminal:new', event)
xtermPlugin.new(event)
})
ipcMain.on('template:open', async (event) => { ipcMain.on('template:open', async (event) => {
console.log('template:open', event) console.log('template:open', event)
templatesPlugin.openTemplate(event) templatesPlugin.openTemplate(event)

@ -96,6 +96,7 @@ import WindowMenu from './menus/window';
import EditMenu from './menus/edit'; import EditMenu from './menus/edit';
import GitMenu from './menus/git'; import GitMenu from './menus/git';
import ViewMenu from './menus/view'; import ViewMenu from './menus/view';
import TerminalMenu from './menus/terminal';
import { execCommand } from './menus/commands'; import { execCommand } from './menus/commands';

@ -12,6 +12,11 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
ipcMain.emit('fs:openFolder', focusedWindow.webContents.id); ipcMain.emit('fs:openFolder', focusedWindow.webContents.id);
} }
}, },
'terminal:new': (focusedWindow) => {
if (focusedWindow) {
ipcMain.emit('terminal:new', focusedWindow.webContents.id);
}
},
'template:open': (focusedWindow) => { 'template:open': (focusedWindow) => {
if (focusedWindow) { if (focusedWindow) {
ipcMain.emit('template:open', focusedWindow.webContents.id); ipcMain.emit('template:open', focusedWindow.webContents.id);

@ -0,0 +1,20 @@
import {BrowserWindow, MenuItemConstructorOptions} from 'electron';
export default (
commandKeys: Record<string, string>,
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
): MenuItemConstructorOptions => {
const isMac = process.platform === 'darwin';
return {
label: 'Terminal',
submenu: [
{
label: 'New Terminal',
click(item, focusedWindow) {
execCommand('terminal:new', focusedWindow);
}
}
]
};
};

@ -6,27 +6,27 @@ import os from 'os';
import * as pty from "node-pty" import * as pty from "node-pty"
import process from 'node:process'; import process from 'node:process';
import {userInfo} from 'node:os'; import { userInfo } from 'node:os';
export const detectDefaultShell = () => { export const detectDefaultShell = () => {
const {env} = process; const { env } = process;
if (process.platform === 'win32') { if (process.platform === 'win32') {
return env.SHELL || 'powershell.exe'; return env.SHELL || 'powershell.exe';
} }
try { try {
const {shell} = userInfo(); const { shell } = userInfo();
if (shell) { if (shell) {
return shell; return shell;
} }
} catch {} } catch { }
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
return env.SHELL || '/bin/zsh'; return env.SHELL || '/bin/zsh';
} }
return env.SHELL || '/bin/sh'; return env.SHELL || '/bin/sh';
}; };
// Stores default shell when imported. // Stores default shell when imported.
@ -49,6 +49,13 @@ export class XtermPlugin extends ElectronBasePlugin {
super(profile, clientProfile, XtermPluginClient) super(profile, clientProfile, XtermPluginClient)
} }
new(webContentsId: any): void {
const client = this.clients.find(c => c.webContentsId === webContentsId)
if (client) {
client.new()
}
}
} }
const clientProfile: Profile = { const clientProfile: Profile = {
@ -114,4 +121,7 @@ class XtermPluginClient extends ElectronBasePluginClient {
this.emit('data', data, pid) this.emit('data', data, pid)
} }
async new(): Promise<void> {
}
} }
Loading…
Cancel
Save