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

Fixes #3692 - Rearchitects drivers #3837

Draft
wants to merge 101 commits into
base: v2_develop
Choose a base branch
from
Draft

Conversation

tznind
Copy link
Collaborator

@tznind tznind commented Nov 19, 2024

This is a super set of #3791 and exists to see diff and direction of v2 drivers as discussed in #3821

Fixes

Progress

  • Keyboard
    • Exit
    • Typing
    • Backspace
  • Views
    • Run/RequestStop
    • MenuBar
  • Mouse (see MouseInterpreter)
    • Button 1 click
    • Multi clicks
    • All buttons
    • Scroll wheel
  • Other
    • Clipboard

Proposed Changes/Todos

Splits drivers up into logical components, simplifies and centralizes shared code patterns.

image

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@tig tig changed the title V2 drivers Fixes #3692 - Rearchitects drivers Nov 23, 2024
@tig
Copy link
Collaborator

tig commented Nov 23, 2024

Hope you're ok with me updating the title & first post...

@tznind
Copy link
Collaborator Author

tznind commented Nov 23, 2024

Hope you're ok with me updating the title & first post...

No problem! Always appreciate a clear naming

Now we have fledgling support for

  • Keyboard
  • Mouse
  • Screen size

Net (i.e. native dotnet) and Windows (i.e win 32 api) are the two implementations - I assume we can drop curses and don't need to port?

resize-etc

@tznind tznind mentioned this pull request Nov 23, 2024
@tznind
Copy link
Collaborator Author

tznind commented Dec 15, 2024

Ok most stuff works and cpu sits at about 0%

Now needs loads of tests, and to round out a few implementations like all the various key translations, double click etc

I think I will add ILogger support so we can see things like ignored ansi codes, record where/if there is slowdown etc. That will be a dependency for ILogger but actual implementation is down to user e.g. NLog / Serilog etc

@tznind
Copy link
Collaborator Author

tznind commented Dec 19, 2024

Ok I need to work a bit on my understanding of how to integrate Application.Run.

The users main entry thread for Program.cs is going to call Application.Init and then Run.

That method will 'block' but it also is the thread that processes Click events e.g. if the user wants to Run another View.

Currently I have 2 main threads

  • Input Loop
  • Everything else loop (output, timers, layout, draw etc)

But I'm realizing now that that is an issue for integrating with Run. Because Run has to appear to block but still process user event code (e.g. click) and be able to put another Run call onto the csharp call stack.

Any insight into my understanding of things or suggestions would be welcome - especially clarifications on how it is currently working as its a bit opaque.

This is my vision for how v2 will work. At the moment Run just blocks and loops, looking at the state of the coordinator. But that does not work well for starting a nested Run or exiting a nested Run back into the parent Run.

image
V2 vision of the 3 threads that will make up any Terminal.Gui program

@tznind
Copy link
Collaborator Author

tznind commented Dec 20, 2024

Ok I have got it! Looking at the existing codebase the 'Iterate/Output' loop that I have on its own thread is actually called repeatedly within Run. This means that the entry thread the application has in their program is the one that the UI code is all running on.

That makes sense and is 1 less thread so I'm up for it. Now you can open and close as many scenarios as you want.

So it is more like this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants