Commit Graph

48 Commits

Author SHA1 Message Date
Kartik K. Agaram 0fc15e81a5 move comment to a better place 2024-09-18 17:45:39 -07:00
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 0bd43b931b simplify end of file check on right arrow 2024-09-08 16:37:17 -07:00
Kartik K. Agaram ff04771be0 fix line wrap in a comment 2024-09-03 15:23:41 -07:00
Kartik K. Agaram 0078f0a757 reuse get_rect in edit.draw 2024-09-01 19:54:26 -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 074978f4e0 bugfix 2024-08-30 00:48:42 -07:00
Kartik K. Agaram a6b9cd94be bugfix: move/delete/name operations on points 2024-08-18 11:18:38 -07:00
Kartik K. Agaram 1fe8a2dc4a bugfix: reduce error in edit.hor
Cursor no longer drifts left as you repeatedly press up/down arrow
within a region of filled screen lines.
2024-07-28 20:20:16 -07:00
Kartik K. Agaram 0193ad7d18 bugfix: positioning cursor on first screen line of line 2024-07-28 20:13:05 -07:00
Kartik K. Agaram 2a8b48fcec get rid of debug UI 2024-07-28 19:48:33 -07:00
Kartik K. Agaram 0215156e4c bugfix: edit.get_rect is now in sync with edit.draw
I fixed 1 bug in edit.draw and 4 bugs in the debug UI :)
2024-07-28 19:45:57 -07:00
Kartik K. Agaram 31dd8aa7c6 debug UI shows draw_rects is out of sync with edit.draw 2024-07-28 19:33:21 -07:00
Kartik K. Agaram ce1b60a2e6 hoist some code within edit.get_rect 2024-07-28 19:18:44 -07:00
Kartik K. Agaram 901b12224a make get_rect better fit the domain
* It receives a starting location, not always a full line. If it starts
  in the middle of a line, I only create rects starting from there (and
  stop at end of line at most).

* I stop when I create enough screen lines to get to the bottom. This is
  important when the caller is trying to compute the location for a
  pixel. If I click below all lines, the caller can just grab the
  absolute final char rect and everything works out.
2024-07-26 21:43:01 -07:00
Kartik K. Agaram 0e69ded5d0 bugfix: clicking below bottom margin when bottom line on screen is a drawing 2024-07-21 23:18:20 -07:00
Kartik K. Agaram 820c6270d0 bugfix: keep mouse clicks within visible lines 2024-07-21 23:15:22 -07:00
Kartik K. Agaram 0ee0069e10 bugfix: clicking to move cursor when top of screen is midway through a (wrapping) line 2024-07-21 23:08:54 -07:00
Kartik K. Agaram 4662a86a30 3 bugfixes
up arrow when going up to same line -> crash
right arrow at end of wrapping line -> nothing happens
down arrow from final screen line of line -> nothing happens
2024-07-21 22:50:10 -07:00
Kartik K. Agaram 20c2bf70c5 bugfix: press left arrow from cursor at start of second screen line of line 2024-07-21 22:34:54 -07:00
Kartik K. Agaram 6c05677dcf continue the fix of commit 5b16cc7f19 2024-07-21 22:25:30 -07:00
Kartik K. Agaram 3472571758 some debug info 2024-07-21 22:24:56 -07:00
Kartik K. Agaram d27c81e3b2 couple of bugfixes 2024-07-21 21:16:22 -07:00
Kartik K. Agaram 6124b4c40e delete some dead code 2024-07-21 18:28:32 -07:00
Kartik K. Agaram 5b16cc7f19 still lots of crashing 2024-07-21 18:12:06 -07:00
Kartik K. Agaram bb539a7b52 snapshot
An experiment in collaboration with yumaikas.
There's still one open bug that I know about.
There's also an open question: how to handle screen_top when it's not at start of line.
2024-07-21 17:58:46 -07:00
Kartik K. Agaram ce69def683 flag a bug 2024-07-21 17:56:40 -07:00
Kartik K. Agaram ca3234262b bugfix: handle clicks below all lines
Now we also can select when releasing below all lines.
2024-07-21 17:55:22 -07:00
Kartik K. Agaram cc319f1540 bugfix: return nil coord if loc is above screen 2024-07-21 17:52:59 -07:00
Kartik K. Agaram e8a2eab767 . 2024-07-21 17:52:13 -07:00
Kartik K. Agaram 72537ff2e4 bugfix
I do have one caller where I hor from one variable and write to another.
2024-07-21 17:47:01 -07:00
Kartik K. Agaram acfcd22c61 those bugs seem fixed 2024-07-21 11:53:29 -07:00
Kartik K. Agaram 1f7ad652e8 mostly seems to be working now
Only bug I see: up/left arrows can't go past drawings.
2024-07-21 11:45:04 -07:00
Kartik K. Agaram baa94e9e26 Text.down now scrolls and stops at bottom of file 2024-07-21 11:34:54 -07:00
Kartik K. Agaram 72dd6c41d0 rename
The old name didn't quite fit once I added the max width.
2024-07-21 11:13:31 -07:00
Kartik K. Agaram f87ab659fc new primitive analogous to Font:getWrap in LÖVE 2024-07-21 11:10:25 -07:00
Kartik K. Agaram 22b0efed74 rename 2024-07-21 11:01:25 -07:00
Kartik K. Agaram 58efe12ed6 Give up on drawing partial drawings at top of screen
There are still open questions with that:
- say there's a partial drawing up top. Do we want to support drawing on
  it? It would be jarring for it to move right as you click on it. But
  might also not be a great experience to only see part of it.

- the current problem with snapping cursor to bottom is that I only want
  to include whole screen lines in that particular call to edit.up.

  On the other hand, drawings were supporting partial screen lines,
  which added a second layer of complexity to it. Now there's at least
  only one problem.

- all my basic move operations were always maintaining yoff in drawings.
  It's meaningless and ignored in cursor for the most part. But if I
  ever copy screen_top from cursor I have to remember to reset yoff. Now
  there's one less thing to remember.
2024-07-21 09:14:01 -07:00
Kartik K. Agaram 7dd966f039 snapshot
Try running from the terminal, pressing down arrow twice. The cursor
disappears off screen. Where is the bug?
2024-07-20 22:46:09 -07:00
Kartik K. Agaram cc70880ea2 tmp - Text.down seems to be working again 2024-07-20 12:16:14 -07:00