namespace Terminal.Gui.Drivers;
///
/// Represents the desired screen state for console rendering. This interface provides methods for building up
/// visual content (text, attributes, fills) in a buffer that can be efficiently written to the terminal
/// in a single operation at the end of each iteration. Final output is handled by .
///
///
///
/// The acts as an intermediary between Terminal.Gui's high-level drawing operations
/// and the low-level console output. Rather than writing directly to the console for each operation, views
/// draw to this buffer during layout and rendering. The buffer is then flushed to the terminal by
/// after all drawing is complete, minimizing flicker and improving performance.
///
///
/// The buffer maintains a 2D array of objects in , where each cell
/// represents a single character position on screen with its associated character, attributes, and dirty state.
/// Drawing operations like and modify cells at the
/// current cursor position (tracked by and ), respecting any active
/// region.
///
///
public interface IOutputBuffer
{
/// Adds the specified rune to the display at the current cursor position.
/// Rune to add.
void AddRune (Rune rune);
///
/// Adds the specified character to the display at the current cursor position. This is a convenience method for
/// AddRune.
///
/// Character to add.
void AddRune (char c);
/// Adds the string to the display at the current cursor position.
/// String to add.
void AddStr (string str);
/// Clears the contents of the buffer.
void ClearContents ();
///
/// Gets or sets the clip rectangle that and are subject
/// to.
///
/// The rectangle describing the of region.
public Region? Clip { get; set; }
///
/// Gets the column last set by . and are used by
/// and to determine where to add content.
///
public int Col { get; }
/// The number of columns visible in the terminal.
int Cols { get; set; }
///
/// The contents of the application output. The driver outputs this buffer to the terminal when UpdateScreen is called.
///
Cell [,]? Contents { get; set; }
///
/// The that will be used for the next AddRune or AddStr call.
///
Attribute CurrentAttribute { get; set; }
///
/// Fills the given with the given
/// symbol using the currently selected attribute.
///
///
///
void FillRect (Rectangle rect, Rune rune);
///
/// Fills the given with the given
/// symbol using the currently selected attribute.
///
///
///
void FillRect (Rectangle rect, char rune);
///
/// Tests whether the specified coordinate is valid for drawing the specified Text.
///
/// Used to determine if one or two columns are required.
/// The column.
/// The row.
///
/// True if the coordinate is valid for the Text; false otherwise.
///
bool IsValidLocation (string text, int col, int row);
///
/// The first cell index on left of screen - basically always 0.
/// Changing this may have unexpected consequences.
///
int Left { get; set; }
///
/// Updates the column and row to the specified location in the buffer.
///
/// The column to move to.
/// The row to move to.
void Move (int col, int row);
///
/// Gets the row last set by . and are used by
/// and to determine where to add content.
///
public int Row { get; }
/// The number of rows visible in the terminal.
int Rows { get; set; }
///
/// Changes the size of the buffer to the given size
///
///
///
void SetSize (int cols, int rows);
///
/// The first cell index on top of screen - basically always 0.
/// Changing this may have unexpected consequences.
///
int Top { get; set; }
}