fmt.spad line 180 [edit on github]
The domain OutputBox
represents the two-dimensional form of an expression by a number of strings (lines). Such a box has a baseline (at which such boxes will be horizontally aligned, a height (size above and including the baseline), a depth (size below the baseline), and a width (horizontal size).
box(s)
creates a box that contains the string s
.
depth(box)
returns the height of the box
below the baseline.
Create an empty box of size 0.
empty?(b)
returns true
of the box has height and depth equal to 0.
hcenter(w)(box)
centers the box horizontally inside a box of width w
.
hconcat(lbox)
aligns the boxes at their baseline and concats those boxes horizontally from left to right.
height(box)
returns the height of the box
(above the baseline) including the baseline.
lines(box)
returns the contents of the box
as strings (all of the same length (width(box
)).
pad(t, b, l, r)(box)
returns a new box that is padded by t
empty lines at the top, b
empty lines at the bottom, l
space characters at the left, r
space characters at the right. If w
, h
, d
are the width, height and depth of box then the resulting box will have width l+w+r and height t+h
and depth d+b
.
vconcat(lbox, h)
returns vconcat(lbox,h, 0)
,
vconcat(lbox, h, adjust)
computes the maximal width of the boxes in the list lbox
; then if adjust<0
, left adjusts, if adjust>0
, right adjusts, and otherwise centers each smaller box in a new box of this maximal width and returns a box by putting all the boxes vertically on top of each other. The height of the new box is given by h
, the depth results from the difference of the number of lines and h
.
width(box)
returns the width of the box
.