Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 83af950d8f
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (26 sloc) 0.835 kb
\section{Page Breaking}
\begin{code}
module PageBreak
( breakpages
) where
import Measures
import Boxes
\end{code}
This module breaks pages. A page is simply a \code{VBox} that is as large as a page.
The algorithm is simply \emph{best fit}:
\begin{code}
breakpages :: Dimen -> [VBox] -> [VBox]
breakpages _ [] = []
breakpages textheight (vb:vbs) = (first:breakpages textheight rest)
where
first = mergeBoxes V (vb:first')
(first',rest) = breakpages' (textheight `dsub` (theight vb)) vbs
theight b = (height b) `dplus` (depth b)
breakpages' _ [] = ([], [])
breakpages' s (v:vs)
| hfirst `dgt` s = ([], (v:vs))
| otherwise = ((v:h),t)
where
hfirst = theight v
(h,t) = breakpages' (s `dsub` hfirst) vs
\end{code}
Jump to Line
Something went wrong with that request. Please try again.