From f2a42df2f33c99a47e0c04d1bc17662f2319b8b1 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 12 Apr 2021 13:33:32 -0400 Subject: =?UTF-8?q?Add=20=E2=80=A2Show=20to=20REPLs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bqn.js | 4 +++- docs/repl.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/bqn.js b/docs/bqn.js index 896a39a5..891248f2 100755 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -358,7 +358,9 @@ if (typeof module!=='undefined') { let args = process.argv.slice(2); args.map(a=>{ try { - console.log(fmt(bqn(a))) + let out=[]; sysvals.show = (x,w) => { out.push(x); return x; } + out.push(bqn(a)); + console.log(out.map(fmt).join('\n')); } catch(e) { console.error(''+fmtErr(Array.from(a),e)+''); } diff --git a/docs/repl.js b/docs/repl.js index ec79324f..40eb6c4f 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -26,9 +26,11 @@ let repl = ()=>{ setcount(s); setTimeout(() => { try { + let out=[]; sysvals.show = (x,w) => { out.push(x); return x; } let c=compile(src,rt_sys); setExplain(src,c); - doc.rslt.textContent=fmt(run.apply(null,c)); + out.push(run.apply(null,c)); + doc.rslt.textContent=out.map(fmt).join('\n'); } catch(e) { doc.rslt.classList.add('err'); doc.rslt.textContent=fmtErr(src,e); -- cgit v1.2.3