From 277091df19b3348edc022c5963ba98f1b4164229 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 15 Oct 2025 23:10:23 +0100 Subject: [PATCH] webstead: slightly more robust invocation of bedstead Now we don't assume that stdout is line-buffered and that we'll therefore get a single call to print(). Instead, we collect up all the output in a string and use it when the program exits. --- webstead.xhtml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/webstead.xhtml b/webstead.xhtml index 3b582e4..0515640 100644 --- a/webstead.xhtml +++ b/webstead.xhtml @@ -75,18 +75,19 @@ } if (c_update_needed) document.getElementById("c").value = ` {"${cstr}", U() },`; + var charstring = ""; Bedstead({ - arguments: args, - print: function(charstring) { - document.getElementById("rendered") - .setAttribute("d", charstring - .replaceAll(//g, "") - .replace(/^.* [hv]stem /, "") - .replace(/^cntrmask [01]* /, "") - .replaceAll(/(\S+ +\S+ +)rmoveto/g, "m$1") - .replaceAll(/ rlineto/g, "") - .replace(/ endchar/, "")); - } + arguments: args, + print: printed => charstring += printed + }).then(() => { + document.getElementById("rendered") + .setAttribute("d", charstring + .replaceAll(//g, "") + .replace(/^.* [hv]stem /, "") + .replace(/^cntrmask [01]* /, "") + .replaceAll(/(\S+ +\S+ +)rmoveto/g, "m$1") + .replaceAll(/ rlineto/g, "") + .replace(/ endchar/, "")); }); } function from_c(c) { -- 2.30.2