The cl-ansi-text Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-ansi-text Reference Manual

This is the cl-ansi-text Reference Manual, version 1.0, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:07:27 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

cl-ansi-text

Because color in your terminal is nice. Build Status

Usage example -

* (ql:quickload :cl-ansi-text)
;To load "cl-ansi-text":
;  Load 1 ASDF system:
;    cl-ansi-text
;; Loading "cl-ansi-text"
; => (:CL-ANSI-TEXT)

The main macro is called with-color, which creates an enviroment where everything that is put on stream gets colored according to color. Color options are :black, :red, :green, :yellow, :blue, :magenta, :cyan and :white. You can also use a color structure from CL-COLORS, like cl-colors:+red+.

* (import 'cl-ansi-text:with-color)
; => T
* (with-color (:red)
    (princ "Gets printed red...")
    (princ "and this too!"))
; Gets printed red...and this too!
; => "and this too!"

There are also functions with the name of the colors, that return the string, colored:

* (import 'cl-ansi-text:yellow)
; => T
* (yellow "Yellow string")
; => "Yellow string"
* (princ (yellow "String with yellow background" :style :background))
; "String with yellow background"
; => "String with yellow background"
* (import 'cl-ansi-text:red)
; => T
* (princ
   (concatenate
    'string
    (yellow "Five") " test results went " (red "terribly wrong") "!"))
; Five test results went terribly wrong!
; => "Five test results went terribly wrong!"

At any point, you can bind the *enabled* special variable to nil, and anything inside that binding will not be printed colorfully:

* (let (cl-ansi-text:*enabled*)
    (princ (red "This string is printed normally")))

API

BLUE

Returns a string with the blue'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

MAGENTA

Returns a string with the magenta'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

CYAN

Returns a string with the cyan'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

GREEN

Returns a string with the green'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

WITH-COLOR

Writes out the string denoting a switch to color, executes body, then writes out the string denoting a reset.

enabled dynamically controls expansion..

YELLOW

Returns a string with the yellow'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

BLACK

Returns a string with the black'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

ENABLED

Turns on/off the colorization of functions

MAKE-COLOR-STRING

Takes either a cl-color or a list denoting the ANSI colors and returns a string sufficient to change to the given color.

Will be dynamically controlled by enabled unless manually specified otherwise

RED

Returns a string with the red'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

WHITE

Returns a string with the white'string denotation preppended and thereset' string denotation appended.

enabled dynamically controls the function.

+RESET-COLOR-STRING+

This string will reset ANSI colors

Note

Note that your terminal MUST be ANSI-compliant to show these colors. My SLIME REPL (as of Feb 2013) does not display these colors. I have to use a typical Linux/OSX terminal to see them.

This has been tested to work on a Linux system with SBCL, CLISP and CCL. CCL may not work quite perfectly, some level of conniptions were encountered in testing. The interested reader is advised to check the MAKE-LOAD-FORM defmethod in cl-ansi-text.lisp.

An earlier variant was tested on OSX 10.6 with SBCL.

License: LLGPL


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-ansi-text

Maintainer

Paul Nathan

Author

Paul Nathan

License

LLGPL

Description

ANSI control string characters, focused on color

Long Description

ANSI control string management, specializing in
colors. Sometimes it is nice to have text output in colors

Version

1.0

Dependencies
Source

cl-ansi-text.asd (file)

Component

cl-ansi-text.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-ansi-text.asd

Location

cl-ansi-text.asd

Systems

cl-ansi-text (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-ansi-text/cl-ansi-text.lisp

Parent

cl-ansi-text (system)

Location

cl-ansi-text.lisp

Packages

cl-ansi-text

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 cl-ansi-text

Source

cl-ansi-text.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *enabled*

Turns on/off the colorization of functions

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Special Variable: +reset-color-string+

This string will reset ANSI colors

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Macros

Macro: with-color (COLOR &key STREAM EFFECT STYLE) &body BODY

Writes out the string denoting a switch to ‘color‘, executes body, then writes out the string denoting a ‘reset‘.

*enabled* dynamically controls expansion..

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Functions

Function: black STRING &key EFFECT STYLE

Returns a string with the ‘black’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: blue STRING &key EFFECT STYLE

Returns a string with the ‘blue’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: cyan STRING &key EFFECT STYLE

Returns a string with the ‘cyan’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: green STRING &key EFFECT STYLE

Returns a string with the ‘green’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: magenta STRING &key EFFECT STYLE

Returns a string with the ‘magenta’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: make-color-string COLOR &key EFFECT STYLE (ENABLED *ENABLED*)

Takes either a cl-color or a list denoting the ANSI colors and returns a string sufficient to change to the given color.

Will be dynamically controlled by *enabled* unless manually specified otherwise

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: red STRING &key EFFECT STYLE

Returns a string with the ‘red’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: white STRING &key EFFECT STYLE

Returns a string with the ‘white’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: yellow STRING &key EFFECT STYLE

Returns a string with the ‘yellow’string denotation preppended and the ‘reset’ string denotation appended.

*enabled* dynamically controls the function.

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: +cl-colors+

CL-COLORS colors

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Special Variable: +term-colors+

Basic colors

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Special Variable: +term-effects+

ANSI terminal effects

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Special Variable: +text-style+

One or the other. Not an ANSI effect

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: gen-color-functions COLOR-NAMES-VECTOR
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: build-control-string COLOR &optional EFFECT STYLE

Color (cl-color or term-color) Effect
Style

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: cl-colors-to-ansi COLOR
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: code-from-rgb STYLE RED GREEN BLUE
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: eq-colors A B

Equality for cl-colors

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: find-color-code COLOR

Find the list denoting the color

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: find-effect-code EFFECT

Returns the number for the text effect OR t if no effect should be used OR
nil if the effect is unknown.

effect should be a member of +term-effects+

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: find-style-code STYLE
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: generate-color-string CODE
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: generate-control-string CODE

General ANSI code

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: rgb-code-p COLOR
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: rgb-to-ansi RED GREEN BLUE
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Function: term-colors-to-ansi COLOR
Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Generic functions

Generic Function: rgb-color-code COLOR &optional STYLE

Returns the 256-color code suitable for rendering on the Linux extensions to xterm

Package

cl-ansi-text

Source

cl-ansi-text.lisp (file)

Methods
Method: rgb-color-code (COLOR integer) &optional STYLE
Method: rgb-color-code (COLOR list) &optional STYLE

Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-ansi-text.asd: The cl-ansi-text<dot>asd file
cl-ansi-text/cl-ansi-text.lisp: The cl-ansi-text/cl-ansi-text<dot>lisp file

F
File, Lisp, cl-ansi-text.asd: The cl-ansi-text<dot>asd file
File, Lisp, cl-ansi-text/cl-ansi-text.lisp: The cl-ansi-text/cl-ansi-text<dot>lisp file

L
Lisp File, cl-ansi-text.asd: The cl-ansi-text<dot>asd file
Lisp File, cl-ansi-text/cl-ansi-text.lisp: The cl-ansi-text/cl-ansi-text<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   B   C   E   F   G   M   R   T   W   Y  
Index Entry  Section

B
black: Exported functions
blue: Exported functions
build-control-string: Internal functions

C
cl-colors-to-ansi: Internal functions
code-from-rgb: Internal functions
cyan: Exported functions

E
eq-colors: Internal functions

F
find-color-code: Internal functions
find-effect-code: Internal functions
find-style-code: Internal functions
Function, black: Exported functions
Function, blue: Exported functions
Function, build-control-string: Internal functions
Function, cl-colors-to-ansi: Internal functions
Function, code-from-rgb: Internal functions
Function, cyan: Exported functions
Function, eq-colors: Internal functions
Function, find-color-code: Internal functions
Function, find-effect-code: Internal functions
Function, find-style-code: Internal functions
Function, generate-color-string: Internal functions
Function, generate-control-string: Internal functions
Function, green: Exported functions
Function, magenta: Exported functions
Function, make-color-string: Exported functions
Function, red: Exported functions
Function, rgb-code-p: Internal functions
Function, rgb-to-ansi: Internal functions
Function, term-colors-to-ansi: Internal functions
Function, white: Exported functions
Function, yellow: Exported functions

G
gen-color-functions: Internal macros
generate-color-string: Internal functions
generate-control-string: Internal functions
Generic Function, rgb-color-code: Internal generic functions
green: Exported functions

M
Macro, gen-color-functions: Internal macros
Macro, with-color: Exported macros
magenta: Exported functions
make-color-string: Exported functions
Method, rgb-color-code: Internal generic functions
Method, rgb-color-code: Internal generic functions

R
red: Exported functions
rgb-code-p: Internal functions
rgb-color-code: Internal generic functions
rgb-color-code: Internal generic functions
rgb-color-code: Internal generic functions
rgb-to-ansi: Internal functions

T
term-colors-to-ansi: Internal functions

W
white: Exported functions
with-color: Exported macros

Y
yellow: Exported functions

Jump to:   B   C   E   F   G   M   R   T   W   Y  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
S  
Index Entry  Section

*
*enabled*: Exported special variables

+
+cl-colors+: Internal special variables
+reset-color-string+: Exported special variables
+term-colors+: Internal special variables
+term-effects+: Internal special variables
+text-style+: Internal special variables

S
Special Variable, *enabled*: Exported special variables
Special Variable, +cl-colors+: Internal special variables
Special Variable, +reset-color-string+: Exported special variables
Special Variable, +term-colors+: Internal special variables
Special Variable, +term-effects+: Internal special variables
Special Variable, +text-style+: Internal special variables

Jump to:   *   +  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
cl-ansi-text: The cl-ansi-text system
cl-ansi-text: The cl-ansi-text package

P
Package, cl-ansi-text: The cl-ansi-text package

S
System, cl-ansi-text: The cl-ansi-text system

Jump to:   C   P   S