From d9aa6ef1c4c635b759fb40f816fa33436fda1b0f Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Tue, 10 Sep 2024 14:38:41 +0200 Subject: [PATCH] New window command --- plug-api/syscalls/editor.ts | 4 ++++ plugs/editor/editor.plug.yaml | 6 ++++++ plugs/editor/editor.ts | 4 ++++ web/syscalls/editor.ts | 7 +++++++ 4 files changed, 21 insertions(+) diff --git a/plug-api/syscalls/editor.ts b/plug-api/syscalls/editor.ts index b7806a5f..9cef3b9c 100644 --- a/plug-api/syscalls/editor.ts +++ b/plug-api/syscalls/editor.ts @@ -123,6 +123,10 @@ export function openUrl(url: string, existingWindow = false): Promise { return syscall("editor.openUrl", url, existingWindow); } +export function newWindow(): Promise { + return syscall("editor.newWindow"); +} + /** * This is calling the `go()` method from the History Web API. * @param delta Position in history to move to relative to the current page, diff --git a/plugs/editor/editor.plug.yaml b/plugs/editor/editor.plug.yaml index 95f344b8..794e89be 100644 --- a/plugs/editor/editor.plug.yaml +++ b/plugs/editor/editor.plug.yaml @@ -72,6 +72,12 @@ functions: path: "./editor.ts:toggleDarkMode" command: name: "Editor: Toggle Dark Mode" + newWindow: + path: editor.ts:newWindowCommand + command: + name: "Editor: New Window" + key: "Ctrl-n" + mac: "Cmd-n" openCommandPalette: path: editor.ts:openCommandPalette diff --git a/plugs/editor/editor.ts b/plugs/editor/editor.ts index 5c824b2e..8818db30 100644 --- a/plugs/editor/editor.ts +++ b/plugs/editor/editor.ts @@ -97,3 +97,7 @@ export function redoCommand() { export function deleteLineCommand() { return editor.deleteLine(); } + +export function newWindowCommand() { + return editor.newWindow(); +} diff --git a/web/syscalls/editor.ts b/web/syscalls/editor.ts index d7701360..35b6a37c 100644 --- a/web/syscalls/editor.ts +++ b/web/syscalls/editor.ts @@ -81,6 +81,13 @@ export function editorSyscalls(client: Client): SysCallMapping { location.href = url; } }, + "editor.newWindow": () => { + globalThis.open( + location.href, + "rnd" + Math.random(), + `width=${globalThis.innerWidth},heigh=${globalThis.innerHeight}`, + ); + }, "editor.goHistory": (_ctx, delta: number) => { window.history.go(delta); },