libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TuiScreen Class Reference

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.
 

Detailed Description

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.

Member Function Documentation

◆ cell()

TuiCell TuiScreen::cell ( int  x,
int  y 
) const

Returns the cell at the given position in the back buffer.

Parameters
xColumn (0-based).
yRow (0-based).
Returns
The cell data, or a default cell if out of bounds.

◆ clear()

void TuiScreen::clear ( const Color fg = Color::White,
const Color bg = Color::Black 
)

Clears the back buffer with blank cells.

Parameters
fgDefault foreground color.
bgDefault background color.

◆ colorMode()

Terminal::ColorSupport TuiScreen::colorMode ( ) const
inline

Returns the current color mode.

Returns
The color support level in use.

◆ flush()

void TuiScreen::flush ( AnsiStream stream)

Diffs front vs back buffer and emits minimal ANSI updates.

Parameters
streamThe AnsiStream to write to.

◆ resize()

void TuiScreen::resize ( int  cols,
int  rows 
)

Resizes both buffers to the given dimensions.

Parameters
colsNumber of columns.
rowsNumber of rows.

◆ setCell()

void TuiScreen::setCell ( int  x,
int  y,
const TuiCell cell 
)

Sets a cell in the back buffer.

Parameters
xColumn (0-based).
yRow (0-based).
cellThe cell data to write.

◆ setColorMode()

void TuiScreen::setColorMode ( Terminal::ColorSupport  mode)
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.

Parameters
modeThe color support level to use.
See also
Terminal::colorSupport()

The documentation for this class was generated from the following file: