about summary refs log tree commit diff stats
path: root/select.lua
Commit message (Collapse)AuthorAgeFilesLines
* 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
m> 2016-12-26 11:44:14 -0800 3710' href='/akkartik/mu/commit/html/054static_dispatch.cc.html?h=hlt&id=204dae921abff0c70e017215bb3c91fa6ca11aff'>204dae92 ^
201458e3 ^
204dae92 ^











2c678a4e ^
201458e3 ^
2c678a4e ^
201458e3 ^
204dae92 ^
f6645643 ^






















1c2d788b ^
2c678a4e ^
f6645643 ^

2c678a4e ^
1c2d788b ^
f6645643 ^
































2c678a4e ^
2b250717 ^
1c2d788b ^
f6645643 ^

1c2d788b ^

2c678a4e ^
1c2d788b ^
f6645643 ^
1c2d788b ^
f6645643 ^


1c2d788b ^
f6645643 ^
1c2d788b ^
f6645643 ^




1c2d788b ^
f6645643 ^
1c2d788b ^
f6645643 ^









2c678a4e ^
f6645643 ^
1c2d788b ^
f6645643 ^






2c678a4e ^
f6645643 ^
1c2d788b ^
b7df1a7a ^


2c678a4e ^
f6645643 ^

1c2d788b ^
f6645643 ^








2c678a4e ^
f6645643 ^
1c2d788b ^
f6645643 ^






2c678a4e ^
f6645643 ^
1c2d788b ^
b7df1a7a ^


2c678a4e ^
f6645643 ^

1c2d788b ^
f6645643 ^


















2c678a4e ^
f6645643 ^
1c2d788b ^
f6645643 ^






2c678a4e ^
f6645643 ^
1c2d788b ^
b7df1a7a ^


2c678a4e ^
f6645643 ^

1c2d788b ^
f6645643 ^










2c678a4e ^
f6645643 ^

2c678a4e ^

f6645643 ^
2c678a4e ^
f6645643 ^


2c678a4e ^
f6645643 ^









b7df1a7a ^

f6645643 ^

2c678a4e ^
f6645643 ^






2c678a4e ^
f6645643 ^















b7df1a7a ^
f6645643 ^






b7df1a7a ^


f6645643 ^












































b7df1a7a ^
f6645643 ^













b7df1a7a ^
f6645643 ^





















































b7df1a7a ^
f6645643 ^















b7df1a7a ^
f6645643 ^















b7df1a7a ^
f6645643 ^



















4945e77a ^
f6645643 ^


4945e77a ^



2c678a4e ^
4945e77a ^

2c678a4e ^
4945e77a ^






2c678a4e ^
4945e77a ^

2c678a4e ^
4945e77a ^































































































76755b28 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756