Table of Contents

Class CliGrid

Namespace
ItTiger.TigerCli.Rendering
Assembly
ItTiger.TigerCli.dll
Lower-level grid layout and rendering building block used by tables, detail/list builders, and TUI widgets. Most command output should start with CliList<T>, CliDetails, or CliTable; create a CliGrid directly when building custom renderables, composite layouts, or widgets.
public class CliGrid : CliLayoutComponent
Inheritance
CliGrid
Inherited Members

Remarks

Coordinates are zero-based and use (column, row) order. Cells hold formatted content or a nested subgrid, row and column definitions supply axis styles, and Measure(ICliRenderSink) resolves wrapping, sizing, spans, alignment, frames, overlays, and scroll information before rendering.

Constructors

CliGrid(int, int)

Lower-level grid layout and rendering building block used by tables, detail/list builders, and TUI widgets. Most command output should start with CliList<T>, CliDetails, or CliTable; create a CliGrid directly when building custom renderables, composite layouts, or widgets.
public CliGrid(int columnCount, int rowCount)

Parameters

columnCount int
Number of columns in the grid. Valid cell columns are 0 through columnCount - 1.
rowCount int
Number of rows in the grid. Valid cell rows are 0 through rowCount - 1.

Remarks

Coordinates are zero-based and use (column, row) order. Cells hold formatted content or a nested subgrid, row and column definitions supply axis styles, and Measure(ICliRenderSink) resolves wrapping, sizing, spans, alignment, frames, overlays, and scroll information before rendering.

Properties

ActivePoint

Logical cursor/selection anchor position within the grid.
public ActivePoint? ActivePoint { get; set; }

Property Value

ActivePoint

ColumnCount

Number of columns in the grid.
public int ColumnCount { get; init; }

Property Value

int

CursorMode

Cursor visibility mode.
public CursorMode CursorMode { get; set; }

Property Value

CursorMode

IsFrameLayoutInitialized

Whether frame areas have been expanded into structural grid cells.
public bool IsFrameLayoutInitialized { get; }

Property Value

bool

IsMeasured

Whether Measure(ICliRenderSink) has completed without subsequent invalidation.
public bool IsMeasured { get; }

Property Value

bool

MeasuredActivePoint

Result of mapping ActivePoint through the measurement pipeline.
public MeasuredActivePoint? MeasuredActivePoint { get; }

Property Value

MeasuredActivePoint

MeasuredHeight

Total measured height after Measure(ICliRenderSink); null before measurement.
public int? MeasuredHeight { get; }

Property Value

int?

MeasuredWidth

Total measured width after Measure(ICliRenderSink); null before measurement.
public int? MeasuredWidth { get; }

Property Value

int?

OffsetX

Horizontal scroll offset used by scrollable host cells.
public int OffsetX { get; set; }

Property Value

int

OffsetY

Vertical scroll offset used by scrollable host cells.
public int OffsetY { get; set; }

Property Value

int

ParentGrid

Parent grid when this grid is hosted as a subgrid; set automatically by SetSubgrid(int, int, CliGrid, CliScrollMode, CliScrollThumbMode).
public CliGrid? ParentGrid { get; }

Property Value

CliGrid

RowCount

Number of rows in the grid.
public int RowCount { get; init; }

Property Value

int

StylePrecedence

Controls whether row styles or column styles win when both define the same cell property. Cell-level style always has final precedence.
public CliStylePrecedence StylePrecedence { get; set; }

Property Value

CliStylePrecedence

TreatDbNullAsNull

Per-grid override for treating Value as null. When null, falls back to TreatDbNullAsNull.
public bool? TreatDbNullAsNull { get; set; }

Property Value

bool?

Methods

AddFrameArea(CliFrameJoinStyle, int, int, int, int, CliCharStyle?)

Adds a rectangular frame area to be expanded into frame cells during measurement.
public CliFrameArea AddFrameArea(CliFrameJoinStyle joinStyle, int firstColumn, int firstRow, int lastColumn, int lastRow, CliCharStyle? charStyle = null)

Parameters

joinStyle CliFrameJoinStyle
firstColumn int
firstRow int
lastColumn int
lastRow int
charStyle CliCharStyle?

Returns

CliFrameArea

Exceptions

TigerCliException
Frame layout has already been initialized.

AddOverlay(CliOverlay)

Registers an overlay to be applied after grid measurement. No two overlays may start at the same cell, and overlays must not overlap.
public void AddOverlay(CliOverlay overlay)

Parameters

overlay CliOverlay

GetCellStyle(int, int)

Returns the effective style for a cell after default, row, column, and cell styles are merged.
public CliCellStyle GetCellStyle(int column, int row)

Parameters

column int
row int

Returns

CliCellStyle

GetHorizontalScrollInfo()

Gets horizontal scroll information for the active scrollable cell, or null when there is no active horizontal scrollable cell.
public (bool visible, int offset, int viewport, int total, int maxOffset)? GetHorizontalScrollInfo()

Returns

(bool visible, int offset, int viewport, int total, int maxOffset)?

Remarks

The returned values are clamped and normalized for scrollbar rendering. visible indicates whether the content is wider than the viewport; offset is the horizontal viewport offset; viewport is the visible width; total is the total content width; and maxOffset is the largest valid offset.

GetHorizontalScrollInfo(int, int)

Horizontal scroll info for a specific scrollable cell, regardless of whether it is active. Returns null when the addressed cell is not a horizontally scrollable cell.
public (bool visible, int offset, int viewport, int total, int maxOffset)? GetHorizontalScrollInfo(int column, int row)

Parameters

column int
row int

Returns

(bool visible, int offset, int viewport, int total, int maxOffset)?

GetMeasuredCell(int, int)

Gets a cell's measured representation, or null before measurement.
protected MeasuredCell? GetMeasuredCell(int col, int row)

Parameters

col int
The zero-based column.
row int
The zero-based row.

Returns

MeasuredCell
The measured cell, or null when the grid has not been measured.

GetMeasuredCellOrigin(int, int)

Returns the measured top-left rendered origin of a cell, or null when the grid has not been measured or the coordinate is outside the grid.
public CliPoint? GetMeasuredCellOrigin(int column, int row)

Parameters

column int
row int

Returns

CliPoint?

GetMeasuredColumnWidth(int)

Gets a column's measured width, or null before measurement.
protected int? GetMeasuredColumnWidth(int col)

Parameters

col int
The zero-based column.

Returns

int?
The measured width, or null when the grid has not been measured.

GetMeasuredRowHeight(int)

Gets a row's measured height, or null before measurement.
protected int? GetMeasuredRowHeight(int row)

Parameters

row int
The zero-based row.

Returns

int?
The measured height, or null when the grid has not been measured.

GetScrollMode(int, int)

Gets the scroll mode assigned to a grid cell.
protected CliScrollMode GetScrollMode(int col, int row)

Parameters

col int
The zero-based column.
row int
The zero-based row.

Returns

CliScrollMode
The cell's scroll mode, or None when none is assigned.

GetVerticalScrollInfo()

Gets vertical scroll information for the grid's scrollable cell. Returns null if no vertical scrollable cell is defined.
public (bool visible, int offset, int viewport, int total, int maxOffset)? GetVerticalScrollInfo()

Returns

(bool visible, int offset, int viewport, int total, int maxOffset)?

Remarks

The returned values are normalized so that scrollbar rendering can stay mode-agnostic: offset is the value the scrollbar thumb tracks, and maxOffset is the largest valid value for offset. Per thumb mode:
  • Offset: offset is the viewport's first-line index in [0, total - viewport]; maxOffset = total - viewport.
  • ActivePoint: offset is the absolute active line index in [0, total - 1]; maxOffset = total - 1.
All values are clamped: viewport >= 1, total >= viewport, maxOffset >= 0, and offset in [0, maxOffset].

GetVerticalScrollInfo(int, int)

Vertical scroll info for a specific scrollable cell, regardless of whether it is active. Returns null when the addressed cell is not a vertically scrollable cell.
public (bool visible, int offset, int viewport, int total, int maxOffset)? GetVerticalScrollInfo(int column, int row)

Parameters

column int
row int

Returns

(bool visible, int offset, int viewport, int total, int maxOffset)?

InvalidateLayout()

Clears measurement state for this grid and any parent grid that depends on it.
public void InvalidateLayout()

Measure(ICliRenderSink)

Runs the layout pipeline for this grid against the provided render sink.
public void Measure(ICliRenderSink sink)

Parameters

sink ICliRenderSink

Remarks

Measurement expands frames, initializes cells, applies wrapping/truncation, resolves axis sizes, aligns and fills content, applies overlays, and records measured dimensions. Subgrids contribute to parent sizing on non-scrolling axes; scrollable axes are sized by the parent constraints and expose scroll information through the scroll-info methods.

Set(int, int, object?, CliCellStyle?, int, int)

Sets the content and optional style/span at a cell coordinate.
public void Set(int column, int row, object? content, CliCellStyle? style = null, int colSpan = 1, int rowSpan = 1)

Parameters

column int
row int
content object
style CliCellStyle
colSpan int
rowSpan int

Remarks

Content is formatted by the cell's effective CliCellStyle during measurement. Use SetSubgrid(int, int, CliGrid, CliScrollMode, CliScrollThumbMode) when the content is another CliGrid.

Exceptions

ArgumentOutOfRangeException
The coordinate or span is outside the grid, or a span is less than one.
TigerCliException
The target conflicts with an existing covered, frame, or differently-spanned cell.

SetAxis(int, int, CliGridAxis, CliGridAxisDefinition)

Sets a row or column definition selected by axis. For Row, row is used; for Column, column is used.
public void SetAxis(int column, int row, CliGridAxis axis, CliGridAxisDefinition definition)

Parameters

column int
row int
axis CliGridAxis
definition CliGridAxisDefinition

SetColumn(int, CliGridColumnDefinition)

Sets the style and sizing definition for a column.
public void SetColumn(int column, CliGridColumnDefinition definition)

Parameters

column int
definition CliGridColumnDefinition

Exceptions

ArgumentOutOfRangeException
column is outside the grid.
ArgumentNullException
definition is null.
TigerCliException
The column width was locked by frame layout and the new definition is incompatible with the locked width.

SetRow(int, CliGridRowDefinition)

Sets the style definition for a row.
public void SetRow(int row, CliGridRowDefinition definition)

Parameters

row int
definition CliGridRowDefinition

Exceptions

ArgumentOutOfRangeException
row is outside the grid.
ArgumentNullException
definition is null.
TigerCliException
The row height was locked by frame layout and the new definition is incompatible with the locked height.

SetSubgrid(int, int, CliGrid, CliScrollMode, CliScrollThumbMode)

Hosts another grid in a cell, optionally making that host cell scrollable.
public void SetSubgrid(int column, int row, CliGrid subgrid, CliScrollMode scrollMode = CliScrollMode.None, CliScrollThumbMode thumbMode = CliScrollThumbMode.Offset)

Parameters

column int
row int
subgrid CliGrid
scrollMode CliScrollMode
thumbMode CliScrollThumbMode

Remarks

The hosted grid's ParentGrid is assigned automatically. A grid can host multiple scrollable cells; each cell keeps its own offsets. Re-setting the same coordinate with a different scroll mode or thumb mode is invalid.