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

12.73 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 indent

{text.multicolumn} Display items in a list of strings strs in multicolumn format, to the current output port. The items shouldn’t contain newline or tab characters; the procedure doesn’t treat them specially, so the output would be disturbed.

The width of a column is chosen to contain the longest string in strs 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.

The indent argument must be a nonnegative exact integer. If it is greater than zero, that number of whitespaces are prepended before each line. The width includes this indentation; so the actual area of text becomes narrower by indent characters.

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 text.tree - 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.



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