= The `ANSITerm` structure
:Author: John Reppy
:Date: {release-date}
:stem: latexmath
:source-highlighter: pygments
:VERSION: {smlnj-version}

The `ANSITerm` structure provides support for displaying stylized
text using the https://en.wikipedia.org/wiki/ANSI_escape_code[ANSI escape codes].

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

== Synopsis

[source,sml]
------------
structure ANSITerm
------------

== Interface

[source,sml]
------------
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

`[.kw]#datatype# color = ...`::
  This datatype can be used to specify the eight standard colors, plus the default
  color.

`[.kw]#datatype# style = ...`::
  This datatype specifies the different styles that can be used when
  displaying text.  The styles are
+
--
    `FG [.kw]#of# color`::
	specifies the foreground color of the text.

    `BG [.kw]#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.
--

`[.kw]#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]`.

`[.kw]#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

xref:smlnj-lib.adoc[__The Util Library__]
