snap.love/0030-update_editor_box
Kartik K. Agaram 2f34ef4eb8 snapshot: a new debug tool
I might have finally hit on the right approach: a hotkey that dumps
information. Doesn't swamp me with data, and also doesn't perturb
anything.

y_of_schema1 returns consistent results as I pan around.
I'm just not actually printing the lines at that y. I'm printing it at
that y/Viewport.zoom.

What might be confusing here is that I started out with a simple mental
model:
  * perform computations in surface coordinates (sx,sy)
  * render in viewport coordinates (vx,vy)

But for text quality reasons I need to perform many computations in
"scaled surface" coordinates.

Viewport coordinates are both offset and scaled relative to surface
coordinates. Scaled surface = just scaled relative to surface, not
offset.

I don't have a clear mental model here for when to use this.

I did already use it in one place with my simple mental model: you have
to scale distances like rect.w and rect.h but it's incorrect to offset
them. Maybe I'm getting this wrong somehow.
2023-10-25 11:02:03 -07:00

17 lines
577 B
Plaintext

update_editor_box = function(node)
if node.editor == nil then return end
if node.y > Viewport.y then
if node ~= Cursor_node then
node.editor.screen_top1.line = 1
node.editor.screen_top1.pos = 1
end
node.editor.top = vy(node.y)
else
node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, Viewport.y-node.y)
end
node.editor.left = math.floor(vx(node.x))
node.editor.right = math.ceil(vx(node.x+node.w))
node.editor.width = node.editor.right - node.editor.left
edit.update_font_settings(node.editor, scale(20))
Text.redraw_all(node.editor)
end