A tabular data widget. More...
Public Member Functions | |
| void | Render (IRenderContext ctx) |
| Renders the header row, separator line, and data rows into ctx 's allocated region. | |
| Table () | |
| Object-initializer constructor. | |
| Table (IReadOnlyList< TableColumn > columns, IReadOnlyList< IReadOnlyList< string > > rows, int selectedIndex=-1, Style? headerStyle=null, Style? rowStyle=null, int paddingLeft=1, int paddingRight=1, int scrollOffset=0) | |
| Positional constructor for inline usage. | |
Static Public Member Functions | |
| static int | ComputeScrollOffset (int selectedIndex, int viewportHeight, int currentScrollOffset) |
| Computes a new ScrollOffset that keeps selectedIndex within the visible data-row viewport. | |
Properties | |
| IReadOnlyList< TableColumn > | Columns = [] [get] |
| Column definitions. Must not be empty. | |
| Style | HeaderStyle = Style.Default.Bold(true) [get] |
| Style applied to the header row. Inherits theme base style when unset. | |
| SizeConstraint | Height = SizeConstraint.Flex(1) [get] |
| Vertical size constraint. Defaults to SizeConstraint.Flex(int) weight 1 (fill available height). | |
| int | PaddingLeft = 1 [get] |
| Blank columns inserted to the left of each cell's text. | |
| int | PaddingRight = 1 [get] |
| Blank columns reserved to the right of each cell's text. | |
| IReadOnlyList< IReadOnlyList< string > > | Rows = [] [get] |
| Data rows. | |
| Style | RowStyle = Style.Default [get] |
| Style applied to data rows. Inherits theme base style when unset. | |
| int | ScrollOffset [get] |
| Zero-based index of the first data row rendered in the viewport. | |
| int | SelectedIndex = -1 [get] |
| Zero-based index of the selected row. -1 means no selection. | |
| Style | SelectedRowStyle = Style.Default.Reverse(true) [get] |
| Style applied to the currently selected row (when SelectedIndex ≥ 0). | |
| char | Separator = '\0' [get] |
| Character used to separate columns. | |
| Style | Style = Style.Default [get] |
| Base style applied to the widget. Individual row and header styles override this per-section. | |
| SizeConstraint | Width = SizeConstraint.Flex(1) [get] |
| Horizontal size constraint. Defaults to SizeConstraint.Flex(int) weight 1 (fill available width). | |
A tabular data widget.
Renders a header row followed by data rows. Columns are defined by Columns; each row is a string array whose elements correspond to each column in order.
Columns with Width == 0 share the remaining horizontal space equally. Content that exceeds a column's width is truncated. No scrolling — clip to the available height. For scrolling, wrap in a scrollable Container.
|
static |
Computes a new ScrollOffset that keeps selectedIndex within the visible data-row viewport.
Call this from your model's Update handler when processing TableSelectionChangedMsg.
| selectedIndex | The newly selected row index. |
| viewportHeight | Number of rows in the Table's region minus 1 for the header row. |
| currentScrollOffset | Current ScrollOffset. |
| void ConsoleForge.Widgets.Table.Render | ( | IRenderContext | ctx | ) |
Renders the header row, separator line, and data rows into ctx 's allocated region.
Rows that exceed the available height are clipped. Column widths are resolved on each render; flex columns share remaining space equally.
| ctx | The render context providing the target region, theme, and write methods. |
Implements ConsoleForge.Layout.IWidget.
|
get |
Blank columns inserted to the left of each cell's text.
Provides breathing room between the column edge and the content. Defaults to 1, matching the Bubbles table convention.
|
get |
Blank columns reserved to the right of each cell's text.
Defaults to 1, matching the Bubbles table convention.
|
get |
Data rows.
Each row must have the same number of elements as Columns; extra elements are ignored, missing elements are treated as empty strings.
|
get |
Zero-based index of the first data row rendered in the viewport.
The header row is not affected by this offset. Update via ComputeScrollOffset when handling TableSelectionChangedMsg to keep the selected row visible.
|
get |
Character used to separate columns.
Defaults to '\0' (no separator). When non-zero the separator is always rendered with the base row style so it never inherits the selection highlight.