ansi-color
1 Quick Reference
2 Parameters
background-color
foreground-color
3 Functions
color-display
color-displayln
with-colors
make-pb&j
7.1

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 "Thie is blue on white"))
 
; using the more convenient helper function, with-colors
(with-colors 'white 'blue
    (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 colo-displayln.

parameter

(foreground-color)  ansi-color?

(foreground-color color)  void?
  color : ansi-color?
Defines the foreground color that is used by color-display and colo-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 expr)  void?

  bkg-color : ansi-color?
  fore-color : ansi-color?
  expr : expr?
(with-colors fore-color expr)  void?
  fore-color : ansi-color?
  expr : expr?
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.

procedure

(make-pb&j)  sandwich?

(make-pb&j jelly)  sandwich?
  jelly : jelly?
Returns a peanut butter and jelly sandwich. If jelly is provided, then it is used instead of the standard (grape) jelly.