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

Merged
merged 226 commits into from
Feb 28, 2025
Merged

Fixes #3692++ - Rearchitects drivers #3837

merged 226 commits into from
Feb 28, 2025

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");
}

Class Diagram

image

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.

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 tznind marked this pull request as ready for review February 22, 2025 16:40
Copy link
Collaborator

@tig tig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Just a few asks...

@tznind tznind requested a review from tig February 27, 2025 20:06
@tznind
Copy link
Collaborator Author

tznind commented Feb 28, 2025

Merge conflict fixed

@tig
Copy link
Collaborator

tig commented Feb 28, 2025

I want to merge this, but we keep getting unit test failures (see #3930).

likely not due to this PR, but I'm not going to merge until this passes at least once. I just restarted the action....

@tig tig merged commit c88c772 into gui-cs:v2_develop Feb 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment