The ANSITerm structure

The ANSITerm structure provides support for displaying stylized text using the ANSI escape codes.

Note that currently this module only supports the limited palette of eight fixed colors.

Synopsis

structure ANSITerm

Interface

datatype color
  = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White | Default

datatype style
  = FG of color
  | BG of color
  | BF
  | DIM
  | NORMAL
  | UL
  | UL_OFF
  | BLINK
  | BLINK_OFF
  | REV
  | REV_OFF
  | INVIS
  | INVIS_OFF
  | RESET

val toString : style list -> string

val setStyle : TextIO.outstream * style list -> unit

Description

datatype color = …​

This datatype can be used to specify the eight standard colors, plus the default color.

datatype style = …​

This datatype specifies the different styles that can be used when displaying text. The styles are

FG of color

specifies the foreground color of the text.

BG of color

specifies the background color of the text.

BF

specifies bold or bright text (note that this does not cancel the effect of DIM).

DIM

specifies dim text (note that this does not cancel the effect of BF).

NORMAL

specifies normal color and intensity (cancels the effect of BF and DIM).

UL

enables underlining of the text.

UL_OFF

cancels underlining.

BLINK

enables blinking text.

BLINK_OFF

cancels blinking mode.

REV

reverses the foreground and background colors.

REV_OFF

cancels reverse mode.

INVIS

makes the text invisible.

INVIS_OFF

cancels invisible mode.

RESET

resets the style to the default mode.

val toString : style list -> string

toString styles returns a command string that will cause the terminal to switch to the specified styles.

(* output commands to set the given styles; the empty list is "normal" *)
val setStyle : TextIO.outstream * style list -> unit

setStyle (outS, styles) sets the styles for the terminal connected to the output stream outS.

See Also