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

Restoring drivers with the structural changes. #3844

Merged
merged 156 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
9de21e0
Fixes #3767. Allowing any driver to request ANSI escape sequence with…
BDisp Sep 30, 2024
0b3d219
Using a more appropriate request for cursor position.
BDisp Sep 30, 2024
c89a9c8
Add AnsiEscapeSequenceRequest and AnsiEscapeSequenceResponse classes.
BDisp Sep 30, 2024
21c3155
Prevents empty response error.
BDisp Oct 1, 2024
7142a04
Add AnsiEscapeSequenceRequests scenario.
BDisp Oct 1, 2024
dd31796
Improving scenario layout.
BDisp Oct 1, 2024
8d52fe7
Fix NetDriver read key issue.
BDisp Oct 2, 2024
1d20bce
Change file name.
BDisp Oct 2, 2024
c320fc2
Improves null dequeues handling.
BDisp Oct 2, 2024
8050202
Replace ExecuteAnsiRequest with TryParse.
BDisp Oct 5, 2024
bdc6fe6
Code cleanup.
BDisp Oct 5, 2024
922f586
Replace from TryParse to TryExecuteAnsiRequest.
BDisp Oct 5, 2024
2c76ed2
Fix exception throwing if no terminator is specified.
BDisp Oct 7, 2024
331a49e
Fix merge errors.
BDisp Oct 9, 2024
e5c30eb
Make AnsiEscapeSequenceRequest agnostic of each driver.
BDisp Oct 13, 2024
7249de0
Cannot run with unit tests.
BDisp Oct 13, 2024
f850e73
Fix unit test.
BDisp Oct 13, 2024
67d497c
Fixes CursesDriver stale buffer.
BDisp Oct 13, 2024
b35b9f5
Add abstract WriteAnsi into the ConsoleDriver for each driver handlin…
BDisp Oct 14, 2024
a2e4d82
Add WriteAnsiDefault method to common code.
BDisp Oct 14, 2024
cc1d668
Fix Window Terminal Preview using WindowsDriver.
BDisp Oct 14, 2024
5ce3996
Prevents throwing if selected item is equal to minus 1.
BDisp Oct 14, 2024
d963941
Preparing NetDriver to handle ansi response on demand.
BDisp Oct 15, 2024
0de8262
View.Mouse cleanup - WIP
tig Oct 15, 2024
c318748
View.Mouse cleanup - WIP3
tig Oct 15, 2024
2ad9887
View.Mouse cleanup - Fixed combobox
tig Oct 15, 2024
ec14b62
Merged MouseEvent and MouseEventEventArgs into MouseEventArgs
tig Oct 15, 2024
9dcfe02
Fixed Time/DateField crash
tig Oct 15, 2024
59396ae
Fixed Time/DateField crash 2
tig Oct 15, 2024
49096fa
Fix merge errors.
BDisp Oct 15, 2024
884011e
Improving WriteAnsi method to return the response.
BDisp Oct 16, 2024
9348328
Rename to WriteAnsiRequest.
BDisp Oct 16, 2024
1645d1f
Ensure dequeue on bad requests or without response in NetDriver.
BDisp Oct 16, 2024
34fb5b5
Non-blocking ReadConsoleInput in WindowsDriver.
BDisp Oct 16, 2024
8a6928e
Merge branch 'v2_develop' into v2_3767_ansi-escape-sequence-all-drivers
BDisp Oct 17, 2024
7fa098f
Remove unnecessary IsSuspendRead property.
BDisp Oct 18, 2024
9759b97
Remove unused variable.
BDisp Oct 18, 2024
1ecff5e
Fix ansi multi-thread requests handling in the NetDriver.
BDisp Oct 18, 2024
9a840dd
Remove unnecessary WriteAnsiRequestDefault method.
BDisp Oct 19, 2024
cc4f7e9
Simplifying code.
BDisp Oct 19, 2024
542d82d
Remove response from error.
BDisp Oct 19, 2024
9749142
Set _forceRead as true before set _waitForProbe.
BDisp Oct 20, 2024
9eb7023
Improves CursesDriver to allow non-blocking input polling.
BDisp Oct 20, 2024
4090ea4
Avoids response starting without Esc char on stressing tests.
BDisp Oct 20, 2024
5ef34b8
Refactoring code.
BDisp Oct 21, 2024
ee0f93d
Merge branch 'v2_develop' into v2_3767_ansi-escape-sequence-all-drivers
BDisp Oct 28, 2024
c1063a0
Remove unneeded abstract ConsoleDriver objects.
BDisp Oct 31, 2024
1b6963f
Improves a lot of console key mappings.
BDisp Oct 31, 2024
ba607f1
Commenting GetIsKeyCodeAtoZ contradiction debug check.
BDisp Oct 31, 2024
ee8d040
Fix NetDriver and WindowsDriver.
BDisp Oct 31, 2024
8ab7ec5
Fix for WindowsDriver.
BDisp Oct 31, 2024
de45b4b
Refactoring a lot CursesDriver.
BDisp Oct 31, 2024
6f25337
Cleanup unused code and comments.
BDisp Nov 1, 2024
126bcef
Add EscSeqRequests support to WindowsDriver.
BDisp Nov 1, 2024
5b39c3d
Fix unit test.
BDisp Nov 1, 2024
c89efe5
Add tab view for single/multi request sends
tznind Nov 2, 2024
0ddc11c
Add bulk send to scenario
tznind Nov 2, 2024
64ad1a9
Fix a bug which was sending the terminator to the mainloop.
BDisp Nov 2, 2024
a2872cd
Ensures a new iteration when _eventReady is already set.
BDisp Nov 2, 2024
1d58ba4
Merge pull request #201 from tznind/single-multi
BDisp Nov 2, 2024
68b41a3
Set CanFocus true and only SetNeedsDisplay if were sent or answered.
BDisp Nov 2, 2024
c999fc0
Trying fix unit tests.
BDisp Nov 2, 2024
3c4564c
Explain what the colors represent.
BDisp Nov 2, 2024
2e0bc01
Fixes #3807. WindowsDriver doesn't process characters with accents.
BDisp Nov 4, 2024
2d8bfd5
Fix comment.
BDisp Nov 4, 2024
808896d
Fix bug where some key were not been split.
BDisp Nov 4, 2024
782325f
Change to ConcurrentQueue.
BDisp Nov 4, 2024
e2f3b7b
Using empty string instead of space.
BDisp Nov 4, 2024
e35b37f
Add InvalidRequestTerminator property.
BDisp Nov 4, 2024
da21ef1
Improves drivers responses to being more reliable.
BDisp Nov 4, 2024
81eb301
Fix escSeqRequests that may be null running unit tests.
BDisp Nov 4, 2024
173f820
Disable HACK_CHECK_WINCHANGED.
BDisp Nov 4, 2024
472ec45
Remove _screenBuffer and only using the alternate buffer.
BDisp Nov 5, 2024
ad4f6c4
Fix unit test.
BDisp Nov 5, 2024
f73c817
Fix unit tests.
BDisp Nov 5, 2024
7921ae3
Returns ansiRequest.Response instead of a variable for more thread safe.
BDisp Nov 5, 2024
ecbbed0
For re-run CI.
BDisp Nov 5, 2024
2919d55
Code Review
tig Nov 6, 2024
4ac79c5
Merge pull request #203 from tig/BDisp-v2_3767_ansi-escape-sequence-a…
BDisp Nov 6, 2024
7d9ae7f
Ad more unit test to handling with IsLetterOrDigit, IsPunctuation and…
BDisp Nov 6, 2024
eb98707
Revert Key class changes.
BDisp Nov 6, 2024
0b11e20
Change Response to a nullable string.
BDisp Nov 6, 2024
bdcc0ff
Return null instead if empty and fix a bug that was returning the ter…
BDisp Nov 6, 2024
629cea8
Handling null response.
BDisp Nov 7, 2024
f87c2b1
Rename EscSeq to AnsiEscapeSequence and move to his folder.
BDisp Nov 7, 2024
dba089f
Change category.
BDisp Nov 7, 2024
5efba6a
Code cleanup.
BDisp Nov 7, 2024
b7b9e01
Fix error with Key.Space using lowercase letters.
BDisp Nov 7, 2024
a64f68c
Moving MapKey method to the AnsiEscapeSequenceRequestUtils class.
BDisp Nov 7, 2024
cc21bd4
Fix a bug where a esc key was ignored.
BDisp Nov 7, 2024
3e952df
Change to BlockingCollection, thanks to @tznind.
BDisp Nov 7, 2024
44d5997
Split more WindowDriver classes and #nullable enable.
BDisp Nov 7, 2024
873b578
#nullable enable.
BDisp Nov 7, 2024
ea0cacf
There is no null values here.
BDisp Nov 7, 2024
2124ad3
Cleanup code.
BDisp Nov 7, 2024
a6af3aa
An huge improvements on drivers and bug fixes.
BDisp Nov 8, 2024
55e5944
Merge branch 'v2_develop' into v2_3767_ansi-escape-sequence-all-drivers
BDisp Nov 8, 2024
8e9bb95
Code cleanup.
BDisp Nov 8, 2024
012d47e
Fix IncompleteCkInfos bug.
BDisp Nov 8, 2024
8c5832f
Fix NetDriver to also work well in Linux.
BDisp Nov 9, 2024
c6512e6
Finally fixed IncompleteCkInfos handling in NetDriver.
BDisp Nov 9, 2024
c8aac60
Add handling error in the scenario.
BDisp Nov 9, 2024
1680ec5
Make AnsiEscapeSequenceRequests static.
BDisp Nov 10, 2024
6444cc0
Fix ansi responses not being handling in WSL.
BDisp Nov 10, 2024
5e2b611
Resolving merge conflicts.
BDisp Nov 10, 2024
88f4045
Fix merge errors.
BDisp Nov 10, 2024
71fb38d
Add unit test for Screen.
BDisp Nov 10, 2024
0f6ce06
Fix SetCursorVisibility in CursesDriver.
BDisp Nov 10, 2024
f51fbbe
Forgot Shutdown in unit test.
BDisp Nov 10, 2024
089f756
Simplify request responses handling.
BDisp Nov 10, 2024
36876b9
Change TryWriteAnsiRequest method to virtual which use common code fo…
BDisp Nov 11, 2024
7d146b7
Fix unit test which was causing With_Subview_Using_PosFunc failing.
BDisp Nov 11, 2024
3425c5a
Forgot to use _waitForInput.Reset and remove unnecessary finally block.
BDisp Nov 11, 2024
644afa9
Change filter in the ansi request scenario.
BDisp Nov 11, 2024
1b830bd
Cleanup code.
BDisp Nov 11, 2024
1795547
ProcessInputQueue must be outside the wait block.
BDisp Nov 11, 2024
70e91f2
Tidy up code.
BDisp Nov 11, 2024
967cbc2
Switch to ConcurrentQueue for all drivers.
BDisp Nov 11, 2024
ae1bdd1
Fix a bug where for e.g. two 'c' terminator were included in the resp…
BDisp Nov 11, 2024
6bac652
Fix ansiSequence bug not being clear after finish get the response wh…
BDisp Nov 11, 2024
d31f43d
Add ObjectDisposedException to the catch block.
BDisp Nov 11, 2024
7cd8440
Switch to IMainLoopDriver._waitForInput.
BDisp Nov 11, 2024
54f6264
Add ProcessAnsiRequestHandler method task.
BDisp Nov 11, 2024
a3c961e
Prevents an alone escape being eating by the response.
BDisp Nov 11, 2024
5b76f4d
Remove the answer from the _sends variable. Normally it's always zero.
BDisp Nov 12, 2024
53ea0a8
Replace to ForceRead and to WaitForInput.
BDisp Nov 13, 2024
be1dc80
Fix comment.
BDisp Nov 13, 2024
f0b2474
Code cleanup.
BDisp Nov 13, 2024
efba784
Using _timeoutsLockToken instead of the _timeouts for all.
BDisp Nov 13, 2024
302a7cf
Decrease interval if there is more sent requests.
BDisp Nov 13, 2024
ce0183f
Avoids exit after read the response with empty key.
BDisp Nov 17, 2024
a649b12
Rename to _ansiResponseReady.
BDisp Nov 17, 2024
c06c157
Tidying up layout.
BDisp Nov 17, 2024
1ea9ae0
Handles error on request values.
BDisp Nov 17, 2024
99350b7
Add local function to clear input.
BDisp Nov 17, 2024
e30200d
Remove duplicate wait.
BDisp Nov 17, 2024
7ce20f2
Resolving merge conflicts.
BDisp Nov 22, 2024
bea9669
Restoring drivers with the sctructural changes.
BDisp Nov 23, 2024
38e05dd
Fixing unit test.
BDisp Nov 23, 2024
5c1c002
Avoids initial black screen after moving the mouse at first time.
BDisp Nov 23, 2024
29fe919
Revert changes.
BDisp Nov 23, 2024
e1d7275
Fix unit test.
BDisp Nov 23, 2024
be9cb6b
Always reset IncompleteCkInfos.
BDisp Nov 23, 2024
180b06f
Simplify and correctness ANSI escape sequences.
BDisp Nov 23, 2024
50b0f5a
Resolving merge conflicts.
BDisp Nov 23, 2024
0446c22
NumOutstanding is never equal to zero because they are always removed.
BDisp Nov 23, 2024
e9e12ab
Trying to fix unit tests.
BDisp Nov 23, 2024
0b26355
Fix unit test failing.
BDisp Nov 23, 2024
90d4927
Adds IConsoleDriver
tznind Nov 24, 2024
1d63695
Fix enumerating drivers
tznind Nov 24, 2024
e19bffb
Move IConsoleDriver to its own file
tznind Nov 24, 2024
9f1d0b3
Fix parameter naming updated in error as part of refactor
tznind Nov 24, 2024
14dff21
Merge pull request #209 from tznind/iconsoledriver
BDisp Nov 24, 2024
e829154
Merge branch 'v2_develop' into v2_3767_restoring-drivers-and-fixes
BDisp Nov 24, 2024
d471061
Merge branch 'v2_develop' into v2_3767_restoring-drivers-and-fixes
BDisp Nov 26, 2024
e8e8c59
Merge branch 'v2_develop' into v2_3767_restoring-drivers-and-fixes
tig Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NativeAot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace NativeAot;

