Commit Graph

664 Commits

Author SHA1 Message Date
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 cc5ab51c53 delete some duplicate initialization 2022-07-19 08:04:21 -07:00
Kartik K. Agaram 8abd986054 clean up a cross-test leakage 2022-07-19 07:50:53 -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 c0ea369607 drop some extra args 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
Kartik K. Agaram 2fc5bb9a61 fold together two largely similar cases 2022-07-17 08:05:22 -07:00
Kartik K. Agaram 038f06a342 drop some redundant args from Text.draw 2022-07-17 08:00:56 -07:00
Kartik K. Agaram 0ac44f0756 formatting 2022-07-16 19:27:58 -07:00
Kartik K. Agaram f61d4269f5 bring back a set of constants
It's starting to sink in that I don't want hard-coded constants inside
objects.
2022-07-16 08:48:02 -07:00
Kartik K. Agaram c26b377ab3 more decoupling editor tests from App 2022-07-16 08:33:05 -07:00
Kartik K. Agaram a2b654b534 more decoupling editor tests from App 2022-07-16 08:27:11 -07:00
Kartik K. Agaram 51b4efa59a more decoupling editor tests from App 2022-07-16 08:20:47 -07:00
Kartik K. Agaram a1da18c107 more precise name 2022-07-15 22:15:07 -07:00
Kartik K. Agaram 2884f872d8 make test initializations a little more obvious 2022-07-15 22:12:25 -07:00
Kartik K. Agaram fc6b602342 bugfix: zoom in/out hotkeys
Broken since commit 3b36093553 5 hours ago.
2022-07-13 23:31:52 -07:00
Kartik K. Agaram 119abbd52e bugfix: resize 2022-07-13 15:40:14 -07:00
Kartik K. Agaram e4f9d50a55 a more radical attempt at ignoring nil y's 2022-07-13 09:31:54 -07:00
Kartik K. Agaram d231f4d37d no, bring back that defense
Scenario where I ran into it:
  start a stroke inside a drawing
  press 'o' to switch to circle mode (but any mode switch will do)

The problem is that Text.textinput unconditionally blows away all .y
values. Sometimes we have to wait for a draw() to fill them back in.
2022-07-13 09:21:19 -07:00
Kartik K. Agaram 22ad5373c5 a bug I've never run into
The previous commit was failing inside a test that I can't reproduce
manually. Perhaps it's something about how often draw/update run in
practice. Anyways, it's definitely uncovered a real issue.
2022-07-13 08:40:04 -07:00
Kartik K. Agaram 6659de60f3 hoist couple of variables out
This seems to uncover a corner case I'd never run into until now.
2022-07-13 08:24:16 -07:00
Kartik K. Agaram 3b1f2cf9de use available variables 2022-07-13 08:19:58 -07:00
Kartik K. Agaram 5017659bf4 more idiomatic variable names 2022-07-13 08:19:06 -07:00
Kartik K. Agaram 457136a986 chunking by simple local variable 2022-07-13 08:14:01 -07:00
Kartik K. Agaram 9f962b7cac make local functions look different 2022-07-13 08:04:06 -07:00
Kartik K. Agaram cfa04c3ca1 more chunks, same approach 2022-07-13 08:02:41 -07:00
Kartik K. Agaram 5a04d0c221 chunk up some long lines
Hopefully this is more approachable. Though now I'm creating two new
temporary functions on every draw. Whether I need them or not.
2022-07-13 07:50:50 -07:00
Kartik K. Agaram 75ec5c9087 . 2022-07-12 22:13:06 -07:00
Kartik K. Agaram 9e9e8ed35c drop final mention of state global beyond main.lua
This is all unfortunate in several ways
- lots of functions have extra args
- table lookups where we used to have a simple variable
- program initialization is a lot more delicate

Let's see if it was worthwhile. Can we now actually build around the
editor component in forks?
2022-07-12 22:05:53 -07:00
Kartik K. Agaram 70a15b3bc9 replace globals with args in a few functions
- Drawing.draw_shape
  - Drawing.draw_pending_shape
  - Drawing.in_drawing
  - Drawing.find_or_insert_point
  - Drawing.near
  - Drawing.pixels
2022-07-12 21:58:46 -07:00
Kartik K. Agaram 307e875c1c correct a mis-named threshold 2022-07-12 21:41:09 -07:00
Kartik K. Agaram 3dd5413dbf drop heavyweight near check on file load/store 2022-07-12 21:29:30 -07:00
Kartik K. Agaram 2ae9cacd97 deduce left/right from state where possible 2022-07-12 20:59:24 -07:00
Kartik K. Agaram 3b36093553 left/right margin -> left/right coordinates
Editor state initialization now depends on window dimensions, so we have
to more carefully orchestrate startup.
2022-07-12 20:54:50 -07:00
Kartik K. Agaram 1ede1c3c6d add state arg to a few functions
- Drawing.current_drawing
  - Drawing.select_shape_at_mouse
  - Drawing.select_point_at_mouse
  - Drawing.select_drawing_at_mouse
2022-07-12 17:27:00 -07:00