Commit Graph

1502 Commits

Author SHA1 Message Date
Kartik K. Agaram f86ebf6247 clean up a debug print 2023-11-10 10:20:57 -08:00
Kartik K. Agaram 17175e8112 Merge text.love 2023-11-10 09:08:03 -08:00
Kartik K. Agaram 3007ea0014 Merge lines.love 2023-11-10 09:05:04 -08:00
Kartik K. Agaram a6738b49c4 clean up some cruft from error callstacks
before:

  stack traceback:
    [string "text.lua"]:9: in function 'draw'
    [string "edit.lua"]:200: in function 'draw'
    [string "run.lua"]:140: in function 'draw'
    [string "main.lua"]:162: in function <[string "main.lua"]:155>
    [C]: in function 'xpcall'
    [string "app.lua"]:38: in function <[string "app.lua"]:20>
    [C]: in function 'xpcall'
    [love "boot.lua"]:370: in function <[love "boot.lua"]:337>

after:

  stack traceback:
    text.lua:9: in function 'draw'
    edit.lua:200: in function 'draw'
    run.lua:140: in function 'draw'
    main.lua:162: in function <[string "main.lua"]:155>
    [C]: in function 'xpcall'
    app.lua:38: in function <[string "app.lua"]:20>
    [C]: in function 'xpcall'
    [love "boot.lua"]:370: in function <[love "boot.lua"]:337>
2023-11-10 08:41:56 -08:00
Kartik K. Agaram 8b70258978 remove a no-op regex munging on callstacks
Port of a fix "upstream": commit b38f172ceb in template-live-editor.
2023-11-10 07:24:46 -08:00
Kartik K. Agaram b30b25a9f9 Merge text.love 2023-10-28 00:59:12 -07:00
Kartik K. Agaram f737d63c69 Merge lines.love 2023-10-28 00:54:14 -07:00
Kartik K. Agaram aa9a0b0b15 use my name for a dir 2023-10-27 23:58:42 -07:00
Kartik K. Agaram 5d41640d2f remove stale variable from docs 2023-10-27 23:57:18 -07:00
Kartik K. Agaram 523db004d9 change section delimiters in log for OpenBSD
Thanks eril for the report and patch.
2023-10-20 15:53:03 -07:00
Kartik K. Agaram eb6a8772c5 Merge text.love 2023-10-16 23:29:49 -07:00
Kartik K. Agaram 0f115e4501 Merge lines.love 2023-10-16 23:25:09 -07:00
Kartik K. Agaram f61976c61a use color alpha in button backgrounds 2023-10-16 22:59:04 -07:00
Kartik K. Agaram 4b3f359526 clearer API for drawing a button
Make it more obvious that the color passed in is just for the background.
The icon will do the rest.
r/g/b keys are more consistent with App.color().
2023-10-16 22:57:46 -07:00
Kartik K. Agaram 4f653add05 Merge text.love 2023-10-15 14:45:49 -07:00
Kartik K. Agaram 80ba5851e7 Merge lines.love 2023-10-15 14:42:28 -07:00
Kartik K. Agaram ea4a8379fe rfind bugfix: handle empty pattern like string.find 2023-10-15 14:21:41 -07:00
Kartik K. Agaram 6b723363b8 add some tests for rfind 2023-10-15 14:20:55 -07:00
Kartik K. Agaram 2e6c4fce70 Merge text.love 2023-10-09 21:03:57 -07:00
Kartik K. Agaram b84cbf6d21 Merge lines.love 2023-10-09 20:55:24 -07:00
Kartik K. Agaram 69d86cae5b fix all tests in LÖVE v12
This is all quite hacky. Many of my tests are unfortunately brittle to
changes in text rendering. Fortunately there's only one test that
currently requires a hacky special case (and a second test I tweaked
slightly to be more robust).

I can't think of a better approach. It doesn't help to standardize the
font, because version changes still come with changes to text-shaping
algorithms even if the font itself is unchanged. I could base all my
assertions on the widths of individual characters, but that would make
the tests much less readable and not express intent as clearly. So here
we are, with hopefully just a few hacky special cases (there might be a
few more as LÖVE v12 advances towards publication, and in further
versions).
2023-10-09 20:25:08 -07:00
Kartik K. Agaram 6e391d7875 start supporting LÖVE v12
To do this I need some support for multiple versions. And I need an
'error' mode to go with existing 'run' and 'source' modes
(`Current_app`). Most errors will automatically transition to 'source'
editor mode, but some errors aren't really actionable in the editor. For
those we'll use 'error' mode.

The app doesn't yet work with LÖVE v12. There are some unit tests failing
because of differences in font rendering.
2023-10-09 20:05:19 -07:00
Kartik K. Agaram 8adfe41cb2 Merge text.love 2023-09-20 14:46:43 -07:00
Kartik K. Agaram 3aec915559 Merge lines.love 2023-09-20 14:32:01 -07:00
Kartik K. Agaram bd6f7d48e7 bugfix: clear selection when clicking above or below lines
Matt Wynne pointed out that snap.love would crash when a node went off
screen. While debugging it I noticed that selection1 was being set when
it shouldn't be.

