6.14.9.13. Code Displays
Code is delineated by two horizontal lines and set in Courier font.
Each line of code is treated as normal Lout input with all characters special
to Lout converted as necessary. The lines of code are wrapped within
an "lines @Break" object to ensure that each code line is left
adjusted and page breaks can occur.
The Lout that we emit is looks relatively complex but is really
straight-forward. Here is what we do:
- Issue a conditional new page comand.
- Begin an indented display so that the code segment is slightly shifted
to right from the rest of the text. This helps to distinguish the
code.
- Reduce the font size by 2 points and report the section information.
- Add a full width rule the full width of the display. The @HExpand is
necessary to get the line as long as the current page width. Add a
little space below the rule.
- Start a segment where each line results in its own output line.
- Change the font to Courier and 1 point smaller than the default font.
- Change the space interpretation mode to lout to ensure that all spaces
in the code result in spaces in the output. This ensures that the
indentation of the resulting text matchces that of the input.
The footer simply reverses the process: it ends the blocks that were
opened, writes another full width rule, and report the section ending.
6.14.9.13.1. Code Introduction and Epilog
6.14.9.13.2. Code Formating