Browse Source

Adds IConsoleDriver

tznind 8 months ago
parent
commit
90d492716a
45 changed files with 447 additions and 160 deletions
  1. 2 2
      NativeAot/Program.cs
  2. 1 1
      SelfContained/Program.cs
  3. 4 4
      Terminal.Gui/Application/Application.Driver.cs
  4. 10 10
      Terminal.Gui/Application/Application.Initialization.cs
  5. 2 2
      Terminal.Gui/Application/Application.Keyboard.cs
  6. 4 4
      Terminal.Gui/Application/Application.Run.cs
  7. 2 2
      Terminal.Gui/Application/Application.Screen.cs
  8. 3 3
      Terminal.Gui/Application/Application.cs
  9. 2 2
      Terminal.Gui/Application/MainLoop.cs
  10. 1 1
      Terminal.Gui/Clipboard/Clipboard.cs
  11. 2 2
      Terminal.Gui/Clipboard/ClipboardBase.cs
  12. 313 26
      Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
  13. 5 5
      Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
  14. 3 3
      Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs
  15. 3 3
      Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs
  16. 1 1
      Terminal.Gui/ConsoleDrivers/FakeDriver/FakeMainLoop.cs
  17. 1 1
      Terminal.Gui/ConsoleDrivers/KeyCode.cs
  18. 3 3
      Terminal.Gui/ConsoleDrivers/NetDriver/NetDriver.cs
  19. 3 3
      Terminal.Gui/ConsoleDrivers/NetDriver/NetEvents.cs
  20. 5 5
      Terminal.Gui/ConsoleDrivers/NetDriver/NetMainLoop.cs
  21. 7 7
      Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsDriver.cs
  22. 4 4
      Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsMainLoop.cs
  23. 1 1
      Terminal.Gui/Drawing/Attribute.cs
  24. 1 1
      Terminal.Gui/Drawing/Cell.cs
  25. 3 3
      Terminal.Gui/Drawing/LineCanvas.cs
  26. 1 1
      Terminal.Gui/Drawing/SixelToRender.cs
  27. 2 2
      Terminal.Gui/README.md
  28. 2 2
      Terminal.Gui/Text/TextFormatter.cs
  29. 1 1
      Terminal.Gui/View/View.cs
  30. 1 1
      Terminal.Gui/Views/ColorPicker.Prompt.cs
  31. 1 1
      Terminal.Gui/Views/GraphView/Axis.cs
  32. 1 1
      Terminal.Gui/Views/Menu/MenuBar.cs
  33. 1 1
      Terminal.Gui/Views/TableView/TableStyle.cs
  34. 2 2
      Terminal.Gui/Views/TableView/TableView.cs
  35. 5 5
      Terminal.Gui/Views/TreeView/Branch.cs
  36. 1 1
      UICatalog/Scenarios/GraphViewExample.cs
  37. 1 1
      UICatalog/UICatalog.cs
  38. 2 2
      UnitTests/Application/ApplicationTests.cs
  39. 1 1
      UnitTests/ConsoleDrivers/AddRuneTests.cs
  40. 3 3
      UnitTests/ConsoleDrivers/ClipRegionTests.cs
  41. 6 6
      UnitTests/ConsoleDrivers/ConsoleDriverTests.cs
  42. 3 3
      UnitTests/ConsoleDrivers/ContentsTests.cs
  43. 3 3
      UnitTests/ConsoleDrivers/DriverColorTests.cs
  44. 12 12
      UnitTests/ConsoleDrivers/MainLoopDriverTests.cs
  45. 12 12
      UnitTests/TestHelpers.cs

+ 2 - 2
NativeAot/Program.cs

@@ -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 ();

+ 1 - 1
SelfContained/Program.cs

@@ -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 ();

+ 4 - 4
Terminal.Gui/Application/Application.Driver.cs

@@ -5,13 +5,13 @@ 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; }
 
     /// <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; }
@@ -21,7 +21,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))]

+ 10 - 10
Terminal.Gui/Application/Application.Initialization.cs

@@ -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>
@@ -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;
 
@@ -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
     )
