boxes is a pretty-printing library for laying out text in two dimensions. It is a direct port of the Haskell library boxes by Brent Yorgey.
boxes' core data type is the
Box, which has a width, a height and some contents. A box's contents can be text or other boxes. There are functions for creating boxes from text and for combining boxes into bigger boxes.
text function can be used to create a box from a string, which will have height 1 and length N, where N is the length of the string (Nx1).
char creates a 1x1 box containing a single character.
emptyBox creates an empty box of arbitrary width and height.
para :: Alignment -> Int -> String -> Box creates a box from a string with a specific width. The box will be as high as necessary to fit the text, which is layed out according to the given alignment.
<+> operators combine boxes horizontally with and without a column of space between both boxes, respectively. The
/+/ operators are similar, but combine boxes vertically instead of horizontally.
vcat are versions of
// that combine whole lists of boxes instead of two at a time.
vsep are versions of
/+/ that operate on lists, with a configurable amount of space between each two boxes.
punctuateV also combine lists of boxes horizontally and vertically, but allow us to specify another box which is copied in between each two boxes.
alignHoriz functions can be used to create new boxes which contain other boxes in some alignment.
moveRight move boxes by some amount inside larger boxes.
table creates a table from a list of rows and a list of widths for each column.
render function renders a box to a string. The
printBox function prints a box to stdout.