Commit Graph

687 Commits

Author SHA1 Message Date
Kartik K. Agaram ce31b74b10 infrastructure for caching LÖVE text objects 2022-08-24 13:27:04 -07:00
Kartik K. Agaram 89222f86a0 set color for each fragment
In general it seems like good practice to minimize assumptions about
the current color.
2022-08-23 15:09:14 -07:00
Kartik K. Agaram 43dfa184d6 helper: trimming whitespace from strings 2022-08-23 15:06:18 -07:00
Kartik K. Agaram aeaa7d150c helper: file_exists 2022-08-23 15:04:30 -07:00
Kartik K. Agaram 019a829279 make App.open_for_* look more like io.open
Now missing files will result in similar behavior: nil file handles.
2022-08-23 13:12:24 -07:00
Kartik K. Agaram b6f42ebf01 pass all button params to the icon 2022-08-23 12:13:22 -07:00
Kartik K. Agaram 8747415461 allow buttons to nest as well 2022-08-23 11:48:52 -07:00
Kartik K. Agaram 468b791050 flip return value of button handlers
This is compatible with Javascript, and it also seems like a better
default; when people forget to think about return values in click
handlers, they should be consumed.
2022-08-23 11:43:10 -07:00
Kartik K. Agaram 8057f3e8fe stop putting button state in a global
Symptom: a test (test_click_to_create_drawing) started randomly failing
after I inserted a `return` 2 commits ago.

Cause: my tests call edit.draw, but button handlers only get cleared in
app.draw. So my tests weren't clearing button handlers, and every call
to edit.draw was accumulating states. Still unclear why those were going
to different state objects after the `return`, but anyway. I'm not going
to understand every last thing that happens when things go wrong, just
guarantee they can't go wrong. And the way to do that is to decentralize
button handlers to each state that receives them.

The State object in buttons.lua doesn't have to be Editor_state. It just
has to be some table that provides a Schelling Point for shared state.
2022-08-23 10:59:58 -07:00
Kartik K. Agaram ce79623231 improve explanation for buttons 2022-08-23 09:44:16 -07:00
Kartik K. Agaram aadc50f3b6 allow buttons to interrupt events
Most button onpress1 handlers will want to return true.
2022-08-23 09:40:48 -07:00
Kartik K. Agaram 490f10c6f8 indent 2022-08-23 09:37:38 -07:00
Kartik K. Agaram cfdac28e18 distinguish consistently between mouse buttons and other buttons 2022-08-23 09:36:08 -07:00
Kartik K. Agaram 418ce8480a include pensieve.love even though it's in development 2022-08-22 20:26:44 -07:00
Kartik K. Agaram 038f054ede include a fork 2022-08-21 14:29:05 -07:00
Kartik K. Agaram 61eb87b03c correct a comment
We no longer have undo history directly in globals.
2022-08-21 14:26:50 -07:00
Kartik K. Agaram 13f67fa851 regression: dropping files on the window
Also improve the test to catch this next time.
2022-08-19 17:05:41 -07:00
Kartik K. Agaram cbd8f678d2 fix a name 2022-08-19 16:27:38 -07:00
Kartik K. Agaram fc9490c964 reclaim a couple more functions after tests 2022-08-19 10:29:48 -07:00
Kartik K. Agaram dd15f15640 couple of accidental globals
Luckily they didn't bite me yet.
2022-08-18 13:37:14 -07:00
Kartik K. Agaram 72866ec0ad get rid of some ridiculous code
I guess I wrote it before I settled into the idiom of:
* first change cursor
* then scroll if necessary
2022-08-18 13:04:04 -07:00
Kartik K. Agaram 0bf34a9ce0 spurious args 2022-08-18 12:09:50 -07:00
Kartik K. Agaram edcd3d7a9a dead code 2022-08-18 12:07:50 -07:00
Kartik K. Agaram 1d3c9f4708 generalize a function 2022-08-18 10:32:03 -07:00
Kartik K. Agaram cf8d9774ea drop some obsolete args 2022-08-18 10:29:50 -07:00
Kartik K. Agaram 3c04310503 subsection headings in a long switch 2022-08-18 10:09:20 -07:00
Kartik K. Agaram a14f1096b6 extract a variable 2022-08-18 09:51:43 -07:00
Kartik K. Agaram f79dd4824c simplify 2022-08-18 00:19:07 -07:00
Kartik K. Agaram 2381f7b43f simpler location comparison 2022-08-17 21:23:24 -07:00
Kartik K. Agaram 1221fde164 move caching behavior inside compute_fragments 2022-08-17 16:15:35 -07:00
Kartik K. Agaram 3a74e4bb6c remove some unnecessary work 2022-08-17 16:13:46 -07:00
Kartik K. Agaram dd899d2096 standardize scroll check in a few places
I'm taking some lessons from pensieve.love here. It seem like specific
pixel thresholds don't matter too much for plain lines.love.

I'd probably feel safer if I just used Text.cursor_out_of_screen in
these places, but it means we draw the screen twice for most events[1].
Let's see if we can get by with the current approach.

[1] Or we have to start scheduling things for the next draw, which is
more complex to orchestrate.
2022-08-17 09:40:44 -07:00
Kartik K. Agaram f029c710b5 simplify cursor-on-screen check 2022-08-17 09:36:17 -07:00
Kartik K. Agaram 1d710912cc swap return values 2022-08-17 09:10:52 -07:00
Kartik K. Agaram 4f128f39f3 obsolete comment 2022-08-16 13:38:10 -07:00
Kartik K. Agaram eba973369e move 2022-08-15 16:07:32 -07:00
Kartik K. Agaram 333a0318d9 drop some unnecessary calls 2022-08-15 15:48:44 -07:00
Kartik K. Agaram 9e0cd4ad4c stop confusingly reading a global
The way Text.draw is called by edit.draw, we know it'll never be called
for lines above screen_top1.line. Comparing every line on screen with
screen_top1 makes no sense. The intent is really just to compare with
screen_top1 only for the first line, and otherwise to ignore this check.
2022-08-15 15:45:02 -07:00
Kartik K. Agaram 974d17ffc0 new mirror 2022-08-14 09:08:44 -07:00
Kartik K. Agaram 27913df486 more cogent onboarding instructions
Someone looking at the repo will probably prefer the terminal.
2022-08-14 08:52:58 -07:00
Kartik K. Agaram 9459d91abc remove some duplication 2022-08-14 08:10:24 -07:00
Kartik K. Agaram 4d1e7f922d bugfix: obsolete location for attribute 2022-08-14 07:56:12 -07:00
Kartik K. Agaram cc289363fa overzealous search-and-replace 2022-08-13 22:01:40 -07:00
Kartik K. Agaram f3df1cda0f bugfix: check after cursor on same line when searching upwards 2022-08-11 22:23:16 -07:00
Kartik K. Agaram 8b880f4fe8 search: transparently handle drawings everywhere 2022-08-11 22:23:16 -07:00
Kartik K. Agaram e85a7e73d0 bugfix: search upwards 2022-08-11 22:23:16 -07:00
Kartik K. Agaram 0afd03e721 bugfix: check before cursor on same line 2022-08-11 22:23:16 -07:00
Kartik K. Agaram d14e03d706 bugfix: handle drawings when updating screen top 2022-08-11 19:35:12 -07:00
Kartik K. Agaram 9ac68d710b rename 2022-08-11 19:34:18 -07:00
Kartik K. Agaram da34fabf72 bugfix: pagedown was sometimes bouncing up 2022-08-10 22:56:10 -07:00