namespace Terminal.Gui.Drivers; /// Base interface for Terminal.Gui Driver implementations. /// /// There are currently four implementations: UnixDriver, WindowsDriver, DotNetDriver, and FakeDriver /// public interface IDriver { /// /// Gets the name of the driver implementation. /// string? GetName (); /// /// Class responsible for processing native driver input objects /// e.g. into events /// and detecting and processing ansi escape sequences. /// IInputProcessor InputProcessor { get; } /// /// Describes the desired screen state. Data source for . /// IOutputBuffer OutputBuffer { get; } /// /// Interface for classes responsible for reporting the current /// size of the terminal window. /// ISizeMonitor SizeMonitor { get; } /// Get the operating system clipboard. /// IClipboard? Clipboard { get; } /// Gets the location and size of the terminal screen. Rectangle Screen { get; } /// /// Sets the screen size for testing purposes. Only supported by FakeDriver. /// is the source of truth for screen dimensions. /// /// The new width in columns. /// The new height in rows. /// Thrown when called on non-FakeDriver instances. void SetScreenSize (int width, int height); /// /// 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 Text. /// 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 (string text, 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 screen changes (size, position, etc.). /// is the source of truth for screen dimensions. /// event EventHandler? SizeChanged; /// Suspends the application (e.g. on Linux via SIGTSTP) and upon resume, resets the console driver. /// This is only implemented in UnixDriver. void Suspend (); /// /// Sets the position of the terminal cursor to and /// . /// void UpdateCursor (); /// Initializes the driver void 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 (); /// 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; /// /// Enqueues a key input event to the driver. For unit tests. /// /// void EnqueueKeyEvent (Key key); /// /// Queues the given for execution /// /// public void QueueAnsiRequest (AnsiEscapeSequenceRequest request); /// /// Gets the for the driver /// /// public AnsiRequestScheduler GetRequestScheduler (); /// /// Gets a string representation of . /// /// public string ToString (); /// /// Gets an ANSI escape sequence representation of . This is the /// same output as would be written to the terminal to recreate the current screen contents. /// /// public string ToAnsi (); }