Skip to content

Fixes #3692++ - Rearchitects drivers#3837

Merged
tig merged 226 commits intogui-cs:v2_developfrom
tznind:v2-drivers
Feb 28, 2025
Merged

Fixes #3692++ - Rearchitects drivers#3837
tig merged 226 commits intogui-cs:v2_developfrom
tznind:v2-drivers

Conversation

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

tig commented Nov 23, 2024

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

@tznind
Copy link
Copy Markdown
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
Copy Markdown
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...

Comment thread Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs Outdated
Comment thread Terminal.Gui/ConsoleDrivers/V2/InputProcessor.cs
@tznind tznind requested a review from tig February 27, 2025 20:06
@tznind
Copy link
Copy Markdown
Collaborator Author

tznind commented Feb 28, 2025

Merge conflict fixed

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment