Concrete implementation of IRenderContext backed by a cell buffer where each cell stores a pre-rendered ANSI string for one character. More...
Public Member Functions | |
| SubRenderContext | CreateSub (Region subRegion) |
| Create a sub-context restricted to a sub-region of this context. | |
| void | RegisterWidget (IWidget widget, Region region) |
| Record that widget was rendered at region this frame. | |
| RenderContext (Region region, Theme theme, ColorProfile colorProfile, ResolvedLayout layout) | |
| Initialises a fresh render context for a single full-redraw frame. | |
| void | Reset (Region region, Theme theme, ColorProfile colorProfile, ResolvedLayout layout) |
| Prepare this context for a new frame. | |
| void | SetCursorDescriptor (CursorDescriptor cursor) |
| Set cursor on the Rendering Context. | |
| string | ToAnsiFrame () |
| Produce a minimal ANSI frame string by diffing current cell buffer against the previous frame. | |
| bool | TryReuseWidget (IWidget widget, Region region) |
If widget (same object reference) was rendered at exactly region last frame AND the previous cell buffer exists, copy those cells into the current buffer and return true (caller should skip rendering). | |
| void | Write (int col, int row, string text, Style style) |
| Write a styled string at absolute terminal position (col, row). | |
Properties | |
| ColorProfile | ColorProfile [get] |
| Detected terminal color capability. | |
| CursorDescriptor? | Cursor [get] |
| Cursor information for TextArea and TextInput widgets. | |
| ResolvedLayout | Layout [get] |
| Resolved layout for the current frame. | |
| Region | Region [get] |
| The allocated region for this widget (absolute terminal coordinates). | |
| Theme | Theme [get] |
| Active theme for style inheritance. Updated by Reset. | |
Concrete implementation of IRenderContext backed by a cell buffer where each cell stores a pre-rendered ANSI string for one character.
Supports double-buffering: ToAnsiFrame diffs the current cell buffer against the previous frame and emits only changed cells, then swaps the buffers. On the first frame (no previous buffer) all cells are emitted.
Call Reset before each frame to clear the current buffer and update the region. The previous buffer is untouched until ToAnsiFrame swaps.
| ConsoleForge.Layout.RenderContext.RenderContext | ( | Region | region, |
| Theme | theme, | ||
| ColorProfile | colorProfile, | ||
| ResolvedLayout | layout ) |
Initialises a fresh render context for a single full-redraw frame.
| region | The terminal region this context covers. |
| theme | Active visual theme. |
| colorProfile | ANSI color output profile. |
| layout | Pre-resolved widget-to-region layout map. |
| SubRenderContext ConsoleForge.Layout.RenderContext.CreateSub | ( | Region | subRegion | ) |
Create a sub-context restricted to a sub-region of this context.
Writes to the sub-context are forwarded to this context with adjusted coordinates.
Record that widget was rendered at region this frame.
Called by Widgets.Container after rendering each child.
Implements ConsoleForge.Layout.IRenderContext.
| void ConsoleForge.Layout.RenderContext.Reset | ( | Region | region, |
| Theme | theme, | ||
| ColorProfile | colorProfile, | ||
| ResolvedLayout | layout ) |
Prepare this context for a new frame.
Clears the current cell buffer (so stale content from last frame is not present) and updates Region/Layout/Theme. The previous frame buffer is preserved for diffing in ToAnsiFrame. If terminal dimensions changed, the previous buffer is discarded (forces full redraw).
| string ConsoleForge.Layout.RenderContext.ToAnsiFrame | ( | ) |
Produce a minimal ANSI frame string by diffing current cell buffer against the previous frame.
Only emits cells that changed. On first frame (no previous buffer) emits all cells. Pre-sizes StringBuilder to avoid repeated reallocations. After emitting, swaps current ↔ previous buffers.
If widget (same object reference) was rendered at exactly region last frame AND the previous cell buffer exists, copy those cells into the current buffer and return true (caller should skip rendering).
Otherwise return false.
Implements ConsoleForge.Layout.IRenderContext.
| void ConsoleForge.Layout.RenderContext.Write | ( | int | col, |
| int | row, | ||
| string | text, | ||
| Style | style ) |
Write a styled string at absolute terminal position (col, row).
Clips text that extends beyond or starts before the Region bounds. Each visible character is stored as a pre-rendered styled cell. Uses Rune-based enumeration to avoid StringInfo allocations per character. ASCII fast path skips grapheme cluster logic entirely.
Implements ConsoleForge.Layout.IRenderContext.
|
get |
Resolved layout for the current frame.
Container widgets use this to retrieve child regions without re-running layout.
Implements ConsoleForge.Layout.IRenderContext.