This document captures design and implementation notes for Table.
For end-user usage and examples, see Table.
Visual (not just text), so tables can embed composed UIs (e.g. VStack, TextArea, badges).Table : Visual (sealed)HeaderCells : VisualList<Visual>
RowCells : BindableList<VisualList<Visual>>
VisualList<Visual> owned by the tableShowHeaderSeparator : bool
TableStyle.ShowHeaderSeparatorMost call sites use VisualExtensions helpers:
Headers(params Visual[] headers) / AddHeader(Visual header)AddRow(params Visual[] cells) / Rows(params Visual[][] rows)These helpers create row lists with the correct owner (new VisualList<Visual>(table, ...)) so RowCells validation passes.
Measure computes the intrinsic “grid” size in three phases:
max(HeaderCells.Count, max(RowCells[r].Count)).LayoutConstraints.Unboundedmax(cell.DesiredSize.Width) per columnFitColumnWidthsToWidth(widths, constraints.MaxWidth, ...) with expandToAvailable: falseThen it computes row heights:
MaxWidth = columnWidth (unbounded height)max(cell.DesiredSize.Height) across columns plus TableStyle.CellPadding.VerticalThe resulting fixed desired size includes:
TableStyle.CellPadding and separator widthsArrange re-fits the cached column widths to the final width:
FitColumnWidthsToWidth(..., expandToAvailable: true)
Cells are then arranged in row order:
Rectangle that is the column content width and row content height (after padding)Rendering draws the table “chrome” (backgrounds and separators); cells render themselves as children.
Table uses:
LineGlyphs (from TableStyle.Glyphs or Theme.Lines) for borders/separatorsTableStyle.ResolveBorderStyle(theme, focused) for lines/borders (focused = HasFocusWithin)TableStyle.ResolveCellStyle(theme) for body background fillTableStyle.ResolveHeaderStyle(theme) for header background fillRender order:
RowCells only accepts rows whose VisualOwner is the Table instance; otherwise it throws.Key knobs:
ShowOuterBorder, ShowVerticalLines, ShowRowSeparators, ShowHeaderSeparatorCellPadding (applied inside every cell)Glyphs (single/rounded/double line sets)CellStyle, HeaderStyle, BorderStyleProvided presets:
TableStyle.Minimal, TableStyle.Grid, TableStyle.RoundedGrid, TableStyle.DoubleGridsrc/XenoAtom.Terminal.UI.Tests/TableRenderingTests.cs (including multi-line cell content)