#nullable enable namespace Terminal.Gui; /// Base interface for Terminal.Gui ConsoleDriver implementations. /// /// There are currently four implementations: - (for Unix and Mac) - /// - that uses the .NET Console API - /// for unit testing. /// public interface IConsoleDriver { /// Get the operating system clipboard. IClipboard? Clipboard { get; } /// Gets the location and size of the terminal screen. Rectangle Screen { get; } /// /// Gets or sets the clip rectangle that and are subject /// to. /// /// The rectangle describing the of region. Region? Clip { get; set; } /// /// Gets the column last set by . and are used by /// and to determine where to add content. /// int Col { get; } /// The number of columns visible in the terminal. int Cols { get; set; } // BUGBUG: This should not be publicly settable. /// /// Gets or sets the contents of the application output. The driver outputs this buffer to the terminal. /// The format of the array is rows, columns. The first index is the row, the second index is the column. /// Cell [,]? Contents { get; set; } /// The leftmost column in the terminal. int Left { get; set; } /// /// Gets the row last set by . and are used by /// and to determine where to add content. /// int Row { get; } /// The number of rows visible in the terminal. int Rows { get; set; } /// The topmost row in the terminal. int Top { get; set; } /// Gets whether the supports TrueColor output. bool SupportsTrueColor { get; } /// /// Gets or sets whether the should use 16 colors instead of the default TrueColors. /// See to change this setting via . /// /// /// /// Will be forced to if is /// , indicating that the cannot support TrueColor. /// /// bool Force16Colors { get; set; } /// /// The that will be used for the next or /// call. /// Attribute CurrentAttribute { get; set; } /// Returns the name of the driver and relevant library version information. /// string GetVersionInfo (); /// /// Provide proper writing to send escape sequence recognized by the . /// /// void WriteRaw (string ansi); /// Tests if the specified rune is supported by the driver. /// /// /// if the rune can be properly presented; if the driver does not /// support displaying this rune. /// bool IsRuneSupported (Rune rune); /// Tests whether the specified coordinate are valid for drawing the specified Rune. /// Used to determine if one or two columns are required. /// The column. /// The row. /// /// if the coordinate is outside the screen bounds or outside of /// . /// otherwise. /// bool IsValidLocation (Rune rune, int col, int row); /// /// Updates and to the specified column and row in /// . /// Used by and to determine /// where to add content. /// /// /// This does not move the cursor on the screen, it only updates the internal state of the driver. /// /// If or are negative or beyond /// and /// , the method still sets those properties. /// /// /// Column to move to. /// Row to move to. void Move (int col, int row); /// Adds the specified rune to the display at the current cursor position. /// /// /// When the method returns, will be incremented by the number of columns /// required, even if the new column value is outside of the /// or screen /// dimensions defined by . /// /// /// If requires more than one column, and plus the number /// of columns /// needed exceeds the or screen dimensions, the default Unicode replacement /// character (U+FFFD) /// will be added instead. /// /// /// Rune to add. void AddRune (Rune rune); /// /// Adds the specified to the display at the current cursor position. This method is a /// convenience method that calls with the /// constructor. /// /// Character to add. void AddRune (char c); /// Adds the to the display at the cursor position. /// /// /// When the method returns, will be incremented by the number of columns /// required, unless the new column value is outside of the /// or screen /// dimensions defined by . /// /// If requires more columns than are available, the output will be clipped. /// /// String. void AddStr (string str); /// Clears the of the driver. void ClearContents (); /// /// Fills the specified rectangle with the specified rune, using /// event EventHandler ClearedContents; /// Fills the specified rectangle with the specified rune, using /// /// The value of is honored. Any parts of the rectangle not in the clip will not be /// drawn. /// /// The Screen-relative rectangle. /// The Rune used to fill the rectangle void FillRect (Rectangle rect, Rune rune = default); /// /// Fills the specified rectangle with the specified . This method is a convenience method /// that calls . /// /// /// void FillRect (Rectangle rect, char c); /// Gets the terminal cursor visibility. /// The current /// upon success bool GetCursorVisibility (out CursorVisibility visibility); /// Updates the screen to reflect all the changes that have been done to the display buffer void Refresh (); /// Sets the terminal cursor visibility. /// The wished /// upon success bool SetCursorVisibility (CursorVisibility visibility); /// The event fired when the terminal is resized. event EventHandler? SizeChanged; /// Suspends the application (e.g. on Linux via SIGTSTP) and upon resume, resets the console driver. /// This is only implemented in . void Suspend (); /// /// Sets the position of the terminal cursor to and /// . /// void UpdateCursor (); /// Initializes the driver /// Returns an instance of using the for the driver. MainLoop Init (); /// Ends the execution of the console driver. void End (); /// Selects the specified attribute as the attribute to use for future calls to AddRune and AddString. /// Implementations should call base.SetAttribute(c). /// C. Attribute SetAttribute (Attribute c); /// Gets the current . /// The current attribute. Attribute GetAttribute (); /// Makes an . /// The foreground color. /// The background color. /// The attribute for the foreground and background colors. Attribute MakeColor (in Color foreground, in Color background); /// Event fired when a mouse event occurs. event EventHandler? MouseEvent; /// Event fired when a key is pressed down. This is a precursor to . event EventHandler? KeyDown; /// Event fired when a key is released. /// /// Drivers that do not support key release events will fire this event after /// processing is /// complete. /// event EventHandler? KeyUp; /// Simulates a key press. /// The key character. /// The key. /// If simulates the Shift key being pressed. /// If simulates the Alt key being pressed. /// If simulates the Ctrl key being pressed. void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool ctrl); /// /// Queues the given for execution /// /// public void QueueAnsiRequest (AnsiEscapeSequenceRequest request); /// /// Gets the for the driver /// /// public AnsiRequestScheduler GetRequestScheduler (); }