Commit Graph

31 Commits

Author SHA1 Message Date
Kartik K. Agaram 515dad95f9 keep drawings within the line width slider as well 2022-06-22 21:08:17 -07:00
Kartik K. Agaram 8e68c699f5 bugfix: delete selection before pasting 2022-06-21 09:56:04 -07:00
Kartik K. Agaram 0d1e6aacd9 revert selection logic to before commit 3ffc2ed8f
We still have a failing test, but now it's the one we introduced in
commit 3ffc2ed8f.
2022-06-20 13:12:29 -07:00
Kartik K. Agaram 978c143397 snapshot: test for a new regression
Caused by commit 3ffc2ed8f.

We might need to bring back a lot of complexity for this.
2022-06-20 12:12:09 -07:00
Kartik K. Agaram 7508a70ed5 selection bugfix 2022-06-20 12:02:51 -07:00
Kartik K. Agaram 3986e99fe0 no, that's not right
Bugfix: we want selections to persist even when we lift up the shift
key.

This requires hoisting some code inside every case inside the whole
keypress hierarchy, to ensure we never clear selections before
textinput events can handle them.

Current cross-cutting concerns we're explicitly scattering code for.
  - autosave
  - undo
  - selection management
2022-06-20 11:31:14 -07:00
Kartik K. Agaram 3be413602a bugfix: typing should delete highlighted text
The test harness now also mimics real usage more precisely.
2022-06-20 10:48:35 -07:00
Kartik K. Agaram 3ffc2ed8f3 bugfix
To reproduce:
  click to position cursor at end of a line
  hit enter
  press any key

before:
  newline got erased and key got added to previous line

now:
  newline is preserved

The new test checks a generalization of this.
2022-06-19 09:21:32 -07:00
Kartik K. Agaram e3c7e9c96b extract variables for drawing padding 2022-06-14 10:49:10 -07:00
Kartik K. Agaram f277a78455 extract variable Margin_left 2022-06-14 10:49:06 -07:00
Kartik K. Agaram 70e184deeb . 2022-06-14 10:07:55 -07:00
Kartik K. Agaram cf38c26bc1 lots more tests
I've been adding diligently to manual_tests but not actually
_performing_ any manual tests before releases. They were just a todo
list of automated tests to write, and long out of date. Now the list is
up to date and much shorter.
2022-06-14 09:26:18 -07:00
Kartik K. Agaram c1d8201d44 mouse buttons are integers, not strings
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.
2022-06-14 09:05:02 -07:00
Kartik K. Agaram 4c39c436bf answered an open question
The default font seems somehow different than the font created by
newFont with just a font size.
2022-06-14 08:33:02 -07:00
Kartik K. Agaram e20935ad7a bugfix
manifestation: clicking past end of a long, wrapping line containing
non-ASCII would cause the cursor to disappear rather than position past
end of screen line. Hitting enter would then throw an assertion with the
following stack trace:

  Error: text.lua:381: bad argument #2 to 'sub' (number expected, got nil)
  stack traceback:
    [love "boot.lua"]:345: in function <[love "boot.lua"]:341>
    [C]: in function 'sub'
    text.lua:381: in function 'insert_return'
    text.lua:179: in function 'keychord_pressed'
    main.lua:495: in function 'keychord_pressed'
    keychord.lua:10: in function <keychord.lua:5>
    app.lua:34: in function <app.lua:25>
    [C]: in function 'xpcall'

cause: the click caused a call to Text.to_pos_on_line whose result was
not on a UTF-8 character boundary.

fix: make to_pos_on_line utf8-aware.
2022-06-14 08:02:25 -07:00
Kartik K. Agaram 9b0577f79e bugfix: UTF-8 in compute_fragments 2022-06-14 08:01:53 -07:00
Kartik K. Agaram 5b6171cf02 . 2022-06-14 08:01:53 -07:00
Kartik K. Agaram 26640c9101 new test
For commit e4e12c77ad which fixed a regression caused by commit
24a0d162ef.
2022-06-12 10:59:42 -07:00
Kartik K. Agaram 4f64784833 new test
For commit ff88a2a927 which fixed a regression caused by commit
e51ce12969.

I'm trying to provide enough guardrails for myself and future readers
without causing a combinatorial explosion in tests. The previous commit
was able to get more value out of existing tests, but this test feels
necessary. And useful in general without reference to a specific bug.
2022-06-12 10:34:53 -07:00
Kartik K. Agaram 059efba79d override mouse state lookups in tests
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
2022-06-12 09:04:21 -07:00
Kartik K. Agaram f554ce878b include a unit test 2022-06-09 18:36:16 -07:00
Kartik K. Agaram 6ba10b4de6 fix a corner case when selecting text
The hard part here is keeping click-drag selection working (without
pressing and holding shift).
2022-06-09 15:49:16 -07:00
Kartik K. Agaram fa5bf1218a move 2022-06-09 15:48:07 -07:00
Kartik K. Agaram 173d3a3de0 test both ways of selecting text with mouse 2022-06-09 15:09:32 -07:00
Kartik K. Agaram 9cafed99f4 another bugfix in scrolling while inserting text
I'm being unprincipled at the moment between pos and x,y coordinates.
Whatever is more convenient. Perhaps a cleaner approach will come to me
over time.
2022-06-05 10:08:28 -07:00
Kartik K. Agaram e7a985bd0a bugfix in previous commit
I almost pushed this to production. That would have been catastrophic;
the very first keystroke anyone typed into the editor would have failed.

And in the process, this fixes the next bug on my TODO list! Paste on
first line wasn't working. Now it is.
2022-06-05 09:51:54 -07:00
Kartik K. Agaram de473046bc check for scroll when just typing 2022-06-05 08:29:38 -07:00
Kartik K. Agaram 8c0f54ee64 some typos 2022-06-05 07:59:44 -07:00
Kartik K. Agaram fa267e25e6 experiment: slightly adaptive scrolling
When long wrapping lines go past the current page, I find myself
scrolling before I get to the bottom. So let's scroll less, usually from
the start of the bottom-most line, even if it wraps multiple screen
lines.

The challenge with this is to ensure that a long line that fills the
whole page by itself doesn't get you stuck. I take some care to make
sure <pagedown> always makes forward progress.
2022-06-04 14:55:52 -07:00
Kartik K. Agaram 1326914d7b select text with shift + mouseclick
It's still a bit simple-minded. Most software will keep the first bound
fixed and move the second. Lines currently has the bounds in a queue of
sorts. But I have a test to indicate the behavior that is definitely
desired. We'll see if we need it to get more complex.
2022-06-04 14:54:40 -07:00
Kartik K. Agaram 0d52962b3e extract a couple of files 2022-06-03 14:17:41 -07:00