A.2 library(ansi_term): Print decorated text to ANSI consoles
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(ansi_term): Print decorated text to ANSI consoles
          • ansi_format/3
          • ansi_format/4
          • ansi_sgr/2
          • console_color/3
          • console_color/2
          • message_line_element/2
          • ansi_hyperlink/2
          • ansi_hyperlink/3
          • tty_url_hook/2
          • ansi_get_color/2
    • Packages
Availability::- use_module(library(ansi_term)).(can be autoloaded)
Source[det]ansi_sgr(+ClassOrAttributes, -Sequence:string)
True when Sequence is the ANSI Select Graphic Rendition sequence that activates the attributes of ClassOrAttributes. Sequence is the empty string if the Prolog flag color_term is false or the class resolves to no attributes.

Unlike ansi_format/4 this does not write to a stream and thus does not require a terminal. It is used to decorate strings that are handed to code that is not aware of colors, notably the toplevel prompt (see the Prolog flag toplevel_prompt). As the caller controls where the sequence ends up, the caller is also responsible for verifying that the destination is a terminal and for emitting the reset sequence ‘\e[0m`.

See also
ansi_format/3 for the possible values of ClassOrAttributes.