mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-15 04:42:45 +00:00
Fix desktop terminal link and context menu behavior
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { app, Menu, BrowserWindow } from "electron";
|
||||
import { app, Menu, BrowserWindow, ipcMain } from "electron";
|
||||
|
||||
type ShowContextMenuInput = {
|
||||
kind?: "terminal";
|
||||
hasSelection?: boolean;
|
||||
};
|
||||
|
||||
function withBrowserWindow(
|
||||
callback: (win: BrowserWindow) => void,
|
||||
@@ -89,4 +94,36 @@ export function setupApplicationMenu(): void {
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
ipcMain.handle("paseo:menu:showContextMenu", (event, input?: ShowContextMenuInput) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
if (!win) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (input?.kind !== "terminal") {
|
||||
return;
|
||||
}
|
||||
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: "Copy",
|
||||
role: "copy",
|
||||
enabled: input.hasSelection === true,
|
||||
},
|
||||
{
|
||||
label: "Paste",
|
||||
role: "paste",
|
||||
},
|
||||
{
|
||||
type: "separator",
|
||||
},
|
||||
{
|
||||
label: "Select All",
|
||||
role: "selectAll",
|
||||
},
|
||||
]);
|
||||
|
||||
menu.popup({ window: win });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user