data Box
A box has a defined size (rows x cols) and some content.
Constructors:
data Alignment
Box alignment.
Constructors:
AlignFirst
:: Alignment
align at top/left
AlignCenter1
:: Alignment
centered, but biased to top/left
AlignCenter2
:: Alignment
centered, but biased to bottom/right
AlignLast
:: Alignment
align at bottom/right
data Content
Content of a box.
Constructors:
Blank
:: Content
no content
Text
:: String -> Content
a string
Row
:: [Box] -> Content
a row of boxes
Col
:: [Box] -> Content
a column of boxes
SubBox
:: Alignment -> Alignment -> Box -> Content
an aligned subbox
data Para
A paragraph has a width and some content.
Constructors:
Para
:: Int -> ParaContent -> Para
Fields:
paraWidth
:: Int
paraContent
:: ParaContent
data ParaContent
A paragraph's content is a block consisting of many full lines and a single last line.
Constructors:
data Line
A line has a length and a list of words.
Constructors:
data Word
A word has a length and its contents.
Constructors:
Top alignment.
Botton alignment.
Left alignment.
Right alignment.
Center-top/left alignment.
Center-bottom/right alignment.
Creates an empty 0x0 box.
Creates an empty box with the given size.
:: Int
|
number of rows |
-> Int
|
number of columns |
-> Box
|
Creates a 1x1 box from a character.
Creates a Nx1 box from a string of length N.
Combine two boxes horizontally with top alignment.
Combine two boxes horizontally with top alignment and leave one column between the boxes.
Combine two boxes vertically with left alignment.
Combine two boxes vertically with left alignment and leave one row between the boxes.
hcat
:: Alignment -> [Box] -> Box
Combines a list of boxes horizontally with the given alignment.
hsep
:: Int -> Alignment -> [Box] -> Box
Combines a list of boxes horizontally with the given alignment and space between all boxes.
vcat
:: Alignment -> [Box] -> Box
Combines a list of boxes vertically with the given alignment.
sumMax
:: Ord b => (a -> Int) -> b -> (a -> b) -> [a] -> (Int, b)
Calculate sum and maximum of a list.
vsep
:: Int -> Alignment -> [Box] -> Box
Combines a list of boxes vertically with the given alignment and space between all boxes.
punctuateH
:: Alignment -> Box -> [Box] -> Box
Combine a list of boxes horizontally with the given alignment and a copy of the given box between each two boxes.
punctuateV
:: Alignment -> Box -> [Box] -> Box
Combine a list of boxes vertically with the given alignment and a copy of the given box between each two boxes.
paraFill
:: Alignment -> Int -> String -> Box
mkParaBoxFill
:: Alignment -> Int -> Int -> [String] -> Box
para
:: Alignment -> Int -> String -> Box
Create a box of the given width, containing a specific text. The text is flowed to fit the width according to the alignment.
:: Alignment
|
the alignment of the text |
-> Int
|
the box's width |
-> String
|
the box's contents |
-> Box
|
columns
:: Alignment -> Int -> Int -> String -> [Box]
Creates a list of boxes, each of a specific width and height. The given text is flowed into as many columns as necessary according to the given alignment.
mkParaBox
:: Alignment -> Int -> [String] -> Box
Creates a box of a specific height that contains a list of texts.
flow
:: Int -> String -> [String]
Flows a given text into a given width, creating many different strings.
Creates an empty paragraph of the given width.
Returns all lines of a paragraph.
Creates a line from a list of words.
Creates a line from a single word.
Creates a word from a string.
addWordP
:: Para -> Word -> Para
Adds a word to a paragraph.
addWordL
:: Word -> Line -> Line
Adds a word to a line.
wordFits
:: Int -> Word -> Line -> Bool
Checks whether a word fits into a line.
alignHoriz
:: Alignment -> Int -> Box -> Box
Creates a box of a specific width containing another box's content aligned according to the given alignment.
alignVert
:: Alignment -> Int -> Box -> Box
Creates a box of a specific height containing another box's content aligned according to the given alignment.
align
:: Alignment -> Alignment -> Int -> Int -> Box -> Box
Creates a box of a specific width and height containing another box's content aligned according to the given alignment.
Move a box up by putting it into a larger box with extra rows, aligned to the top. See remarks for moveLeft.
Move a box down by putting it into a larger box with extra rows, aligned to the bottom. See remarks for moveLeft.
Move a box left by putting it into a larger box with extra columns, aligned to the left. Note that this will only move the box by the specified amount if it is already in a larger right-aligned box.
moveRight
:: Int -> Box -> Box
Move a box right by putting it into a larger box with extra columns, aligned to the right. See remarks for moveRight.
table
:: [[String]] -> [Int] -> Box
Create a table from a list of rows. A fixed width for each column must be specified.
Render a box to a string.
takeP
:: a -> Int -> [a] -> [a]
Takes a number of elements from a list. If the list is shorter than that number, fill the rest with a filler.
fReverse
:: ([a], b) -> ([a], b)
(***)
:: (a -> b) -> (c -> d) -> (a, c) -> (b, d)
takePA
:: Alignment -> a -> Int -> [a] -> [a]
Generates a string of spaces.
Render a box as a list of lines.
renderBoxWithRows
:: Int -> Box -> [String]
Render a box as a list of lines with a given number of rows.
renderBoxWithCols
:: Int -> Box -> [String]
Render a box as a list of lines with a given number of columns.
resizeBox
:: Int -> Int -> [String] -> [String]
Resize a rendered list of lines.
resizeBoxAligned
:: Int -> Int -> Alignment -> Alignment -> [String] -> [String]
Resize a rendered list of lines using the given alignments.
Print a box to stdout.
chunksOf
:: Int -> [a] -> [[a]]