Turns out I introduced a bug when I fixed the inscript bug back in June
(commit 9656e13774). One invariant I want to preserve is: selection1
should be unset after a mouse click (press and release without
intervening drag). This invariant was violated in my bugfix back in
June. I was concerned only with selection back then, and I didn't
realize I was breaking the mouse click case (in a fairly subtle way; you
can have selection set, and when it's set identically to the cursor
everything looks the same).

I think there might still be an issue in snap.love after this fix. I
noticed screen_bottom1.pos was nil, and as far as I recall that should
never happen.
2023-09-20 13:39:29 -07:00
Kartik K. Agaram 7d800f6c3c Merge text.love 2023-09-17 09:28:02 -07:00
Kartik K. Agaram 5c5a8a88ab Merge lines.love 2023-09-17 09:24:52 -07:00
Kartik K. Agaram c43d884b6f indent 2023-09-16 22:41:55 -07:00
Kartik K. Agaram 9241fedf3a port an old fix to source editor 2023-09-16 22:40:46 -07:00
Kartik K. Agaram 6e2137c5b6 bugfix to the helper I added yesterday 2023-09-16 22:39:51 -07:00
Kartik K. Agaram 8238b54ca5 Merge text.love 2023-09-16 00:10:08 -07:00
Kartik K. Agaram e1168f4eff fix a bad merge 2023-09-16 00:07:07 -07:00
Kartik K. Agaram 4347baea83 Merge text.love 2023-09-16 00:03:58 -07:00
Kartik K. Agaram 09c76c82c2 Merge lines.love 2023-09-15 23:56:49 -07:00
Kartik K. Agaram 715c6fd32f source: show file being edited in window title bar 2023-09-15 13:36:27 -07:00
Kartik K. Agaram 6ed60848a4 delete some dead code
This is a holdover from the days of bifold text.
2023-09-15 13:33:26 -07:00
Kartik K. Agaram 76f119b7b9 hide line numbers from log browser 2023-09-15 13:30:42 -07:00
Kartik K. Agaram ab5ba3f3e5 assume starty can be nil in update
This is a backport of a bugfix in pensieve.love. It's not _technically_
a bug here in lines.love, but it seems worth establishing an
architectural invariant (or rather lack of invariant).

LÖVE's standard event loop performs the following sequence of operations
in a single frame:
  * process events
  * update
  * draw

Ideally any mutations to global state happen during the first two
phases, while drawing includes no mutation.

However, there is a special case: `starty`, the top y coordinate for
each each line in the editor. This is used all over the place, and the
cheapest way to compute it is to simply save it while drawing.

However, draw by definition only updates `starty` for lines that are
drawn on screen. To avoid stale data on lines off screen, say after
scrolling, events often clear `starty` for all lines, leaving it to the
next draw phase to repopulate the right lines.

Sandwiched between the above two "however"s, the update phase needs to
gracefully handle `starty` being nil in the occasional frame right after
an event.

I think I've audited all our uses of `starty`, and this commit fixes the
only place that violates this rule.
2023-09-15 11:13:04 -07:00
Kartik K. Agaram bafc45b028 bugfix: crash when using mouse wheel
All the Text functions assume the cursor is always on a text line. I was
violating that invariant.

* When scrolling up, I start the cursor at the top-most line below the
  screen top.

* When scrolling down, I start the cursor at the top-most line below the
  screen bottom.

  I think it would feel slightly more natural for it to be the
  bottom-most line above the screen bottom.

  However, the Text functions maintain an invariant that the bottom-most
  line in a buffer will be text. There's no such invariant for the
  top-most line.
2023-09-15 08:52:39 -07:00
Kartik K. Agaram 0a12e4c733 change a helper slightly 2023-09-15 08:46:36 -07:00
Kartik K. Agaram 0e20565e17 clean up a slight jitter when drawing circles
Earlier the ghost while drawing wouldn't quite match the final shape.
Now the math is identical in draw_pending_shape.

It's a little unfortunate that we have this duplication of formulae.

At least there are no other stray calls of App.mouse_x in
draw_pending_shape.
2023-09-15 08:30:15 -07:00
Kartik K. Agaram 01270f3af2 Merge text.love 2023-09-14 22:43:30 -07:00
Kartik K. Agaram 1a88b4a290 Merge lines.love 2023-09-14 22:39:18 -07:00
Kartik K. Agaram 1fd30c0462 always show line numbers in source editor
The drawing buttons are now absolutely positioned, which is a horrible
hack. But for just the source editor it seems good enough. The
alternative is to modify magic constants in all the tests :/
2023-09-14 22:27:38 -07:00
Kartik K. Agaram 274fb9a3b6 Merge text.love 2023-09-10 22:00:42 -07:00
Kartik K. Agaram 37cb030489 Merge lines.love 2023-09-10 21:56:43 -07:00
Kartik K. Agaram 7062963888 Revert "deemphasize the source editor"
Now that we have decent error handling, I think we can encourage people
to press ctrl+e again.

This reverts commit 4b43e9e85d.
2023-09-10 21:45:59 -07:00
Kartik K. Agaram cadc64b904 Merge text.love 2023-09-09 09:49:53 -07:00
Kartik K. Agaram 28a6bb37cd Merge lines.love 2023-09-09 09:47:23 -07:00
Kartik K. Agaram 790b7f18db yet another bugfix X-(
This time it really does work with pensieve.love
2023-09-09 09:27:56 -07:00