Commit Graph

31 Commits

Author SHA1 Message Date
Kartik K. Agaram bddd673e94 Merge driver.love 2024-07-25 22:27:21 -07:00
Kartik K. Agaram 2647e7dc3a bugfix: initial animation updates font size 2024-07-25 22:23:58 -07:00
Kartik K. Agaram 91b9a02b28 redo font caching
This is a do-over of parts of commits b32a60548 and f1de276ce.

The key ideas are:
  if edit.update_font_settings receives a font object, it's already of the requested font_height
  if update_editor_box receives a font, it's already of the requested height scale(20)
  if B                 receives a font, it's already of the requested height scale(20)
  whether B receives a font or not,
    all the editors on Surface will share a single font object when it's done, and
    the font object will have the right size
  A sets the font and passes it in to all the above functions.
2024-07-25 21:52:29 -07:00
Kartik K. Agaram 93db26b610 Merge driver.love 2024-07-12 16:21:32 -07:00
Kartik K. Agaram 7cc402c36b bugfix: stale argument 2024-07-12 16:17:33 -07:00
Kartik K. Agaram 971623c28b Merge driver.love 2024-07-10 01:31:56 -07:00
Kartik K. Agaram 6be4ab6c9e Merge luaML.love
A() determines the font and passes it in explicitly to all editors.
2024-07-10 01:27:25 -07:00
Kartik K. Agaram ca82d861dd Merge driver.love 2023-10-27 18:35:54 -07:00
Kartik K. Agaram b74f2b917d Merge luaML.love
Manual tests rechecked for this fork.
2023-10-27 18:23:24 -07:00
Kartik K. Agaram 1031f47496 snapshot: a whole new approach to panning
Basic idea: If the goal is for the cursor to be on the viewport, focus
the code on ensuring that constraint by construction.

Motivation: The downstream driver.love fork still has persistent bugs.
And I'm seeing some inconclusive signs that edit.lua might be failing to
change screen_top some of the time when it needs to. But this only
happens in driver.love, never in lines.love. So the null hypothesis is
that there's some subtle assumption in lines.love that we're violating
when rendering it on a surface.

What do you do with such subtleties? It might actually be
counterproductive to fix them at source. You end up with complexity
upstream that won't actually matter there if it breaks. Which is a
recipe for it to break silently and far away from the downstream fork
that might actually care about it. Or it might confuse people in future
who don't care about the downstream forks, just lines.love.

Maybe it makes sense to modify edit.lua here and take the hit on all
possible future merge conflicts. But considering the cost of tracking
this down, it seems simplest to:
a) come up with the constraint I care about, and
b) modify outside edit.lua, either what it sees or its results, to
preserve the new constraint.

Long ago I used to have this assertion in pensieve.love that the cursor
must be within the viewport, but I ended up taking it out because it
kept breaking for me when I was trying to do real work. It seems clear
that there are possible assertions that are useful and yet
counterproductive. If you can't keep it out of the product in the course
of testing, then it annoys users where ignoring it would be a more
graceful experience. Even when the user is just yourself! So it turns
out this is not a problem only for large teams of extrinsically
motivated people who don't eat their own dog food. No, for some things
you have to fix the problem by construction, not just verify it with an
assertion.

This plan isn't fully working yet in this commit. I've only fixed cases
for down-arrow. I need to address up arrow, and there might also be
changes for left/right arrows. Hmm, I'm going to try to follow the
implementation of bring_cursor_of_cursor_node_in_view() in
pensieve.love.

In the process of doing this I also noticed a bug with page-up/down. It
already existed, but this approach has made it more obvious.
2023-10-27 16:07:34 -07:00
Kartik K. Agaram 45c32104a8 Merge driver.love 2023-10-25 21:03:14 -07:00
Kartik K. Agaram 8c73b2f783 Merge luaML.love 2023-10-25 20:05:59 -07:00
Kartik K. Agaram 8d9af77ab1 clean up all the mess since commit fe4e1395d0
In the process we find a new bug. Scrolling with keyboard is overly
eager to clamp screen_top to bottom of screen when the top used to be
within the viewport.

Until recently, scrolling past the bottom when the margin was visible
would move the cursor correctly but pan the surface to the top of the
viewport. Slightly jarring, but good enough.
2023-10-25 17:59:38 -07:00
Kartik K. Agaram ed08869d25 fix a stupid mistake
Everything seems to be working now!
2023-10-25 17:48:00 -07:00
Kartik K. Agaram 45c1e42de2 snapshot: a cleaner organization
scenarios:
  * Zoom = 1
    * pan with mouse: ✓
    * pan with up arrow: ✓
    * pan with down arrow: ✓
  * Zoom < 1
    * pan with mouse: ✓
    * pan with up arrow: ✓
    * pan with down arrow: ✗
  * Zoom > 1
    * pan with mouse: ✓
    * pan with up arrow: ✗
    * pan with down arrow: ✓

What ✓ means:
* pan with mouse: lines don't slide relative to the surface
  * will still slide relative to the surface when zooming in/out;
    that's unavoidable because we want integer pixels for crisp text
* pan with keyboard: at least some part of cursor is always peeking within the viewport
  * might still look ugly, with the line containing the cursor almost invisible,
    but hitting the down arrow will never pan upwards, or vice versa

