Class CliGrid
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
columnCountint- Number of columns in the grid. Valid cell columns are
0throughcolumnCount - 1. rowCountint- Number of rows in the grid. Valid cell rows are
0throughrowCount - 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
ColumnCount
Number of columns in the grid.
public int ColumnCount { get; init; }
Property Value
CursorMode
Cursor visibility mode.
public CursorMode CursorMode { get; set; }
Property Value
IsFrameLayoutInitialized
Whether frame areas have been expanded into structural grid cells.
public bool IsFrameLayoutInitialized { get; }
Property Value
IsMeasured
Whether Measure(ICliRenderSink) has completed without subsequent invalidation.
public bool IsMeasured { get; }
Property Value
MeasuredActivePoint
Result of mapping ActivePoint through the measurement pipeline.
public MeasuredActivePoint? MeasuredActivePoint { get; }
Property Value
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
OffsetY
Vertical scroll offset used by scrollable host cells.
public int OffsetY { get; set; }
Property Value
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
RowCount
Number of rows in the grid.
public int RowCount { get; init; }
Property Value
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
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
joinStyleCliFrameJoinStylefirstColumnintfirstRowintlastColumnintlastRowintcharStyleCliCharStyle?
Returns
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
overlayCliOverlay
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
Returns
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
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
Returns
GetMeasuredCell(int, int)
Gets a cell's measured representation, or
null before measurement.protected MeasuredCell? GetMeasuredCell(int col, int row)
Parameters
Returns
- MeasuredCell
- The measured cell, or
nullwhen 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
Returns
GetMeasuredColumnWidth(int)
Gets a column's measured width, or
null before measurement.protected int? GetMeasuredColumnWidth(int col)
Parameters
colint- The zero-based column.
Returns
- int?
- The measured width, or
nullwhen the grid has not been measured.
GetMeasuredRowHeight(int)
Gets a row's measured height, or
null before measurement.protected int? GetMeasuredRowHeight(int row)
Parameters
rowint- The zero-based row.
Returns
- int?
- The measured height, or
nullwhen 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
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
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:
offsetis the viewport's first-line index in [0,total - viewport];maxOffset = total - viewport. - ActivePoint:
offsetis the absolute active line index in [0,total - 1];maxOffset = total - 1.
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
Returns
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
sinkICliRenderSink
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
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)
public void SetAxis(int column, int row, CliGridAxis axis, CliGridAxisDefinition definition)
Parameters
columnintrowintaxisCliGridAxisdefinitionCliGridAxisDefinition
SetColumn(int, CliGridColumnDefinition)
Sets the style and sizing definition for a column.
public void SetColumn(int column, CliGridColumnDefinition definition)
Parameters
columnintdefinitionCliGridColumnDefinition
Exceptions
- ArgumentOutOfRangeException
columnis outside the grid.- ArgumentNullException
definitionisnull.- 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
rowintdefinitionCliGridRowDefinition
Exceptions
- ArgumentOutOfRangeException
rowis outside the grid.- ArgumentNullException
definitionisnull.- 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
columnintrowintsubgridCliGridscrollModeCliScrollModethumbModeCliScrollThumbMode
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.