Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Move timers from TermControl to Core/Interactivity #15969

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented Sep 15, 2023

This WIP PR moves the blink and cursor timers down to Core (where it has unfettered access to everything it needs).

It also puts Core in charge of displaying the cursor when there is input, and managing the cursor's focus visibility.

It also means that Core no longer needs a "BlinkCursor" method?

This PR will allow us to remove the timer from the WPF layer as well.

This PR also moves the autoscroll timer down into ControlInteractivity (!)
which means that all interactivity consumers get it for free. That's RAD.

All the logic is the same.

I also took the opportunity to remove some silly parts of the ControlInteractivity API that supported this, like it needing to be told whether the pointer was pressed while it was inside the box and whether it is focused (???)

Now it darn well keeps track of those things itself.

TODO:

  • Fix "allow cursor while blurred"
  • Fix a crash I observed trying to blink a nonexistent text buffer
    cursor ??? while splitting a bunch of panes all at once
  • Test more
  • Make the ControlInteractivityUnitTests pass (!)

@DHowett
Copy link
Member Author

DHowett commented Sep 15, 2023

Also, look! The WPF control!

This is with the port to ControlCore/ControlInteractivity.

VT blink never worked(!), as didn't autoscroll.

msedge_jo9e3yTWS3

@lhecker
Copy link
Member

lhecker commented Sep 15, 2023

There's an option to clean this up even more drastically than this. It's probably too much (given your limited time to code), but I personally think it's a fun idea regardless. In short: You could move the blink on/off state from the Cursor class into Renderer.

...and use IRenderData only to provide information what the current blink interval is, etc. All other information, like whether the cursor is hidden, or whether the blink interval should be reset on the next frame (i.e. whenever Cursor::SetOn is called when new text is received), etc., can remain in Cursor just like it is now.

This splits the "cursor on/off" into "blink on/off" and "reset on next frame to be forced on/off".

With that done all that remains is to pass the blink interval to this function:

WaitForSingleObject(_hEvent, INFINITE);

or to use WaitForMultipleObjects with CreateWaitableTimerW (probably more elegant?).

It has access to its own dispatcher, so it can do this on its own.
We'll be able to remove the timer from the WPF control in the future as
well.

TODO:
- [ ] Fix "allow cursor while blurred"
- [ ] Fix a crash I observed trying to blink a nonexistent text buffer
  cursor ??? while splitting a bunch of panes all at once
- [ ] Test more
This removes "focused" and "pointerPressedInBounds" from the
ControlInteractivity API.
@DHowett DHowett force-pushed the dev/duhowett/move-timers-down-into-core-interactivity-etc branch from 0bff156 to 9eb8537 Compare September 20, 2023 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants