| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rainbox.BicolorTable
Description
Functions and types to build BicolorTables. Everything you should
typically need is exported from Rainbox.
Synopsis
- type BicolorTableCellLine = Seq Chunk
- type BicolorTableCell = Seq BicolorTableCellLine
- type BicolorTableRow = Seq BicolorTableCell
- data BicolorTable = BicolorTable {}
- bctSpacerWidth :: Lens' BicolorTable Int
- bctRows :: Lens' BicolorTable (Seq BicolorTableRow)
- bctOddBackground :: Lens' BicolorTable Radiant
- bctEvenBackground :: Lens' BicolorTable Radiant
- bctAlignments :: Lens' BicolorTable (Seq (Alignment Vertical))
- bicolorTable :: BicolorTable -> Either String (Box Vertical)
- hPutBicolorTable :: Handle -> BicolorTable -> IO ()
- putBicolorTable :: BicolorTable -> IO ()
- numberSeq :: Seq a -> Seq (Int, a)
- convertChunkForRendering :: Radiant -> Chunk -> Chunk
- convertBicolorTableCellLineForRendering :: Radiant -> BicolorTableCellLine -> BicolorTableCellLine
- convertBicolorTableCellForRendering :: Radiant -> BicolorTableCell -> BicolorTableCell
- bicolorToPlainCell :: Radiant -> Alignment Vertical -> BicolorTableCell -> Cell
- bicolorToPlainRow :: Radiant -> Radiant -> Int -> Int -> Seq (Alignment Vertical) -> BicolorTableRow -> Either String (Seq Cell)
- bicolorToPlainTable :: BicolorTable -> Either String (Seq (Seq Cell))
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 # | |
Defined in Rainbox.BicolorTable Methods showsPrec :: Int -> BicolorTable -> ShowS # show :: BicolorTable -> String # showList :: [BicolorTable] -> ShowS # | |
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.
convertChunkForRendering Source #
Convert a Chunk for rendering by substituting the table's
row background for the chunk's row background if applicable.
convertBicolorTableCellLineForRendering :: Radiant -> BicolorTableCellLine -> BicolorTableCellLine Source #
Converts a BicolorTableCellLine for rendering.
convertBicolorTableCellForRendering :: Radiant -> BicolorTableCell -> BicolorTableCell Source #
Converts a BicolorTableCell for rendering.
Arguments
| :: Radiant | Appropriate background color |
| -> Alignment Vertical | Column alignment |
| -> BicolorTableCell | |
| -> Cell |
Convert a BicolorTable cell to a plain Cell. Does all necessary Chunk conversions.
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.