• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

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
          • theme_base/2
          • message_line_element/2
          • ansi_hyperlink/2
          • ansi_hyperlink/3
          • tty_url_hook/2
          • ansi_get_color/2
    • Packages
[semidet,multifile]prolog:console_color(+Theme, +Term, -AnsiAttributes)
Hook that allows for mapping abstract terms to concrete ANSI attributes. This hook is used by theme files to adjust the rendering based on user preferences and context. Theme is the current theme: the value of the Prolog flag theme or, if no theme is selected, the theme of a loaded theme file. Defaults are defined in the file boot/messages.pl, default_theme/2.

Besides the classes used for messages (code, comment, var, warning, error, truth(Truth), port(Port), message(Kind), ...), the interactive toplevel uses these:

prompt
The ?- prompt and its ‘| ‘ continuation.
input
The text typed by the user at the prompt.
answer(Parity)
An answer written by the toplevel. Parity is odd or even and alternates over the answers of a single query, which allows for striping the answers using a background color. Only an answer that shows bindings, residual goals or delays uses this class: true. and false. are not answers to stripe, and neither is the empty line that separates the answer from the next query.
binding(name)
The variable name in a binding such as X = 1.

The debugger uses, besides frame(level) and port(Port):

goal(Port, Parity)
The goal of a frame reported for Port. Parity is odd or even and alternates over the steps of a trace, which allows for striping the goals using a background color. Match on Port to color the goal by port instead of (or in addition to) striping.

Note that a background color on prompt, input or answer(_) is painted up to the right margin using ‘\e[K`. A background on goal(_,_) is not: the debugger writes its ? prompt on the same line.

If Theme does not define Term, the theme it is based on is used (see prolog:theme_base/2).

See also
library(theme/dark) for an example implementation and the Term values used by the system messages.
ClioPatria (version V3.1.1-59-g7b9a7a3)