The SML of NJ Library
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. Specifying the empty list is equivalent to `[RESET]`.

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

  `setStyle (outS, styles)` sets the styles for the terminal connected to the output stream `outS`. Specifying the empty list is equivalent to `[RESET]`.

## See Also

The Util Library

SML/NJ Version 110.99.3 (August 1, 2023)
Last updated 2023-07-31 17:59:01 UTC