Commit Graph

1161 Commits

Author SHA1 Message Date
Kartik K. Agaram 99b04ae3c4 bugfix: handle cursor past end of line 2024-09-16 01:06:52 -07:00
Kartik K. Agaram 208cc02ed8 support 2 cursors yet again
This time we assume that while a position may map to multiple rects,
only one of them will actually show the character.
2024-09-15 23:14:04 -07:00
Kartik K. Agaram 9d8a518085 bugfix: up-arrow when cursor straddles a wrapping line
We can have multiple rects corresponding to the same location. But only
one of them has show_cursor enabled. This disambiguates which one we
mean.

With the current rect-based design, it's much harder to get 2 cursors
than I thought.
2024-09-15 14:47:26 -07:00
Kartik K. Agaram 0030e5d4f5 no, undo last 2 commits
Bug: showing 2 cursors breaks up-arrow when cursor straddles a wrapping
line.
2024-09-15 14:30:01 -07:00
Kartik K. Agaram 084e7de924 oh, now we can get rid of show_cursor support!
Compare the state now with a few hours ago (commit 284dfe616f)
2024-09-15 11:24:07 -07:00
Kartik K. Agaram d0491d11c2 show 2 cursors when straddling a wrapping line 2024-09-15 11:21:39 -07:00
Kartik K. Agaram 2b1fc7746d more precise click-handling in word-wrapping lines 2024-09-15 11:18:14 -07:00
Kartik K. Agaram 23418d4b6a bugfix: position cursor at end of wrapping line
Before this commit lines that split in the middle of a word were
positioning clicks to the right of the margin _before_ the rightmost
character of the screen line.

Now it's slightly visually confusing that the cursor shows up at start
of next wrapping line. Still seems like an improvement, though.
2024-09-15 11:14:09 -07:00
Kartik K. Agaram aad9d9e3e0 only show a single cursor at a time like in text2
Until now, clicking at the end of a soft-wrapped line would show the
cursor at both the end of the first screen line and the start of the
second.

However, I just noticed a bug: if the soft-wrapped line is splitting
within the middle of a word, 2 cursors appear on the same line. (All is
well when splitting between words.)

First reaction to a bug: delete the offending feature.

This requires also transplanting the 'show_cursor' field support from
text2.

Now the code is easy to reason about: I always show the cursor at a
single place for any given pos. And the pos I'm showing cursor at is
always the current pos.

But this isn't the end of the story. I do like the feature of showing 2
cursors when straddling screen lines.

There's also a second bug in text2 that has also transplanted here:
clicking to the right of a wrapping screen line actually positions
cursor _before_ the right-most character, not after.

I'm going to try to keep lines2 and text2 sync in this respect as I make
future edits. (text2 will continue to exclusively support 'conceal' and
'draw' fields.)
2024-09-15 10:50:10 -07:00
Kartik K. Agaram 284dfe616f don't always pop up keyboard on mobile devices
We don't want to do this during app initialization because other forks
might not start out with an editor on screen even if this one does.

We also don't want to perform side-effects like this within
edit.mouse_press.
2024-09-10 21:25:36 -07:00
Kartik K. Agaram 2f51b693af streamline Readme 2024-09-08 23:13:50 -07:00
Kartik K. Agaram 0bd43b931b simplify end of file check on right arrow 2024-09-08 16:37:17 -07:00
Kartik K. Agaram 1c81f15237 fine, I'll add a badge 2024-09-05 14:30:52 -07:00
Kartik K. Agaram ff04771be0 fix line wrap in a comment 2024-09-03 15:23:41 -07:00
Kartik K. Agaram 64a4282ffd Merge branch 'yumaikas-experiment'
After using get_rect in edit.draw I grow more confident that this is a
better approach. The only drawback is that edit.up and
edit._up_whole_screen_lines need some extra work to fight the
abstraction of get_rect. But that feels like a net win.
2024-09-01 19:55:35 -07:00
Kartik K. Agaram 0078f0a757 reuse get_rect in edit.draw 2024-09-01 19:54:26 -07:00
Kartik K. Agaram 6e17b2ea1a stale hack 2024-08-31 19:44:12 -07:00
Kartik K. Agaram df76d50d19 stale hack 2024-08-31 19:43:44 -07:00
Kartik K. Agaram 3720f8a875 clean up an issue I feel confident about 2024-08-31 19:17:56 -07:00
Kartik K. Agaram 6c71be2e56 clean up an issue I feel confident about 2024-08-31 19:17:32 -07:00
Kartik K. Agaram 008ab3df6c rename 2024-08-31 19:06:09 -07:00
Kartik K. Agaram afff83fa84 rename 2024-08-31 19:05:58 -07:00
Kartik K. Agaram d75603da7e explicitly state when operations manage undo 2024-08-31 19:03:29 -07:00
Kartik K. Agaram 2f2eeff1dd explicitly state when operations manage undo 2024-08-31 19:01:33 -07:00
Kartik K. Agaram 04ca57c326 make function arg lowercase
This might have introduced a bug. I _think_ I've checked for functions
without an `Editor` arg, but one may have slipped past. I don't know how
to be sure. (Not without tests :/)
2024-08-31 18:50:52 -07:00
Kartik K. Agaram 95837a50f6 make function arg lowercase
This might have introduced a bug. I _think_ I've checked for functions
without an `Editor` arg, but one may have slipped past. I don't know how
to be sure. (Not without tests :/)
2024-08-31 18:48:40 -07:00
Kartik K. Agaram cd34c94a4a bugfix
scenario:
  start with an empty file, there's one line with a '+' button on it
  press the '+' to create a drawing in the top line
  press C-z to undo
  = before this commit, undo would create a weird intermediate state where there were two lines with '+' on them

