39 Commits

Author SHA1 Message Date
Ben Harris
940069cfe6 webstead: remove "test" from page title 2026-01-13 21:42:18 +00:00
Ben Harris
922af33a25 webstead: use .mjs for JavaSript module
This means that emcc automatically uses the correct mode, and seems
slightly more correct to me.
2026-01-13 21:42:18 +00:00
Ben Harris
277091df19 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.
2026-01-13 21:42:18 +00:00
Ben Harris
d84ca8b4e7 webstead: add some instructions 2026-01-13 21:42:18 +00:00
Ben Harris
a9bceeb6e7 webstead: click handler for output side
It's kind of ugly because there's no :active, but I can't see a nice
way to fake that.
2026-01-13 21:42:18 +00:00
Ben Harris
0ecf8f3ebf webstead: style for #pixels input:focus-visible
The usual focus ring in Firefox and Chromium appears at the same
stacking level as the element it's attached to.  This means that it's
hidden by elements after it in the document, including pixels below it
and to its right.  Fiddling with the z-index of the focussed pixel
helps with this.
2026-01-13 21:42:18 +00:00
Ben Harris
3c097befba webstead: add page icon 2026-01-13 21:42:18 +00:00
Ben Harris
1078f31ad1 webstead: support arrow keys for navigation 2026-01-13 21:42:18 +00:00
Ben Harris
da628c5e44 webstead: visual distinction for input:checked:active too
It's a bit crude, but I think it helps.
2026-01-13 21:42:18 +00:00
Ben Harris
e3fca90c39 webstead: mark :active pixels
This makes it more obvious that something is happening when the mouse
button is pressed, even though the tickybox doesnt change state until
it's released.  Thus should make the UI feel less sluggish.
2026-01-13 21:42:18 +00:00
Ben Harris
d99c68a2ba webstead: enable strict mode in top-level script
Now that it's not a module, we need to do this explicitly.  Also fix
various undeclared variables that this exposed.
2026-01-13 21:42:18 +00:00
Ben Harris
96f2490058 webstead: JavaScript is not Perl
Remove some braces accordingly.
2026-01-13 21:42:18 +00:00
Ben Harris
4457cf5107 webstead: allow for editing C version of character
The new code triggers when the <input> is edited.  It updates the
pixel tickyboxes and the rendered glyph, but suppresses updating the
<input> itself.  This can be used for interactive editing, but is
mostly to allow for pasting in character bitmaps.
2026-01-13 21:42:18 +00:00
Ben Harris
212db5dd91 webstead: reset form at start of from_c()
That way we don't get fragments of the old glyph if it stops early.
2026-01-13 21:42:18 +00:00
Ben Harris
4d3b7ecc4c 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.
2026-01-13 21:42:18 +00:00
Ben Harris
d6ccde8a4a webstead: use an <input> to display C code 2026-01-13 21:42:18 +00:00
Ben Harris
15f9f591a1 webstead: more sensible viewBox for <svg> 2026-01-13 21:42:18 +00:00
Ben Harris
e6b411252b webstead: use a non-module <script> and import()
According to <https://github.com/fuweichin/xhtml5-esm-support>, an
internal script (a <script> element with content) can't be a module in
an XHTML page in Safari.  So following the suggestion on that page, I
make the <script> on the page into a classic script, and use import()
to load the module containing the bedstead executable.  Maybe this
will work on a reasonable selection of modern browsers.
2026-01-13 21:42:18 +00:00
Ben Harris
b62b0454b5 webstead: add Emscripten and musl copyright notices
Programs compiled with Emscripten end up statically linked against the
Emscripten runtime, which includes musl libc.  So we need to comply with
their licences by including a copy of the licence and the relevant
copyright notices.  I think putting them on the webstead page in small
print is probably the best approach.

This might need updating each release to match the version of Emscripten
that I build the editor with.
2026-01-13 21:42:18 +00:00
Ben Harris
c99994e91d webstead: prefer querySelector[All] over getElement*
It's a bit shorter, a bit more general, and allows me to properly
query only input elements that are children of the table of pixels.
2026-01-13 21:42:18 +00:00
Ben Harris
e6c1e44db0 webstead: mark script as async
Apparently Chromium can't cope with "defer" scripts (which modules are
by default) in XHTML documents.  But "async" scripts work properly,
so now we use one of those and then wait for DOMContentLoaded as
necessary.
2026-01-13 21:42:18 +00:00
Ben Harris
295660b1f9 webstead: set color:inherit on tickyboxes
Chromium's browser stylesheet overrides this.
2026-01-13 21:42:18 +00:00
Ben Harris
96ee19d038 webstead: put border on tickboxes, not table cells
That means the borders are clickable, which is what I want.
2026-01-13 21:42:18 +00:00
Ben Harris
7ba57f2e27 webstead: scale input and output better with window size
It turns out that setting --pix to 7vmin, while rather unprincipled,
does actually work quite adequately.
2026-01-13 21:42:18 +00:00
Ben Harris
64b18f30bb webstead: use currentColor for checked background
This means that webstead.xhtml doesn't know anything about the colours
in bedstead.css.
2026-01-13 21:42:18 +00:00
Ben Harris
8825e680dd webstead: use <pre> for C code 2026-01-13 21:42:18 +00:00
Ben Harris
74463d2a76 webstead: generate initialisers to paste into bedstead.c 2026-01-13 21:42:18 +00:00
Ben Harris
02514737cd webstead: slight CSS simplification
Don't need to specify border colour if it's the current colour anyway.
2026-01-13 21:42:18 +00:00
Ben Harris
e1e16471c8 webstead: better layout 2026-01-13 21:42:18 +00:00
Ben Harris
3a6e2bc265 webstead: almost-acceptable pixel-looking input 2026-01-13 21:42:18 +00:00
Ben Harris
70cbbde7f9 webstead: slightly cleverer path translation
Now paths with successive rlineto operations (to avoid overflowing the
Type 2 stack) work.
2026-01-13 21:42:18 +00:00
Ben Harris
357fbbc829 webstead: SVG transform to turn output right way up 2026-01-13 21:42:18 +00:00
Ben Harris
568d7f43ab webstead: properly ignore cntrmask 2026-01-13 21:42:18 +00:00
Ben Harris
09c777481b webstead: input from an array of tickyboxes 2026-01-13 21:42:18 +00:00
Ben Harris
6cf53005fe webstead: make a named function to update the rendered glyph 2026-01-13 21:42:18 +00:00
Ben Harris
111484a4f1 webstead: SVG rendering by extremely crude regexps 2026-01-13 21:42:18 +00:00
Ben Harris
1a49f8d120 webstead: use standard bedstead.css 2026-01-13 21:42:18 +00:00
Ben Harris
fb377b66af Capture output in HTML 2026-01-13 21:42:18 +00:00
Ben Harris
861c4749e6 Minimal build system and test page for Bedstead-in-WASM
Just allows for typing a command line and seeing the output.
2026-01-13 21:42:18 +00:00