chiark / gitweb /
webstead: add a function to read a C string
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 7 Oct 2025 22:43:53 +0000 (23:43 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 13 Jan 2026 21:42:18 +0000 (21:42 +0000)
Like pasting in the Python editor.  Now I just need to tie this into
the UI in a way that's not horrible.

webstead.xhtml

index 5e0735c40ecd3bb99b219629ba8eb248e7e8ba1c..7dfcbb4287e6c15193643047bd42741399593928 100644 (file)
             }
         });
     }
+    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;