@@ -136,7 +136,7 @@ public static partial class Application // Initialization (Init/Shutdown)
 
                 if (driverType is { })
                 {
-                    Driver = (ConsoleDriver)Activator.CreateInstance (driverType)!;
+                    Driver = (IConsoleDriver)Activator.CreateInstance (driverType)!;
                 }
                 else
                 {
@@ -181,7 +181,7 @@ public static partial class Application // Initialization (Init/Shutdown)
     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 ()
@@ -193,7 +193,7 @@ public static partial class Application // Initialization (Init/Shutdown)
         {
             foreach (Type? type in asm.GetTypes ())
             {
-                if (type.IsSubclassOf (typeof (ConsoleDriver)) && !type.IsAbstract)
+                if (type.IsSubclassOf (typeof (IConsoleDriver)) && !type.IsAbstract)
                 {
                     driverTypes.Add (type);
                 }

+ 2 - 2
Terminal.Gui/Application/Application.Keyboard.cs

@@ -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>
@@ -111,7 +111,7 @@ public static partial class Application // Keyboard handling
     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>

+ 4 - 4
Terminal.Gui/Application/Application.Run.cs

@@ -305,7 +305,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
     /// <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
@@ -323,14 +323,14 @@ public static partial class Application // Run (Begin, Run, End, Stop)
     /// </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)
@@ -369,7 +369,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
     ///         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>

+ 2 - 2
Terminal.Gui/Application/Application.Screen.cs

@@ -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

+ 3 - 3
Terminal.Gui/Application/Application.cs

@@ -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)
         {
@@ -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)
         {

+ 2 - 2
Terminal.Gui/Application/MainLoop.cs

@@ -37,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
 {
     internal List<Func<bool>> _idleHandlers = new ();
     internal SortedList<long, Timeout> _timeouts = new ();
@@ -50,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)

+ 1 - 1
Terminal.Gui/Clipboard/Clipboard.cs

@@ -111,7 +111,7 @@ public static class Clipboard
 
 /// <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
 {

+ 2 - 2
Terminal.Gui/Clipboard/ClipboardBase.cs

@@ -103,7 +103,7 @@ public abstract class ClipboardBase : IClipboard
     }
 
     /// <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>
@@ -111,7 +111,7 @@ public abstract class ClipboardBase : IClipboard
     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>

+ 313 - 26
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -4,13 +4,300 @@ using System.Diagnostics;
 
 namespace Terminal.Gui;
 
+public interface IConsoleDriver
+{
+    /// <summary>Get the operating system clipboard.</summary>
+    IClipboard? Clipboard { get; }
+
+    /// <summary>Gets the location and size of the terminal screen.</summary>
+    Rectangle Screen { get; }
+
+    /// <summary>
+    ///     Gets or sets the clip rectangle that <see cref="AddRune(Rune)"/> and <see cref="AddStr(string)"/> are subject
+    ///     to.
+    /// </summary>
+    /// <value>The rectangle describing the of <see cref="Clip"/> region.</value>
+    Region? Clip { get; set; }
+
+    /// <summary>
+    ///     Gets the column last set by <see cref="Move"/>. <see cref="Col"/> and <see cref="Row"/> are used by
+    ///     <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
+    /// </summary>
+    int Col { get; }
+
+    /// <summary>The number of columns visible in the terminal.</summary>
+    int Cols { get; set; }
+
+    /// <summary>
+    ///     The contents of the application output. The driver outputs this buffer to the terminal when
+    ///     <see cref="UpdateScreen"/> is called.
+    ///     <remarks>The format of the array is rows, columns. The first index is the row, the second index is the column.</remarks>
+    /// </summary>
+    Cell [,]? Contents { get; set; }
+
+    /// <summary>The leftmost column in the terminal.</summary>
+    int Left { get; set; }
+
+    /// <summary>
+    ///     Gets the row last set by <see cref="Move"/>. <see cref="Col"/> and <see cref="Row"/> are used by
+    ///     <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
+    /// </summary>
+    int Row { get; }
+
+    /// <summary>The number of rows visible in the terminal.</summary>
+    int Rows { get; set; }
+
+    /// <summary>The topmost row in the terminal.</summary>
+    int Top { get; set; }
+
+    /// <summary>Gets whether the <see cref="ConsoleDriver"/> supports TrueColor output.</summary>
+    bool SupportsTrueColor { get; }
+
+    /// <summary>
+    ///     Gets or sets whether the <see cref="ConsoleDriver"/> should use 16 colors instead of the default TrueColors.
+    ///     See <see cref="Application.Force16Colors"/> to change this setting via <see cref="ConfigurationManager"/>.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         Will be forced to <see langword="true"/> if <see cref="ConsoleDriver.SupportsTrueColor"/> is
+    ///         <see langword="false"/>, indicating that the <see cref="ConsoleDriver"/> cannot support TrueColor.
+    ///     </para>
+    /// </remarks>
+    bool Force16Colors { get; set; }
+
+    /// <summary>
+    ///     The <see cref="Attribute"/> that will be used for the next <see cref="AddRune(Rune)"/> or <see cref="AddStr"/>
+    ///     call.
+    /// </summary>
+    Attribute CurrentAttribute { get; set; }
+
+    /// <summary>Returns the name of the driver and relevant library version information.</summary>
+    /// <returns></returns>
+    string GetVersionInfo ();
+
+    /// <summary>
+    ///     Provide proper writing to send escape sequence recognized by the <see cref="ConsoleDriver"/>.
+    /// </summary>
+    /// <param name="ansi"></param>
+    void WriteRaw (string ansi);
+
+    /// <summary>Tests if the specified rune is supported by the driver.</summary>
+    /// <param name="rune"></param>
+    /// <returns>
+    ///     <see langword="true"/> if the rune can be properly presented; <see langword="false"/> if the driver does not
+    ///     support displaying this rune.
+    /// </returns>
+    bool IsRuneSupported (Rune rune);
+
+    /// <summary>Tests whether the specified coordinate are valid for drawing.</summary>
+    /// <param name="col">The column.</param>
+    /// <param name="row">The row.</param>
+    /// <returns>
+    ///     <see langword="false"/> if the coordinate is outside the screen bounds or outside of <see cref="ConsoleDriver.Clip"/>.
+    ///     <see langword="true"/> otherwise.
+    /// </returns>
+    bool IsValidLocation (int col, int row);
+
+    /// <summary>Tests whether the specified coordinate are valid for drawing the specified Rune.</summary>
+    /// <param name="rune">Used to determine if one or two columns are required.</param>
+    /// <param name="col">The column.</param>
+    /// <param name="row">The row.</param>
+    /// <returns>
+    ///     <see langword="false"/> if the coordinate is outside the screen bounds or outside of <see cref="ConsoleDriver.Clip"/>.
+    ///     <see langword="true"/> otherwise.
+    /// </returns>
+    bool IsValidLocation (Rune rune, int col, int row);
+
+    /// <summary>
+    ///     Updates <see cref="ConsoleDriver.Col"/> and <see cref="ConsoleDriver.Row"/> to the specified column and row in <see cref="ConsoleDriver.Contents"/>.
+    ///     Used by <see cref="ConsoleDriver.AddRune(System.Text.Rune)"/> and <see cref="ConsoleDriver.AddStr"/> to determine where to add content.
+    /// </summary>
+    /// <remarks>
+    ///     <para>This does not move the cursor on the screen, it only updates the internal state of the driver.</para>
+    ///     <para>
+    ///         If <paramref name="col"/> or <paramref name="row"/> are negative or beyond  <see cref="ConsoleDriver.Cols"/> and
+    ///         <see cref="ConsoleDriver.Rows"/>, the method still sets those properties.
+    ///     </para>
+    /// </remarks>
+    /// <param name="col">Column to move to.</param>
+    /// <param name="row">Row to move to.</param>
+    void Move (int col, int row);
+
+    /// <summary>Adds the specified rune to the display at the current cursor position.</summary>
+    /// <remarks>
+    ///     <para>
+    ///         When the method returns, <see cref="ConsoleDriver.Col"/> will be incremented by the number of columns
+    ///         <paramref name="rune"/> required, even if the new column value is outside of the <see cref="ConsoleDriver.Clip"/> or screen
+    ///         dimensions defined by <see cref="ConsoleDriver.Cols"/>.
+    ///     </para>
+    ///     <para>
+    ///         If <paramref name="rune"/> requires more than one column, and <see cref="ConsoleDriver.Col"/> plus the number of columns
+    ///         needed exceeds the <see cref="ConsoleDriver.Clip"/> or screen dimensions, the default Unicode replacement character (U+FFFD)
+    ///         will be added instead.
+    ///     </para>
+    /// </remarks>
+    /// <param name="rune">Rune to add.</param>
+    void AddRune (Rune rune);
+
+    /// <summary>
+    ///     Adds the specified <see langword="char"/> to the display at the current cursor position. This method is a
+    ///     convenience method that calls <see cref="ConsoleDriver.AddRune(System.Text.Rune)"/> with the <see cref="Rune"/> constructor.
+    /// </summary>
+    /// <param name="c">Character to add.</param>
+    void AddRune (char c);
+
+    /// <summary>Adds the <paramref name="str"/> to the display at the cursor position.</summary>
+    /// <remarks>
+    ///     <para>
+    ///         When the method returns, <see cref="ConsoleDriver.Col"/> will be incremented by the number of columns
+    ///         <paramref name="str"/> required, unless the new column value is outside of the <see cref="ConsoleDriver.Clip"/> or screen
+    ///         dimensions defined by <see cref="ConsoleDriver.Cols"/>.
+    ///     </para>
+    ///     <para>If <paramref name="str"/> requires more columns than are available, the output will be clipped.</para>
+    /// </remarks>
+    /// <param name="str">String.</param>
+    void AddStr (string str);
+
+    /// <summary>Fills the specified rectangle with the specified rune, using <see cref="ConsoleDriver.CurrentAttribute"/></summary>
+    /// <remarks>
+    ///     The value of <see cref="ConsoleDriver.Clip"/> is honored. Any parts of the rectangle not in the clip will not be drawn.
+    /// </remarks>
+    /// <param name="rect">The Screen-relative rectangle.</param>
+    /// <param name="rune">The Rune used to fill the rectangle</param>
+    void FillRect (Rectangle rect, Rune rune = default);
+
+    /// <summary>
+    ///     Fills the specified rectangle with the specified <see langword="char"/>. This method is a convenience method
+    ///     that calls <see cref="ConsoleDriver.FillRect(System.Drawing.Rectangle,System.Text.Rune)"/>.
+    /// </summary>
+    /// <param name="rect"></param>
+    /// <param name="c"></param>
+    void FillRect (Rectangle rect, char c);
+
+    /// <summary>Clears the <see cref="ConsoleDriver.Contents"/> of the driver.</summary>
+    void ClearContents ();
+
+    /// <summary>
+    ///     Raised each time <see cref="ConsoleDriver.ClearContents"/> is called. For benchmarking.
+    /// </summary>
+    event EventHandler<EventArgs>? ClearedContents;
+
+    /// <summary>
+    /// Sets <see cref="ConsoleDriver.Contents"/> as dirty for situations where views
+    /// don't need layout and redrawing, but just refresh the screen.
+    /// </summary>
+    void SetContentsAsDirty ();
+
+    /// <summary>Determines if the terminal cursor should be visible or not and sets it accordingly.</summary>
+    /// <returns><see langword="true"/> upon success</returns>
+    bool EnsureCursorVisibility ();
+
+    /// <summary>Gets the terminal cursor visibility.</summary>
+    /// <param name="visibility">The current <see cref="CursorVisibility"/></param>
+    /// <returns><see langword="true"/> upon success</returns>
+    bool GetCursorVisibility (out CursorVisibility visibility);
+
+    /// <summary>Called when the terminal size changes. Fires the <see cref="ConsoleDriver.SizeChanged"/> event.</summary>
+    /// <param name="args"></param>
+    void OnSizeChanged (SizeChangedEventArgs args);
+
+    /// <summary>Updates the screen to reflect all the changes that have been done to the display buffer</summary>
+    void Refresh ();
+
+    /// <summary>
+    ///     Raised each time <see cref="ConsoleDriver.Refresh"/> is called. For benchmarking.
+    /// </summary>
+    event EventHandler<EventArgs<bool>>? Refreshed;
+
+    /// <summary>Sets the terminal cursor visibility.</summary>
+    /// <param name="visibility">The wished <see cref="CursorVisibility"/></param>
+    /// <returns><see langword="true"/> upon success</returns>
+    bool SetCursorVisibility (CursorVisibility visibility);
+
+    /// <summary>The event fired when the terminal is resized.</summary>
+    event EventHandler<SizeChangedEventArgs>? SizeChanged;
+
+    /// <summary>Suspends the application (e.g. on Linux via SIGTSTP) and upon resume, resets the console driver.</summary>
+    /// <remarks>This is only implemented in <see cref="CursesDriver"/>.</remarks>
+    void Suspend ();
+
+    /// <summary>Sets the position of the terminal cursor to <see cref="ConsoleDriver.Col"/> and <see cref="ConsoleDriver.Row"/>.</summary>
+    void UpdateCursor ();
+
+    /// <summary>Redraws the physical screen with the contents that have been queued up via any of the printing commands.</summary>
+    /// <returns><see langword="true"/> if any updates to the screen were made.</returns>
+    bool UpdateScreen ();
+
+    /// <summary>Initializes the driver</summary>
+    /// <returns>Returns an instance of <see cref="MainLoop"/> using the <see cref="IMainLoopDriver"/> for the driver.</returns>
+    MainLoop Init ();
+
+    /// <summary>Ends the execution of the console driver.</summary>
+    void End ();
+
+    /// <summary>Selects the specified attribute as the attribute to use for future calls to AddRune and AddString.</summary>
+    /// <remarks>Implementations should call <c>base.SetAttribute(c)</c>.</remarks>
+    /// <param name="c">C.</param>
+    Attribute SetAttribute (Attribute c);
+
+    /// <summary>Gets the current <see cref="Attribute"/>.</summary>
+    /// <returns>The current attribute.</returns>
+    Attribute GetAttribute ();
+
+    /// <summary>Makes an <see cref="Attribute"/>.</summary>
+    /// <param name="foreground">The foreground color.</param>
+    /// <param name="background">The background color.</param>
+    /// <returns>The attribute for the foreground and background colors.</returns>
+    Attribute MakeColor (in Color foreground, in Color background);
+
+    /// <summary>Event fired when a mouse event occurs.</summary>
+    event EventHandler<MouseEventArgs>? MouseEvent;
+
+    /// <summary>Called when a mouse event occurs. Fires the <see cref="ConsoleDriver.MouseEvent"/> event.</summary>
+    /// <param name="a"></param>
+    void OnMouseEvent (MouseEventArgs a);
+
+    /// <summary>Event fired when a key is pressed down. This is a precursor to <see cref="ConsoleDriver.KeyUp"/>.</summary>
+    event EventHandler<Key>? KeyDown;
+
+    /// <summary>
+    ///     Called when a key is pressed down. Fires the <see cref="ConsoleDriver.KeyDown"/> event. This is a precursor to
+    ///     <see cref="ConsoleDriver.OnKeyUp"/>.
+    /// </summary>
+    /// <param name="a"></param>
+    void OnKeyDown (Key a);
+
+    /// <summary>Event fired when a key is released.</summary>
+    /// <remarks>
+    ///     Drivers that do not support key release events will fire this event after <see cref="ConsoleDriver.KeyDown"/> processing is
+    ///     complete.
+    /// </remarks>
+    event EventHandler<Key>? KeyUp;
+
+    /// <summary>Called when a key is released. Fires the <see cref="ConsoleDriver.KeyUp"/> event.</summary>
+    /// <remarks>
+    ///     Drivers that do not support key release events will call this method after <see cref="ConsoleDriver.OnKeyDown"/> processing
+    ///     is complete.
+    /// </remarks>
+    /// <param name="a"></param>
+    void OnKeyUp (Key a);
+
+    /// <summary>Simulates a key press.</summary>
+    /// <param name="keyChar">The key character.</param>
+    /// <param name="key">The key.</param>
+    /// <param name="shift">If <see langword="true"/> simulates the Shift key being pressed.</param>
+    /// <param name="alt">If <see langword="true"/> simulates the Alt key being pressed.</param>
+    /// <param name="ctrl">If <see langword="true"/> simulates the Ctrl key being pressed.</param>
+    void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool ctrl);
+}
+
 /// <summary>Base class for Terminal.Gui ConsoleDriver implementations.</summary>
 /// <remarks>
 ///     There are currently four implementations: - <see cref="CursesDriver"/> (for Unix and Mac) -
 ///     <see cref="WindowsDriver"/> - <see cref="NetDriver"/> that uses the .NET Console API - <see cref="FakeConsole"/>
 ///     for unit testing.
 /// </remarks>
-public abstract class ConsoleDriver
+public abstract class ConsoleDriver : IConsoleDriver
 {
     /// <summary>
     ///     Set this to true in any unit tests that attempt to test drivers other than FakeDriver.
@@ -38,7 +325,7 @@ public abstract class ConsoleDriver
     ///     Provide proper writing to send escape sequence recognized by the <see cref="ConsoleDriver"/>.
     /// </summary>
     /// <param name="ansi"></param>
-    internal abstract void WriteRaw (string ansi);
+    public abstract void WriteRaw (string ansi);
 
     #endregion ANSI Esc Sequence Handling
 
@@ -50,7 +337,7 @@ public abstract class ConsoleDriver
 
     // QUESTION: When non-full screen apps are supported, will this represent the app size, or will that be in Application?
     /// <summary>Gets the location and size of the terminal screen.</summary>
-    internal Rectangle Screen => new (0, 0, Cols, Rows);
+    public Rectangle Screen => new (0, 0, Cols, Rows);
 
     private Region? _clip;
 
@@ -59,7 +346,7 @@ public abstract class ConsoleDriver
     ///     to.
     /// </summary>
     /// <value>The rectangle describing the of <see cref="Clip"/> region.</value>
-    internal Region? Clip
+    public Region? Clip
     {
         get => _clip;
         set
@@ -83,10 +370,10 @@ public abstract class ConsoleDriver
     ///     Gets the column last set by <see cref="Move"/>. <see cref="Col"/> and <see cref="Row"/> are used by
     ///     <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
     /// </summary>
-    internal int Col { get; private set; }
+    public int Col { get; private set; }
 
     /// <summary>The number of columns visible in the terminal.</summary>
-    internal virtual int Cols
+    public virtual int Cols
     {
         get => _cols;
         set
@@ -101,10 +388,10 @@ public abstract class ConsoleDriver
     ///     <see cref="UpdateScreen"/> is called.
     ///     <remarks>The format of the array is rows, columns. The first index is the row, the second index is the column.</remarks>
     /// </summary>
-    internal Cell [,]? Contents { get; set; }
+    public Cell [,]? Contents { get; set; }
 
     /// <summary>The leftmost column in the terminal.</summary>
-    internal virtual int Left { get; set; } = 0;
+    public virtual int Left { get; set; } = 0;
 
     /// <summary>Tests if the specified rune is supported by the driver.</summary>
     /// <param name="rune"></param>
@@ -147,10 +434,10 @@ public abstract class ConsoleDriver
     ///     Gets the row last set by <see cref="Move"/>. <see cref="Col"/> and <see cref="Row"/> are used by
     ///     <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
     /// </summary>
-    internal int Row { get; private set; }
+    public int Row { get; private set; }
 
     /// <summary>The number of rows visible in the terminal.</summary>
-    internal virtual int Rows
+    public virtual int Rows
     {
         get => _rows;
         set
@@ -161,7 +448,7 @@ public abstract class ConsoleDriver
     }
 
     /// <summary>The topmost row in the terminal.</summary>
-    internal virtual int Top { get; set; } = 0;
+    public virtual int Top { get; set; } = 0;
 
     /// <summary>Adds the specified rune to the display at the current cursor position.</summary>
     /// <remarks>
@@ -177,7 +464,7 @@ public abstract class ConsoleDriver
     ///     </para>
     /// </remarks>
     /// <param name="rune">Rune to add.</param>
-    internal void AddRune (Rune rune)
+    public void AddRune (Rune rune)
     {
         int runeWidth = -1;
         bool validLocation = IsValidLocation (rune, Col, Row);
@@ -352,7 +639,7 @@ public abstract class ConsoleDriver
     ///     convenience method that calls <see cref="AddRune(Rune)"/> with the <see cref="Rune"/> constructor.
     /// </summary>
     /// <param name="c">Character to add.</param>
-    internal void AddRune (char c) { AddRune (new Rune (c)); }
+    public void AddRune (char c) { AddRune (new Rune (c)); }
 
     /// <summary>Adds the <paramref name="str"/> to the display at the cursor position.</summary>
     /// <remarks>
@@ -364,7 +651,7 @@ public abstract class ConsoleDriver
     ///     <para>If <paramref name="str"/> requires more columns than are available, the output will be clipped.</para>
     /// </remarks>
     /// <param name="str">String.</param>
-    internal void AddStr (string str)
+    public void AddStr (string str)
     {
         List<Rune> runes = str.EnumerateRunes ().ToList ();
 
@@ -380,7 +667,7 @@ public abstract class ConsoleDriver
     /// </remarks>
     /// <param name="rect">The Screen-relative rectangle.</param>
     /// <param name="rune">The Rune used to fill the rectangle</param>
-    internal void FillRect (Rectangle rect, Rune rune = default)
+    public void FillRect (Rectangle rect, Rune rune = default)
     {
         // BUGBUG: This should be a method on Region
         rect = Rectangle.Intersect (rect, Clip?.GetBounds () ?? Screen);
@@ -406,7 +693,7 @@ public abstract class ConsoleDriver
     }
 
     /// <summary>Clears the <see cref="Contents"/> of the driver.</summary>
-    internal void ClearContents ()
+    public void ClearContents ()
     {
         Contents = new Cell [Rows, Cols];
 
@@ -446,7 +733,7 @@ public abstract class ConsoleDriver
     /// Sets <see cref="Contents"/> as dirty for situations where views
     /// don't need layout and redrawing, but just refresh the screen.
     /// </summary>
-    internal void SetContentsAsDirty ()
+    public void SetContentsAsDirty ()
     {
         lock (Contents!)
         {
@@ -468,7 +755,7 @@ public abstract class ConsoleDriver
     /// </summary>
     /// <param name="rect"></param>
     /// <param name="c"></param>
-    internal void FillRect (Rectangle rect, char c) { FillRect (rect, new Rune (c)); }
+    public void FillRect (Rectangle rect, char c) { FillRect (rect, new Rune (c)); }
 
     #endregion Screen and Contents
 
@@ -491,7 +778,7 @@ public abstract class ConsoleDriver
     ///     <see langword="false"/> if the coordinate is outside the screen bounds or outside of <see cref="Clip"/>.
     ///     <see langword="true"/> otherwise.
     /// </returns>
-    internal bool IsValidLocation (Rune rune, int col, int row)
+    public bool IsValidLocation (Rune rune, int col, int row)
     {
         if (rune.GetColumns () < 2)
         {
@@ -506,10 +793,10 @@ public abstract class ConsoleDriver
 
     /// <summary>Called when the terminal size changes. Fires the <see cref="SizeChanged"/> event.</summary>
     /// <param name="args"></param>
-    internal void OnSizeChanged (SizeChangedEventArgs args) { SizeChanged?.Invoke (this, args); }
+    public void OnSizeChanged (SizeChangedEventArgs args) { SizeChanged?.Invoke (this, args); }
 
     /// <summary>Updates the screen to reflect all the changes that have been done to the display buffer</summary>
-    internal void Refresh ()
+    public void Refresh ()
     {
         bool updated = UpdateScreen ();
         UpdateCursor ();
@@ -547,10 +834,10 @@ public abstract class ConsoleDriver
 
     /// <summary>Initializes the driver</summary>
     /// <returns>Returns an instance of <see cref="MainLoop"/> using the <see cref="IMainLoopDriver"/> for the driver.</returns>
-    internal abstract MainLoop Init ();
+    public abstract MainLoop Init ();
 
     /// <summary>Ends the execution of the console driver.</summary>
-    internal abstract void End ();
+    public abstract void End ();
 
     #endregion
 
@@ -571,7 +858,7 @@ public abstract class ConsoleDriver
     ///         <see langword="false"/>, indicating that the <see cref="ConsoleDriver"/> cannot support TrueColor.
     ///     </para>
     /// </remarks>
-    internal virtual bool Force16Colors
+    public virtual bool Force16Colors
     {
         get => Application.Force16Colors || !SupportsTrueColor;
         set => Application.Force16Colors = value || !SupportsTrueColor;
@@ -605,7 +892,7 @@ public abstract class ConsoleDriver
     /// <summary>Selects the specified attribute as the attribute to use for future calls to AddRune and AddString.</summary>
     /// <remarks>Implementations should call <c>base.SetAttribute(c)</c>.</remarks>
     /// <param name="c">C.</param>
-    internal Attribute SetAttribute (Attribute c)
+    public Attribute SetAttribute (Attribute c)
     {
         Attribute prevAttribute = CurrentAttribute;
         CurrentAttribute = c;
@@ -615,7 +902,7 @@ public abstract class ConsoleDriver
 
     /// <summary>Gets the current <see cref="Attribute"/>.</summary>
     /// <returns>The current attribute.</returns>
-    internal Attribute GetAttribute () { return CurrentAttribute; }
+    public Attribute GetAttribute () { return CurrentAttribute; }
 
     // TODO: This is only overridden by CursesDriver. Once CursesDriver supports 24-bit color, this virtual method can be
     // removed (and Attribute can lose the platformColor property).

+ 5 - 5
Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

@@ -14,7 +14,7 @@ internal class CursesDriver : ConsoleDriver
 {
     public override string GetVersionInfo () { return $"{Curses.curses_version ()}"; }
 
-    internal override int Cols
+    public override int Cols
     {
         get => Curses.Cols;
         set
@@ -24,7 +24,7 @@ internal class CursesDriver : ConsoleDriver
         }
     }
 
-    internal override int Rows
+    public override int Rows
     {
         get => Curses.Lines;
         set
@@ -582,7 +582,7 @@ internal class CursesDriver : ConsoleDriver
     private UnixMainLoop? _mainLoopDriver;
     private object _processInputToken;
 
-    internal override MainLoop Init ()
+    public override MainLoop Init ()
     {
         _mainLoopDriver = new (this);
 
@@ -1084,7 +1084,7 @@ internal class CursesDriver : ConsoleDriver
         }
     }
 
-    internal override void End ()
+    public override void End ()
     {
         EscSeqUtils.ContinuousButtonPressed -= EscSeqUtils_ContinuousButtonPressed;
 
@@ -1128,7 +1128,7 @@ internal class CursesDriver : ConsoleDriver
     }
 
     /// <inheritdoc/>
-    internal override void WriteRaw (string ansi) { _mainLoopDriver?.WriteRaw (ansi); }
+    public override void WriteRaw (string ansi) { _mainLoopDriver?.WriteRaw (ansi); }
 }
 
 // TODO: One type per file - move to another file

+ 3 - 3
Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs

@@ -48,11 +48,11 @@ internal class UnixMainLoop : IMainLoopDriver
     private Pollfd []? _pollMap;
     private bool _winChanged;
 
-    public UnixMainLoop (ConsoleDriver consoleDriver)
+    public UnixMainLoop (IConsoleDriver IConsoleDriver)
     {
-        ArgumentNullException.ThrowIfNull (consoleDriver);
+        ArgumentNullException.ThrowIfNull (IConsoleDriver);
 
-        _cursesDriver = (CursesDriver)consoleDriver;
+        _cursesDriver = (CursesDriver)IConsoleDriver;
     }
 
     void IMainLoopDriver.Wakeup ()

+ 3 - 3
Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs

@@ -76,7 +76,7 @@ public class FakeDriver : ConsoleDriver
         }
     }
 
-    internal override void End ()
+    public override void End ()
     {
         FakeConsole.ResetColor ();
         FakeConsole.Clear ();
@@ -84,7 +84,7 @@ public class FakeDriver : ConsoleDriver
 
     private FakeMainLoop _mainLoopDriver;
 
-    internal override MainLoop Init ()
+    public override MainLoop Init ()
     {
         FakeConsole.MockKeyPresses.Clear ();
 
@@ -393,7 +393,7 @@ public class FakeDriver : ConsoleDriver
     }
 
     /// <inheritdoc />
-    internal override void WriteRaw (string ansi) { throw new NotImplementedException (); }
+    public override void WriteRaw (string ansi) { throw new NotImplementedException (); }
 
     public void SetBufferSize (int width, int height)
     {

+ 1 - 1
Terminal.Gui/ConsoleDrivers/FakeDriver/FakeMainLoop.cs

@@ -4,7 +4,7 @@ internal class FakeMainLoop : IMainLoopDriver
 {
     public Action<ConsoleKeyInfo> MockKeyPressed;
 
-    public FakeMainLoop (ConsoleDriver consoleDriver = null)
+    public FakeMainLoop (IConsoleDriver IConsoleDriver = null)
     {
         // No implementation needed for FakeMainLoop
     }

+ 1 - 1
Terminal.Gui/ConsoleDrivers/KeyCode.cs

@@ -2,7 +2,7 @@
 namespace Terminal.Gui;
 
 /// <summary>
-///     The <see cref="KeyCode"/> enumeration encodes key information from <see cref="ConsoleDriver"/>s and provides a
+///     The <see cref="KeyCode"/> enumeration encodes key information from <see cref="IConsoleDriver"/>s and provides a
 ///     consistent way for application code to specify keys and receive key events.
 ///     <para>
 ///         The <see cref="Key"/> class provides a higher-level abstraction, with helper methods and properties for

+ 3 - 3
Terminal.Gui/ConsoleDrivers/NetDriver/NetDriver.cs

@@ -226,7 +226,7 @@ internal class NetDriver : ConsoleDriver
 
     internal NetMainLoop? _mainLoopDriver;
 
-    internal override MainLoop Init ()
+    public override MainLoop Init ()
     {
         PlatformID p = Environment.OSVersion.Platform;
 
@@ -350,7 +350,7 @@ internal class NetDriver : ConsoleDriver
         }
     }
 
-    internal override void End ()
+    public override void End ()
     {
         if (IsWinPlatform)
         {
@@ -717,7 +717,7 @@ internal class NetDriver : ConsoleDriver
     #region Low-Level DotNet tuff
 
     /// <inheritdoc/>
-    internal override void WriteRaw (string ansi)
+    public override void WriteRaw (string ansi)
     {
         Console.Out.Write (ansi);
         Console.Out.Flush ();

+ 3 - 3
Terminal.Gui/ConsoleDrivers/NetDriver/NetEvents.cs

@@ -8,15 +8,15 @@ internal class NetEvents : IDisposable
     private readonly ManualResetEventSlim _inputReady = new (false);
     private CancellationTokenSource? _inputReadyCancellationTokenSource;
     private readonly Queue<InputResult> _inputQueue = new ();
-    private readonly ConsoleDriver _consoleDriver;
+    private readonly IConsoleDriver _consoleDriver;
     private ConsoleKeyInfo []? _cki;
     private bool _isEscSeq;
 #if PROCESS_REQUEST
     bool _neededProcessRequest;
 #endif
-    public NetEvents (ConsoleDriver consoleDriver)
+    public NetEvents (IConsoleDriver IConsoleDriver)
     {
-        _consoleDriver = consoleDriver ?? throw new ArgumentNullException (nameof (consoleDriver));
+        _consoleDriver = IConsoleDriver ?? throw new ArgumentNullException (nameof (IConsoleDriver));
         _inputReadyCancellationTokenSource = new ();
 
         Task.Run (ProcessInputQueue, _inputReadyCancellationTokenSource.Token);

+ 5 - 5
Terminal.Gui/ConsoleDrivers/NetDriver/NetMainLoop.cs

@@ -24,16 +24,16 @@ internal class NetMainLoop : IMainLoopDriver
     private MainLoop? _mainLoop;
 
     /// <summary>Initializes the class with the console driver.</summary>
-    /// <remarks>Passing a consoleDriver is provided to capture windows resizing.</remarks>
-    /// <param name="consoleDriver">The console driver used by this Net main loop.</param>
+    /// <remarks>Passing a IConsoleDriver is provided to capture windows resizing.</remarks>
+    /// <param name="IConsoleDriver">The console driver used by this Net main loop.</param>
     /// <exception cref="ArgumentNullException"></exception>
-    public NetMainLoop (ConsoleDriver consoleDriver)
+    public NetMainLoop (IConsoleDriver IConsoleDriver)
     {
-        ArgumentNullException.ThrowIfNull (consoleDriver);
+        ArgumentNullException.ThrowIfNull (IConsoleDriver);
 
         if (!ConsoleDriver.RunningUnitTests)
         {
-            _netEvents = new (consoleDriver);
+            _netEvents = new (IConsoleDriver);
         }
     }
 

+ 7 - 7
Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsDriver.cs

@@ -187,7 +187,7 @@ internal class WindowsDriver : ConsoleDriver
         }
     }
 
-    internal override void WriteRaw (string ansi) { WinConsole?.WriteANSI (ansi); }
+    public override void WriteRaw (string ansi) { WinConsole?.WriteANSI (ansi); }
 
     #region Not Implemented
 
@@ -402,7 +402,7 @@ internal class WindowsDriver : ConsoleDriver
         return updated;
     }
 
-    internal override void End ()
+    public override void End ()
     {
         if (_mainLoopDriver is { })
         {
@@ -424,7 +424,7 @@ internal class WindowsDriver : ConsoleDriver
         }
     }
 
-    internal override MainLoop Init ()
+    public override MainLoop Init ()
     {
         _mainLoopDriver = new WindowsMainLoop (this);
 
@@ -867,7 +867,7 @@ internal class WindowsDriver : ConsoleDriver
         int delay = START_DELAY;
         while (_isButtonPressed)
         {
-            // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
+            // TODO: This makes IConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
             View? view = Application.WantContinuousButtonPressedView;
 
             if (view is null)
@@ -890,7 +890,7 @@ internal class WindowsDriver : ConsoleDriver
             //Debug.WriteLine($"ProcessContinuousButtonPressedAsync: {view}");
             if (_isButtonPressed && (mouseFlag & MouseFlags.ReportMousePosition) == 0)
             {
-                // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
+                // TODO: This makes IConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
                 Application.Invoke (() => OnMouseEvent (me));
             }
         }
@@ -945,7 +945,7 @@ internal class WindowsDriver : ConsoleDriver
 
         if (_isButtonDoubleClicked || _isOneFingerDoubleClicked)
         {
-            // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
+            // TODO: This makes IConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
             Application.MainLoop!.AddIdle (
                                            () =>
                                            {
@@ -1017,7 +1017,7 @@ internal class WindowsDriver : ConsoleDriver
 
             if ((mouseFlag & MouseFlags.ReportMousePosition) == 0)
             {
-                // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
+                // TODO: This makes IConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
                 Application.MainLoop!.AddIdle (
                                                () =>
                                                {

+ 4 - 4
Terminal.Gui/ConsoleDrivers/WindowsDriver/WindowsMainLoop.cs

@@ -18,7 +18,7 @@ internal class WindowsMainLoop : IMainLoopDriver
     /// </summary>
     public EventHandler<SizeChangedEventArgs>? WinChanged;
 
-    private readonly ConsoleDriver _consoleDriver;
+    private readonly IConsoleDriver _consoleDriver;
     private readonly ManualResetEventSlim _eventReady = new (false);
 
     // The records that we keep fetching
@@ -29,13 +29,13 @@ internal class WindowsMainLoop : IMainLoopDriver
     private readonly CancellationTokenSource _inputHandlerTokenSource = new ();
     private MainLoop? _mainLoop;
 
-    public WindowsMainLoop (ConsoleDriver consoleDriver)
+    public WindowsMainLoop (IConsoleDriver IConsoleDriver)
     {
-        _consoleDriver = consoleDriver ?? throw new ArgumentNullException (nameof (consoleDriver));
+        _consoleDriver = IConsoleDriver ?? throw new ArgumentNullException (nameof (IConsoleDriver));
 
         if (!ConsoleDriver.RunningUnitTests)
         {
-            _winConsole = ((WindowsDriver)consoleDriver).WinConsole;
+            _winConsole = ((WindowsDriver)IConsoleDriver).WinConsole;
             _winConsole!._mainLoop = this;
         }
     }

+ 1 - 1
Terminal.Gui/Drawing/Attribute.cs

@@ -17,7 +17,7 @@ public readonly record struct Attribute : IEqualityOperators<Attribute, Attribut
     [JsonIgnore]
     public static Attribute Default => new (Color.White, Color.Black);
 
-    /// <summary>The <see cref="ConsoleDriver"/>-specific color value.</summary>
+    /// <summary>The <see cref="IConsoleDriver"/>-specific color value.</summary>
     [JsonIgnore (Condition = JsonIgnoreCondition.Always)]
     internal int PlatformColor { get; init; }
 

+ 1 - 1
Terminal.Gui/Drawing/Cell.cs

@@ -2,7 +2,7 @@
 
 /// <summary>
 ///     Represents a single row/column in a Terminal.Gui rendering surface (e.g. <see cref="LineCanvas"/> and
-///     <see cref="ConsoleDriver"/>).
+///     <see cref="IConsoleDriver"/>).
 /// </summary>
 public record struct Cell (Attribute? Attribute = null, bool IsDirty = false, Rune Rune = default)
 {

+ 3 - 3
Terminal.Gui/Drawing/LineCanvas.cs

@@ -384,7 +384,7 @@ public class LineCanvas : IDisposable
         // TODO: Add other resolvers
     };
 
-    private Cell? GetCellForIntersects (ConsoleDriver? driver, IntersectionDefinition? [] intersects)
+    private Cell? GetCellForIntersects (IConsoleDriver? driver, IntersectionDefinition? [] intersects)
     {
         if (!intersects.Any ())
         {
@@ -404,7 +404,7 @@ public class LineCanvas : IDisposable
         return cell;
     }
 
-    private Rune? GetRuneForIntersects (ConsoleDriver? driver, IntersectionDefinition? [] intersects)
+    private Rune? GetRuneForIntersects (IConsoleDriver? driver, IntersectionDefinition? [] intersects)
     {
         if (!intersects.Any ())
         {
@@ -727,7 +727,7 @@ public class LineCanvas : IDisposable
         internal Rune _thickV;
         protected IntersectionRuneResolver () { SetGlyphs (); }
 
-        public Rune? GetRuneForIntersects (ConsoleDriver? driver, IntersectionDefinition? [] intersects)
+        public Rune? GetRuneForIntersects (IConsoleDriver? driver, IntersectionDefinition? [] intersects)
         {
             bool useRounded = intersects.Any (
                                               i => i?.Line.Length != 0

+ 1 - 1
Terminal.Gui/Drawing/SixelToRender.cs

@@ -2,7 +2,7 @@
 
 /// <summary>
 ///     Describes a request to render a given <see cref="SixelData"/> at a given <see cref="ScreenPosition"/>.
-///     Requires that the terminal and <see cref="ConsoleDriver"/> both support sixel.
+///     Requires that the terminal and <see cref="IConsoleDriver"/> both support sixel.
 /// </summary>
 public class SixelToRender
 {

+ 2 - 2
Terminal.Gui/README.md

@@ -9,8 +9,8 @@ All files required to build the **Terminal.Gui** library (and NuGet package).
 	- `Application\` - The core `Application` logic, including `Application.cs`, which is is a `static` class that provides the base 'application engine', `RunState`, and `MainLoop`.
 
 - `ConsoleDrivers\`
-	- `ConsoleDriver.cs` - Definition for the Console Driver API.
-	- Source files for the three `ConsoleDriver`-based drivers: .NET: `NetDriver`, Unix & Mac: `UnixDriver`, and Windows: `WindowsDriver`.
+	- `IConsoleDriver.cs` - Definition for the Console Driver API.
+	- Source files for the three `IConsoleDriver`-based drivers: .NET: `NetDriver`, Unix & Mac: `UnixDriver`, and Windows: `WindowsDriver`.
 
 - `Configuration\` - Classes related the `ConfigurationManager`.
 

+ 2 - 2
Terminal.Gui/Text/TextFormatter.cs

@@ -43,7 +43,7 @@ public class TextFormatter
         set => _textDirection = EnableNeedsFormat (value);
     }
 
-    /// <summary>Draws the text held by <see cref="TextFormatter"/> to <see cref="ConsoleDriver"/> using the colors specified.</summary>
+    /// <summary>Draws the text held by <see cref="TextFormatter"/> to <see cref="IConsoleDriver"/> using the colors specified.</summary>
     /// <remarks>
     ///     Causes the text to be formatted (references <see cref="GetLines"/>). Sets <see cref="NeedsFormat"/> to
     ///     <c>false</c>.
@@ -59,7 +59,7 @@ public class TextFormatter
         Attribute normalColor,
         Attribute hotColor,
         Rectangle maximum = default,
-        ConsoleDriver? driver = null
+        IConsoleDriver? driver = null
     )
     {
         // With this check, we protect against subclasses with overrides of Text (like Button)

+ 1 - 1
Terminal.Gui/View/View.cs

@@ -126,7 +126,7 @@ public partial class View : IDisposable, ISupportInitializeNotification
     ///     Points to the current driver in use by the view, it is a convenience property for simplifying the development
     ///     of new views.
     /// </summary>
-    public static ConsoleDriver? Driver => Application.Driver;
+    public static IConsoleDriver? Driver => Application.Driver;
 
     /// <summary>Initializes a new instance of <see cref="View"/>.</summary>
     /// <remarks>

+ 1 - 1
Terminal.Gui/Views/ColorPicker.Prompt.cs

@@ -4,7 +4,7 @@ public partial class ColorPicker
 {
     /// <summary>
     ///     Open a <see cref="Dialog"/> with two <see cref="ColorPicker"/> or <see cref="ColorPicker16"/>, based on the
-    ///     <see cref="ConsoleDriver.Force16Colors"/> is false or true, respectively, for <see cref="Attribute.Foreground"/>
+    ///     <see cref="IConsoleDriver.Force16Colors"/> is false or true, respectively, for <see cref="Attribute.Foreground"/>
     ///     and <see cref="Attribute.Background"/> colors.
     /// </summary>
     /// <param name="title">The title to show in the dialog.</param>

+ 1 - 1
Terminal.Gui/Views/GraphView/Axis.cs

@@ -97,7 +97,7 @@ public class HorizontalAxis : Axis
     /// <param name="text">Text to render under the axis tick</param>
     public override void DrawAxisLabel (GraphView graph, int screenPosition, string text)
     {
-        ConsoleDriver driver = Application.Driver;
+        IConsoleDriver driver = Application.Driver;
         int y = GetAxisYPosition (graph);
 
         graph.Move (screenPosition, y);

+ 1 - 1
Terminal.Gui/Views/Menu/MenuBar.cs

@@ -667,7 +667,7 @@ public class MenuBar : View, IDesignable
         return true;
     }
 
-    /// <summary>Gets the superview location offset relative to the <see cref="ConsoleDriver"/> location.</summary>
+    /// <summary>Gets the superview location offset relative to the <see cref="IConsoleDriver"/> location.</summary>
     /// <returns>The location offset.</returns>
     internal Point GetScreenOffset ()
     {

+ 1 - 1
Terminal.Gui/Views/TableView/TableStyle.cs

@@ -29,7 +29,7 @@ public class TableStyle
 
     /// <summary>
     ///     True to invert the colors of the first symbol of the selected cell in the <see cref="TableView"/>. This gives
-    ///     the appearance of a cursor for when the <see cref="ConsoleDriver"/> doesn't otherwise show this
+    ///     the appearance of a cursor for when the <see cref="IConsoleDriver"/> doesn't otherwise show this
     /// </summary>
     public bool InvertSelectedCellFirstCharacter { get; set; } = false;
 

+ 2 - 2
Terminal.Gui/Views/TableView/TableView.cs

@@ -1277,7 +1277,7 @@ public class TableView : View, IDesignable
 
     /// <summary>
     ///     Override to provide custom multi colouring to cells.  Use <see cref="View.Driver"/> to with
-    ///     <see cref="ConsoleDriver.AddStr(string)"/>.  The driver will already be in the correct place when rendering and you
+    ///     <see cref="IConsoleDriver.AddStr(string)"/>.  The driver will already be in the correct place when rendering and you
     ///     must render the full <paramref name="render"/> or the view will not look right.  For simpler provision of color use
     ///     <see cref="ColumnStyle.ColorGetter"/> For changing the content that is rendered use
     ///     <see cref="ColumnStyle.RepresentationGetter"/>
@@ -1335,7 +1335,7 @@ public class TableView : View, IDesignable
     /// <returns></returns>
     internal int GetHeaderHeightIfAny () { return ShouldRenderHeaders () ? GetHeaderHeight () : 0; }
 
-    private void AddRuneAt (ConsoleDriver d, int col, int row, Rune ch)
+    private void AddRuneAt (IConsoleDriver d, int col, int row, Rune ch)
     {
         Move (col, row);
         d?.AddRune (ch);

+ 5 - 5
Terminal.Gui/Views/TreeView/Branch.cs

@@ -73,7 +73,7 @@ internal class Branch<T> where T : class
     /// <param name="colorScheme"></param>
     /// <param name="y"></param>
     /// <param name="availableWidth"></param>
-    public virtual void Draw (ConsoleDriver driver, ColorScheme colorScheme, int y, int availableWidth)
+    public virtual void Draw (IConsoleDriver driver, ColorScheme colorScheme, int y, int availableWidth)
     {
         List<Cell> cells = new ();
         int? indexOfExpandCollapseSymbol = null;
@@ -291,7 +291,7 @@ internal class Branch<T> where T : class
     /// </summary>
     /// <param name="driver"></param>
     /// <returns></returns>
-    public Rune GetExpandableSymbol (ConsoleDriver driver)
+    public Rune GetExpandableSymbol (IConsoleDriver driver)
     {
         Rune leafSymbol = tree.Style.ShowBranchLines ? Glyphs.HLine : (Rune)' ';
 
@@ -313,7 +313,7 @@ internal class Branch<T> where T : class
     ///     line body).
     /// </summary>
     /// <returns></returns>
-    public virtual int GetWidth (ConsoleDriver driver)
+    public virtual int GetWidth (IConsoleDriver driver)
     {
         return
             GetLinePrefix (driver).Sum (r => r.GetColumns ()) + GetExpandableSymbol (driver).GetColumns () + (tree.AspectGetter (Model) ?? "").Length;
@@ -408,7 +408,7 @@ internal class Branch<T> where T : class
     /// </summary>
     /// <param name="driver"></param>
     /// <returns></returns>
-    internal IEnumerable<Rune> GetLinePrefix (ConsoleDriver driver)
+    internal IEnumerable<Rune> GetLinePrefix (IConsoleDriver driver)
     {
         // If not showing line branches or this is a root object.
         if (!tree.Style.ShowBranchLines)
@@ -453,7 +453,7 @@ internal class Branch<T> where T : class
     /// <param name="driver"></param>
     /// <param name="x"></param>
     /// <returns></returns>
-    internal bool IsHitOnExpandableSymbol (ConsoleDriver driver, int x)
+    internal bool IsHitOnExpandableSymbol (IConsoleDriver driver, int x)
     {
         // if leaf node then we cannot expand
         if (!CanExpand ())

+ 1 - 1
UICatalog/Scenarios/GraphViewExample.cs

@@ -1000,7 +1000,7 @@ public class GraphViewExample : Scenario
 
         protected override void DrawBarLine (GraphView graph, Point start, Point end, BarSeriesBar beingDrawn)
         {
-            ConsoleDriver driver = Application.Driver;
+            IConsoleDriver driver = Application.Driver;
 
             int x = start.X;
 

+ 1 - 1
UICatalog/UICatalog.cs

@@ -136,7 +136,7 @@ public class UICatalogApp
         // Process command line args
         // "UICatalog [--driver <driver>] [--benchmark] [scenario name]"
         // If no driver is provided, the default driver is used.
-        Option<string> driverOption = new Option<string> ("--driver", "The ConsoleDriver to use.").FromAmong (
+        Option<string> driverOption = new Option<string> ("--driver", "The IConsoleDriver to use.").FromAmong (
              Application.GetDriverTypes ()
                         .Select (d => d!.Name)
                         .ToArray ()

+ 2 - 2
UnitTests/Application/ApplicationTests.cs

@@ -248,7 +248,7 @@ public class ApplicationTests
     [InlineData (typeof (CursesDriver))]
     public void Init_DriverName_Should_Pick_Correct_Driver (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         Application.Init (driverName: driverType.Name);
         Assert.NotNull (Application.Driver);
         Assert.NotEqual (driver, Application.Driver);
@@ -630,7 +630,7 @@ public class ApplicationTests
 
         driver.Cols = 100;
         driver.Rows = 30;
-        // ConsoleDriver.Screen isn't assignable
+        // IConsoleDriver.Screen isn't assignable
         //driver.Screen = new (0, 0, driver.Cols, Rows);
         Assert.Equal (new (0, 0, 100, 30), driver.Screen);
         Assert.NotEqual (new (0, 0, 100, 30), Application.Screen);

+ 1 - 1
UnitTests/ConsoleDrivers/AddRuneTests.cs

@@ -25,7 +25,7 @@ public class AddRuneTests
     [InlineData (typeof (CursesDriver))]
     public void AddRune (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
 
         driver.Rows = 25;

+ 3 - 3
UnitTests/ConsoleDrivers/ClipRegionTests.cs

@@ -24,7 +24,7 @@ public class ClipRegionTests
     [InlineData (typeof (CursesDriver))]
     public void AddRune_Is_Clipped (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         Application.Init (driver);
         Application.Driver!.Rows = 25;
         Application.Driver!.Cols = 80;
@@ -62,7 +62,7 @@ public class ClipRegionTests
     [InlineData (typeof (CursesDriver))]
     public void Clip_Set_To_Empty_AllInvalid (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         Application.Init (driver);
 
         // Define a clip rectangle
@@ -92,7 +92,7 @@ public class ClipRegionTests
     [InlineData (typeof (CursesDriver))]
     public void IsValidLocation (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         Application.Init (driver);
         Application.Driver!.Rows = 10;
         Application.Driver!.Cols = 10;

+ 6 - 6
UnitTests/ConsoleDrivers/ConsoleDriverTests.cs

@@ -25,7 +25,7 @@ public class ConsoleDriverTests
     [InlineData (typeof (CursesDriver))]
     public void End_Cleans_Up (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
         driver.End ();
     }
@@ -34,7 +34,7 @@ public class ConsoleDriverTests
     [InlineData (typeof (FakeDriver))]
     public void FakeDriver_MockKeyPresses (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         Application.Init (driver);
 
         var text = "MockKeyPresses";
@@ -85,7 +85,7 @@ public class ConsoleDriverTests
     [InlineData (typeof (FakeDriver))]
     public void FakeDriver_Only_Sends_Keystrokes_Through_MockKeyPresses (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         Application.Init (driver);
 
         Toplevel top = new ();
@@ -124,7 +124,7 @@ public class ConsoleDriverTests
     [InlineData (typeof (CursesDriver))]
     public void Init_Inits (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         MainLoop ml = driver.Init ();
         Assert.NotNull (ml);
         Assert.NotNull (driver.Clipboard);
@@ -140,7 +140,7 @@ public class ConsoleDriverTests
     //[InlineData (typeof (FakeDriver))]
     //public void FakeDriver_MockKeyPresses_Press_AfterTimeOut (Type driverType)
     //{
-    //	var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+    //	var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
     //	Application.Init (driver);
 
     //	// Simulating pressing of QuitKey after a short period of time
@@ -201,7 +201,7 @@ public class ConsoleDriverTests
     [InlineData (typeof (CursesDriver))]
     public void TerminalResized_Simulation (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver?.Init ();
         driver.Cols = 80;
         driver.Rows = 25;

+ 3 - 3
UnitTests/ConsoleDrivers/ContentsTests.cs

@@ -24,7 +24,7 @@ public class ContentsTests
     //[InlineData (typeof (WindowsDriver))] // TODO: Uncomment when #2610 is fixed
     public void AddStr_Combining_Character_1st_Column (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
         var expected = "\u0301!";
         driver.AddStr ("\u0301!"); // acute accent + exclamation mark
@@ -42,7 +42,7 @@ public class ContentsTests
     //[InlineData (typeof (WindowsDriver))] // TODO: Uncomment when #2610 is fixed
     public void AddStr_With_Combining_Characters (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
 
         var acuteaccent = new Rune (0x0301); // Combining acute accent (é)
@@ -98,7 +98,7 @@ public class ContentsTests
     [InlineData (typeof (CursesDriver))]
     public void Move_Bad_Coordinates (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
 
         Assert.Equal (0, driver.Col);

+ 3 - 3
UnitTests/ConsoleDrivers/DriverColorTests.cs

@@ -17,7 +17,7 @@ public class DriverColorTests
     [InlineData (typeof (CursesDriver))]
     public void Force16Colors_Sets (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
 
         driver.Force16Colors = true;
@@ -35,7 +35,7 @@ public class DriverColorTests
     [InlineData (typeof (CursesDriver))]
     public void SetColors_Changes_Colors (Type driverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
 
         Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
@@ -63,7 +63,7 @@ public class DriverColorTests
     [InlineData (typeof (CursesDriver), true)]
     public void SupportsTrueColor_Defaults (Type driverType, bool expectedSetting)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         driver.Init ();
 
         Assert.Equal (expectedSetting, driver.SupportsTrueColor);

+ 12 - 12
UnitTests/ConsoleDrivers/MainLoopDriverTests.cs

@@ -17,7 +17,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_AddIdle_ValidIdleHandler_ReturnsToken (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
         var idleHandlerInvoked = false;
@@ -47,7 +47,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_AddTimeout_ValidParameters_ReturnsToken (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
         var callbackInvoked = false;
@@ -83,7 +83,7 @@ public class MainLoopDriverTests
         Type mainLoopDriverType
     )
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -107,7 +107,7 @@ public class MainLoopDriverTests
         Type mainLoopDriverType
     )
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -130,7 +130,7 @@ public class MainLoopDriverTests
         Type mainLoopDriverType
     )
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -151,7 +151,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_Constructs_Disposes (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -182,7 +182,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_RemoveIdle_InvalidToken_ReturnsFalse (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -201,7 +201,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_RemoveIdle_ValidToken_ReturnsTrue (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -223,7 +223,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_RemoveTimeout_InvalidToken_ReturnsFalse (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -241,7 +241,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_RemoveTimeout_ValidToken_ReturnsTrue (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
 
@@ -261,7 +261,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
     public void MainLoop_RunIteration_ValidIdleHandler_CallsIdleHandler (Type driverType, Type mainLoopDriverType)
     {
-        var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+        var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
         var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
         var mainLoop = new MainLoop (mainLoopDriver);
         var idleHandlerInvoked = false;
@@ -287,7 +287,7 @@ public class MainLoopDriverTests
     //[InlineData (typeof (WindowsDriver), typeof (WindowsMainLoop))]
     //public void MainLoop_Invoke_ValidAction_RunsAction (Type driverType, Type mainLoopDriverType)
     //{
-    //	var driver = (ConsoleDriver)Activator.CreateInstance (driverType);
+    //	var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
     //	var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, new object [] { driver });
     //	var mainLoop = new MainLoop (mainLoopDriver);
     //	var actionInvoked = false;

+ 12 - 12
UnitTests/TestHelpers.cs

@@ -25,21 +25,21 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
     /// </summary>
     /// <param name="autoInit">If true, Application.Init will be called Before the test runs.</param>
     /// <param name="consoleDriverType">
-    ///     Determines which ConsoleDriver (FakeDriver, WindowsDriver, CursesDriver, NetDriver)
+    ///     Determines which IConsoleDriver (FakeDriver, WindowsDriver, CursesDriver, NetDriver)
     ///     will be used when Application.Init is called. If null FakeDriver will be used. Only valid if
     ///     <paramref name="autoInit"/> is true.
     /// </param>
     /// <param name="useFakeClipboard">
     ///     If true, will force the use of <see cref="FakeDriver.FakeClipboard"/>. Only valid if
-    ///     <see cref="ConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
+    ///     <see cref="IConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
     /// </param>
     /// <param name="fakeClipboardAlwaysThrowsNotSupportedException">
     ///     Only valid if <paramref name="autoInit"/> is true. Only
-    ///     valid if <see cref="ConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
+    ///     valid if <see cref="IConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
     /// </param>
     /// <param name="fakeClipboardIsSupportedAlwaysTrue">
     ///     Only valid if <paramref name="autoInit"/> is true. Only valid if
-    ///     <see cref="ConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
+    ///     <see cref="IConsoleDriver"/> == <see cref="FakeDriver"/> and <paramref name="autoInit"/> is true.
     /// </param>
     /// <param name="configLocation">Determines what config file locations <see cref="ConfigurationManager"/> will load from.</param>
     /// <param name="verifyShutdown">If true and <see cref="Application.Initialized"/> is true, the test will fail.</param>
@@ -135,7 +135,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
                 View.Instances.Clear ();
             }
 #endif
-            Application.Init ((ConsoleDriver)Activator.CreateInstance (_driverType));
+            Application.Init ((IConsoleDriver)Activator.CreateInstance (_driverType));
         }
     }
 
@@ -251,12 +251,12 @@ internal partial class TestHelpers
     ///     <paramref name="expectedAttributes"/>.
     /// </param>
     /// <param name="output"></param>
-    /// <param name="driver">The ConsoleDriver to use. If null <see cref="Application.Driver"/> will be used.</param>
+    /// <param name="driver">The IConsoleDriver to use. If null <see cref="Application.Driver"/> will be used.</param>
     /// <param name="expectedAttributes"></param>
     public static void AssertDriverAttributesAre (
         string expectedLook,
         ITestOutputHelper output,
-        ConsoleDriver driver = null,
+        IConsoleDriver driver = null,
         params Attribute [] expectedAttributes
     )
     {
@@ -321,12 +321,12 @@ internal partial class TestHelpers
     /// <summary>Asserts that the driver contents match the expected contents, optionally ignoring any trailing whitespace.</summary>
     /// <param name="expectedLook"></param>
     /// <param name="output"></param>
-    /// <param name="driver">The ConsoleDriver to use. If null <see cref="Application.Driver"/> will be used.</param>
+    /// <param name="driver">The IConsoleDriver to use. If null <see cref="Application.Driver"/> will be used.</param>
     /// <param name="ignoreLeadingWhitespace"></param>
     public static void AssertDriverContentsAre (
         string expectedLook,
         ITestOutputHelper output,
-        ConsoleDriver driver = null,
+        IConsoleDriver driver = null,
         bool ignoreLeadingWhitespace = false
     )
     {
@@ -367,12 +367,12 @@ internal partial class TestHelpers
     /// </summary>
     /// <param name="expectedLook"></param>
     /// <param name="output"></param>
-    /// <param name="driver">The ConsoleDriver to use. If null <see cref="Application.Driver"/> will be used.</param>
+    /// <param name="driver">The IConsoleDriver to use. If null <see cref="Application.Driver"/> will be used.</param>
     /// <returns></returns>
     public static Rectangle AssertDriverContentsWithFrameAre (
         string expectedLook,
         ITestOutputHelper output,
-        ConsoleDriver driver = null
+        IConsoleDriver driver = null
     )
     {
         List<List<Rune>> lines = new ();
@@ -625,7 +625,7 @@ internal partial class TestHelpers
     /// </summary>
     /// <param name="driver">if null uses <see cref="Application.Driver"/></param>
     /// <param name="expectedColors"></param>
-    internal static void AssertDriverUsedColors (ConsoleDriver driver = null, params Attribute [] expectedColors)
+    internal static void AssertDriverUsedColors (IConsoleDriver driver = null, params Attribute [] expectedColors)
     {
         driver ??= Application.Driver;
         Cell [,] contents = driver.Contents;