17 Table Formatting

  • 17.1 Overview of Table Formatting Facilities
  • 17.2 Table Formatting Functions
  • 17.3 The Table and Item List Formatting Protocols
  • CLIM provides a mechanism for tabular formatting of arbitrary output. [annotate]

    To employ these facilities the programmer annotates some output-generating code with advisory macros that describe the high-level formatting constraints, for example, what parts of code produce a row of the table, what parts of that produce the cells in the row. [annotate]

    For example, the following produces a table consisting of three columns containing a number, its square, and its cube. The output can be seen in Figure 17.1. [annotate]

    (defun table-test (count stream)
      (fresh-line stream)
      (formatting-table (stream :x-spacing '(3 :character))
        (dotimes (i count)
          (formatting-row (stream)
            (formatting-cell (stream :align-x :right)
              (prin1 i stream))
            (formatting-cell (stream :align-x :right)
              (prin1 (* i i) stream))
            (formatting-cell (stream :align-x :right)
              (prin1 (* i i i) stream))))))

    Figure 17.1: Example of tabular output.

    The general contract of these facilities is described in the next section. [annotate]