diff --git a/index.html b/index.html
index 6c54e64..ba1cefa 100644
--- a/index.html
+++ b/index.html
@@ -322,8 +322,12 @@
.status {
color: red;
}
- .options {
+
+ .open_run_window {
margin-left: auto;
+ }
+
+ .options {
padding: 5px;
}
.options > * {
@@ -384,8 +388,6 @@
-
diff --git a/src/editor/ui.js b/src/editor/ui.js
index 2d7a35f..00002e8 100644
--- a/src/editor/ui.js
+++ b/src/editor/ui.js
@@ -1,4 +1,4 @@
-import {exec, get_state} from '../index.js'
+import {exec, get_state, open_run_window} from '../index.js'
import {Editor} from './editor.js'
import {Files} from './files.js'
import {CallTree} from './calltree.js'
@@ -67,6 +67,15 @@ export class UI {
'Fullscreen'
),
*/
+
+ el('a', {
+ 'class': 'open_run_window',
+ href: 'javascript: void(0)',
+ click: open_run_window,
+ },
+ '(Re)open run window (F6)'
+ ),
+
this.options = el('div', 'options',
el('label', {'for': 'standard'},
el('input', {
@@ -126,6 +135,10 @@ export class UI {
if(e.key == 'F5'){
this.fullscreen_editor()
}
+
+ if(e.key == 'F6'){
+ open_run_window()
+ }
})
if(!FLAGS.embed_value_explorer) {
diff --git a/src/eval.js b/src/eval.js
index 47ca818..5fb4b4b 100644
--- a/src/eval.js
+++ b/src/eval.js
@@ -57,15 +57,16 @@ type Node = ToplevelCall | Call
*/
// TODO just export const Iframe_Function?
-const make_function = globalThis.process != null
- // Tests are run in Node.js, no iframe
- ? (...args) => new Function(...args)
- // Browser context, run code in iframe
- : (...args) => {
- /* access window object for iframe */
- const fn_constructor = globalThis.run_code.contentWindow.Function
- return new fn_constructor(...args)
- }
+const make_function = (...args) => {
+ if(globalThis.run_window == null) {
+ // Tests are run in Node.js or user have not opened run_window
+ return new Function(...args)
+ } else {
+ // Code run in browser and user opened run_window
+ const fn_constructor = globalThis.run_window.Function
+ return new fn_constructor(...args)
+ }
+}
const codegen_function_expr = (node, cxt, name) => {
const do_codegen = n => codegen(n, cxt)
diff --git a/src/index.js b/src/index.js
index de5a971..818d45c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -10,6 +10,13 @@ const EXAMPLE = `const fib = n =>
: fib(n - 1) + fib(n - 2)
fib(6)`
+export const open_run_window = () => {
+ if(globalThis.run_window != null) {
+ globalThis.run_window.close()
+ }
+ globalThis.run_window = open('about:blank')
+}
+
const read_modules = async () => {
const default_module = {'': localStorage.code || EXAMPLE}
const current = {