HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulebrick-2.10Haskell2010

Brick.Widgets.Table

This module provides a table widget that can draw other widgets in a table layout, draw borders between rows and columns, and allow configuration of row and column alignment. To get started, see table.

  • 6 types
  • 18 values
  • Packagebrick-2.10
  • Exports24
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTable.hs

Types

4 declarations
datadata Table n
#

A table data structure for widgets of type Widget n. Create a table with table.

datadata ColumnAlignment
#

Column alignment modes. Use these modes with the alignment functions in this module to configure column alignment behavior.

Constructors

Instances3Eq, Read, Show
datadata RowAlignment
#

Row alignment modes. Use these modes with the alignment functions in this module to configure row alignment behavior.

Constructors

Instances3Eq, Read, Show
datadata TableException
#

A table creation exception.

Constructors

Instances4Eq, Read, Show, Exception

Construction

1 declaration
valuetable :: [[Widget n]] -> Table n
#

Construct a new table.

The argument is the list of rows with the topmost row first, with each element of the argument list being the contents of the cells in in each column of the respective row, with the leftmost cell first.

Each row's height is determined by the height of the tallest cell in that row, and each column's width is determined by the width of the widest cell in that column. This means that control over row and column dimensions is a matter of controlling the size of the individual cells, such as by wrapping cell contents in padding, fill and hLimit or vLimit, etc. This also means that it is not necessary to explicitly set the width of most table cells because the table will determine the per-row and per-column dimensions by looking at the largest cell contents. In particular, this means that the table's alignment logic only has an effect when a given cell's contents are smaller than the maximum for its row and column, thus giving the table some way to pad the contents to result in the desired alignment.

By default:

  • All columns are left-aligned. Use the alignment functions in this module to change that behavior.

  • All rows are top-aligned. Use the alignment functions in this module to change that behavior.

  • The table will draw borders between columns, between rows, and around the outside of the table. Border-drawing behavior can be configured with the API in this module. Note that tables always draw with joinBorders enabled. If a cell's contents has smart borders but you don't want those borders to connect to the surrounding table borders, wrap the cell's contents with freezeBorders.

All cells of all rows MUST use the Fixed growth policy for both horizontal and vertical growth. If the argument list contains any cells that use the Greedy policy, this function will raise a TableException.

All rows MUST have the same number of cells. If not, this function will raise a TableException.

Configuration

13 declarations
valuealignLeft :: Int -> Table n -> Table n
#

Align the specified column to the left. The argument is the column index, starting with zero. Silently does nothing if the index is out of range.

valuealignRight :: Int -> Table n -> Table n
#

Align the specified column to the right. The argument is the column index, starting with zero. Silently does nothing if the index is out of range.

valuealignCenter :: Int -> Table n -> Table n
#

Align the specified column to center. The argument is the column index, starting with zero. Silently does nothing if the index is out of range.

valuealignTop :: Int -> Table n -> Table n
#

Align the specified row to the top. The argument is the row index, starting with zero. Silently does nothing if the index is out of range.

valuealignMiddle :: Int -> Table n -> Table n
#

Align the specified row to the middle. The argument is the row index, starting with zero. Silently does nothing if the index is out of range.

valuealignBottom :: Int -> Table n -> Table n
#

Align the specified row to bottom. The argument is the row index, starting with zero. Silently does nothing if the index is out of range.

Rendering

1 declaration

Low-level API

5 declarations
valuealignColumns
  1. :: [ColumnAlignment]

    The column alignments to use for each widget, respectively.

  2. -> [Int]

    The width of each column in terminal columns, respectively.

  3. -> [Widget n]

    The column cells to align.

  4. -> [Widget n]
#

Given a "table row" of widgets, align each one according to the list of specified column alignments in columns of the specified widths.