[Top] | [Contents] | [Index] | [ ? ] |
This document describes cl-ansi-term library, utility that aids to print various primitives on ANSI-compliant terminals. This program is distributed under GNU General Public License, version 3.
All symbols described in this document live in cl-ansi-term
package, it has the following nicknames: term
.
1. Graphic Rendition | Creating and using style-sheets. | |
2. Primitives | Functions and variables to print various primitives. | |
3. Hooks | How to use hooks to extend or alter behavior of cl-ansi-term. | |
Concept Index | Index of concepts described in this manual. | |
Function and Variable Index | Index of externally visible functions and variables. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes variables and functions that allow to control graphic rendition on ANSI-complaint terminals.
cl-ansi-term uses the concept of style sheets for graphic rendition. This means that the programmer doesn’t need to specify all rendition parameters every time he/she wants to use specific graphical effects. Instead, the programmer is provided with the tools to define styles of output, and then use abstract names of the styles to specify how output should be rendered. This allows to reduce repetition of rendition parameters in code and avoid associated errors.
Note that cl-ansi-term is able to detect when the output goes to a file instead of a terminal. In this case, it does not print escape sequences.
If this variable is bound to non-nil
value, graphic rendition
effects (and other terminal-dependent effects) are enabled, otherwise
they are disabled.
Update style sheet used by the application. Every item of alist
must be a list with car
denoting name of style sheet entry and
cdr
representing collection of tokens that define terminal
rendition. 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. However, 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 :default
style, it’s always represent
default parameters of rendition.
Example:
(update-style-sheet '((:header :cyan :underline) (:mark :red :reverse) (:term :yellow :bold))) |
Foreground colors are (default value is :default
):
:default
:black
:red
:green
:yellow
:blue
:magneta
:cyan
:white*
:black*
:red*
:green*
:yellow*
:blue*
:magneta*
:cyan*
:white*
Colors that are denoted by keywords ending with asterisk are not in ANSI standard (high intensity variants of 8 basic colors).
Background colors are (default value is :b-default
):
:b-default
:b-black
:b-red
:b-green
:b-yellow
:b-blue
:b-magneta
:b-cyan
:b-white*
:b-black*
:b-red*
:b-green*
:b-yellow*
:b-blue*
:b-magneta*
:b-cyan*
:b-white*
Colors that are denoted by keywords ending with asterisk are not in ANSI standard (high intensity variants of 8 basic colors).
Rendition effects are (default value is :normal
):
:bold
– bold or increased intensity
:faint
– decreased intensity (not widely supported)
:italic
– not widely supported, sometimes treated as inverse
:underline
– single underline
:blink
– less than 150 per minute
:bad-blink
– MS-DOS ANSI.SYS, 150+ per minute, not widely
supported
:inverse
– swap foreground and background colors, reverse
video
:hide
– not widely supported
:fraktur
– hardly ever supported
:normal
– normal color and intensity
:framed
:encircled
:overlined
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes a variable and functions to print various primitives on ANSI-complaint terminals. All the functions take many keyword parameters so the programmer has great control over them.
Many functions use this value to output text nicely. Default value is
80
. If you want to dynamically change this value, write and
register :before-printing
hook and reassign terminal width
before printing takes place (see section Hooks).
&key
base-style margin fill-column align streamConcatenate 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.
Example:
(term:cat-print '(:abc :def :ghi)) ABCDEFGHI (term:cat-print '(:abc :def :ghi) :align :center) ABCDEFGHI |
&key
args base-style margin fill-column align streamInsert arguments from args (list designator) into
control-string substituting tildes ~
. Any region of text
in control-string can be printed in specified style following
this pattern:
[
text](
name-of-style)
. Where
name-of-style is downcased name of symbol (keyword) in style
sheet. Style of the rest of the output defaults 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.
Example:
(term:print-styled "~ and ~" :args '("foo" "bar")) ;; "foo and bar" |
&key
filler style width align streamPrint 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.
Example:
(term:hr :filler "=") ================================================================================ |
&key
margin label-style filler bar-style num-style bar-width streamPrint a progress bar. 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). Size of 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.
&key
bullet mark-suffix bullet-style item-style mark-style margin level-margin fill-column streamPrint 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. bullet must be a string
designator, it will be converted to string if needed and its
characters will be used as bullets: zeroth character will be the
bullet for top level of the list, first character is the bullet for
sublist, etc. If there are more levels of nesting than characters in
the string, it will be cycled. 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.
Example:
(term:u-list '((:one one-a :one-b) :two)) * ONE - ONE-A - ONE-B * TWO |
&key
index delimiter mark-suffix index-style item-style mark-style margin level-margin fill-column streamPrint 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. 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.
Example:
(term:o-list '((:one one-a :one-b) :two)) 1. ONE 1. ONE-A 2. ONE-B 2. TWO |
&key
mark-suffix border-chars border-style header-style cell-style mark-style col-header margin column-width align streamPrint a table filling cells with objects. objects must be
a list of list designators with equal lengths. If border-style
is nil
, no border will be printed, otherwise border-style
is expected to be a keyword that denotes 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. margin, column-width (list designator,
may be used to set different width for every column), and align
can also be specified. Valid values of align are: :left
(default value), :center
, and :right
. Output goes to
stream.
Example:
(term:table (list '("name" "age") '("me" "7"))) +---------+---------+ |name |age | +---------+---------+ |me |7 | +---------+---------+ |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes functions that allow to register custom hooks that will be invoked on specific predefined events.
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 is 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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | B F H R S |
---|
Index Entry | Section | |
---|---|---|
| ||
B | ||
background colors | 1. Graphic Rendition | |
| ||
F | ||
foreground colors | 1. Graphic Rendition | |
| ||
H | ||
hooks | 3. Hooks | |
| ||
R | ||
rendition effects | 1. Graphic Rendition | |
| ||
S | ||
style sheet | 1. Graphic Rendition | |
|
Jump to: | B F H R S |
---|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | *
C H O P R T U |
---|
Jump to: | *
C H O P R T U |
---|
[Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated by vince on May 1, 2020 using texi2html 1.82.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ Up ] | Up | Up section | 1.2 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated by vince on May 1, 2020 using texi2html 1.82.