AnsiColorString - Maple Help

ColorTools

 AnsiColorString
 add ANSI color codes to a string

 Calling Sequence AnsiColorString( s, foreground=fgcolor, background=bgcolor)

Parameters

 s - string - the string to be formatted fgcolor - color format recognized by ColorTools, default "White" bgcolor - color format recognized by ColorTools, default "Black"

Description

 • This routine adds the ANSI escape codes to the input string so that it will be displayed with the specified foreground and background colors in environments that support ANSI escape codes. This is meant for use with the command line interface version of Maple where the escape codes will not be printed, even if they are not properly supported.
 • The standard user interface of Maple does not support ANSI escape codes and returned strings will have the ANSI escape codes visible in them.

Examples

The output of this command will be full of weird character in the Maple standard user interface, but should be displayed in the given colors in command-line Maple used in a terminal that supports ANSI colors.

 > $\mathrm{ColorTools}:-\mathrm{AnsiColorString}\left("Hello World",\mathrm{foreground}="Gold",\mathrm{background}="Blue"\right)$
 ${"\left[38;5;220m\left[48;5;21mHello World\left[49;39m"}$ (1)

Compatibility

 • The ColorTools[AnsiColorString] command was introduced in Maple 2021.