From 2f34ef4eb86d7ef17f76f7c7a4933fcea443c917 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 25 Oct 2023 11:02:03 -0700 Subject: [PATCH] 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. --- 0023-on.keychord_press | 4 +++- 0030-update_editor_box | 3 +-- 0034-dump_state | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 0034-dump_state diff --git a/0023-on.keychord_press b/0023-on.keychord_press index 10658d6..061c78e 100644 --- a/0023-on.keychord_press +++ b/0023-on.keychord_press @@ -14,6 +14,8 @@ on.keychord_press = function(chord, key) -- reset zoom Viewport.zoom = 1.0 A() + elseif chord == 'C-z' then + dump_state() elseif Cursor_node and Cursor_node.editor.cursor_x then local old_top = {line=Cursor_node.editor.screen_top1.line, pos=Cursor_node.editor.screen_top1.pos} edit.keychord_press(Cursor_node.editor, chord, key) @@ -54,4 +56,4 @@ on.keychord_press = function(chord, key) B() end end -end +end \ No newline at end of file diff --git a/0030-update_editor_box b/0030-update_editor_box index 33aa595..3baed3c 100644 --- a/0030-update_editor_box +++ b/0030-update_editor_box @@ -8,11 +8,10 @@ update_editor_box = function(node) node.editor.top = vy(node.y) else node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, Viewport.y-node.y) - print('update', Viewport.y-node.y+node.editor.top - y_of_schema1(node.editor, node.editor.screen_top1)) 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 +end \ No newline at end of file diff --git a/0034-dump_state b/0034-dump_state new file mode 100644 index 0000000..5ce6667 --- /dev/null +++ b/0034-dump_state @@ -0,0 +1,10 @@ +dump_state = function() + print('===') + print('zoom', Viewport.zoom) + print('viewport', Viewport.y) + print('node', Page.data[1].y) + print('node renders from', Page.data[1].editor.top) + print('screen top', Page.data[1].editor.screen_top1.line) + local l = 25 + print('y of line', l, y_of_schema1(Page.data[1].editor, {line=l, pos=1})) +end \ No newline at end of file