sclass JLeftArrowScriptIDE is Swingable { settable SimpleLiveValue lvScript = stringLiveValue(); S sectionTitle = "Left arrow script"; transient CompileResult compileResult; transient RSyntaxTextAreaWithSearch taScript; transient new Q compileQ; transient JLabel lblCompileResult; transient JButton btnRun; visual { taScript = liveValueRSyntaxTextArea_bothWays(lvScript); awtCalcEvery(taScript.textArea(), 1.0, -> compileQ.add(r compile)); ret jCenteredSection(sectionTitle, centerAndSouthWithMargin( taScript.visualize(), centerAndEastWithMargin( lblCompileResult = jlabel(), btnRun = jbutton("Run" := rThread runScript)))); } bool visible() { ret isShowing(lblCompileResult); } void compile { var script = lvScript!; var result = compileResult; if (result == null || !eq(result.script, script)) { try { result = new CompileResult; result.script = script; result.parser = new GazelleV_LeftArrowScriptParser; modifyParser(result.parser); result.parsedScript = result.parser.parse(result.script); print(result.parsedScript); } catch print e { result.compileError = e; } compileResult = result; setText(lblCompileResult, compileResult); updateRunButtonState(); } } swappable void updateRunButtonState() { setEnabled(btnRun, compileResult != null && compileResult.runnable()); } CompileResult freshCompileResult() { runInQAndWait(compileQ, r compile); ret compileResult; } GazelleV_LeftArrowScript.Script parsedScript() { ret freshCompileResult().parsedScript; } swappable void runButtonAction { runScript(); } void runScript { //showText_fast_noWrap("Script Error", renderStackTrace(e)); var result = freshCompileResult(); if (result.parsedScript != null) result.result = okOrError(-> result.parsedScript!); } class CompileResult { S script; GazelleV_LeftArrowScriptParser parser; Throwable compileError; GazelleV_LeftArrowScript.Script parsedScript; OKOrError result; toString { ret compileError != null ? exceptionToStringShorter(compileError) : "Compiled OK"; } bool runnable() { ret parsedScript != null; } } swappable void modifyParser(GazelleV_LeftArrowScriptParser parser) { parser.allowTheWorld(mc()); } void showRuntimeError(Throwable e) { setText(lblCompileResult, exceptionToStringShorter(e)); } }