about summary refs log tree commit diff stats
path: root/edit.lua
Commit message (Collapse)AuthorAgeFilesLines
* Merge lines.loveKartik K. Agaram2023-12-031-5/+0
|\
| * clearing starty is redundant in mutationsKartik K. Agaram2023-12-031-5/+0
| | | | | | | | | | | | | | | | | | We'll end up calling Text.redraw_all anyway, which will clear starty and much more besides. We'll still conservatively continue clearing starty in a few places where there's a possibility that Text.redraw_all may not be called. This change is riskier than most.
* | Merge lines.loveKartik K. Agaram2023-12-011-0/+2
|\|
| * manually maintain mouse button press stateKartik K. Agaram2023-12-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Just checking mouse.isDown works if the editor is the entirety of the app, as is true in this fork. However, we often want to introduce other widgets. We'd like tapping on them to not cause the selection to flash: https://news.ycombinator.com/context?id=38404923&submission=38397715 The right architecture to enforce this is: have each layer of the UI maintain its own state machine between mouse_press and mouse_release events. And only check the state machine in the next level down rather than lower layers or the bottommost layer of raw LÖVE.
* | Merge lines.loveKartik K. Agaram2023-11-181-8/+2
|\|
| * audit all assertsKartik K. Agaram2023-11-181-11/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Each one should provide a message that will show up within LÖVE. Stop relying on nearby prints to the terminal. I also found some unnecessary ones. There is some potential here for performance regressions: the format() calls will trigger whether or not the assertion fails, and cause allocations. So far Lua's GC seems good enough to manage the load even with Moby Dick, even in some situations that caused issues in the past like undo.
| * clearer API for drawing a buttonKartik K. Agaram2023-10-161-1/+1
| | | | | | | | | | | | 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().
* | Merge lines.loveKartik K. Agaram2023-09-201-13/+26
|\|
| * bugfix: clear selection when clicking above or below linesKartik K. Agaram2023-09-201-13/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 9656e137742). 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.
| * indentKartik K. Agaram2023-09-161-8/+8
| |
| * bugfix to the helper I added yesterdayKartik K. Agaram2023-09-161-0/+1
| |
* | fix a bad mergeKartik K. Agaram2023-09-161-2/+0
| |
* | Merge lines.loveKartik K. Agaram2023-09-151-0/+2
|\|
| * bugfix: crash when using mouse wheelKartik K. Agaram2023-09-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * change a helper slightlyKartik K. Agaram2023-09-151-7/+11
| |
* | Merge lines.loveKartik K. Agaram2023-08-301-3/+3
|\|
| * make a few names consistent with snake_caseKartik K. Agaram2023-08-301-3/+3
| |
* | Merge lines.loveKartik K. Agaram2023-06-081-1/+11
|\|
| * several bugfixes in saving/loading cursor positionKartik K. Agaram2023-06-081-1/+11
| |
* | Merge lines.loveKartik K. Agaram2023-06-071-1/+0
|\|
* | Merge lines.loveKartik K. Agaram2023-06-061-0/+2
|\|
| * return height of editor widget after drawingKartik K. Agaram2023-06-061-0/+2
| |
* | Merge lines.loveKartik K. Agaram2023-06-041-12/+32
|\|
| * port inscript's bugfix to source editorKartik K. Agaram2023-06-041-1/+1
| |
| * bugfix: inscript's bugKartik K. Agaram2023-06-041-10/+21
| | | | | | | | | | | | | | | | | | | | To fix this I have to first stop incrementally updating screen_bottom1 in the middle of a frame. Now it always has a good value from the end of a frame. I'm also running into some limitations in the test I'd ideally like to write (that are documented in a comment), but I still get some sort of automated test for this bugfix.
| * handle wrapping linesKartik K. Agaram2023-06-031-2/+2
| |
| * change how we handle clicks above top marginKartik K. Agaram2023-06-031-0/+11
| |
| * get rid of recent_mouseKartik K. Agaram2023-06-011-4/+0
| | | | | | | | | | | | | | | | | | | | | | It's a hack: - if you start selecting from below final line the start of the selection is the most recent click even if it was forever ago - (the crash we're currently fixing) if you start up and immediately select all then click below final line => crash. recent_mouse was never set. - getting rid of it breaks no tests (except the crash we're currently fixing)
| * idea: set recent_mouse on mouse eventsKartik K. Agaram2023-06-011-1/+2
| | | | | | | | | | 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
| * ah, I see the problemKartik K. Agaram2023-06-011-7/+7
| | | | | | | | | | | | | | 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.
| * some temporary logging to catch a bugKartik K. Agaram2023-06-011-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge lines.loveKartik K. Agaram2023-04-081-1/+1
|\|
| * enhance bugfix of commit a9aa3436f (Dec 2024)Kartik K. Agaram2023-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge lines.loveKartik K. Agaram2023-04-031-2/+0
|\|
| * switch source side to new screen-line-based renderKartik K. Agaram2023-04-031-1/+0
| | | | | | | | Also copy over the implementation of links from pensieve.love.
| * streamline the interface for Text.drawKartik K. Agaram2023-04-021-1/+0
| |
* | Merge lines.loveKartik K. Agaram2023-04-021-9/+1
|\|
| * update documentation on fragmentsKartik K. Agaram2023-04-011-1/+1
| | | | | | | | | | | | 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.
| * no more Text allocationsKartik K. Agaram2023-04-011-1/+0
| | | | | | | | Is it just my imagination, or does the app feel lighter and more fluffy?
| * App.width can no longer take a TextKartik K. Agaram2023-04-011-7/+0
| | | | | | | | | | 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.
* | Merge lines.loveKartik K. Agaram2023-03-261-4/+7
|\|
| * bugfix: naming pointsKartik K. Agaram2023-03-261-4/+5
| |
| * bugfixKartik K. Agaram2023-03-261-4/+6
| |
| * bugfixKartik K. Agaram2023-03-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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'
| * clean up some absolute coordinatesKartik K. Agaram2023-03-251-1/+1
| |
* | Merge lines.loveKartik K. Agaram2023-03-231-0/+14
|\|
| * some minor cleanupKartik K. Agaram2023-03-231-1/+1
| | | | | | | | | | 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.
| * mouse wheel supportKartik K. Agaram2023-03-231-0/+14
| |
* | Merge lines.loveKartik K. Agaram2023-03-181-1/+1
|\|
| * move default file locationKartik K. Agaram2023-03-181-1/+1
| | | | | | | | | | | | | | | | 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.