rainbox-0.24.4.0: Two-dimensional box pretty printing, with colors

Safe HaskellNone
LanguageHaskell2010

Rainbox.BicolorTable

Description

Functions and types to build BicolorTables. Everything you should typically need is exported from Rainbox.

Synopsis

Documentation

type BicolorTableCellLine = Seq Chunk Source #

A single line within a cell in a BicolorTable. For each Chunk, leave the back as the default if you want the Chunk background to match _bctEvenBackground or _bctOddBackground. If you specify a background color for any Chunk, it will for that Chunk override the table's background color.

type BicolorTableCell = Seq BicolorTableCellLine Source #

The set of all lines within a cell in a BicolorTable.

type BicolorTableRow = Seq BicolorTableCell Source #

The set of all columns in a single row. The length of each BicolorTableRow must be equal to the length of _bctAlignments; otherwise, bicolorTable will fail with an error message.

data BicolorTable Source #

Description for a table with rows of alternating background colors. For instance, if designed for a terminal with a white background, the row backgrounds might alternate between white and light grey. The different backgrounds help with readability.

For the Chunk that are in the table, simply leave the back color blank if you wish to use the row's background color. Upon rendering, bicolorTable will render the Chunk with a background color that matches that of the row. If you specify a background color for a Chunk, it will override the background color for the row.

Note that a row may contain more than one line of text.

Unlike tables built with tableByRows or tableByColumns, all tables built with bicolorTable will have separator colums between each column.

Constructors

BicolorTable 

Fields

Instances
Show BicolorTable Source # 
Instance details

Defined in Rainbox.BicolorTable

bicolorTable :: BicolorTable -> Either String (Box Vertical) Source #

Creates a bi-color table. If the number of columns in each BicolorTableRow is not equal to the length of _bctAlignments, this will return Left; otherwise, returns Right with a Box Vertical that can then be rendered.

hPutBicolorTable :: Handle -> BicolorTable -> IO () Source #

Creates a bi-color table and renders it to the given Handle using bicolorTable and hPutBox. Any errors from bicolorTable are repored with fail.

putBicolorTable :: BicolorTable -> IO () Source #

Creates a bi-color table and renders it to standard output using hPutBicolorTable.

numberSeq :: Seq a -> Seq (Int, a) Source #

Number each row of a Seq with its row number.

convertChunkForRendering Source #

Arguments

:: Radiant

Background for this row

-> Chunk 
-> Chunk 

Convert a Chunk for rendering by substituting the table's row background for the chunk's row background if applicable.

bicolorToPlainCell Source #

Arguments

:: Radiant

Appropriate background color

-> Alignment Vertical

Column alignment

-> BicolorTableCell 
-> Cell 

Convert a BicolorTable cell to a plain Cell. Does all necessary Chunk conversions.

bicolorToPlainRow Source #

Arguments

:: Radiant

Background color for even rows

-> Radiant

Background color for odd rows

-> Int

Width of spacer cells

-> Int

Number for this row

-> Seq (Alignment Vertical)

Column alignments

-> BicolorTableRow 
-> Either String (Seq Cell) 

Convert a BicolorTable row to a plain Row. Does all necessary Chunk conversions. Includes spacer cells.

bicolorToPlainTable :: BicolorTable -> Either String (Seq (Seq Cell)) Source #

Converts a BicolorTable table to a plain table with Cell. Does all necessary Chunk conversions, and includes spacer cells.