table (cellium v0.1.0)
View SourceThe table widget module provides functionality for rendering tabular data with borders, headers, and rows. It supports various box styles and can render multi-column tables with configurable column widths.
Summary
Functions
Draws the bottom line of a table.
Draws the header line of a table.
Draws a complete table with borders.
Generates the bottom border line of a table.
Generates a row separator line for a table.
Generates the top border line of a table.
Handles keyboard events for editable tables.
Creates a new table widget with default dimensions (0x0).
Creates a new table widget with the specified identifier, width, and height.
Renders a complete table widget with headers and data.
Renders the table when it has focus (shows selected cell highlight).
Functions
-spec draw_bottom(integer(), integer(), atom(), atom(), #box{top_left :: term(), top :: term(), top_divider :: term(), top_right :: term(), head_left :: term(), head_vertical :: term(), head_right :: term(), head_row_left :: term(), head_row_horizontal :: term(), head_row_cross :: term(), head_row_right :: term(), mid_left :: term(), mid_vertical :: term(), mid_right :: term(), row_left :: term(), row_horizontal :: term(), row_cross :: term(), row_right :: term(), foot_row_left :: term(), foot_row_horizontal :: term(), foot_row_cross :: term(), foot_row_right :: term(), foot_left :: term(), foot_vertical :: term(), foot_right :: term(), bottom_left :: term(), bottom :: term(), bottom_divider :: term(), bottom_right :: term(), is_ascii :: term()}, [non_neg_integer()], map()) -> map().
Draws the bottom line of a table.
X: Starting X coordinateY: Starting Y coordinateFg: Foreground colorBg: Background colorBox: Box style to useColumnWidths: List of column widthsBuffer: Current frame buffer- Returns: Updated buffer
-spec draw_header(integer(), integer(), atom(), atom(), #box{top_left :: term(), top :: term(), top_divider :: term(), top_right :: term(), head_left :: term(), head_vertical :: term(), head_right :: term(), head_row_left :: term(), head_row_horizontal :: term(), head_row_cross :: term(), head_row_right :: term(), mid_left :: term(), mid_vertical :: term(), mid_right :: term(), row_left :: term(), row_horizontal :: term(), row_cross :: term(), row_right :: term(), foot_row_left :: term(), foot_row_horizontal :: term(), foot_row_cross :: term(), foot_row_right :: term(), foot_left :: term(), foot_vertical :: term(), foot_right :: term(), bottom_left :: term(), bottom :: term(), bottom_divider :: term(), bottom_right :: term(), is_ascii :: term()}, [non_neg_integer()], map()) -> map().
Draws the header line of a table.
X: Starting X coordinateY: Starting Y coordinateFg: Foreground colorBg: Background colorBox: Box style to useColumnWidths: List of column widths
-spec draw_table(integer(), integer(), integer(), atom(), atom(), #box{top_left :: term(), top :: term(), top_divider :: term(), top_right :: term(), head_left :: term(), head_vertical :: term(), head_right :: term(), head_row_left :: term(), head_row_horizontal :: term(), head_row_cross :: term(), head_row_right :: term(), mid_left :: term(), mid_vertical :: term(), mid_right :: term(), row_left :: term(), row_horizontal :: term(), row_cross :: term(), row_right :: term(), foot_row_left :: term(), foot_row_horizontal :: term(), foot_row_cross :: term(), foot_row_right :: term(), foot_left :: term(), foot_vertical :: term(), foot_right :: term(), bottom_left :: term(), bottom :: term(), bottom_divider :: term(), bottom_right :: term(), is_ascii :: term()}, [non_neg_integer()], map()) -> map().
Draws a complete table with borders.
Renders a table frame consisting of header, row separators, and bottom. Does not render content, only the structural elements.
X: Starting X coordinateY: Starting Y coordinateHeight: Number of rows to drawFg: Foreground colorBg: Background colorBox: Box style recordColumnWidths: List of column widthsBuffer: Current frame buffer- Returns: Updated buffer
-spec get_bottom(#box{top_left :: term(), top :: term(), top_divider :: term(), top_right :: term(), head_left :: term(), head_vertical :: term(), head_right :: term(), head_row_left :: term(), head_row_horizontal :: term(), head_row_cross :: term(), head_row_right :: term(), mid_left :: term(), mid_vertical :: term(), mid_right :: term(), row_left :: term(), row_horizontal :: term(), row_cross :: term(), row_right :: term(), foot_row_left :: term(), foot_row_horizontal :: term(), foot_row_cross :: term(), foot_row_right :: term(), foot_left :: term(), foot_vertical :: term(), foot_right :: term(), bottom_left :: term(), bottom :: term(), bottom_divider :: term(), bottom_right :: term(), is_ascii :: term()}, [non_neg_integer()]) -> string().
Generates the bottom border line of a table.
Box: The box style record defining border charactersWidths: List of column widths- Returns: A flattened iolist representing the bottom border
-spec get_row(#box{top_left :: term(), top :: term(), top_divider :: term(), top_right :: term(), head_left :: term(), head_vertical :: term(), head_right :: term(), head_row_left :: term(), head_row_horizontal :: term(), head_row_cross :: term(), head_row_right :: term(), mid_left :: term(), mid_vertical :: term(), mid_right :: term(), row_left :: term(), row_horizontal :: term(), row_cross :: term(), row_right :: term(), foot_row_left :: term(), foot_row_horizontal :: term(), foot_row_cross :: term(), foot_row_right :: term(), foot_left :: term(), foot_vertical :: term(), foot_right :: term(), bottom_left :: term(), bottom :: term(), bottom_divider :: term(), bottom_right :: term(), is_ascii :: term()}, head | row | mid | foot, [non_neg_integer()]) -> string().
Generates a row separator line for a table.
Different separator styles are available depending on the level:
head: Header row separatorrow: Regular row separatormid: Middle separator (minimal)foot: Footer row separatorBox: The box style record defining border charactersLevel: The type of row separator to generateWidths: List of column widthsReturns: A flattened iolist representing the row separator
-spec get_top(#box{top_left :: term(), top :: term(), top_divider :: term(), top_right :: term(), head_left :: term(), head_vertical :: term(), head_right :: term(), head_row_left :: term(), head_row_horizontal :: term(), head_row_cross :: term(), head_row_right :: term(), mid_left :: term(), mid_vertical :: term(), mid_right :: term(), row_left :: term(), row_horizontal :: term(), row_cross :: term(), row_right :: term(), foot_row_left :: term(), foot_row_horizontal :: term(), foot_row_cross :: term(), foot_row_right :: term(), foot_left :: term(), foot_vertical :: term(), foot_right :: term(), bottom_left :: term(), bottom :: term(), bottom_divider :: term(), bottom_right :: term(), is_ascii :: term()}, [non_neg_integer()]) -> string().
Generates the top border line of a table.
Box: The box style record defining border charactersWidths: List of column widths- Returns: A flattened iolist representing the top border
Handles keyboard events for editable tables.
Creates a new table widget with default dimensions (0x0).
-spec new(term(), non_neg_integer(), non_neg_integer()) -> map().
Creates a new table widget with the specified identifier, width, and height.
Parameters:
Id: A unique identifier for the widget.Width: Initial width of the table.Height: Initial height of the table.
Renders a complete table widget with headers and data.
Draws a full table including frame, optional headers, and data rows.
Widget: Table widget map containing position, dimensions, headers, and rowsBuffer: Current frame buffer- Returns: Updated buffer
Renders the table when it has focus (shows selected cell highlight).