From: Ben Harris Date: Tue, 7 Oct 2025 22:43:53 +0000 (+0100) Subject: webstead: add a function to read a C string X-Git-Tag: bedstead-3.261~43 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=4d3b7ecc4c37141b3a1c77a5916fd2732e24cba5;p=bedstead.git webstead: add a function to read a C string Like pasting in the Python editor. Now I just need to tie this into the UI in a way that's not horrible. --- diff --git a/webstead.xhtml b/webstead.xhtml index 5e0735c..7dfcbb4 100644 --- a/webstead.xhtml +++ b/webstead.xhtml @@ -75,6 +75,22 @@ } }); } + function from_c(c) { + re = /[0-7]+/g; + for (row of document.querySelector('#pixels').rows) { + match = re.exec(c); + if (match == null) { + break; + } + rowbits = Number.parseInt(match[0], 8); + for (var pixel + of Array.from(row.querySelectorAll('input')).reverse()) { + pixel.checked = (rowbits & 1 != 0); + rowbits >>= 1; + } + } + update_glyph(); + } function init() { for (var e of document.querySelectorAll('#pixels input')) { e.onchange = update_glyph;