Still not working though. I'm pretty much guaranteeing by construction that if
Viewport.y was set from screen_top1, then screen_top1 will not be perturbed.
And yet using scale() inside update_editor_box is incorrect. Hmm..
2023-10-25 16:49:39 -07:00
Kartik K. Agaram 0a37b1b80c revert commit 4c8960b5c7
Well, almost. I'm just reminding myself of the sort of plumbing I need,
not reintroducing the old logic that never worked right and had
undergone n iterations of corruption.
2023-10-25 16:23:28 -07:00
Kartik K. Agaram e10ac63be5 snapshot: insight
Ugh, it's been in front of my eyes all along. The logs have been
repeatedly showing a recurrence within a single frame:

key press -> update Viewport.y from screen_top -> A -> B -> update_editor_box -> update screen_top from Viewport.y

We need both those updates, but both should never occur at the same
time to the same node.

I think this is why screen panning works if I take out the scale inside
update_editor_box: the scale has already happened "once" in
updating Viewport.y, and it doesn't converge if we perform it a second
time in a frame. But the solution is just to do one or the other to a
node, never both.

I knew this (learned it the hard way) when I first built pensieve.love,
and I had an assertion to avoid it. But my assertion was brittle, and it
kept failing, and I took it out, and then I slowly took out all the code
that prevented this recurrence.
2023-10-25 16:14:08 -07:00
Kartik K. Agaram d0dffb4d00 undo 2 most recent commits 2023-10-25 09:29:22 -07:00
Kartik K. Agaram f54e1ad064 abort: switch to LÖVE's coordinate transforms
This is a big change, and I'd have to first modify lines.love to use the
coordinate transforms. And that fork doesn't really need a principled
coordinate system.
2023-10-25 09:28:14 -07:00
Kartik K. Agaram c2f765489a commit 0ca5bb0e8d did indeed cause the regression
Unscaled y makes cursor scrolling more stable, but it seems to be
compensating for an error elsewhere. The location of the top margin of
text is not stable, and I only notice when I can see the bottom margin
of the bounding box. (When the top margin is visible we never enter that
branch in update_editor_box.)

I should just use LÖVE's standard translation and scaling transforms for
the surface! Don't know why I didn't think of that.
2023-10-25 09:27:45 -07:00
Kartik K. Agaram d5e4443a64 Merge driver.love 2023-10-21 10:21:38 -07:00
Kartik K. Agaram ac305b8e6c Merge luaML.love 2023-10-21 10:12:09 -07:00
Kartik K. Agaram 4c8960b5c7 greatly simplify layout
I don't know why this was so hard, but I don't need this variable
preserve_screen_top_of_cursor_node at all. We only set it when the
cursor is in some node, but we also only check for when the current node
is the cursor. Comparing with a nil cursor node works just as well.

I've also checked that driver.love doesn't need
preserve_screen_top_of_cursor_node. I think it came from pensieve.love,
where I've since taken it out. Did I ever need it even there?
2023-10-21 09:57:44 -07:00
Kartik K. Agaram 4d7a8ac4d1 bounds when panning by keyboard
This makes the keyboard navigation feel more solid.

I'm not bothering to do the same for panning with the mouse. Mostly
because I'm lazy, but also as an escape hatch in case I find myself
wanting to move the top lower down the screen or something. But it'll
still snap back the first time I pan using the keyboard. Let's see how
much it matters.
2023-06-23 22:45:55 -07:00
Kartik K. Agaram 4735a138da click on file picker to open thread
There's one remaining issue: the DOM is changing between mouse press and
mouse release, which is confusing the select handler.

Options:
  * some sort of hacky thing to ignore the first mouse release
  * put the file picker handlers on mouse release rather than mouse
    press

There's some precedent for the latter option even if it might get
confusing in the presence of drag operations. But that seems confusing
either way. Just be consistent.
2023-06-21 22:48:47 -07:00
Kartik K. Agaram c8cd9bb6b6 start rendering file picker on the surface as well
This will make things more consistent in the long term, but I realize
one major cost: our button abstraction doesn't work well with luaML and
compute_layout. So we need something to replace it.
2023-06-21 22:28:56 -07:00
Kartik K. Agaram 37d5358290 start rendering the initialized thread
This required a little more restructuring of Global_state. It's not flat
now, it's hierarchical again, but in a different way.

after commit 3d89b8eb9d:
  post
    \- reply A
        \- reply B
    \- reply C

after commit f9f7dab9b7:
  post
  reply A
  reply B
  reply C

after this commit:
  row
    \- col
        \- indent 0
        \- post
    \- col
        \- indent 1
        \- reply A
    \- col
        \- indent 2
        \- reply B
    \- col
        \- indent 1
        \- reply C

The indents are just invisible rectangles of different widths with 0
height.

One change I had to make was to initialize_editor. Neither luaML and
driver load lines from disk, but that's arguably the common scenario to
support.
2023-06-20 20:10:10 -07:00
Kartik K. Agaram a6b725e77a get rid of driver.love's node.key
I don't plan to support moving nodes around the surface in this fork.
2023-06-20 17:29:21 -07:00
Kartik K. Agaram 0e3f1f7732 bugfix: size text/box when changing zoom
This is a backport from driver.love
2023-04-22 22:27:30 -07:00
Kartik K. Agaram 2d5abe140b make order of files consistent with upstream
Luckily I only had a chance to mess this up in one fork.

And I don't need to actually make any changes because my definitions are
order-independent.
2023-04-22 18:50:18 -07:00
Kartik K. Agaram b138f1ff9b Merge template-live-editor 2023-04-16 11:30:56 -07:00