For Development HEAD DRAFTSearch (procedure/syntax/module):

Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]

12.68 text.multicolumn - Multicolumn formatting

Module: text.multicolumn

This module provides the means to format a list of words into a multicolumn text. Think of the output of ls command.

(display-multicolumn
  (string-tokenize "The quick brown fox \
                    jumps over the lazy dog"))
 ⇒ prints
The     fox     the
quick   jumps   lazy
brown   over    dog

Various options are provided to customize the output.

Function: display-multicolumn strs :key width minimum-width max-columns order

{text.multicolumn} Display items in a list of strings strs in multicolumn format. The width of a column is chosen to contain the longest string in str or minimum-width, whichever greater. The default of minimum-width is 8.

Then as many columns are displayed as fit in width characters, whose default is 80. However, the number of columns won’t exceed max-columns if it is given and not #f.

The order argument must be either a symbol column or row. If it is column (default), the items are sorted column-first; that is, it is filled in the first column from top to down, then the second column from top to down, and so on. If it is row, the items are sorted row-first; it is filled in the first row from left to right, and then second row, and so on.

Function: layout-multicolumn strs :key width minimum-width max-columns order

{text.multicolumn} This is an underlying procedure of display-multicolumn. It returns a list of text tree (see Lazy text construction). Each text tree stands for a line, not including the newline character. This can be handy if you want to modify the layout.

(layout-multicolumn
  (string-tokenize "The quick brown fox \
                    jumps over the lazy dog"))
 ⇒
(("The     " "fox     " "the")
 ("quick   " "jumps   " "lazy")
 ("brown   " "over    " "dog"))

NB: The actual structure of each text tree may be changed, but passing it to tree->string or write-tree produces the line.


Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]


For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT