New window command

lua
Zef Hemel 2024-09-10 14:38:41 +02:00
parent 880c67d6cd
commit d9aa6ef1c4
4 changed files with 21 additions and 0 deletions

View File

@ -123,6 +123,10 @@ export function openUrl(url: string, existingWindow = false): Promise<void> {
return syscall("editor.openUrl", url, existingWindow); return syscall("editor.openUrl", url, existingWindow);
} }
export function newWindow(): Promise<void> {
return syscall("editor.newWindow");
}
/** /**
* This is calling the `go()` method from the History Web API. * This is calling the `go()` method from the History Web API.
* @param delta Position in history to move to relative to the current page, * @param delta Position in history to move to relative to the current page,

View File

@ -72,6 +72,12 @@ functions:
path: "./editor.ts:toggleDarkMode" path: "./editor.ts:toggleDarkMode"
command: command:
name: "Editor: Toggle Dark Mode" name: "Editor: Toggle Dark Mode"
newWindow:
path: editor.ts:newWindowCommand
command:
name: "Editor: New Window"
key: "Ctrl-n"
mac: "Cmd-n"
openCommandPalette: openCommandPalette:
path: editor.ts:openCommandPalette path: editor.ts:openCommandPalette

View File

@ -97,3 +97,7 @@ export function redoCommand() {
export function deleteLineCommand() { export function deleteLineCommand() {
return editor.deleteLine(); return editor.deleteLine();
} }
export function newWindowCommand() {
return editor.newWindow();
}

View File

@ -81,6 +81,13 @@ export function editorSyscalls(client: Client): SysCallMapping {
location.href = url; location.href = url;
} }
}, },
"editor.newWindow": () => {
globalThis.open(
location.href,
"rnd" + Math.random(),
`width=${globalThis.innerWidth},heigh=${globalThis.innerHeight}`,
);
},
"editor.goHistory": (_ctx, delta: number) => { "editor.goHistory": (_ctx, delta: number) => {
window.history.go(delta); window.history.go(delta);
}, },