Module

Text.PrettyPrint.Boxes

Package
purescript-boxes
Repository
cdepillabout/purescript-boxes

#Box Source

newtype Box

The basic data type. A box has a specified size and some sort of contents.

Instances

#nullBox Source

nullBox :: Box

The null box, which has no content and no size. It is quite useless.

#emptyBox Source

emptyBox :: Int -> Int -> Box

emptyBox r c is an empty box with r rows and c columns. Useful for effecting more fine-grained positioning of other boxes, by inserting empty boxes of the desired size in between them.

#char Source

char :: Char -> Box

A 1x1 box containing a single character.

#text Source

text :: String -> Box

A (1 x len) box containing a string of length len.

#para Source

para :: Alignment -> Int -> String -> Box

para algn w t is a box of width w, containing text t, aligned according to algn, flowed to fit within the given width.

#columns Source

columns :: Alignment -> Int -> Int -> String -> Array Box

columns w h t is a list of boxes, each of width w and height at most h, containing text t flowed into as many columns as necessary.

#appendHorizTop Source

appendHorizTop :: Box -> Box -> Box

Paste two boxes together horizontally, using a default (top) alignment.

#appendHorizTopExtraCol Source

appendHorizTopExtraCol :: Box -> Box -> Box

Paste two boxes together horizontally with a single intervening column of space, using a default (top) alignment.

#(<<>>) Source

Operator alias for Text.PrettyPrint.Boxes.appendHorizTop (left-associative / precedence 7)

#(<<+>>) Source

Operator alias for Text.PrettyPrint.Boxes.appendHorizTopExtraCol (left-associative / precedence 7)

#hcat Source

hcat :: forall f. Foldable f => Alignment -> f Box -> Box

Glue a list of boxes together horizontally, with the given alignment.

#hsep Source

hsep :: forall f. Foldable f => Int -> Alignment -> f Box -> Box

hsep sep a bs lays out bs horizontally with alignment a, with sep amount of space in between each.

#appendVertLeft Source

appendVertLeft :: Box -> Box -> Box

Paste two boxes together vertically, using a default (left) alignment.

#appendVertLeftExtraCol Source

appendVertLeftExtraCol :: Box -> Box -> Box

Paste two boxes together vertically with a single intervening row of space, using a default (left) alignment.

#(//) Source

Operator alias for Text.PrettyPrint.Boxes.appendVertLeft (left-associative / precedence 7)

#(/+/) Source

Operator alias for Text.PrettyPrint.Boxes.appendVertLeftExtraCol (left-associative / precedence 7)

#vcat Source

vcat :: forall f. Foldable f => Alignment -> f Box -> Box

Glue a list of boxes together vertically, with the given alignment.

#vsep Source

vsep :: forall f. Foldable f => Int -> Alignment -> f Box -> Box

vsep sep a bs lays out bs vertically with alignment a, with sep amount of space in between each.

#punctuateH Source

punctuateH :: forall f. Foldable f => Alignment -> Box -> f Box -> Box

punctuateH a p bs horizontally lays out the boxes bs with a copy of p interspersed between each.

#punctuateV Source

punctuateV :: forall f. Foldable f => Alignment -> Box -> f Box -> Box

A vertical version of 'punctuateH'.

#Alignment Source

data Alignment

Data type for specifying the alignment of boxes.

Instances

#left Source

left :: Alignment

Align boxes to the left.

#right Source

right :: Alignment

Align boxes to the right.

#top Source

top :: Alignment

Align boxes along their tops.

#bottom Source

bottom :: Alignment

Align boxes along their bottoms.

#center1 Source

center1 :: Alignment

Align boxes centered, but biased to the left/top in case of

#center2 Source

center2 :: Alignment

Align boxes centered, but biased to the right/bottom in case of

#moveLeft Source

moveLeft :: Int -> Box -> Box

Move a box left by putting it in a larger box with extra columns, aligned left. Note that the name of this function is something of a white lie, as this will only result in the box being moved left by the specified amount if it is already in a larger right-aligned context.

#moveRight Source

moveRight :: Int -> Box -> Box

Move a box right by putting it in a larger box with extra columns, aligned right. See the disclaimer for 'moveLeft'.

#moveUp Source

moveUp :: Int -> Box -> Box

Move a box "up" by putting it in a larger box with extra rows, aligned to the top. See the disclaimer for 'moveLeft'.

#moveDown Source

moveDown :: Int -> Box -> Box

Move a box down by putting it in a larger box with extra rows, aligned to the bottom. See the disclaimer for 'moveLeft'.

#alignHoriz Source

alignHoriz :: Alignment -> Int -> Box -> Box

alignHoriz algn n bx creates a box of width n, with the contents and height of bx, horizontally aligned according to algn.

#alignVert Source

alignVert :: Alignment -> Int -> Box -> Box

alignVert algn n bx creates a box of height n, with the contents and width of bx, vertically aligned according to algn.

#align Source

align :: Alignment -> Alignment -> Int -> Int -> Box -> Box

align ah av r c bx creates an r x c box with the contents of bx, aligned horizontally according to ah and vertically according to av.

#rows Source

rows :: Box -> Int

#cols Source

cols :: Box -> Int

#render Source

render :: Box -> String

Render a Box as a String, suitable for writing to the screen or a file.