Table of Contents

Interface IOutputBuffer

Namespace
Terminal.Gui.Drivers
Assembly
Terminal.Gui.dll

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 IOutput.

public interface IOutputBuffer

Remarks

The IOutputBuffer 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 IOutput after all drawing is complete, minimizing flicker and improving performance.

The buffer maintains a 2D array of Cell objects in Contents, where each cell represents a single character position on screen with its associated character, attributes, and dirty state. Drawing operations like AddRune(Rune) and AddStr(string) modify cells at the current cursor position (tracked by Col and Row), respecting any active Clip region.

Properties

Clip

Gets or sets the clip rectangle that AddRune(Rune) and AddStr(string) are subject to.

Col

Gets the column last set by Move(int, int). Col and Row are used by AddRune(Rune) and AddStr(string) to determine where to add content.

Cols

The number of columns visible in the terminal.

Contents

The contents of the application output. The driver outputs this buffer to the terminal when UpdateScreen is called.

CurrentAttribute

The Attribute that will be used for the next AddRune or AddStr call.

Left

The first cell index on left of screen - basically always 0. Changing this may have unexpected consequences.

Row

Gets the row last set by Move(int, int). Col and Row are used by AddRune(Rune) and AddStr(string) to determine where to add content.

Rows

The number of rows visible in the terminal.

Top

The first cell index on top of screen - basically always 0. Changing this may have unexpected consequences.

Methods

AddRune(char)

Adds the specified character to the display at the current cursor position. This is a convenience method for AddRune.

AddRune(Rune)

Adds the specified rune to the display at the current cursor position.

AddStr(string)

Adds the string to the display at the current cursor position.

ClearContents()

Clears the contents of the buffer.

FillRect(Rectangle, char)

Fills the given rect with the given symbol using the currently selected attribute.

FillRect(Rectangle, Rune)

Fills the given rect with the given symbol using the currently selected attribute.

IsValidLocation(string, int, int)

Tests whether the specified coordinate is valid for drawing the specified Text.

Move(int, int)

Updates the column and row to the specified location in the buffer.

SetSize(int, int)

Changes the size of the buffer to the given size