scenario:
  type something into the first line, press enter to append a second line
  press the '+' on the second line to create a drawing
  press C-z to undo
  = crash

The root cause in both cases: we end up creating 2 undo events starting
from the same before snapshot: one inside the button handler, and a
second on mouse release.

This doesn't affect lines 1 because we had a separate variable called
current_drawing which protected the mouse release handler from
triggering.
2024-08-31 18:32:52 -07:00
Kartik K. Agaram 5ce18bdf6d bugfix
scenario:
  start with an empty file, there's one line with a '+' button on it
  press the '+' to create a drawing in the top line
  press C-z to undo
  = before this commit, undo would create a weird intermediate state where there were two lines with '+' on them

scenario:
  type something into the first line, press enter to append a second line
  press the '+' on the second line to create a drawing
  press C-z to undo
  = crash

The root cause in both cases: we end up creating 2 undo events starting
from the same before snapshot: one inside the button handler, and a
second on mouse release.

This doesn't affect lines 1 because we had a separate variable called
current_drawing which protected the mouse release handler from
triggering.
2024-08-31 18:28:48 -07:00
Kartik K. Agaram 73f5b9632f bugfix
scenario:
* open a file with a drawing on the first line
* position cursor in the line below
* hit backspace

I _think_ this is the only place where I need to update screen_top
_before_ the scroll check (because screen_top switches mode and has
gotten corrupted).
2024-08-31 17:55:23 -07:00
Kartik K. Agaram 48a0e0e59d bugfix
scenario:
* open a file with a drawing on the first line
* position cursor in the line below
* hit backspace

I _think_ this is the only place where I need to update screen_top
_before_ the scroll check (because screen_top switches mode and has
gotten corrupted).
2024-08-31 17:53:19 -07:00
Kartik K. Agaram 074978f4e0 bugfix 2024-08-30 00:48:42 -07:00
Kartik K. Agaram cc12ef92c4 bugfix 2024-08-30 00:48:33 -07:00
Kartik K. Agaram b6bf7d526d clean up a few stale comments 2024-08-30 00:47:26 -07:00
Kartik K. Agaram b7a911a7cc clean up a few stale comments 2024-08-30 00:47:04 -07:00
Kartik K. Agaram e2a3b0eda0 fix a stupid bug 2024-08-28 20:23:14 -07:00
Kartik K. Agaram 9879a059ff fix a stupid bug 2024-08-28 20:22:00 -07:00
Kartik K. Agaram 7ae717aeae implicitly compute line_height from font_height 2024-08-28 17:58:16 -07:00
Kartik K. Agaram 28ad0eb8e7 implicitly compute line_height from font_height 2024-08-28 17:58:05 -07:00
Kartik K. Agaram 54242d9d07 bugfix: don't process most keys if cursor is out of view
I think the only situation this can happen is after pressing C-a to
select a file (that doesn't fit on screen). But it's important for
potential forks, e.g. positioning editors on infinite surfaces.
2024-08-28 17:55:27 -07:00
Kartik K. Agaram 34546e15ca bugfix: don't process most keys if cursor is out of view
I think the only situation this can happen is after pressing C-a to
select a file (that doesn't fit on screen). But it's important for
potential forks, e.g. positioning editors on infinite surfaces.
2024-08-28 17:52:13 -07:00
Kartik K. Agaram 00d9169bda bugfix: move/delete/name operations on points 2024-08-18 11:20:14 -07:00
Kartik K. Agaram a6b9cd94be bugfix: move/delete/name operations on points 2024-08-18 11:18:38 -07:00
Kartik K. Agaram d5ae54c2ec bugfix: check for no point at mouse 2024-08-18 11:00:47 -07:00
Kartik K. Agaram 91c1463cb1 bugfix: check for no point at mouse 2024-08-18 11:00:08 -07:00
Kartik K. Agaram 76df6e5dd6 bugfix: switch screen_top mode when clicking on drawing
I suspect select.lua and search.lua may not be checking for drawings
everywhere they should.
2024-08-18 10:49:06 -07:00
Kartik K. Agaram 9a2bb73df8 recent changes to Readme 2024-08-18 10:48:57 -07:00
Kartik K. Agaram ad2493ffaf bugfix: switch screen_top mode when clicking on drawing
I suspect select.lua and search.lua may not be checking for drawings
everywhere they should.
2024-08-18 10:47:54 -07:00
Kartik K. Agaram fcddbef26f bugfix: use additional space when resizing window 2024-08-18 10:19:31 -07:00
Kartik K. Agaram 692663b884 fixup! bugfix: stale function name 2024-08-18 10:16:53 -07:00
Kartik K. Agaram ff422b9773 update the goal
This fork has no tests; intended more to freeze durably than to add features to.
2024-07-28 22:50:19 -07:00