ansi-color
1 Quick Reference
2 Parameters
background-color
foreground-color
3 Functions
color-display
color-displayln
with-colors
7.7

ansi-color

renato-athaydes

 (require ansi-color) package: ansi-color

A library to make it easy to colorize terminal output using ANSI escape sequences.

Source.

    1 Quick Reference

    2 Parameters

    3 Functions

1 Quick Reference

The following code samples show how to use the basic functions of this library:

; set the parameters used to colorize output...
; if not set, the output is not colorized!
(background-color 'black)
(foreground-color 'green)
 
; display "Hello world" with the current parameters (i.e. green on black)
(color-display "Hello world")
 
; with explicit parameters
(parameterize ([background-color 'white]
               [foreground-color 'blue])
    (color-display "This is blue on white"))
 
; using the more convenient helper function, with-colors
(with-colors 'white 'blue
    (lambda () (displayln "This is also blue on white")))

2 Parameters

parameter

(background-color)  ansi-color?

(background-color color)  void?
  color : ansi-color?
Defines the background color that is used by color-display and color-displayln.

parameter

(foreground-color)  ansi-color?

(foreground-color color)  void?
  color : ansi-color?
Defines the foreground color that is used by color-display and color-displayln.

3 Functions

datum : any/c out : output-port? = (current-output-port)

procedure

(color-display datum [out])  void?

  datum : any/c
  out : output-port? = (current-output-port)
Like display, but using the parameters background-color and foreground-color to colorize and style the output.

procedure

(color-displayln datum [out])  void?

  datum : any/c
  out : output-port? = (current-output-port)
Like displayln, but using the parameters background-color and foreground-color to colorize and style the output.

procedure

(with-colors bkg-color fore-color proc)  void?

  bkg-color : ansi-color?
  fore-color : ansi-color?
  proc : (-> any)
(with-colors fore-color proc)  void?
  fore-color : ansi-color?
  proc : (-> any)
Sets the foreground and, optionally, the background color to be used to display text with the conventional display and displayln functions. Using color-display or color-displayln within the given proc causes the colors to be reset, and thus should be avoided.