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.
Just a couple of options for now, but this will enable syntax
highlighting like borders or underlining. (We can't yet color the
characters themselves; perhaps I should have added that first.)
This will allow clicking on multiple places to move the cursor to a
particular location. But you can use show_cursor to always show the
cursor in one privileged one of those locations.
Example use case: you want padding around a location. Clicking on the
padding focuses cursor on the location.
After using get_rect in edit.draw I grow more confident that this is a
better approach. The only drawback is that I.loc_up and
I.loc_up_whole_screen_lines need some extra work to fight the
abstraction of get_rect. But that feels like a net win.
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 :/)
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 :/)
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.
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.
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).
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).