Skip to main content

Module table

Module table 

Source
Expand description

Columns, narrowing, cell parts and the sort caret, over ratatui’s own Table.

Not feature-gated. It needs no theme: TableStyle carries the tones, and a caller with a loaded theme gets them from TableStyle::from_theme instead of supplying them. Column layout and row structure for tables.

makeover-webview’s list module in the shape a terminal allows. It owns the same four things: which columns exist, how wide they are, which ones survive a narrow viewport, and what each part of a cell is. It does not own what goes in a cell, for the reason that module states: a cell holds whatever the app builds, and a description expressive enough to emit a task row’s five nested spans is a templating language wearing a description’s name.

§What ratatui already answers

Most of the drawing. ratatui::widgets::Table lays tracks out from [Constraint]s, draws a header, highlights a selected row and scrolls through TableState. So this is a mapping layer over it rather than a second table implementation, and it hands back a Table instead of painting one: selection and scroll belong to the app’s state, and a function that painted would have to take that state to give it back.

Two things ratatui does not answer, and they are what this module is:

  • Content measurement. There is no track that sizes to what is in it, so [Width::Content] is measured here from the cells and the heading.
  • Narrowing. A terminal window is resized far more often than a browser one, and [Priority] is how a column earns its place. See below.

§Why positions are the bug

Carried from the webview renderer verbatim, because the mistake is not a CSS mistake. goingson hides its mobile columns with nth-child(n+5) against a seven-column table; insert a column left of the cut and the wrong one disappears, silently, because nothing in the rule knows what column five is. A renderer narrows by raising a cutoff and never by counting, which is the whole reason [Priority] exists. a_column_inserted_left_of_the_cut_does_not_change_what_drops is that bug as a test.

§What it costs when nothing fits

[Priority::Essential] never drops, so a window narrower than the essential columns leaves them overflowing rather than emptying the table. That is deliberate: a row that cannot identify itself is not a narrower row, it is a different one, and ratatui truncates a cell it cannot fit. Truncated and present beats absent.

Structs§

Cell
One cell of a row.
Sizing
The lengths the description deferred, in cells.
TableStyle
The tones and metrics a table draws with.

Functions§

constraints
The tracks for the columns kept at cutoff.
cutoff_for
The weakest cutoff whose columns fit in width.
header
The heading row for the columns kept at cutoff.
overflows
Whether a table drawn at width would leave anything overflowing.
row
One row’s cells, in column order.
table
A described table, sized and narrowed for width.