Skip to content
FutureBlitz

    Install

    Import std.term.widgets

    Table

    std.term.widgets

    class

    Public Class Table

    A table of text, with a header row or not, its columns as wide as their widest cell, which Render draws with a BorderStyle's lines. A cell can have several lines, and each column its own Alignment. With a MaxWidth, the widest columns give way first, down to their widest character, and their cells wrap.

    Examples

    Local table = Table("Name", "Age")
    table.AddRow("Ada", "36")
    table.AddRow("Alan", "41")
    table.Align(1, Alignment.RIGHT)
    Local text = table.Render()
    Expect(table.RowCount == 2)
    Expect(text.Contains("Ada") && text.Contains("41"))

    std/term/widgets.fb, line 151

    • Public Field Border: BorderStyle field #

      The lines it's drawn with.

    • Public Field HeaderStyle: Style field #

      How the header's cells look: bold, at first.

    • Public Field BorderColor: Style field #

      How the lines look.

    • Public Field MaxWidth: Int field #

      The most columns it takes, lines and all, or 0 for as many as it needs.

    • Public Field Padding: Int field #

      The spaces on each side of a cell's text.

    • Public New(headers: String...) constructor #

      A table whose header row is headers, or that has none, without any.

    • Public Property RowCount: Int property #

      How many rows it has, after its header.

    • Public Method AddRow(cells: String...) method #

      Adds a row of cells, from the first column. A row with fewer cells than another has empty ones after them.

    • @PanicsAtCaller Public Method Align(column: Int, alignment: Alignment) method #

      Puts the column's cells where alignment says, the header's too. Panics for a column below 0.

    • Public Method Render(colors: ColorLevel = ColorLevel.NONE): String method #

      Its lines, with a line break between each two, styled as colors shows them, or plain for NONE. A table without a header or a row is "".

    • Public Method Print() method #

      Writes it to stdout, with a line break after, as stdout shows colors.

    • Public Method Draw(terminal: Terminal) method #

      Writes it to terminal, with a line break after, as it shows colors.

    Report an issue with this page or with FutureBlitz on GitHub.