Commit Graph

192 Commits

Author SHA1 Message Date
Kartik K. Agaram 9b3fa33f5b idea: set recent_mouse on mouse events
This helps, but doesn't address the C-a case. As it stands, literally my
first click of the mouse might need access to recent_mouse.line/pos
2023-06-01 21:58:28 -07:00
Kartik K. Agaram 3e848efb08 ah, I see the problem
Text.mouse_pos can sometimes set recent_mouse.time but not
recent_mouse.x/y. I'd assumed x/y is never nil in those situations, but
that's violated. It's most easily seen when typing C-a and then
clicking.
2023-06-01 12:37:17 -07:00
Kartik K. Agaram f1886391c5 some temporary logging to catch a bug
The bug has been spotted twice:

1. In snap.love, I selected text in one node, then another, and hit:
  Error: text.lua:789: attempt to compare nil with number
  stack traceback:
    text.lua:789: in function 'lt1'
    select.lua:19: in function 'clip_selection'
    text.lua:32: in function 'draw'
    edit.lua:117: in function 'draw'
    [string "REPL"]:21: in function 'draw'
    main.lua:152: in function 'draw'
    app.lua:102: in function <app.lua:84>
    [C]: in function 'xpcall'
    app.lua:112: in function <app.lua:111>
    [C]: in function 'xpcall'

  Couldn't reproduce.

2. In text.love, inscript selected all text in a small buffer and then
   clicked outside the text. And got:

  Error: text.lua:784: attempt to compare nil with number
  Traceback
    [love "callbacks.lua"]:228: in function 'handler'
    text.lua:784: in function 'lt1'
    select.lua:19: in function 'clip_selection'
    text.lua:27: in function 'draw'
    edit.lua:117: in function 'draw'
    run.lua:136: in function 'draw'
    main.lua:148: in function 'draw'
    app.lua:42: in function <app.lua:22>
    [C]: in function 'xpcall'

  This is reproducible, and also across forks.
2023-06-01 12:30:19 -07:00
Kartik K. Agaram 9d7e113db9 Merge text.love 2023-04-08 22:01:22 -07:00
Kartik K. Agaram 7e242db523 Merge lines.love 2023-04-08 22:01:01 -07:00
Kartik K. Agaram c969fcdd85 enhance bugfix of commit a9aa3436f (Dec 2024)
Scenario:
* start out with some text on screen
* select some text A, delete
* select some more text B, delete
* press C-z twice to restore A and B
* press C-y twice

Before this commit only the first C-y was having an effect (deleting B).
The second was failing to delete A.
2023-04-08 21:55:51 -07:00
Kartik K. Agaram bc3f1aca36 Merge text.love 2023-04-03 09:23:54 -07:00
Kartik K. Agaram e406fdae0d Merge lines.love 2023-04-03 09:23:28 -07:00
Kartik K. Agaram 282983d084 switch source side to new screen-line-based render
Also copy over the implementation of links from pensieve.love.
2023-04-03 08:33:07 -07:00
Kartik K. Agaram 384fb2d19c streamline the interface for Text.draw 2023-04-02 17:19:03 -07:00
Kartik K. Agaram 24a48e665f Merge text.love 2023-04-02 09:31:56 -07:00
Kartik K. Agaram 3547c18db6 Merge lines.love 2023-04-02 09:22:32 -07:00
Kartik K. Agaram 24a732ebff update documentation on fragments
I see a path to at least maintain a single fragment per screen line. But
can we do better? It even seems unnecessary to maintain two copies of
the data, chopped up into lines and screen lines.
2023-04-01 18:12:29 -07:00
Kartik K. Agaram f64f680f2b no more Text allocations
Is it just my imagination, or does the app feel lighter and more fluffy?
2023-04-01 18:12:29 -07:00
Kartik K. Agaram 876d6298b4 App.width can no longer take a Text
In the process I discovered the horrible fact that Text.x allocates a new Text.
And it gets called (just once, thank goodness) on every single frame.
2023-04-01 18:12:29 -07:00
Kartik K. Agaram 9d785d1c88 Merge text.love 2023-03-26 09:49:40 -07:00
Kartik K. Agaram 46e568c4c5 Merge lines.love 2023-03-26 09:49:03 -07:00
Kartik K. Agaram eae5c9505c bugfix: naming points 2023-03-26 09:36:41 -07:00
Kartik K. Agaram 0ae94b0de5 bugfix 2023-03-26 08:19:40 -07:00
Kartik K. Agaram 7f433753b6 bugfix
scenario: open a file starting with a drawing
After this commit the program doesn't crash.

  Error: [string "edit.lua"]:127: attempt to get length of field 'data' (a nil value)
  stack traceback:
    [love "boot.lua"]:345: in function '__len'
    [string "edit.lua"]:127: in function 'invalid1'
    [string "edit.lua"]:116: in function 'check_locs'
    [string "run.lua"]:35: in function 'initialize'
    main.lua:96: in function 'initialize'
    [string "app.lua"]:144: in function 'run_tests_and_initialize'
    [string "app.lua"]:16: in function <[string "app.lua"]:13>
    [C]: in function 'xpcall'
    [love "boot.lua"]:361: in function <[love "boot.lua"]:348>
    [C]: in function 'xpcall'
