Commit Graph

259 Commits

Author SHA1 Message Date
Kartik K. Agaram 73fefa7d09 support selections in the source editor
I've only tested side A so far, and included a statement of how I want
side B to behave.
2022-09-06 10:05:20 -07:00
Kartik K. Agaram 528c64d690 support drawings in the source editor 2022-09-05 11:29:39 -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 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 cbd8f678d2 fix a name 2022-08-19 16:27:38 -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 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 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 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
Kartik K. Agaram ba48aadaa7 bugfix: backspace from start of final line 2022-08-10 22:38:10 -07:00
Kartik K. Agaram 8cfffdef41 unnecessary args 2022-08-10 22:29:39 -07:00
Kartik K. Agaram 0218980add click to the left of a line 2022-07-29 14:38:45 -07:00
Kartik K. Agaram 0251b3f0c2 bugfix: search
Broken since commit 188bbc73 9 days ago :/ At least we have a test for
it now.
2022-07-21 16:55:05 -07:00
Kartik K. Agaram d61b5dfdeb use line cache for drawings as well 2022-07-20 16:34:09 -07:00
Kartik K. Agaram e2734cd572 bugfix: where cursor is drawn
The published version of lines.love was broken for almost an hour. The
cursor would render one position to the right of where it really is. To
fix it, this commit rolls back 26ba6e4e5a. There doesn't seem a good
way to test it.
2022-07-20 09:11:29 -07:00
Kartik K. Agaram 88013000fc . 2022-07-20 07:50:33 -07:00
Kartik K. Agaram 9f4b41d829 exclude left margin from my word-split heuristic
Gratifying how few tests need changing. Recent commits seem on the right
track.
2022-07-20 07:15:46 -07:00
Kartik K. Agaram a472d218f2 allow Text.nearest_pos_less_than to return 0
This eliminates another case of overflowing margins.
2022-07-20 07:08:28 -07:00
Kartik K. Agaram 7dc47edde8 drop an unnecessary level of indent 2022-07-20 07:03:33 -07:00
Kartik K. Agaram 39f71784c9 clean up some prints
(Looking at prints in Text.draw, Text.compute_fragments and
Text.nearest_pos_less_than)
2022-07-20 07:00:39 -07:00
Kartik K. Agaram b5451e4351 move a var closer to its use 2022-07-20 06:56:19 -07:00
Kartik K. Agaram d41301c1b7 more clearly skip prints before screen top 2022-07-20 06:54:03 -07:00
Kartik K. Agaram 26ba6e4e5a unify two similar functions
The cost is just having to tweak a few more brittle tests. I can't
actually perceive any difference in how the cursor moves when I click on
text.
2022-07-19 17:13:16 -07:00
Kartik K. Agaram efd4a8a883 keep text from overflowing right margin
I've been sloppy about this so far, and outside of tests I can't find
any examples where it matters, but it matters in a potential fork where
I'm rendering multiple columns of text.

It's unfortunate that my tests have this level of brittleness. What I'd
really like to assert in many of these changed lines is that the text
stays inside the margins and that more text would overflow margins.
2022-07-19 16:49:08 -07:00
Kartik K. Agaram 82cdd9ddd1 bugfix: couple of margin-relative computations 2022-07-17 22:29:37 -07:00
Kartik K. Agaram 29dac6a6ec separate data structure for each line's cache data
I have no idea what the performance implications of this are..
2022-07-17 21:05:01 -07:00
Kartik K. Agaram 64eed74980 keep all text cache writes inside text.lua 2022-07-17 10:06:39 -07:00
Kartik K. Agaram 4ff6de9951 switch to line index in a function
- Text.screen_line_width
2022-07-17 09:37:50 -07:00
Kartik K. Agaram 7e7f5b9256 switch to line index in a function
- Text.compute_fragments
2022-07-17 09:30:50 -07:00
Kartik K. Agaram 860cd49f67 make a function oblivious to line data structure
- Text.screen_line_index
2022-07-17 09:21:57 -07:00
Kartik K. Agaram 2859063d9d switch to line index in a function
- Text.to_pos_on_line
2022-07-17 09:19:53 -07:00
Kartik K. Agaram 6b3ddc816f switch to line index in a function
- Text.populate_screen_line_starting_pos
2022-07-17 09:14:10 -07:00
Kartik K. Agaram 48b7de4fde switch to line index in a function
- Text.in_line
2022-07-17 09:14:10 -07:00
Kartik K. Agaram b95206fd0d drop some redundant args when clearing the cache 2022-07-17 08:18:48 -07:00