Double-buffered character cell grid for TUI rendering. More...
#include <screen.h>
Public Member Functions | |
| TuiScreen () | |
| Constructs an empty screen with no buffers. | |
| ~TuiScreen () | |
| Destructor. | |
| void | resize (int cols, int rows) |
| Resizes both buffers to the given dimensions. | |
| int | cols () const |
| Returns the number of columns. | |
| int | rows () const |
| Returns the number of rows. | |
| void | setCell (int x, int y, const TuiCell &cell) |
| Sets a cell in the back buffer. | |
| TuiCell | cell (int x, int y) const |
| Returns the cell at the given position in the back buffer. | |
| void | clear (const Color &fg=Color::White, const Color &bg=Color::Black) |
| Clears the back buffer with blank cells. | |
| void | flush (AnsiStream &stream) |
| Diffs front vs back buffer and emits minimal ANSI updates. | |
| void | invalidate () |
| Forces a full redraw on the next flush. | |
| void | setColorMode (Terminal::ColorSupport mode) |
| Sets the color mode used when emitting colors during flush. | |
| Terminal::ColorSupport | colorMode () const |
| Returns the current color mode. | |
Double-buffered character cell grid for TUI rendering.
Maintains front and back buffers. Widgets draw to the back buffer via setCell(). flush() diffs front vs back and emits minimal ANSI escape sequences for changed cells, then swaps buffers.
Colors are stored as full RGB values in each TuiCell. During flush(), the active colorMode() determines how those colors are emitted: TrueColor uses 24-bit RGB sequences, Color256 maps to the closest ANSI 256-color palette entry, Basic restricts to 16 system colors, and the Grayscale variants convert colors to perceptual luminance before emitting. NoColor suppresses all color output. The TUI will do its best to gracefully degrade color, but for optimal results, use a TuiPalette whose colors are tuned for the active color mode.
NOT an ObjectBase – this is infrastructure.
| TuiCell TuiScreen::cell | ( | int | x, |
| int | y | ||
| ) | const |
Returns the cell at the given position in the back buffer.
| x | Column (0-based). |
| y | Row (0-based). |
Clears the back buffer with blank cells.
| fg | Default foreground color. |
| bg | Default background color. |
|
inline |
Returns the current color mode.
| void TuiScreen::flush | ( | AnsiStream & | stream | ) |
Diffs front vs back buffer and emits minimal ANSI updates.
| stream | The AnsiStream to write to. |
| void TuiScreen::resize | ( | int | cols, |
| int | rows | ||
| ) |
Resizes both buffers to the given dimensions.
| cols | Number of columns. |
| rows | Number of rows. |
Sets a cell in the back buffer.
| x | Column (0-based). |
| y | Row (0-based). |
| cell | The cell data to write. |
|
inline |
Sets the color mode used when emitting colors during flush.
All RGB colors in the cell buffer are converted to the nearest representable value for this mode. For best results, pair with a TuiPalette designed for the chosen mode.
| mode | The color support level to use. |