Next / Previous / Contents / TCC Help System / NM Tech homepage

Abstract

Usage and implementation of a utility program to generate listings of text files in PDF format.

This publication is available in Web form and also as a PDF document. Please forward any comments to tcc-doc@nmt.edu.

Table of Contents

1. Requirements for a text file listing utility
2. Components of the solution
3. Operation of the listext script
3.1. Output examples
3.2. Files online
4. guil: The graphical front end
5. Design notes for listext
5.1. Visual design of the report
5.2. XSL-FO design: General page layout
5.3. XSL-FO design: Line formatting
6. listext: Prologue
7. Imports
8. Manifest constants
8.1. BOUND_MARGIN
8.2. UNBOUND_MARGIN
8.3. NARROW_MARGIN
8.4. COL_GAP
8.5. FONT_ASPECT
8.6. ODD_MASTER
8.7. EVEN_MASTER
8.8. REPEAT_MASTER
8.9. ODD_BEFORE
8.10. EVEN_BEFORE
8.11. HEADING_EXTENT
8.12. MONO_FAMILY
8.13. MONO_FONT
8.14. HEAD_SIZE
8.15. HEAD_FAMILY
8.16. HEAD_FONT
8.17. PAGE_NO_GAP
8.18. HAIRLINE_WIDE
8.19. LEFT_RULE_PAD
8.20. OVERFLOW_COLOR
8.21. WRAPPER_PROPS
8.22. OVERFLOW_INDENT
8.23. OUT_BLOCK_PROPS
9. main(): Main logic of listext
10. setupLayout(): Configure the page layout
11. flowSetup(): Build the XSL-FO layout
12. buildMasters(): Set up the page formats
13. addFlow(): Populate the page-sequence element
14. buildStatic(): Set up page headings
15. wrapFlow: Add a styling block-container
16. fatal(): Fatal error logging
17. class Args: Command line arguments
17.1. Args.__init__()
17.2. Args.__parse(): Option syntax checking
17.3. Args._checkPositive(): Check for a positive integer
17.4. Args._checkPoints(): Check the font size option
17.5. Args._final(): Semantic checking
18. class BodyLayout: Page geometry
18.1. BodyLayout.__init__(): Constructor
18.2. BodyLayout.__findWidths(): Calculate width-related dimensions
18.3. BodyLayout.__findHeights(): Calculate lines per column
19. class InputFile: Input sliced to fit
19.1. InputFile.genBlocks(): Generate contained blocks
19.2. InputFile.__init__(): Constructor
19.3. InputFile.__readFile(): Slice up the input lines
19.4. InputFile.__readLine(): Process one input line
19.5. InputFile.__trimLine(): Implement length changes
19.6. InputFile.__sliceLine(): Cut an input line into output lines
19.7. InputFile.__findBreaks(): Implement --break
19.8. InputFile.__genChunks(): Bracket the chunks separated by break strings
19.9. InputFile.__addChunk(): Add one chunk of lines to the column structure
19.10. InputFile.__delBlankCols(): Suppress entirely blank columns
19.11. InputFile.__genCols(): Find the columns in the block list
19.12. InputFile.__anyNonblank(): Does this column contain any nonblank lines?
20. class Heading: Information for the running head
20.1. Heading.__init__(): Constructor
20.2. Heading.__getModTime(): Find the file's modification time
20.3. Heading.__getPaths(): Set up the directory path and file name
20.4. Heading.rightContent(): Render a right-hand page heading
20.5. Heading.leftContent(): Render a left-hand page heading
20.6. Heading.__buildStatic(): Build a header's static-content
21. class OutBlock: One output block
21.1. OutBlock.__init__(): Constructor
21.2. OutBlock.setBreak(): This block starts a new column
21.3. OutBlock.isBreak(): Does this block start a new column?
21.4. OutBlock.__makeBlock(): Build the block element
21.5. OutBlock.renderLine(): Render text
21.6. OutBlock.renderChar(): Translate one character to XSL-FO
22. class FirstBlock: Block for the first or only line
22.1. FirstBlock.render()
23. class OverflowBlock: Overflow continuation block
23.1. OverflowBlock.render(): Render an overflow block as XSL-FO
24. Epilogue

1. Requirements for a text file listing utility

The author relies heavily on paper listings of ordinary text files, even here in the 21st Century, long past the time when the Paperless Office was supposed to be a reality. Aside from their archival value, sometimes there is no monitor big enough to display all the resources one needs during software design; paper listings on a big physical work table can greatly extend the virtual workspace.

General requirements:

  • Show the input file's absolute path name and the timestamp of its last modification on each page.

  • Provide a variety of font sizes, interline spacing, and multi-column output so that wrapped lines can be minimized, yet display wrapped lines in a way that minimizes interference with the perception of indentation in the input file. Omit columns that contain only empty lines or lines consisting entirely of whitespace.

  • For characters that are not normally printable, display their codes instead in a format different than any ordinary character. We will use a tiny font to display the two-character hexadecimal code for each character in the space usually occupied by a single character.