public static class Program
{
[RequiresUnreferencedCode ("Calls Terminal.Gui.Application.Init(ConsoleDriver, String)")]
[RequiresDynamicCode ("Calls Terminal.Gui.Application.Init(ConsoleDriver, String)")]
[RequiresUnreferencedCode ("Calls Terminal.Gui.Application.Init(IConsoleDriver, String)")]
[RequiresDynamicCode ("Calls Terminal.Gui.Application.Init(IConsoleDriver, String)")]
private static void Main (string [] args)
{
Application.Init ();
Expand Down
2 changes: 1 addition & 1 deletion SelfContained/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace SelfContained;

public static class Program
{
[RequiresUnreferencedCode ("Calls Terminal.Gui.Application.Run<T>(Func<Exception, Boolean>, ConsoleDriver)")]
[RequiresUnreferencedCode ("Calls Terminal.Gui.Application.Run<T>(Func<Exception, Boolean>, IConsoleDriver)")]
private static void Main (string [] args)
{
Application.Init ();
Expand Down
8 changes: 4 additions & 4 deletions Terminal.Gui/Application/Application.Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ public static partial class Application // Driver abstractions
{
internal static bool _forceFakeConsole;

/// <summary>Gets the <see cref="ConsoleDriver"/> that has been selected. See also <see cref="ForceDriver"/>.</summary>
public static ConsoleDriver? Driver { get; internal set; }
/// <summary>Gets the <see cref="IConsoleDriver"/> that has been selected. See also <see cref="ForceDriver"/>.</summary>
public static IConsoleDriver? Driver { get; internal set; }

// BUGBUG: Force16Colors should be nullable.
/// <summary>
/// Gets or sets whether <see cref="Application.Driver"/> will be forced to output only the 16 colors defined in
/// <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
/// as long as the selected <see cref="ConsoleDriver"/> supports TrueColor.
/// as long as the selected <see cref="IConsoleDriver"/> supports TrueColor.
/// </summary>
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
public static bool Force16Colors { get; set; }
Expand All @@ -23,7 +23,7 @@ public static partial class Application // Driver abstractions
/// specified, the driver is selected based on the platform.
/// </summary>
/// <remarks>
/// Note, <see cref="Application.Init(ConsoleDriver, string)"/> will override this configuration setting if called
/// Note, <see cref="Application.Init(IConsoleDriver, string)"/> will override this configuration setting if called
/// with either `driver` or `driverName` specified.
/// </remarks>
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
Expand Down
20 changes: 10 additions & 10 deletions Terminal.Gui/Application/Application.Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static partial class Application // Initialization (Init/Shutdown)
/// <summary>Initializes a new instance of <see cref="Terminal.Gui"/> Application.</summary>
/// <para>Call this method once per instance (or after <see cref="Shutdown"/> has been called).</para>
/// <para>
/// This function loads the right <see cref="ConsoleDriver"/> for the platform, Creates a <see cref="Toplevel"/>. and
/// This function loads the right <see cref="IConsoleDriver"/> for the platform, Creates a <see cref="Toplevel"/>. and
/// assigns it to <see cref="Top"/>
/// </para>
/// <para>
Expand All @@ -21,23 +21,23 @@ public static partial class Application // Initialization (Init/Shutdown)
/// </para>
/// <para>
/// The <see cref="Run{T}"/> function combines
/// <see cref="Init(Terminal.Gui.ConsoleDriver,string)"/> and <see cref="Run(Toplevel, Func{Exception, bool})"/>
/// <see cref="Init(Terminal.Gui.IConsoleDriver,string)"/> and <see cref="Run(Toplevel, Func{Exception, bool})"/>
/// into a single
/// call. An application cam use <see cref="Run{T}"/> without explicitly calling
/// <see cref="Init(Terminal.Gui.ConsoleDriver,string)"/>.
/// <see cref="Init(Terminal.Gui.IConsoleDriver,string)"/>.
/// </para>
/// <param name="driver">
/// The <see cref="ConsoleDriver"/> to use. If neither <paramref name="driver"/> or
/// The <see cref="IConsoleDriver"/> to use. If neither <paramref name="driver"/> or
/// <paramref name="driverName"/> are specified the default driver for the platform will be used.
/// </param>
/// <param name="driverName">
/// The short name (e.g. "net", "windows", "ansi", "fake", or "curses") of the
/// <see cref="ConsoleDriver"/> to use. If neither <paramref name="driver"/> or <paramref name="driverName"/> are
/// <see cref="IConsoleDriver"/> to use. If neither <paramref name="driver"/> or <paramref name="driverName"/> are
/// specified the default driver for the platform will be used.
/// </param>
[RequiresUnreferencedCode ("AOT")]
[RequiresDynamicCode ("AOT")]
public static void Init (ConsoleDriver? driver = null, string? driverName = null) { InternalInit (driver, driverName); }
public static void Init (IConsoleDriver? driver = null, string? driverName = null) { InternalInit (driver, driverName); }

internal static int MainThreadId { get; set; } = -1;

Expand All @@ -53,7 +53,7 @@ public static partial class Application // Initialization (Init/Shutdown)
[RequiresUnreferencedCode ("AOT")]
[RequiresDynamicCode ("AOT")]
internal static void InternalInit (
ConsoleDriver? driver = null,
IConsoleDriver? driver = null,
string? driverName = null,
bool calledViaRunT = false
)
Expand Down Expand Up @@ -136,7 +136,7 @@ internal static void InternalInit (

if (driverType is { })
{
Driver = (ConsoleDriver)Activator.CreateInstance (driverType)!;
Driver = (IConsoleDriver)Activator.CreateInstance (driverType)!;
}
else
{
Expand Down Expand Up @@ -181,7 +181,7 @@ internal static void InternalInit (
private static void Driver_KeyUp (object? sender, Key e) { RaiseKeyUpEvent (e); }
private static void Driver_MouseEvent (object? sender, MouseEventArgs e) { RaiseMouseEvent (e); }

/// <summary>Gets of list of <see cref="ConsoleDriver"/> types that are available.</summary>
/// <summary>Gets of list of <see cref="IConsoleDriver"/> types that are available.</summary>
/// <returns></returns>
[RequiresUnreferencedCode ("AOT")]
public static List<Type?> GetDriverTypes ()
Expand All @@ -193,7 +193,7 @@ internal static void InternalInit (
{
foreach (Type? type in asm.GetTypes ())
{
if (type.IsSubclassOf (typeof (ConsoleDriver)) && !type.IsAbstract)
if (typeof (IConsoleDriver).IsAssignableFrom (type) && !type.IsAbstract && type.IsClass)
{
driverTypes.Add (type);
}
Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Application/Application.Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Terminal.Gui;
public static partial class Application // Keyboard handling
{
/// <summary>
/// Called when the user presses a key (by the <see cref="ConsoleDriver"/>). Raises the cancelable
/// Called when the user presses a key (by the <see cref="IConsoleDriver"/>). Raises the cancelable
/// <see cref="KeyDown"/> event, then calls <see cref="View.NewKeyDownEvent"/> on all top level views, and finally
/// if the key was not handled, invokes any Application-scoped <see cref="KeyBindings"/>.
/// </summary>
Expand Down Expand Up @@ -116,7 +116,7 @@ public static bool RaiseKeyDownEvent (Key key)
public static event EventHandler<Key>? KeyDown;

/// <summary>
/// Called when the user releases a key (by the <see cref="ConsoleDriver"/>). Raises the cancelable <see cref="KeyUp"/>
/// Called when the user releases a key (by the <see cref="IConsoleDriver"/>). Raises the cancelable <see cref="KeyUp"/>
/// event
/// then calls <see cref="View.NewKeyUpEvent"/> on all top level views. Called after <see cref="RaiseKeyDownEvent"/>.
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions Terminal.Gui/Application/Application.Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ internal static bool PositionCursor ()
/// <returns>The created <see cref="Toplevel"/> object. The caller is responsible for disposing this object.</returns>
[RequiresUnreferencedCode ("AOT")]
[RequiresDynamicCode ("AOT")]
public static Toplevel Run (Func<Exception, bool>? errorHandler = null, ConsoleDriver? driver = null) { return Run<Toplevel> (errorHandler, driver); }
public static Toplevel Run (Func<Exception, bool>? errorHandler = null, IConsoleDriver? driver = null) { return Run<Toplevel> (errorHandler, driver); }

/// <summary>
/// Runs the application by creating a <see cref="Toplevel"/>-derived object of type <c>T</c> and calling
Expand All @@ -323,14 +323,14 @@ internal static bool PositionCursor ()
/// </remarks>
/// <param name="errorHandler"></param>
/// <param name="driver">
/// The <see cref="ConsoleDriver"/> to use. If not specified the default driver for the platform will
/// The <see cref="IConsoleDriver"/> to use. If not specified the default driver for the platform will
/// be used ( <see cref="WindowsDriver"/>, <see cref="CursesDriver"/>, or <see cref="NetDriver"/>). Must be
/// <see langword="null"/> if <see cref="Init"/> has already been called.
/// </param>
/// <returns>The created T object. The caller is responsible for disposing this object.</returns>
[RequiresUnreferencedCode ("AOT")]
[RequiresDynamicCode ("AOT")]
public static T Run<T> (Func<Exception, bool>? errorHandler = null, ConsoleDriver? driver = null)
public static T Run<T> (Func<Exception, bool>? errorHandler = null, IConsoleDriver? driver = null)
where T : Toplevel, new()
{
if (!Initialized)
Expand Down Expand Up @@ -369,7 +369,7 @@ public static T Run<T> (Func<Exception, bool>? errorHandler = null, ConsoleDrive
/// return control immediately.
/// </para>
/// <para>When using <see cref="Run{T}"/> or
/// <see cref="Run(System.Func{System.Exception,bool},Terminal.Gui.ConsoleDriver)"/>
/// <see cref="Run(System.Func{System.Exception,bool},Terminal.Gui.IConsoleDriver)"/>
/// <see cref="Init"/> will be called automatically.
/// </para>
/// <para>
Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Application/Application.Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ public static partial class Application // Screen related stuff
private static Rectangle? _screen;

/// <summary>
/// Gets or sets the size of the screen. By default, this is the size of the screen as reported by the <see cref="ConsoleDriver"/>.
/// Gets or sets the size of the screen. By default, this is the size of the screen as reported by the <see cref="IConsoleDriver"/>.
/// </summary>
/// <remarks>
/// <para>
/// If the <see cref="ConsoleDriver"/> has not been initialized, this will return a default size of 2048x2048; useful for unit tests.
/// If the <see cref="IConsoleDriver"/> has not been initialized, this will return a default size of 2048x2048; useful for unit tests.
/// </para>
/// </remarks>
public static Rectangle Screen
Expand Down
6 changes: 3 additions & 3 deletions Terminal.Gui/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static partial class Application
/// <returns>A string representation of the Application </returns>
public new static string ToString ()
{
ConsoleDriver? driver = Driver;
IConsoleDriver? driver = Driver;

if (driver is null)
{
Expand All @@ -43,11 +43,11 @@ public static partial class Application
}

/// <summary>
/// Gets a string representation of the Application rendered by the provided <see cref="ConsoleDriver"/>.
/// Gets a string representation of the Application rendered by the provided <see cref="IConsoleDriver"/>.
/// </summary>
/// <param name="driver">The driver to use to render the contents.</param>
/// <returns>A string representation of the Application </returns>
public static string ToString (ConsoleDriver? driver)
public static string ToString (IConsoleDriver? driver)
{
if (driver is null)
{
Expand Down
31 changes: 14 additions & 17 deletions Terminal.Gui/Application/MainLoop.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//
#nullable enable
//
// MainLoop.cs: IMainLoopDriver and MainLoop for Terminal.Gui
//
// Authors:
Expand Down Expand Up @@ -36,7 +37,7 @@ internal interface IMainLoopDriver
/// Monitoring of file descriptors is only available on Unix, there does not seem to be a way of supporting this
/// on Windows.
/// </remarks>
internal class MainLoop : IDisposable
public class MainLoop : IDisposable
{
tig marked this conversation as resolved.
Show resolved Hide resolved
internal List<Func<bool>> _idleHandlers = new ();
internal SortedList<long, Timeout> _timeouts = new ();
Expand All @@ -49,7 +50,7 @@ internal class MainLoop : IDisposable
/// <summary>Creates a new MainLoop.</summary>
/// <remarks>Use <see cref="Dispose"/> to release resources.</remarks>
/// <param name="driver">
/// The <see cref="ConsoleDriver"/> instance (one of the implementations FakeMainLoop, UnixMainLoop,
/// The <see cref="IConsoleDriver"/> instance (one of the implementations FakeMainLoop, UnixMainLoop,
/// NetMainLoop or WindowsMainLoop).
/// </param>
internal MainLoop (IMainLoopDriver driver)
Expand All @@ -72,7 +73,7 @@ internal ReadOnlyCollection<Func<bool>> IdleHandlers

/// <summary>The current <see cref="IMainLoopDriver"/> in use.</summary>
/// <value>The main loop driver.</value>
internal IMainLoopDriver MainLoopDriver { get; private set; }
internal IMainLoopDriver? MainLoopDriver { get; private set; }

/// <summary>Used for unit tests.</summary>
internal bool Running { get; set; }
Expand Down Expand Up @@ -117,7 +118,7 @@ internal Func<bool> AddIdle (Func<bool> idleHandler)
_idleHandlers.Add (idleHandler);
}

MainLoopDriver.Wakeup ();
MainLoopDriver?.Wakeup ();

return idleHandler;
}
Expand All @@ -130,10 +131,7 @@ internal Func<bool> AddIdle (Func<bool> idleHandler)
/// </remarks>
internal object AddTimeout (TimeSpan time, Func<bool> callback)
{
if (callback is null)
{
throw new ArgumentNullException (nameof (callback));
}
ArgumentNullException.ThrowIfNull (callback);

var timeout = new Timeout { Span = time, Callback = callback };
AddTimeout (time, timeout);
Expand All @@ -156,7 +154,7 @@ internal bool CheckTimersAndIdleHandlers (out int waitTimeout)

waitTimeout = 0;

lock (_timeouts)
lock (_timeoutsLockToken)
{
if (_timeouts.Count > 0)
{
Expand Down Expand Up @@ -191,7 +189,7 @@ internal bool CheckTimersAndIdleHandlers (out int waitTimeout)
/// You can use this method if you want to probe if events are pending. Typically used if you need to flush the
/// input queue while still running some of your own code in your main thread.
/// </remarks>
internal bool EventsPending () { return MainLoopDriver.EventsPending (); }
internal bool EventsPending () { return MainLoopDriver!.EventsPending (); }

/// <summary>Removes an idle handler added with <see cref="AddIdle(Func{bool})"/> from processing.</summary>
/// <param name="token">A token returned by <see cref="AddIdle(Func{bool})"/></param>
Expand Down Expand Up @@ -225,7 +223,7 @@ internal bool RemoveTimeout (object token)
{
lock (_timeoutsLockToken)
{
int idx = _timeouts.IndexOfValue (token as Timeout);
int idx = _timeouts.IndexOfValue ((token as Timeout)!);

if (idx == -1)
{
Expand Down Expand Up @@ -262,17 +260,17 @@ internal void Run ()
/// </remarks>
internal void RunIteration ()
{
lock (_timeouts)
lock (_timeoutsLockToken)
{
if (_timeouts.Count > 0)
{
RunTimers ();
}
}

MainLoopDriver.Iteration ();
MainLoopDriver?.Iteration ();

var runIdle = false;
bool runIdle;

lock (_idleHandlersLock)
{
Expand All @@ -296,8 +294,7 @@ internal void Stop ()
/// Invoked when a new timeout is added. To be used in the case when
/// <see cref="Application.EndAfterFirstIteration"/> is <see langword="true"/>.
/// </summary>
[CanBeNull]
internal event EventHandler<TimeoutEventArgs> TimeoutAdded;
internal event EventHandler<TimeoutEventArgs>? TimeoutAdded;

/// <summary>Wakes up the <see cref="MainLoop"/> that might be waiting on input.</summary>
internal void Wakeup () { MainLoopDriver?.Wakeup (); }
Expand Down
2 changes: 1 addition & 1 deletion Terminal.Gui/Clipboard/Clipboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static bool TrySetClipboardData (string text)

/// <summary>
/// Helper class for console drivers to invoke shell commands to interact with the clipboard. Used primarily by
/// CursesDriver, but also used in Unit tests which is why it is in ConsoleDriver.cs.
/// CursesDriver, but also used in Unit tests which is why it is in IConsoleDriver.cs.
/// </summary>
internal static class ClipboardProcessRunner
{
Expand Down
4 changes: 2 additions & 2 deletions Terminal.Gui/Clipboard/ClipboardBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ public bool TrySetClipboardData (string text)
}

/// <summary>
/// Returns the contents of the OS clipboard if possible. Implemented by <see cref="ConsoleDriver"/>-specific
/// Returns the contents of the OS clipboard if possible. Implemented by <see cref="IConsoleDriver"/>-specific
/// subclasses.
/// </summary>
/// <returns>The contents of the OS clipboard if successful.</returns>
/// <exception cref="NotSupportedException">Thrown if it was not possible to copy from the OS clipboard.</exception>
protected abstract string GetClipboardDataImpl ();

/// <summary>
/// Pastes the <paramref name="text"/> to the OS clipboard if possible. Implemented by <see cref="ConsoleDriver"/>
/// Pastes the <paramref name="text"/> to the OS clipboard if possible. Implemented by <see cref="IConsoleDriver"/>
/// -specific subclasses.
/// </summary>
/// <param name="text">The text to paste to the OS clipboard.</param>
Expand Down
Loading
Loading