This is the cl-ansi-term Reference Manual, version 0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Jul 15 03:36:16 2025 GMT+0.
The main system appears first, followed by any subsystem dependency.
cl-ansi-term
Output colored formatted text, tables and other pretty-printing widgets on ANSI-compliant terminals
vindarel
Mark Karpov
GNU GPL, version 3
0.2
alexandria
(system).
anaphora
(system).
serapeum
(system).
str
(system).
cl-ansi-term.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
cl-ansi-term/cl-ansi-term.lisp
cl-ansi-term
(system).
*effects-enabled*
(special variable).
*prefer-plists-in-tables*
(special variable).
*terminal-width*
(special variable).
alist-table
(function).
alists-table
(function).
banner
(function).
banner-fmt
(function).
cat-print
(function).
hr
(function).
o-list
(function).
plist-table
(function).
plist-vtable
(function).
plists-table
(function).
plists-vtable
(function).
print-styled
(function).
progress-bar
(function).
register-hook
(function).
remove-hook
(function).
table
(function).
title
(function).
title-fmt
(function).
u-list
(function).
update-style-sheet
(function).
vspace
(function).
vtable
(function).
with-table-output-to-string
(macro).
%newline-before-row%
(special variable).
%proper-list-p
(macro).
*coloration*
(special variable).
*column-width*
(special variable).
*default-cell-style*
(special variable).
*enable-effects-on-dumb-terminals*
(special variable).
*hooks*
(special variable).
*long-column-width*
(special variable).
*max-column-width*
(special variable).
*min-column-width*
(special variable).
*stream*
(special variable).
*style*
(special variable).
*style-sheet*
(special variable).
*styles*
(special variable).
+background-colors+
(special variable).
+effects+
(special variable).
+foreground-colors+
(special variable).
align-object
(function).
alist-keys
(function).
alist-values
(function).
alist-vtable
(function).
alists-vtable
(function).
ansi-escape-seq
(function).
association-list-p
(function).
collect-hash-tables-values
(function).
collect-plists-values
(function).
compute-columns-width
(function).
effects-p
(function).
ensure-circular-list
(function).
filter-batches
(function).
filter-lists
(function).
get-cell-style
(function).
ht-table
(function).
ht-vtable
(function).
hts-table
(function).
hts-vtable
(function).
invert-matrix
(function).
issues/association-list-p
(function).
largest-length
(function).
long-column-p
(function).
parse-control-string
(function).
perform-hook
(function).
print-filler
(function).
print-partially
(function).
print-white-space
(function).
print-words
(function).
property-list-p
(function).
remove-keys
(function).
set-style
(function).
shorten-columns-width
(function).
string*
(function).
table-dispatch
(function).
table-lists
(function).
vtable-dispatch
(function).
vtable-lists
(function).
with-reasonable-width
(macro).
Packages are listed by definition order.
cl-ansi-term
term
alexandria
.
anaphora
.
common-lisp
.
*effects-enabled*
(special variable).
*prefer-plists-in-tables*
(special variable).
*terminal-width*
(special variable).
alist-table
(function).
alists-table
(function).
banner
(function).
banner-fmt
(function).
cat-print
(function).
hr
(function).
o-list
(function).
plist-table
(function).
plist-vtable
(function).
plists-table
(function).
plists-vtable
(function).
print-styled
(function).
progress-bar
(function).
register-hook
(function).
remove-hook
(function).
table
(function).
title
(function).
title-fmt
(function).
u-list
(function).
update-style-sheet
(function).
vspace
(function).
vtable
(function).
with-table-output-to-string
(macro).
%newline-before-row%
(special variable).
%proper-list-p
(macro).
*coloration*
(special variable).
*column-width*
(special variable).
*default-cell-style*
(special variable).
*enable-effects-on-dumb-terminals*
(special variable).
*hooks*
(special variable).
*long-column-width*
(special variable).
*max-column-width*
(special variable).
*min-column-width*
(special variable).
*stream*
(special variable).
*style*
(special variable).
*style-sheet*
(special variable).
*styles*
(special variable).
+background-colors+
(special variable).
+effects+
(special variable).
+foreground-colors+
(special variable).
align-object
(function).
alist-keys
(function).
alist-values
(function).
alist-vtable
(function).
alists-vtable
(function).
ansi-escape-seq
(function).
association-list-p
(function).
collect-hash-tables-values
(function).
collect-plists-values
(function).
compute-columns-width
(function).
effects-p
(function).
ensure-circular-list
(function).
filter-batches
(function).
filter-lists
(function).
get-cell-style
(function).
ht-table
(function).
ht-vtable
(function).
hts-table
(function).
hts-vtable
(function).
invert-matrix
(function).
issues/association-list-p
(function).
largest-length
(function).
long-column-p
(function).
parse-control-string
(function).
perform-hook
(function).
print-filler
(function).
print-partially
(function).
print-white-space
(function).
print-words
(function).
property-list-p
(function).
remove-keys
(function).
set-style
(function).
shorten-columns-width
(function).
string*
(function).
table-dispatch
(function).
table-lists
(function).
vtable-dispatch
(function).
vtable-lists
(function).
with-reasonable-width
(macro).
Definitions are sorted by export status, category, package, and then by lexicographic order.
If this variable is bound to non-NIL value, graphic rendition
effects (and other terminal-dependent effects) are enabled, otherwise they
are disabled.
If non-nil, if the TABLE function can’t clearly distinguish between a list of plists and a list of regular lists, it will give precedence to displaying the data as plists.
Many functions use this value to output text nicely. The default value is 80. If you want to dynamically change this variable, write and register :BEFORE-PRINTING hook and reassign terminal width before printing takes place.
Call BODY with with-output-to-string, and fixing a glitch in the table output.
If :EFFECTS is t, enable effects.
Set %newline-before-row% to fix a difference in output between output to a string and to a stream. This is a bug we have to chase for.
Print the alist ALIST as a table: the keys as the headers row, the values as one row below.
See TABLE.
Print the list of alists as a table.
See TABLE.
Print TITLE in-between two horizontal spaces (hr), with vertical space before and after.
SPACE controls how many blank lines are added before and after the title, LEFT-SPACE helps to center the title a bit (defaults to 5).
Same result as BANNER with default styling arguments, but accepts a TITLE with CL:FORMAT control strings that are formatted with ARGS.
Usage:
(banner-fmt "file ~a" "test.csv")
=>
——————————————————————————–
file test.csv
——————————————————————————–
Is equivalent to:
(term:banner (format nil "title ~a" "test.csv"))
but you can pass key arguments to the latter.
Concatenate OBJECTS and print them. OBJECTS must be a list designator that consists of printable objects and lists where CAR is a printable object and CADR is a keyword that denotes style of the object. Unspecified styles default to BASE-STYLE. MARGIN, FILL-COLUMN, and ALIGN control corresponding parameters of output. Valid values for ALIGN are :LEFT (default), :CENTER, and :RIGHT. Output goes to STREAM.
Print a horizontal line. Characters in the line are created by repeating given FILLER until WIDTH characters accumulated. If WIDTH is not a positive number, ‘*terminal-width*’ will be added to it to get positive WIDTH. STYLE controls graphic rendition. ALIGN should be a keyword: :LEFT, :RIGHT, or :CENTER. Output goes to STREAM.
Print an ordered list according to TREE. If we consider TREE a list,
every element must be either a printable object to print as a list item or a
list where CAR is list item and CDR is sublist of the item.
Example:
(term:o-list ’((:one one-a (:one-b :one-b-1 :one-b-2)) :two))
1. ONE
1. ONE-A
2. ONE-B
1. ONE-B-1
2. ONE-B-2
2. TWO
INDEX must be a
list designator, its elements should be keywords that denote how to
represent numeration. Acceptable values are:
:ARABIC—indexes will be printed as arabic numerals (default value)
:ROMAN—indexes will be printed as roman numerals
:LETTER—indexes will be printed as letters of Latin alphabet
:CAPITAL—the same as :LETTER, but capital letters are used
If there are more levels of nesting than elements in the list, it will be cycled. The same applies to DELIMITER, which must be a string designator.
INDEX-STYLE is used for indexes. It can be also list, in this case it’s
possible to specify different styles for different levels of nesting.
ITEM-STYLE is used to render the list items.
MARK-STYLE is used for items
that end with MARK-SUFFIX (it can be any printable object). LEVEL-MARGIN
must be a positive integer that specifies how to increase margin for every
level of nesting, you can also use plain MARGIN.
FILL-COLUMN is used to
split long items, if it’s not a positive number, ‘*terminal-output*’ will be
added to it to get positive FILL-COLUMN.
Output goes to STREAM.
Print PLIST as a table: the plist keys as the headers row, the plist values as one row below.
COLS allows to limit the number of columns.
Other arguments are passed to the TABLE function.
Example:
(plist-table ’(:a 1 :b 2 :c 3))
=>
+———+———+———+
|A |B |C |
+———+———+———+
|1 |2 |3 |
+———+———+———+
See also PLIST-VTABLE for headers in a column.
Print PLIST as a table, where the first column is the keys, the second column is the value.
Example:
(plist-vtable ’(:a 1 :b 2 :c 3))
=>
+———+———+
|A |1 |
+———+———+
|B |2 |
+———+———+
|C |3 |
+———+———+
See also PLIST-TABLE for headers in the first row.
Print a list of plists as a TABLE.
The first row shows the plist keys, taken from the first plist object.
All other rows show the values of all the plist objects.
If KEYS is given, the table will show only the values, and as many columns, for these keys.
If EXCLUDE is given, the plist values and associated columns are ignored.
Example:
(plists-table ’((:A 1 :B 2 :C 3) (:A 10 :B 20 :C 30)))
=>
+———+———+———+
|A |B |C |
+———+———+———+
|1 |2 |3 |
+———+———+———+
|10 |20 |30 |
+———+———+———+
Print a list of plists as a VTABLE.
See also VTABLE with the :plist key argument and ‘*prefer-plists-in-tables*‘.
The first colum (and not row) shows the plist keys, taken from the first plist object.
All other rows show the values of all the plist objects.
If KEYS is given, the table will show only the values, and as many rows, for these keys.
If EXCLUDE is given, the plist values and associated rows are ignored.
Example:
(plists-vtable ’((:A 1 :B 2 :C 3) (:A 10 :B 20 :C 30)))
=>
+———+———+———+
|A |1 |10 |
+———+———+———+
|B |2 |20 |
+———+———+———+
|C |3 |30 |
+———+———+———+
Print text with CAT-PRINT, but apply CONTROL-STRING with the arguments from ARGS, where each tilde character of CONTROL-STRING is replaced with an argument.
A special syntax can be used to apply styles.
Example:
(term:print-styled "~ and ~" :args ’("foo" "bar") :align :center)
is equivalent to
(term:cat-print "foo and bar" :align :center)
Any region of text in CONTROL-STRING can be printed in a
specified style following this pattern:
[text](:name-of-style)
where :name-of-style is a downcase keyword in the style sheet.
The style of the rest of the output defaults to BASE-STYLE.
ALIGN can be :LEFT (default), :CENTER, and :RIGHT.
MARGIN is the length of the left margin.
FILL-COLUMN sets the column width:
(term:print-styled "~ and ~" :args ’("foo" "bar") :align :center :fill-column 10)
foo and
bar
Output goes to STREAM.
Print a progress bar with FILLER characters advanced to PROGRESS percent.
Needs an interactive terminal to have full effect.
On a dumb terminal like Emacs’ Slime REPL, it doesn’t respect the styles and it doesn’t erase the bar on subsequent calls.
If PROGRESS is less than 100, move cursor to the
beginning of current line, so next invocation of ‘progress-bar’ will rewrite
it.
This function doesn’t print anything if PROGRESS is less than 100 and
output stream is not interactive or ‘*effects-enabled*’ is NIL.
Insert MARGIN spaces, then LABEL (style for the label is set with LABEL-STYLE).
The size of the progress bar is set by BAR-WIDTH. If BAR-WIDTH is not a positive
number, ‘*terminal-width*’ will be added to it to get positive BAR-WIDTH.
BAR-STYLE is the style that will be used for the bar itself, while NUM-STYLE
will be used for number of percents and some additional elements.
Output goes to STREAM.
Register a hook. When predefined EVENT occurs FUNCTION will be called.
You can register many functions to call on the same event.
Acceptable values of EVENT:
:BEFORE-PRINTING—FUNCTION is invoked just before printing takes place, no
argument is passed to the function
:AFTER-PRINTING—FUNCTION is invoked after printing, no argument is passed to
the function
:ON-STYLE-CHANGE—FUNCTION is invoked before style changing escape sequence
in printed. One argument is passed to FUNCTION, name of the style, which is
a keyword.
Remove all registered functions that are called on EVENT. Returns T if there were any functions associated with EVENT and NIL otherwise.
Print a table filling cells with OBJECTS.
Apply styles and adapt the columns’ width to the terminal.
Input data
———-
OBJECTS can be:
- a list of lists of string designators with equal lengths
. - generally, the first list is a list of headers.
- a list of hash-tables
- the table displays the first hash-table keys and all the hash-tables values.
- see also HTS-TABLE
- a list of property-lists
- the table prints the keys and all the plists’ values
- to help the TABLE understand the arguments are plists
and not regular lists, set the PLIST key argument to T
or the variable *prefer-plists-in-tables* to T.
- see also PLISTS-TABLE
- a single hash-table
- a single plist.
Filtering keys to display
————————-
KEYS is a list of keys to display. The associated rows or columns will be displayed.
Works naturally for hash-tables and plists.
For list of lists, the default keys (headers) are considered to be in the first list.
EXCLUDE is a list of keys to NOT display. The two options are mutually exclusive.
Example:
(table ’((:A :B :C) (1 2 3)))
=>
+———+———+———+
|A |B |C |
+———+———+———+
|1 |2 |3 |
+———+———+———+
|10 |20 |30 |
+———+———+———+
(table ’((:A :B :C) (1 2 3)) :exclude :b)
=>
+———+———+
|A |C |
+———+———+
|1 |3 |
+———+———+
See VTABLE to print the table vertically.
Adapting the columns’ width
—————————
The TABLE function adapts to not print content wider than the viewport.
It respects the terminal’s width (*TERMINAL-WIDTH*).
If one or more columns take too much width (see *LONG-COLUMN-WIDTH*), they are truncated and
their cells content will be shortened with the unicode "…".
Set :MAX-COLUMN-WIDTH (defaults to 80) to change the maximum width of any column.
Set :COLUMN-WIDTH to give a width to columns.
If :COLUMN-WIDTH is a number, all the columns will have the same width (not exceeding the max).
If :COLUMN-WIDTH is a list of numbers, it sets the width of each respecting column.
Style options
————-
If BORDER-STYLE is NIL, no border will be
printed, otherwise BORDER-STYLE is expected to be a keyword that denotes
the style in which borders of the table should be printed.
HEADER-STYLE will be
applied to the first row of the table (also to the first column if
COL-HEADER is not NIL) and CELL-STYLE will be applied to all other rows. If
CELL-STYLE is a list, its elements will be used to differently render every
column.
Objects that end with MARK-SUFFIX will be printed using MARK-STYLE.
ALIGN controls the alignmet inside a cell. It can take the values :LEFT (default value), :CENTER, and :RIGHT.
MARGIN, an integer, is the left margin of the whole table.
Output goes to STREAM.
Like a BANNER, but with no borders, so simply print TITLE with vertical space above and below.
Accepts the :ALIGN parameter: :left, :center, :right.
Passes other key arguments to BANNER.
Call the title function, but format TITLE with ARGS before.
See BANNER-FMT.
Print an unordered list according to TREE. If we consider TREE a list,
every element must be either a printable object to print as a list item or a
list where CAR is the list item and CDR is sublist of the item.
Example:
(term:u-list ’((:one one-a (:one-b :one-b-1 :one-b-2)) :two))
* ONE
- ONE-A
- ONE-B
~ ONE-B-1
~ ONE-B-2
* TWO
BULLET is a string. Each character will be used, each time in a row,
as the list bullet. They can be cycled over.
Example:
(term:u-list ’((:one one-a (:one-b :one-b-1 :one-b-2)) :two)
:bullet #+)
+ ONE
+ ONE-A
+ ONE-B
+ ONE-B-1
+ ONE-B-2
+ TWO
(term:u-list ’((:one one-a (:one-b :one-b-1 :one-b-2)) :two)
:bullet "+-")
+ ONE
- ONE-A
- ONE-B
+ ONE-B-1
+ ONE-B-2
+ TWO
BULLET-STYLE is used for bullets. It can be also a list, in this
case it’s possible to specify different styles for different levels of
nesting.
ITEM-STYLE is used to render the list items. MARK-STYLE is used for
items that end with MARK-SUFFIX (it can be any printable object).
LEVEL-MARGIN must be a positive integer that specifies how to increase
margin for every level of nesting, you can also use plain MARGIN.
FILL-COLUMN is used to split long items, if it’s not a positive number,
‘*terminal-width*’ will be added to it to get positive FILL-COLUMN.
Output goes to STREAM.
Update the style sheet used by the application.
Every item of STYLES must be a list with:
- a first element that denotes the name of a style sheet entry. The names are yours.
- a rest of elements that represent a collection of tokens that define terminal rendition.
Example:
(update-style-sheet
’((:header :cyan :underline)
(:mark :red :reverse)
(:term :yellow :bold)))
Then use it:
(term:table (list ’(:name :age) ’(:me 7)) :header-style :header)
Tokens can represent various things: foreground color, background
color, and effects. Every type of token has its default value, so you
can omit some tokens.
For a full list of accepted tokens, see ‘+foreground-colors+’, ‘+background-colors+’ and ‘+effects+’.
If there are more than one token of the same type (for example :RED
and :GREEN—both tokens represent foreground color), result is
unpredictable and depends on internal workings of Common Lisp
implementation used.
You cannot redefine the :DEFAULT style, it always represents default
parameters of rendition.
Tokens are interpreted into their ANSI code (:bold is ^[[33;49;1m … )
and the new stylesheet is saved to ‘term::*style-sheet*’.
STYLES are saved into ‘term::*styles*’.
Print vertical space, aka a SPACE amount of newlines,
to STREAM (standard output by default).
Hooks are performed before and after printing.
Print a vertical table.
See TABLE for all options and the accepted OBJECTS types.
KEYS and EXCLUDE allow to filter in or filter out the rows to display.
Example:
(vtable ’((:A :B :C) (1 2 3) (10 20 30) (1.1 2.2 3.3)))
+———+———+———+———+
|A |1 |10 |1.1 |
+———+———+———+———+
|B |2 |20 |2.2 |
+———+———+———+———+
|C |3 |30 |3.3 |
+———+———+———+———+
With :border-style set to NIL:
A 1 10 1.1
B 2 20 2.2
C 3 30 3.3
Necessary when doing with-output-to-string because something.
Alist where CARs are indexes at which to insert ANSI escape sequences to change graphical rendition and CDRs are keywords that denote style of the rendition. This special variable can be used to affect ‘print-partially’.
The table cells’ width (DEPRECATED).
Default cell style (:default), to use when a table :cell-style is not used, or when its parametric function doesn’t return a value.
If non true, don’t print ANSI escape codes on dumb terminals, like Emacs’ Slime.
This variable is bound to a hash table that provides access to lists of functions by given key. We use keywords as keys. Arguments for the functions depend entirely on EVENT on which every function is called.
The size at which we decide this cell content should be truncated.
The maximum table cells’ width.
Should be at least 3
Default stream. Can be let-bound to print to strings.
This variable is bound to currently set style. Styles are set with ‘set-style’ function.
This hash table contains strings for various styles of terminal output, defined with ‘update-style-sheet’.
The raw style sheet, a list of lists, that was given to ‘update-style-sheet’, before interpretation of ANSI codes.
These are the basic background terminal colors. Colors that are denoted by keywords ending with an asterisk are not in ANSI standard (high intensity variants of 8 basic colors).
All supported rendition effects. Some of them are hardly ever supported by real-world terminals.
These are the basic foreground terminal colors. Colors that are denoted by keywords ending with an asterisk are not in the ANSI standard (high intensity variants of 8 basic colors).
Rebind variable VAR, correcting its value in BODY. If VAR is not a positive number, ‘*terminal-width*’ will be added to it to get positive value that will be used.
Print white-space to STREAM so object occupying WIDTH columns will be aligned according to ALIGN if printed immediately after the white space.
Print the alist ALIST as a table: the keys as the headers row, the values as one row below.
See TABLE.
Print the list of alists as a vtable.
See VTABLE.
Convert list of rendition tokens into an ANSI escape sequence that will select appropriate parameters of rendition if “printed” on an ANSI-compatible terminal. If TOKENS is empty, escape sequence that resets all rendition parameters will be returned.
Effects are now enabled everywhere, on real and dumb terminals, but we can control that.
This function evaluates to T if:
- ‘*effects-enabled*’ is T
- STREAM has support for effects (calls to CL:INTERACTIVE-STREAM-P) and ‘*enable-effects-on-dumb-terminals*’ is T.
batches: ((:A 1.1) (:B 2.2) (:C 3.3))
Considering the first list in list-of-lists represents the headers, remove columns in all the lists.
If STYLE-OR-FN is a function, call it with VALUE and HEADER as arguments
and, if it returns NIL, return DEFAULT,
oherwise return STYLE-OR-FN (a keyword representing a style in the current stylesheet.
Used to style individual cells.
Print the hash-table HT as a table: the keys as the headers row, the values as one row below.
COLS allows to limit the number of columns.
KEYS and EXCLUDE allow to filter in and filter out our hash-table keys and values to display.
Other arguments are passed to the TABLE function.
Example:
(ht-table (serapeum:dict :a 1 :b 2 :c 3))
=>
+———+———+———+
|A |B |C |
+———+———+———+
|1 |2 |3 |
+———+———+———+
See also HT-VTABLE for headers in a column.
Print the hash-table HT as a table, where the first column is the keys, the second column is the value.
KEYS and EXCLUDE filter keys and values.
Example:
(ht-vtable ’(:a 1 :b 2 :c 3))
=>
+———+———+
|A |1 |
+———+———+
|B |2 |
+———+———+
|C |3 |
+———+———+
See also HT-TABLE for headers in the first row.
Print the list of hash-tables HT-LIST as a table: the keys as the first row, the values of each hash-table as one row below.
Other arguments are passed to the TABLE function.
Example:
(hts-table (list (serapeum:dict :a 1 :b 2 :c 3)
(serapeum:dict :a 10 :b 20 :c 30)))
=>
+———+———+———+
|A |B |C |
+———+———+———+
|1 |2 |3 |
+———+———+———+
|10 |20 |30 |
+———+———+———+
See also HTS-VTABLE for a vertical table with keys displayed in the left column.
Print the list of HASH-TABLES as a vertical table, where the first column is the keys,
the other columns are the values of each hash-table.
Example:
(hts-vtable (list (dict :a 1 :b 2 :c 3)
(dict :a 10 :b 20 :c 30)))
=>
+———+———+———+
|A |1 |10 |
+———+———+———+
|B |2 |20 |
+———+———+———+
|C |3 |30 |
+———+———+———+
See also HTS-TABLE for a regular display with the keys as headers in the first row.
Transform a list of rows to a list of columns.
(invert-matrix ’((a b c) (1 2 3)))
;; => ((A 1) (B 2) (C 3))
Returns true if OBJECT is an association list.
Examples:
(association-list-p 1) => NIL (association-list-p ’(1 2 3)) => NIL (association-list-p nil) => T (association-list-p ’((foo))) => T (association-list-p ’((:a . 1) (:b . 2))) => T
Return the largest length of the given strings.
Parse the control string according to the format described in the documentation of the PRINT-STYLED function. Return a list, suitable for passing to ‘cat-print’.
Execute functions corresponding to given EVENT. We use this function to perform the hooks, so it’s for internal use. Return T if there is at least one function associated with EVENT and NIL otherwise.
Print WIDTH symbols of FILLER to STREAM. Use STYLE for graphic rendition.
Partially print given TEXT starting from START character until END character is reached. Output will be colorized if ‘*coloration*’ is bound to alist that describes how to colorize the output, see ‘*coloration*’. All output goes to STREAM.
Print WIDTH white-spaces to STREAM.
Print concatenation of OBJECTS using FILL-COLUMN so that line breaks don’t happen inside words, only between them. OBJECTS must be a list designator. It can consist of printable objects and lists where CAR is a printable object and CADR is a keyword that denotes style of the string designator. Unspecified styles default to BASE-STYLE. MARGIN is not applied for the first line. If FILL-COLUMN is not a positive number, ‘*terminal-width*’ will be added to it to get positive FILL-COLUMN. Output can be aligned with ALIGN parameter. Output goes to STREAM.
Returns true if OBJECT is a property list.
Examples:
(property-list-p 1) => NIL (property-list-p ’(1 2 3)) => NIL (property-list-p ’(foo)) => NIL (property-list-p nil) => T (property-list-p ’(foo 1)) => T (property-list-p ’(:a 1 :b 2)) => T
Sets terminal rendition according to defined STYLE. It does nothing if ‘*effects-enabled*’ is NIL or output stream is not interactive (e.g. redirected to a file).
MAX-WIDTHS is a list of numbers, representing the max columns width for each column.
We want a column
- to not be shrinker than *min-column-width* (3, to allow border characters)
- to not be wider than *max-column-width* (set to 80 by default)
But mainly, as soon as the total of the columns’ width is wider than the *terminal-width*, we have to shrink the long columns (the ones that are wider than *long-column-width*).
We keep the wide-enough columns untouched, and the remaining available terminal width
is equally split between all the large columns.
For example, if we have 3 columns of max width ’(4 50 100), then the shortened widths are (4 43 43), for a total width of 90.
Converts printable object OBJECT to its aesthetic string representation.
Call the appropriate TABLE-* function for the type of objects.
ONE-OR-MANY-OBJECTS can be:
- a singe plist
- a singe hash-table
- a list of hash-tables
- a list of property lists: in that case, we can not be sure
that the user manipulates a list of plists or a list of regular lists with
symbols and keywords.
Set the PLIST key argument to T or call the PLISTS-TABLE function directly.
- a list of lists.
The main table directive that does the heavy lifting. All other table functions eventually call this one.
This function works with lists of lists of simple elements.
KEYS is a list of headers to display. Headers are the first list of OBJECTS.
EXCLUDE is a list of headers to not display.
CELL-STYLE can be either a keyword, denoting a style in use, either a lambda function,
that can compute a style for a given cell.
*This feature is experimental.*
It takes two arguments: the cell value, the header, and a key :default argument.
Example:
(update-style-sheet
’((:color :cyan :bold)
(:danger :red :bold)
(:green :green)
(:default :green)
))
Below we print in red prices that are superior to 10,
we print in cyan the other prices,
and we print in green the other cells.
(setf *default-cell-style* :green)
(table objects
:cell-style (lambda (val header)
(when (equal "price" header)
(if (> val 10)
:danger
:color))))
See our tests for examples.
Call the appropriate VTABLE-* function for the type of objects.
ONE-OR-MANY-OBJECTS can be:
- a singe plist
- a singe hash-table
- a list of hash-tables
- a list of property lists: in that case, we can not be sure
that the user manipulates a list of plists or a list of regular lists with
symbols and keywords.
Set the PLIST key argument to T or call the PLISTS-TABLE function directly.
- a list of lists.
Print a table where the headers are in the first column, not the first row.
Like TABLE, OBJECTS must be a list of string designators with the same length.
Jump to: | %
A B C E F G H I L M O P R S T U V W |
---|
Jump to: | %
A B C E F G H I L M O P R S T U V W |
---|
Jump to: | %
*
+
S |
---|
Jump to: | %
*
+
S |
---|
Jump to: | C F P S |
---|
Jump to: | C F P S |
---|