about summary refs log tree commit diff stats
path: root/select.lua
Commit message (Collapse)AuthorAgeFilesLines
* correct some commentsKartik K. Agaram2024-06-231-5/+3
|
* stop caching startyKartik K. Agaram2024-06-111-1/+1
| | | | | This is quite useful because I used to have a long list of places in which to invalidate the cache.
* stop caching screen_bottom1Kartik K. Agaram2024-06-111-1/+2
| | | | | | | | | | | | | | | | | | | I'm not sure this is very useful. I had an initial idea to stop using screen_bottom1 in final_text_loc_on_screen, by starting from screen_top1 rather than screen_bottom1. But that changes the direction in which we scan for the text line in situations where there is somehow no text on screen (something that should never happen but I have zero confidence in that). Still, it doesn't seem like a bad thing to drastically reduce the lifetime of some derived state. Really what I need to do is throw this whole UX out and allow the cursor to be on a drawing as a whole. So up arrow or left arrow below a drawing would focus the whole drawing in a red border, and another up arrow and left arrow would skip the drawing and continue upward. I think that change to the UX will eliminate a whole class of special cases in the code.
* use editor state font for width calculationsKartik K. Agaram2024-01-121-2/+2
|
* manually maintain mouse button press stateKartik K. Agaram2023-12-011-1/+1
| | | | | | | | | | | | 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.
* audit all assertsKartik K. Agaram2023-11-181-5/+5
| | | | | | | | | | | | | 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.
* bugfix: inscript's bugKartik K. Agaram2023-06-041-6/+2
| | | | | | | | | | 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.
* change how we handle clicks above top marginKartik K. Agaram2023-06-031-0/+3
|
* get rid of recent_mouseKartik K. Agaram2023-06-011-10/+1
| | | | | | | | | | | 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-3/+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-6/+1
| | | | | | | 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-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* App.width can no longer take a TextKartik K. Agaram2023-04-011-5/+2
| | | | | 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.
* generalize a functionKartik K. Agaram2022-08-181-1/+1
|
* simpler location comparisonKartik K. Agaram2022-08-171-5/+2
|
* swap return valuesKartik K. Agaram2022-08-171-1/+1
|
* use line cache for drawings as wellKartik K. Agaram2022-07-201-1/+1
|
* separate data structure for each line's cache dataKartik K. Agaram2022-07-171-0/+1
| | | | I have no idea what the performance implications of this are..
* switch to line index in a functionKartik K. Agaram2022-07-171-1/+1
| | | | - Text.to_pos_on_line
* switch to line index in a functionKartik K. Agaram2022-07-171-1/+1
| | | | - Text.in_line
* drop some redundant args when clearing the cacheKartik K. Agaram2022-07-171-1/+1
|
* deduce left/right from state where possibleKartik K. Agaram2022-07-121-13/+13
|
* add state arg to a few functionsKartik K. Agaram2022-07-121-2/+2
| | | | | | | | | | | | | - Text.cursor_at_final_screen_line - Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necessary - Text.snap_cursor_to_bottom_of_screen - Text.in_line - Text.to_pos_on_line - Text.to2 - Text.to1 - Text.previous_screen_line - Text.tweak_screen_top_and_cursor - Text.redraw_all
* add state arg to a few functionsKartik K. Agaram2022-07-121-1/+1
| | | | | - Text.pos_at_start_of_cursor_screen_line - Text.cursor_past_screen_bottom
* add state arg to a few functionsKartik K. Agaram2022-07-121-2/+2
| | | | | | | - record_undo_event - undo_event - redo_event - snapshot
* add state arg to a few functionsKartik K. Agaram2022-07-121-60/+60
| | | | | | | | | | | - Text.draw_highlight - Text.clip_selection - Text.selection - Text.cut_selection - Text.delete_selection - Text.delete_selection_without_undo - Text.mouse_pos - Text.to_pos
* group all editor globalsKartik K. Agaram2022-07-121-47/+47
| | | | We're still accessing them through a global. But we'll change that next.
* make colors easier to editKartik K. Agaram2022-07-111-2/+2
|
* stop pretending globals are localKartik K. Agaram2022-07-111-2/+0
| | | | | One advantage of this approach: we don't end up with multiple lexical scopes containing duplicates of the same modules.
* add args to some functionsKartik K. Agaram2022-07-081-1/+1
| | | | - Text.pos_at_start_of_cursor_screen_line
* add args to some functionsKartik K. Agaram2022-07-081-1/+1
| | | | - Text.to_pos_on_line
* add args to some functionsKartik K. Agaram2022-07-081-1/+1
| | | | - Text.in_line
* add args to some functionsKartik K. Agaram2022-07-081-10/+10
| | | | | | | | | - Text.clip_selection - Text.cut_selection - Text.delete_selection - Text.delete_selection_without_undo - Text.mouse_pos - Text.to_pos
* drop an arg from a functionKartik K. Agaram2022-07-081-1/+1
|
* bugfix: deleting a selection spanning pagesKartik K. Agaram2022-06-261-0/+4
|
* extract a functionKartik K. Agaram2022-06-231-2/+1
|
* bugfix: crash in Text.up() after returnKartik K. Agaram2022-06-191-7/+7
| | | | Let's just make all the utf8.offset calculations more defensive.
* mouse buttons are integers, not stringsKartik K. Agaram2022-06-141-1/+1
| | | | | | Not sure where that idiom comes from or why strings work in some places (auto-coercion?). I picked it up off some example apps. But https://love2d.org/wiki/love.mouse.isDown says it should be an integer.
* override mouse state lookups in testsKartik K. Agaram2022-06-121-2/+2
| | | | | | | If I'd had this stuff in my test harness earlier, two recent commits would have failed tests and given me early warning: ff88238ff1 ff88a2a927
* fix a second BSOD in #4 :/Kartik K. Agaram2022-06-121-1/+1
| | | | I need more tests.
* bugfix: cut (C-x) without first selecting anythingKartik K. Agaram2022-06-091-0/+2
|
* moveKartik K. Agaram2022-06-091-6/+6
|
* speeding up copy, attempt 1Kartik K. Agaram2022-06-091-4/+4
| | | | | | | | | | | | | | Problem: repeatedly copying (relatively large) sections of text quickly makes the app sluggish until it has to be killed. (Thanks John Blommers for the report.) When I instrument with prints, the sluggishness seems to happen in random draw() calls many times after I perform the copy. I don't know for sure, but I'm initially checking if the cause is garbage generated by repeated string concatenation. This attempt doesn't seem to make any difference.
* more precise search highlightingKartik K. Agaram2022-06-031-0/+3
|
* extract a functionKartik K. Agaram2022-06-031-0/+24
|
* extract a couple of filesKartik K. Agaram2022-06-031-0/+153