|
@@ -4,13 +4,300 @@ using System.Diagnostics;
|
|
|
|
|
|
namespace Terminal.Gui;
|
|
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>
|
|
/// <summary>Base class for Terminal.Gui ConsoleDriver implementations.</summary>
|
|
/// <remarks>
|
|
/// <remarks>
|
|
/// There are currently four implementations: - <see cref="CursesDriver"/> (for Unix and Mac) -
|
|
/// 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"/>
|
|
/// <see cref="WindowsDriver"/> - <see cref="NetDriver"/> that uses the .NET Console API - <see cref="FakeConsole"/>
|
|
/// for unit testing.
|
|
/// for unit testing.
|
|
/// </remarks>
|
|
/// </remarks>
|
|
-public abstract class ConsoleDriver
|
|
|
|
|
|
+public abstract class ConsoleDriver : IConsoleDriver
|
|
{
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Set this to true in any unit tests that attempt to test drivers other than FakeDriver.
|
|
/// 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"/>.
|
|
/// Provide proper writing to send escape sequence recognized by the <see cref="ConsoleDriver"/>.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="ansi"></param>
|
|
/// <param name="ansi"></param>
|
|
- internal abstract void WriteRaw (string ansi);
|
|
|
|
|
|
+ public abstract void WriteRaw (string ansi);
|
|
|
|
|
|
#endregion ANSI Esc Sequence Handling
|
|
#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?
|
|
// 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>
|
|
/// <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;
|
|
private Region? _clip;
|
|
|
|
|
|
@@ -59,7 +346,7 @@ public abstract class ConsoleDriver
|
|
/// to.
|
|
/// to.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <value>The rectangle describing the of <see cref="Clip"/> region.</value>
|
|
/// <value>The rectangle describing the of <see cref="Clip"/> region.</value>
|
|
- internal Region? Clip
|
|
|
|
|
|
+ public Region? Clip
|
|
{
|
|
{
|
|
get => _clip;
|
|
get => _clip;
|
|
set
|
|
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
|
|
/// 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.
|
|
/// <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
|
|
/// </summary>
|
|
/// </summary>
|
|
- internal int Col { get; private set; }
|
|
|
|
|
|
+ public int Col { get; private set; }
|
|
|
|
|
|
/// <summary>The number of columns visible in the terminal.</summary>
|
|
/// <summary>The number of columns visible in the terminal.</summary>
|
|
- internal virtual int Cols
|
|
|
|
|
|
+ public virtual int Cols
|
|
{
|
|
{
|
|
get => _cols;
|
|
get => _cols;
|
|
set
|
|
set
|
|
@@ -101,10 +388,10 @@ public abstract class ConsoleDriver
|
|
/// <see cref="UpdateScreen"/> is called.
|
|
/// <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>
|
|
/// <remarks>The format of the array is rows, columns. The first index is the row, the second index is the column.</remarks>
|
|
/// </summary>
|
|
/// </summary>
|
|
- internal Cell [,]? Contents { get; set; }
|
|
|
|
|
|
+ public Cell [,]? Contents { get; set; }
|
|
|
|
|
|
/// <summary>The leftmost column in the terminal.</summary>
|
|
/// <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>
|
|
/// <summary>Tests if the specified rune is supported by the driver.</summary>
|
|
/// <param name="rune"></param>
|
|
/// <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
|
|
/// 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.
|
|
/// <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
|
|
/// </summary>
|
|
/// </summary>
|
|
- internal int Row { get; private set; }
|
|
|
|
|
|
+ public int Row { get; private set; }
|
|
|
|
|
|
/// <summary>The number of rows visible in the terminal.</summary>
|
|
/// <summary>The number of rows visible in the terminal.</summary>
|
|
- internal virtual int Rows
|
|
|
|
|
|
+ public virtual int Rows
|
|
{
|
|
{
|
|
get => _rows;
|
|
get => _rows;
|
|
set
|
|
set
|
|
@@ -161,7 +448,7 @@ public abstract class ConsoleDriver
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>The topmost row in the terminal.</summary>
|
|
/// <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>
|
|
/// <summary>Adds the specified rune to the display at the current cursor position.</summary>
|
|
/// <remarks>
|
|
/// <remarks>
|
|
@@ -177,7 +464,7 @@ public abstract class ConsoleDriver
|
|
/// </para>
|
|
/// </para>
|
|
/// </remarks>
|
|
/// </remarks>
|
|
/// <param name="rune">Rune to add.</param>
|
|
/// <param name="rune">Rune to add.</param>
|
|
- internal void AddRune (Rune rune)
|
|
|
|
|
|
+ public void AddRune (Rune rune)
|
|
{
|
|
{
|
|
int runeWidth = -1;
|
|
int runeWidth = -1;
|
|
bool validLocation = IsValidLocation (rune, Col, Row);
|
|
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.
|
|
/// convenience method that calls <see cref="AddRune(Rune)"/> with the <see cref="Rune"/> constructor.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="c">Character to add.</param>
|
|
/// <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>
|
|
/// <summary>Adds the <paramref name="str"/> to the display at the cursor position.</summary>
|
|
/// <remarks>
|
|
/// <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>
|
|
/// <para>If <paramref name="str"/> requires more columns than are available, the output will be clipped.</para>
|
|
/// </remarks>
|
|
/// </remarks>
|
|
/// <param name="str">String.</param>
|
|
/// <param name="str">String.</param>
|
|
- internal void AddStr (string str)
|
|
|
|
|
|
+ public void AddStr (string str)
|
|
{
|
|
{
|
|
List<Rune> runes = str.EnumerateRunes ().ToList ();
|
|
List<Rune> runes = str.EnumerateRunes ().ToList ();
|
|
|
|
|
|
@@ -380,7 +667,7 @@ public abstract class ConsoleDriver
|
|
/// </remarks>
|
|
/// </remarks>
|
|
/// <param name="rect">The Screen-relative rectangle.</param>
|
|
/// <param name="rect">The Screen-relative rectangle.</param>
|
|
/// <param name="rune">The Rune used to fill the 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
|
|
// BUGBUG: This should be a method on Region
|
|
rect = Rectangle.Intersect (rect, Clip?.GetBounds () ?? Screen);
|
|
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>
|
|
/// <summary>Clears the <see cref="Contents"/> of the driver.</summary>
|
|
- internal void ClearContents ()
|
|
|
|
|
|
+ public void ClearContents ()
|
|
{
|
|
{
|
|
Contents = new Cell [Rows, Cols];
|
|
Contents = new Cell [Rows, Cols];
|
|
|
|
|
|
@@ -446,7 +733,7 @@ public abstract class ConsoleDriver
|
|
/// Sets <see cref="Contents"/> as dirty for situations where views
|
|
/// Sets <see cref="Contents"/> as dirty for situations where views
|
|
/// don't need layout and redrawing, but just refresh the screen.
|
|
/// don't need layout and redrawing, but just refresh the screen.
|
|
/// </summary>
|
|
/// </summary>
|
|
- internal void SetContentsAsDirty ()
|
|
|
|
|
|
+ public void SetContentsAsDirty ()
|
|
{
|
|
{
|
|
lock (Contents!)
|
|
lock (Contents!)
|
|
{
|
|
{
|
|
@@ -468,7 +755,7 @@ public abstract class ConsoleDriver
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="rect"></param>
|
|
/// <param name="rect"></param>
|
|
/// <param name="c"></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
|
|
#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="false"/> if the coordinate is outside the screen bounds or outside of <see cref="Clip"/>.
|
|
/// <see langword="true"/> otherwise.
|
|
/// <see langword="true"/> otherwise.
|
|
/// </returns>
|
|
/// </returns>
|
|
- internal bool IsValidLocation (Rune rune, int col, int row)
|
|
|
|
|
|
+ public bool IsValidLocation (Rune rune, int col, int row)
|
|
{
|
|
{
|
|
if (rune.GetColumns () < 2)
|
|
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>
|
|
/// <summary>Called when the terminal size changes. Fires the <see cref="SizeChanged"/> event.</summary>
|
|
/// <param name="args"></param>
|
|
/// <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>
|
|
/// <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 ();
|
|
bool updated = UpdateScreen ();
|
|
UpdateCursor ();
|
|
UpdateCursor ();
|
|
@@ -547,10 +834,10 @@ public abstract class ConsoleDriver
|
|
|
|
|
|
/// <summary>Initializes the driver</summary>
|
|
/// <summary>Initializes the driver</summary>
|
|
/// <returns>Returns an instance of <see cref="MainLoop"/> using the <see cref="IMainLoopDriver"/> for the driver.</returns>
|
|
/// <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>
|
|
/// <summary>Ends the execution of the console driver.</summary>
|
|
- internal abstract void End ();
|
|
|
|
|
|
+ public abstract void End ();
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -571,7 +858,7 @@ public abstract class ConsoleDriver
|
|
/// <see langword="false"/>, indicating that the <see cref="ConsoleDriver"/> cannot support TrueColor.
|
|
/// <see langword="false"/>, indicating that the <see cref="ConsoleDriver"/> cannot support TrueColor.
|
|
/// </para>
|
|
/// </para>
|
|
/// </remarks>
|
|
/// </remarks>
|
|
- internal virtual bool Force16Colors
|
|
|
|
|
|
+ public virtual bool Force16Colors
|
|
{
|
|
{
|
|
get => Application.Force16Colors || !SupportsTrueColor;
|
|
get => Application.Force16Colors || !SupportsTrueColor;
|
|
set => Application.Force16Colors = value || !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>
|
|
/// <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>
|
|
/// <remarks>Implementations should call <c>base.SetAttribute(c)</c>.</remarks>
|
|
/// <param name="c">C.</param>
|
|
/// <param name="c">C.</param>
|
|
- internal Attribute SetAttribute (Attribute c)
|
|
|
|
|
|
+ public Attribute SetAttribute (Attribute c)
|
|
{
|
|
{
|
|
Attribute prevAttribute = CurrentAttribute;
|
|
Attribute prevAttribute = CurrentAttribute;
|
|
CurrentAttribute = c;
|
|
CurrentAttribute = c;
|
|
@@ -615,7 +902,7 @@ public abstract class ConsoleDriver
|
|
|
|
|
|
/// <summary>Gets the current <see cref="Attribute"/>.</summary>
|
|
/// <summary>Gets the current <see cref="Attribute"/>.</summary>
|
|
/// <returns>The current attribute.</returns>
|
|
/// <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
|
|
// 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).
|
|
// removed (and Attribute can lose the platformColor property).
|