Commit Graph

56 Commits

Author SHA1 Message Date
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
2884f872d8 make test initializations a little more obvious 2022-07-15 22:12:25 -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
92ad99853e call edit rather than App callbacks in tests 2022-07-12 15:41:17 -07:00
Kartik K. Agaram
81ecca89ff start passing in Editor_state explicitly
In this commit, top-level edit functions:
  - edit.draw
  - edit.update
  - edit.quit
  - edit.mouse_pressed
  - edit.mouse_released
  - edit.textinput
  - edit.keychord_pressed
  - edit.key_released
2022-07-12 15:33:06 -07:00
Kartik K. Agaram
e95b4fec12 initialize contains test state 2022-07-12 15:29:22 -07:00
Kartik K. Agaram
8bbc1ffe34 group all editor globals
We're still accessing them through a global. But we'll change that next.
2022-07-12 15:24:56 -07:00
Kartik K. Agaram
9b49c8da77 start decoupling editor tests from App 2022-07-11 23:18:26 -07:00
Kartik K. Agaram
6c4483976e skip multiple consecutive whitespace 2022-07-11 19:18:54 -07:00
Kartik K. Agaram
bc2c14c899 support other whitespace chars in word movements 2022-07-11 18:56:19 -07:00
Kartik K. Agaram
92e572fc89 flesh out some tests for word movements 2022-07-11 18:46:49 -07:00
Kartik K. Agaram
6dfe954c02 yet another bugfix in selection management
Thanks Leonard Schütz for the report!

Failing scenario:
  click to move cursor
  hit backspace

First backspace wasn't being doing anything earlier.
2022-07-07 07:39:01 -07:00
Kartik K. Agaram
914d9c6f98 bugfix: clicking on empty lines 2022-07-01 12:16:43 -07:00
Kartik K. Agaram
429a42eb1c right margin 2022-06-30 22:54:34 -07:00
Kartik K. Agaram
8c7bea8f76 rip out notion of Line_width 2022-06-30 19:50:27 -07:00
Kartik K. Agaram
510b0d1dc3 bugfix: lines that aren't drawn from the start
I can't believe I didn't catch this until now. All I had to do is open
MobyDick.markdown from https://www.hogbaysoftware.com/posts/moby-dick-workout,
press page-down and click on the top screen line (or any screen line
containing the same line as the top screen line). Easy to catch with any
file containing lots of overly long lines, as happens in particular at
the start of Moby Dick.

I _had_ seen this problem before, but it seemed to disappear after
unrelated changes, and I convinced myself I'd fixed it as a side-effect.
The bug just failed to manifest if the top line happened to start at the
top of the screen. Scroll down a few pages in Moby Dick and the dialogue
starts and line length drops precipitously.
2022-06-30 18:14:48 -07:00
Kartik K. Agaram
98fa46bf99 some redundant calls 2022-06-30 17:44:31 -07:00
Kartik K. Agaram
ea4aa0999c clicking to the right of a line within line width 2022-06-29 09:30:23 -07:00
Kartik K. Agaram
8d3adfa36d bugfix: clicking past end of screen line
I could swear I checked this at some point. But I didn't have a test!
2022-06-29 09:17:38 -07:00
Kartik K. Agaram
b49ff8dde9 bugfix: scrolling in left/right movements
I'd always had a funny feeling there was something missing there but
somehow never thought of the right failing test.
2022-06-28 18:48:59 -07:00
Kartik K. Agaram
83ba9e61d1 bugfix: typing a capital letter deletes selection 2022-06-26 17:07:27 -07:00
Kartik K. Agaram
44fb3ecd55 bugfix: deleting a selection spanning pages 2022-06-26 16:34:06 -07:00
Kartik K. Agaram
84875f3c43 bugfix: don't delete selection when moving cursor 2022-06-23 12:05:36 -07:00
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