/usr/local/lib/swipl/library/ansi_term.pl
All Application Manual Name SummaryHelp

  • swipl
    • library
      • error.pl
      • debug.pl -- Print debug messages and test assertions
      • apply.pl
      • lists.pl
      • broadcast.pl
      • shlib.pl
      • option.pl
      • thread_pool.pl
      • gensym.pl
      • settings.pl
      • arithmetic.pl
      • main.pl
      • readutil.pl -- Read utilities
      • operators.pl
      • pairs.pl -- Operations on key-value lists
      • prolog_source.pl
      • record.pl
      • quasi_quotations.pl -- Define Quasi Quotation syntax
      • pure_input.pl -- Pure Input from files and streams
      • solution_sequences.pl -- Modify solution sequences
      • ordsets.pl -- Ordered set manipulation
      • random.pl
      • base64.pl -- Base64 encoding and decoding
      • aggregate.pl -- Aggregation operators on backtrackable predicates
      • yall.pl
      • sandbox.pl
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl -- Binary associations
      • prolog_format.pl -- Analyse format specifications
      • predicate_options.pl
      • csv.pl
      • pprint.pl -- Pretty Print Prolog terms
      • atom.pl
      • modules.pl
      • occurs.pl
      • prolog_xref.pl
      • prolog_colour.pl
      • lazy_lists.pl
      • ugraphs.pl
      • url.pl -- Analysing and constructing URL
      • www_browser.pl
      • prolog_pack.pl
      • git.pl
      • utf8.pl
      • dialect.pl
      • system.pl
      • terms.pl
      • date.pl
      • persistency.pl -- Provide persistent dynamic predicates
      • iostream.pl -- Utilities to deal with streams
      • prolog_stack.pl -- Examine the Prolog stack
      • edinburgh.pl -- Some traditional Edinburgh predicates
      • prolog_clause.pl
      • prolog_breakpoints.pl -- Manage Prolog break-points
      • wfs.pl
      • prolog_code.pl
      • sort.pl
      • dicts.pl
      • dif.pl
      • varnumbers.pl
      • pio.pl
      • backcomp.pl -- Backward compatibility
      • base32.pl
      • charsio.pl
      • codesio.pl -- I/O on Lists of Character Codes
      • coinduction.pl
      • heaps.pl
      • rbtrees.pl
      • statistics.pl
      • when.pl
      • ansi_term.pl -- Print decorated text to ANSI consoles
        • console_color/2
        • message_line_element/2
        • ansi_format/3
        • ansi_hyperlink/2
        • ansi_hyperlink/3
        • tty_url_hook/2
        • ansi_get_color/2
      • prolog_versions.pl -- Demand specific (Prolog) versions
      • help.pl
      • listing.pl -- List programs and pretty print clauses
      • thread.pl -- High level thread primitives
      • nb_set.pl
      • threadutil.pl -- Interactive thread utilities
      • check.pl
      • prolog_codewalk.pl -- Prolog code walker
      • make.pl
      • writef.pl -- Old-style formatted write
      • edit.pl
      • prolog_profile.pl -- Execution profiler
      • optparse.pl
      • macros.pl
      • ctypes.pl -- Character code classification
      • zip.pl
      • tty.pl
      • intercept.pl
      • tables.pl
      • prolog_history.pl -- Per-directory persistent commandline history
      • prolog_config.pl -- Provide configuration information
      • quintus.pl
      • prolog_autoload.pl
      • prolog_jiti.pl
      • shell.pl
      • prolog_coverage.pl
      • hashtable.pl -- Hash tables
      • prolog_trace.pl
      • prolog_wrap.pl -- Wrapping predicates
      • explain.pl
      • exceptions.pl
      • files.pl
      • prolog_debug.pl -- User level debugging tools
      • rwlocks.pl
      • increval.pl
      • strings.pl -- String utilities
      • streams.pl -- Manage Prolog streams
      • portray_text.pl
      • oset.pl
      • prolog_metainference.pl
      • fastrw.pl
 ansi_format(+ClassOrAttributes, +Format, +Args) is det
Format text with ANSI attributes. This predicate behaves as format/2 using Format and Args, but if the current_output is a terminal, it adds ANSI escape sequences according to Attributes. For example, to print a text in bold cyan, do
?- ansi_format([bold,fg(cyan)], 'Hello ~w', [world]).

Attributes is either a single attribute, a list thereof or a term that is mapped to concrete attributes based on the current theme (see prolog:console_color/2). The attribute names are derived from the ANSI specification. See the source for sgr_code/2 for details. Some commonly used attributes are:

bold
underline
fg(Color),bg(Color),hfg(Color),hbg(Color)
For fg(Color) and bg(Color), the colour name can be '#RGB' or '#RRGGBB'
fg8(Spec),bg8(Spec)
8-bit color specification. Spec is a colour name, h(Color) or an integer 0..255.
fg(R,G,B),bg(R,G,B)
24-bit (direct color) specification. The components are integers in the range 0..255.

Defined color constants are below. default can be used to access the default color of the terminal.

  • black, red, green, yellow, blue, magenta, cyan, white

ANSI sequences are sent if and only if

  • The current_output has the property tty(true) (see stream_property/2).
  • The Prolog flag color_term is true.