terminal_table/tables

Search:
Group by:

Core table, row, cell, and column data model.

Types

Cell = object
  text*: string
  alignment*: TextAlignment
  verticalAlignment*: VerticalAlignment
  padding*: CellPadding
  style*: TerminalStyle
  hasAlignment*, hasVerticalAlignment*, hasPadding*: bool
  columnSpan*, rowSpan*: int
Text and optional layout/style overrides for one table cell.
Column = object
  width*: WidthConstraint
  alignment*: TextAlignment
  verticalAlignment*: VerticalAlignment
  padding*: CellPadding
  style*: TerminalStyle
  hasAlignment*, hasVerticalAlignment*, hasPadding*: bool
  widthPriority*: int
Layout, width, and style settings for one column.
Panel = object
  cell*: Cell
  position*: PanelPosition
One full-width cell rendered above or below the normal grid.
Row = object
  cells*: seq[Cell]
  alignment*: TextAlignment
  verticalAlignment*: VerticalAlignment
  padding*: CellPadding
  style*: TerminalStyle
  hasAlignment*, hasVerticalAlignment*, hasPadding*: bool
An ordered collection of cells with optional shared overrides.
Table = object
  header*: Row
  hasHeader*: bool
  footer*: Row
  hasFooter*: bool
  title*: Cell
  hasTitle*: bool
  panels*: seq[Panel]
  rows*: seq[Row]
  columns*: seq[Column]
  theme*: TableTheme
  alignment*: TextAlignment
  verticalAlignment*: VerticalAlignment
  padding*: CellPadding
  margin*: TableMargin
  overflow*: OverflowMode
  truncationSuffix*: string
  style*: TerminalStyle
  borderStyle*: TerminalStyle
  shadow*: Shadow
  useColor*: bool
A complete table model. Rendering never mutates it.

Procs

proc addPanel(table: var Table; text: string; position = panelTop): int {.
    discardable, ...raises: [], tags: [], forbids: [].}
Adds a full-width panel and returns its index in table.panels.
proc addRow(table: var Table; row: Row) {....raises: [ValueError], tags: [],
    forbids: [].}
Appends row, rejecting ragged input immediately.
proc addRow(table: var Table; values: varargs[string, `$`]) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Converts values to strings and appends a validated row.
proc cell(table: Table; rowIndex, columnIndex: int): Cell {....raises: [],
    tags: [], forbids: [].}
Returns an immutable copy of a body cell.
proc cell(table: var Table; rowIndex, columnIndex: int): var Cell {....raises: [],
    tags: [], forbids: [].}
proc clearFooter(table: var Table) {....raises: [], tags: [], forbids: [].}
Removes the footer without changing column definitions.
proc clearHeader(table: var Table) {....raises: [], tags: [], forbids: [].}
Removes the header without changing column definitions.
proc clearSpan(cell: var Cell) {....raises: [], tags: [], forbids: [].}
Restores a cell to a one-column, one-row span.
proc clearTitle(table: var Table) {....raises: [], tags: [], forbids: [].}
Removes the title.
proc column(table: Table; index: int): Column {....raises: [], tags: [],
    forbids: [].}
Returns an immutable copy of a column configuration.
proc column(table: var Table; index: int): var Column {....raises: [], tags: [],
    forbids: [].}
proc columnCount(table: Table): int {....raises: [], tags: [], forbids: [].}
Returns the table's fixed number of columns.
proc footerCell(table: var Table; columnIndex: int): var Cell {.
    ...raises: [ValueError], tags: [], forbids: [].}
proc headerCell(table: var Table; columnIndex: int): var Cell {.
    ...raises: [ValueError], tags: [], forbids: [].}
proc initCell(text: string): Cell {....raises: [], tags: [], forbids: [].}
Creates a cell containing text. Newlines are supported.
proc initColumn(): Column {....raises: [], tags: [], forbids: [].}
Creates a content-sized column with inherited layout settings.
proc initRow(values: openArray[string]): Row {....raises: [], tags: [], forbids: [].}
Creates a row from strings.
proc initTable(columnCount: Positive): Table {....raises: [ValueError], tags: [],
    forbids: [].}
Creates a table without a header and with columnCount columns.
proc initTable(headers: openArray[string]): Table {....raises: [ValueError],
    tags: [], forbids: [].}
Creates a table whose column count is defined by headers.
proc panel(table: var Table; index: int): var Cell {....raises: [], tags: [],
    forbids: [].}
proc row(table: Table; index: int): Row {....raises: [], tags: [], forbids: [].}
Returns an immutable copy of a body row.
proc row(table: var Table; index: int): var Row {....raises: [], tags: [],
    forbids: [].}
proc setAlignment(value`gensym351: var Cell; alignment`gensym351: TextAlignment) {.
    ...raises: [], tags: [], forbids: [].}
Sets an explicit horizontal alignment override.
proc setAlignment(value`gensym353: var Row; alignment`gensym353: TextAlignment) {.
    ...raises: [], tags: [], forbids: [].}
Sets an explicit horizontal alignment override.
proc setAlignment(value`gensym355: var Column;
                  alignment`gensym355: TextAlignment) {....raises: [], tags: [],
    forbids: [].}
Sets an explicit horizontal alignment override.
proc setFooter(table: var Table; values: openArray[string]) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Adds or replaces a footer after validating its width.
proc setHeader(table: var Table; values: openArray[string]) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Adds or replaces the header after validating its width.
proc setPadding(value`gensym351: var Cell; padding`gensym351: CellPadding) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Sets an explicit padding override.
proc setPadding(value`gensym353: var Row; padding`gensym353: CellPadding) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Sets an explicit padding override.
proc setPadding(value`gensym355: var Column; padding`gensym355: CellPadding) {.
    ...raises: [ValueError], tags: [], forbids: [].}
Sets an explicit padding override.
proc setSpan(cell: var Cell; columns = 1; rows = 1) {....raises: [ValueError],
    tags: [], forbids: [].}
Sets this cell's rectangular span. Overlap is checked when rendering.
proc setTitle(table: var Table; text: string) {....raises: [], tags: [],
    forbids: [].}
Adds or replaces the full-width title.
proc setVerticalAlignment(value`gensym351: var Cell;
                          alignment`gensym351: VerticalAlignment) {....raises: [],
    tags: [], forbids: [].}
Sets an explicit vertical alignment override.
proc setVerticalAlignment(value`gensym353: var Row;
                          alignment`gensym353: VerticalAlignment) {....raises: [],
    tags: [], forbids: [].}
Sets an explicit vertical alignment override.
proc setVerticalAlignment(value`gensym355: var Column;
                          alignment`gensym355: VerticalAlignment) {....raises: [],
    tags: [], forbids: [].}
Sets an explicit vertical alignment override.
proc setWidthPriority(column: var Column; priority: int) {....raises: [], tags: [],
    forbids: [].}
Sets responsive shrink priority. Lower values shrink first.