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

Open
wants to merge 202 commits into
base: v2_develop
Choose a base branch
from

Conversation

tznind
Copy link
Collaborator

@tznind tznind commented Nov 19, 2024

Creates new drivers that are simpler versions of existing WindowsDriver and NetDriver. Also introduces a shared architecture such that only subcomponents vary between driver implementations, as discussed in #3821 .

After a period of shared execution with both sets of drivers available we will fix any bugs and then retire the old drivers.

Curses driver is not tackled, I am hopeful it can be retired completely now that net input is so strong and well implemented in core dotnet framework.

Fixes

Metrics

You can now see metrics on ant Terminal.Gui program by using its exe name and a metrics tool e.g.

 dotnet-counters monitor -n UICatalog --counters Terminal.Gui

Implementation uses System.Diagnostics.Metrics making it integrate easily with tools such as OpenTelemetry

Logging

You can enable logging of internals of Terminal.Gui by setting Logging.Logger to any Microsoft.Extensions.Logging compatible logging framework (nlog, serilog etc).

Naturally you must not use a console logger

For example with Serilog to a file:

Logging.Logger = CreateLogger ();

...

private static ILogger CreateLogger ()
{
	// Configure Serilog to write logs to a file
	Log.Logger = new LoggerConfiguration ()
				 .MinimumLevel.Verbose () // Verbose includes Trace and Debug
				 .WriteTo.File ("logs/logfile.txt", rollingInterval: RollingInterval.Day)
				 .CreateLogger ();

	// Create a logger factory compatible with Microsoft.Extensions.Logging
	using var loggerFactory = LoggerFactory.Create (builder =>
						{
							builder
								.AddSerilog (dispose: true) // Integrate Serilog with ILogger
								.SetMinimumLevel (LogLevel.Trace); // Set minimum log level
						});
	// Get an ILogger instance
	return loggerFactory.CreateLogger ("Global Logger");
}

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
@tig
Copy link
Collaborator

tig commented Feb 12, 2025

Travelling and had a few minutes to play.... This is looking great.

I agree with your plan for mergeing...

Some new issues I noticed:

Line Drawing pallette is corrupt.

Drag about box window broken (and crashes) on .win driver.

W0LJM3E 1

Drag scroll bar sometimes doesn't restore non-drag color:

8anNNx5 1

Numeric up/down does not auto-increment/acellerate when held.

Charmap has a bunch of issues. Getting CP info never completes. When loaded, the right hand pane doesn't show until a mouse move.

image

@tznind
Copy link
Collaborator Author

tznind commented Feb 12, 2025

Good finds! seems I was not raising released flags on win driver. cc96920 shoulf fix the 'mouse grab' related bugs (drag window etc)

@tznind
Copy link
Collaborator Author

tznind commented Feb 13, 2025

Line Drawing pallette is corrupt.

Initial size is corrupt, if you drag out the bottom and right it appears as it does in normal drivers. The checker pattern for background color is normal. Though I note that background colour doesnt work in any of the drivers - seems like a regression, I remember it used to work.

Does need fixing though - Need to understand which views are being wrong size and why - they seem to have minimum size.

When loaded, the right hand pane doesn't show until a mouse move.

Hmn probably it doesn't properly implement NeedsDisplay or part of its layout doesn't trigger it. I think there will quite a bit of this, we need to have things like view becoming visible for first time to set it as NeedsDisplay. The old architecture had a lot more Refresh and so on (Refresh is now completely ignored - all views must play nice with the loop and the NeedsDisplay / NeedsLayout flags).

Getting CP info never completes.

Seems Ready event never gets raised in the new code so codepoint fetch never starts (see waitIndicator.Ready)

Relevant code in old Run is

 public static bool RunIteration (ref RunState state, bool firstIteration = false)
 {
     // If the driver has events pending do an iteration of the driver MainLoop
     if (MainLoop!.Running && MainLoop.EventsPending ())
     {
         // Notify Toplevel it's ready
         if (firstIteration)
         {
             state.Toplevel.OnReady ();
         }

         MainLoop.RunIteration ();

@tznind
Copy link
Collaborator Author

tznind commented Feb 13, 2025

Have fixed the Ready event not being raised in 6b9367f.

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