2023-03-26 07:19:27 -07:00
Kartik K. Agaram 57ed70d912 clean up some absolute coordinates 2023-03-25 18:34:28 -07:00
Kartik K. Agaram 5a198d5f96 Merge text.love 2023-03-23 21:43:52 -07:00
Kartik K. Agaram aa8994167f Merge lines.love 2023-03-23 21:43:26 -07:00
Kartik K. Agaram a6dcfc5ac8 some minor cleanup
I can't see the mouse wheel ever setting dx, but it's more obvious now
that the editor doesn't support panning left/right.
2023-03-23 21:38:33 -07:00
Kartik K. Agaram 99faf61abb mouse wheel support 2023-03-23 21:00:09 -07:00
Kartik K. Agaram abfd1eac64 Merge text.love 2023-03-19 00:00:44 -07:00
Kartik K. Agaram ab09ec6387 Merge lines.love 2023-03-18 23:59:42 -07:00
Kartik K. Agaram fceb2404fb move default file location
This works better on mobile platforms while seeming about as useful
anywhere else.

I've verified that anyone who already edited a file will continue to use
its path from settings.
2023-03-18 23:12:50 -07:00
Kartik K. Agaram 22f31f8024 Merge text.love 2023-03-17 22:33:41 -07:00
Kartik K. Agaram eca407cf00 Merge lines.love 2023-03-17 22:30:46 -07:00
Kartik K. Agaram ae429cd78a bring a few things in sync between run and source 2023-03-17 21:40:51 -07:00
Kartik K. Agaram 81ebc6a559 bugfix: disallow font size of 0
Thanks Mikoláš Štrajt.
2023-03-17 19:58:53 -07:00
Kartik K. Agaram 265db2d2fd Merge text.love 2023-03-17 11:03:49 -07:00
Kartik K. Agaram 4dbc097f83 Merge lines.love 2023-03-17 11:02:10 -07:00
Kartik K. Agaram e2c1bbe4e5 more robust state validation 2023-03-17 10:28:10 -07:00
Kartik K. Agaram c4558035c7 Merge text.love 2023-02-09 23:20:11 -08:00
Kartik K. Agaram 67334814a3 Merge lines.love 2023-02-09 23:19:52 -08:00
Kartik K. Agaram 224e8fe85a bugfix
scenario:
  press ctrl+f, type in a string
  hit down arrow if needed until the screen scrolls
  press enter
  click with the mouse somewhere

Before this commit the app would crash because cursor was above screen
top.
2023-02-09 23:09:23 -08:00
Kartik K. Agaram b936e0f9cf Merge lines.love 2023-01-28 10:26:55 -08:00
Kartik K. Agaram 18f44c9761 wait a little to flush disk before quitting
I've been noticing in pensieve.love in particular that once a month or
so I lose data if I quit immediately after typing in something. Nothing
major, just the odd link between notes which leaves things in an
inconsistent state. Let's see if this helps.
2023-01-28 10:21:34 -08:00
Kartik K. Agaram f8213d4a23 Merge text.love 2022-12-24 19:27:21 -08:00
Kartik K. Agaram 4d561e2294 Merge lines.love 2022-12-24 19:26:55 -08:00
Kartik K. Agaram a9aa3436fa bugfix
Scenario: make some edits, select some text, make some more edits. Press
ctrl-z.

Before this commit, undo would stop at the point of selection and
previous edits would become unreachable.

After this commit, both ctrl-z and ctrl-y seem able to span the point of
selection.
2022-12-24 19:24:48 -08:00
Kartik K. Agaram 53fbb905e3 typo 2022-12-24 19:24:48 -08:00
Kartik K. Agaram 8e78294795 Merge text.love 2022-12-23 19:53:38 -08:00
Kartik K. Agaram 4854165630 Merge lines.love 2022-12-23 19:47:10 -08:00
Kartik K. Agaram e0448d7d7f consistent names in a few more places 2022-12-23 19:32:58 -08:00
Kartik K. Agaram 2b3e09ca0f make love event names consistent
I want the words to be easy to read, and to use a consistent tense.
update and focus seem more timeless; let's make everything like those.
2022-12-23 18:52:28 -08:00
Kartik K. Agaram e2e3aea2b1 require editor margins to be ints
Not directly relevant here, but forks of this project that permit
zooming can run into weird glitches if margins are not a whole number of
pixels.

I'd always assumed a type system that divided ints into floats was
strictly superior, but now I have experienced a situation where
requiring ints isn't just a compromise for the underlying CPU
implementation. Particularly since Lua's print() silently hides really
tiny fractions.
2022-12-23 16:57:04 -08:00
Kartik K. Agaram 92eccaea5a bugfix in changing shape mid-stroke 2022-12-12 23:17:02 -08:00
Kartik K. Agaram 605ead1457 Merge text.love 2022-12-12 22:46:40 -08:00
Kartik K. Agaram 3897a9d86d Merge lines.love 2022-12-12 22:45:16 -08:00
Kartik K. Agaram 8b30e0608b bugfix: naming points in drawings
We had a regression since commit 60e1023f0 on Nov 27. Turns out we do
need the ancient hack after all.

But no, we won't go back to the hack. It's a simple problem to fix
right. And while we're at it, we'll fix the test harness to be more
realistic so it would have caught this problem.
2022-12-12 22:31:45 -08:00
Kartik K. Agaram d52711047a Merge text.love 2022-11-27 22:22:43 -08:00
Kartik K. Agaram 5283c16e5c Merge lines.love 2022-11-27 22:22:16 -08:00
Kartik K. Agaram 7557e0904a bugfix 2022-11-27 22:20:26 -08:00
Kartik K. Agaram 43f0152351 Merge text.love 2022-11-19 00:29:07 -08:00
Kartik K. Agaram 356fed8a24 Merge lines.love 2022-11-19 00:28:37 -08:00
Kartik K. Agaram 44aa8226c4 ctrl+a: select entire buffer 2022-11-19 00:27:20 -08:00
Kartik K. Agaram 49100cd7b0 Merge text.love 2022-11-05 19:56:10 -07:00
Kartik K. Agaram 79fd6c4464 purge unused button infrastructure 2022-11-05 19:52:42 -07:00
Kartik K. Agaram fd71bc7d94 Merge lines.love 2022-11-03 21:08:11 -07:00
Kartik K. Agaram 0e0f36f8b4 stop tracking wallclock time
We only need time differences.
2022-11-03 21:02:31 -07:00
Kartik K. Agaram 7fb71f9219 Merge text.love 2022-09-10 19:26:44 -07:00
Kartik K. Agaram b23269f3e0 Merge lines.love 2022-09-10 19:25:00 -07:00
Kartik K. Agaram 511db8cffd bugfix: path munging on Windows 2022-09-10 19:23:34 -07:00
Kartik K. Agaram 81b0646ec1 Merge text.love 2022-09-07 10:20:19 -07:00
Kartik K. Agaram 901dd1fd94 Merge lines.love 2022-09-07 10:19:16 -07:00
Kartik K. Agaram 06c784b576 self-documenting 0 Test_right_margin 2022-09-07 10:16:24 -07:00
Kartik K. Agaram 569f34fb5b Merge text.love 2022-09-05 12:50:33 -07:00
Kartik K. Agaram e0f750913f Merge lines.love 2022-09-05 12:47:27 -07:00
Kartik K. Agaram 528c64d690 support drawings in the source editor 2022-09-05 11:29:39 -07:00
Kartik K. Agaram 60fe0866dd Merge text.love 2022-09-03 15:42:51 -07:00
Kartik K. Agaram e1c5a42f31 editing source code from within the app
integrated from pong.love via text.love:
  https://merveilles.town/@akkartik/108933336531898243
2022-09-03 14:13:22 -07:00
Kartik K. Agaram 42762ce062 editing source code from within the app
integrated from pong.love: https://merveilles.town/@akkartik/108933336531898243
2022-09-03 13:58:30 -07:00
Kartik K. Agaram 0bdadfdafe Merge text.love 2022-08-24 13:35:21 -07:00
Kartik K. Agaram 89081a8a78 Merge lines.love 2022-08-24 13:34:10 -07:00
Kartik K. Agaram ce31b74b10 infrastructure for caching LÖVE text objects 2022-08-24 13:27:04 -07:00
Kartik K. Agaram d9e0e023ea Merge text.love 2022-08-23 13:36:31 -07:00
Kartik K. Agaram d011c0ce32 Merge lines.love 2022-08-23 13:25:55 -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 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 cfdac28e18 distinguish consistently between mouse buttons and other buttons 2022-08-23 09:36:08 -07:00
Kartik K. Agaram aeea740891 new fork: browse an immutable text file
Still has a cursor, which might be unnecessary.
2022-08-20 11:14:33 -07:00
Kartik K. Agaram 61b59f4dd6 Merge lines.love 2022-08-18 13:11:41 -07:00
Kartik K. Agaram 3c04310503 subsection headings in a long switch 2022-08-18 10:09:20 -07:00
Kartik K. Agaram 03f3034930 Merge lines.love 2022-08-17 09:51:17 -07:00
Kartik K. Agaram f029c710b5 simplify cursor-on-screen check 2022-08-17 09:36:17 -07:00
Kartik K. Agaram a655c2113c bring back a level of wrapping
Many projects will require the ability to add metadata to lines, so
let's not drop that.
2022-08-15 11:00:35 -07:00
Kartik K. Agaram a85b984021 clean up a few more loose ends 2022-08-14 09:53:16 -07:00
Kartik K. Agaram 9d792a203b new fork: rip out drawing support 2022-08-14 09:20:14 -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 0218980add click to the left of a line 2022-07-29 14:38:45 -07:00
Kartik K. Agaram 1e6b9e25aa copying to clipboard can never scroll 2022-07-27 20:51:18 -07:00
Kartik K. Agaram 4ce716fe44 line.y -> line_cache.starty in a few more places
Disquieting that none of my tests caught these. On the other hand, I
also haven't noticed any issues in practice. Perhaps cache invalidation
is often unnecessary.
2022-07-27 20:45:46 -07:00
Kartik K. Agaram 48162b9816 have file API operate on state object 2022-07-25 19:56:39 -07:00
Kartik K. Agaram 6f74f95a46 extract method 2022-07-23 23:36:04 -07:00
Kartik K. Agaram 1937379da3 move drawing.starty into line cache 2022-07-20 17:08:00 -07:00