Skip to content

Print programs with editor-based layout and typesetting#264

Merged
osnr merged 65 commits into
mainfrom
osnr/fields
May 29, 2026
Merged

Print programs with editor-based layout and typesetting#264
osnr merged 65 commits into
mainfrom
osnr/fields

Conversation

@osnr
Copy link
Copy Markdown
Collaborator

@osnr osnr commented May 27, 2026

WIP. Still needs support for

  1. A4 / non-letter paper
  2. multi-page printing
IMG_5303
IMG_5302.MOV

The program gets printed at whatever text scale you had in the editor at print time, and with the editor's exact margins and font.

The goal here is to let you edit 'in place' and preview in place so you can test real-world geometric constructs like fields as you program. We want to make the printed code feel like a real interaction element and not just a nice-to-have for the human reader.

osnr added 30 commits May 13, 2026 12:05
This doesn't seem to affect folk-hex, but it might affect other
systems / require re-measuring geometry.

This still doesn't provide perfectly calibrated prints: I think there
are some margin issues:
https://moral.net.au/writing/2023/05/19/printer_actual_size/
where there was a risk we would reuse a not-yet-destroyed match and
then accidentally stomp its destructorSet in the final stage of match
destruction. This now uses a sentinel to distinguish 'removed' and
'fully destroyed' stages.
Want to use for on-top editor.
Goal here is to be able to prototype and preview fields at scale / in
context while writing a program that uses them. The detached editor
wouldn't work for this.
Printing should share as much layout logic with draw as possible.
Turn off Hold of quad rendering -- this may cause blinking, but
hopefully -atomically can handle.

Make tag in print preview not detect.
It's not perfectly aligned -- need to look into.

Also still some subtleties with different paper formats to fix / make
sure work. Basically, I think the editor needs to be
format-aware/media-aware in order for this all to make sense.
Next: use the calibration pdf to calibrate tag size and margins such
that we can print at accurate scale after calibration, and such that
we calibrate at exactly the same tag size that we print programs at.
so that we can live-update them when we hotpatch a dependency
program (they won't just hang around the global namespace for that
interp).
Need to make everything use the same print pipeline so we can be sure
that the user is actually calibrating what they'll actually use to
print programs.
@osnr osnr requested a review from ppkn May 27, 2026 21:37
@osnr
Copy link
Copy Markdown
Collaborator Author

osnr commented May 27, 2026

Some weird other changes here:

  • jimtcl interpreter now tracks column numbers (so we can find field locations later)
  • local fns get revoked when block exits, so they don't stick around in scope (so they get hot-reloaded properly)
  • calibration tags and printed pages are now slightly smaller, should be same size -- you should recalibrate. this should help calibration accuracy in practice (more points per pose, more robust against user tag measurement error since printed tag is same size as calibrated tag)
  • quads are not held, just wished, which may introduce more blinking (need to look at using -atomically for this). fixes some removal race

Comment thread builtin-programs/calibrate/calibrate-page.folk Outdated
Comment thread builtin-programs/calibrate/calibration-board.folk Outdated
Comment thread builtin-programs/editor/editor.folk Outdated
Copy link
Copy Markdown
Collaborator

@smj-edison smj-edison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really exciting, it feels like the digital and physical worlds are coming even closer with this.

@osnr osnr marked this pull request as ready for review May 28, 2026 17:59
@osnr
Copy link
Copy Markdown
Collaborator Author

osnr commented May 28, 2026

How would people feel about merging this? I'm not sure what it does at A4 but everything else seems OK.

@osnr
Copy link
Copy Markdown
Collaborator Author

osnr commented May 28, 2026

This PR also removes word-wrap (since you can manually wrap your lines as you choose) and interactively-refine (which ended up not being that effective)

osnr added 10 commits May 28, 2026 15:16
This fixes quad blinking so it mostly behaves the same as when we were
using Hold to render quads.
We can hopefully factor all of this out and automate it soon, but it's
a useful exercise right now to figure out where we need atomic scopes.
Centralize paper formats in print.folk
so on USB printer driver which has huge margins, we don't end up with
even huger tag/code margins, we can just subtract them to get close to
the margin we're actually targeting.

We re-enable scaling so that the page _never_ cuts off, which I
realized was an issue with no-scaling.
so that we can target even closer when you point an editor at an
existing program.
@osnr osnr merged commit acc537b into main May 29, 2026
@osnr osnr deleted the osnr/fields branch May 29, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants