• 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

4.11 Printing messages
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Printing messages
          • print_message/2
          • print_message_lines/3
          • message_hook/3
          • thread_message_hook/3
          • message_action/2
          • message_property/2
          • message_line_element/2
          • message_prefix_hook/2
          • message_to_string/2
          • version/0
          • version/1
          • Printing from libraries
    • Packages
Availability:built-in
Sourceprint_message_lines(+Stream, +Prefix, +Lines)
Print a message (see print_message/2) that has been translated to a list of message elements. The elements of this list are:
<Format>-<Args>
Where Format is an atom and Args is a list of format arguments. Handed to format/3.
flush
If this appears as the last element, Stream is flushed (see flush_output/1) and no final newline is generated. This is combined with a subsequent message that starts with at_same_line to complete the line.
at_same_line
If this appears as first element, no prefix is printed for the first line and the line position is not forced to 0 (see format/1, ~N).
eol
End the decorated part of the line: paint the remainder using the background colour of the message, if it has one, and reset the attributes. This is used for the last line of a message if that line is not ended using nl, for example because it is ended using ~N in a Format element. Resetting matters because a terminal that scrolls while a background colour is in effect paints the newly exposed line with it, which would colour the empty line that follows the message. Without a background colour this element produces no output.
ansi(+Attributes, +Format, +Args)
This message may be intercepted by means of the hook prolog:message_line_element/2. The library library(ansi_term) implements this hook to achieve coloured output. If it is not intercepted it invokes format(Stream, Format, Args).
url(Location)
Print a source location. Location is one of the terms File:Line:Column, File:Line or File. When using library library(ansi_term), this is translated into a hyperlink for modern terminals.
url(URL, Label)
Print Label. URL is either a real URL or a source location as accepted by url(Location) above. When using library library(ansi_term), this is translated into a hyperlink for modern terminals. Label is one of

  • An atom or string, which is printed as plain text.
  • A term Format-Args, which is handed to format/3.
  • A term ansi(Class, Format, Args), which prints the label using the attributes of Class as well as making it a hyperlink. This is how a predicate reference in a message is both coloured using the code class and linked to its definition.
nl
A new line is started. If the message is not complete, Prefix is printed before the remainder of the message.
begin(Class, Context)
end(Context)
The entire message is headed by begin(Class, Context) and ended by end(Context). This feature is used by, e.g., library library(ansi_term) to colour entire messages. Class is normally the message kind. The interactive top level uses answer(Parity) for the messages of kind query that show bindings, which stripes the answers of a non-deterministic query. See section 2.5.
<Format>
Handed to format/3 as format(Stream, Format,[]). Deprecated because it is ambiguous if Format collides with one of the atomic commands.

Context above is a variable that is bound by the handler for begin(Class, Context) and is passed to the elements that follow it. It allows this handler to restore the decoration of the message as a whole after an element that installs a decoration of its own, and to paint the remainder of a line. Its value is opaque: only the code that implements prolog:message_line_element/2 for begin(Class, Context) may interpret it. If this hook is not defined, or the output is not a terminal, Context is left unbound.

To make Context available to the elements that need it, print_message_lines/3 rewrites the elements nl, flush, eol and ansi(Attributes, Format, Args) of Lines into nl(Context), flush(Context), eol(Context) and ansi(Attributes, Format, Args, Context) before passing them to prolog:message_line_element/2. A message that is created using prolog:message//1 always uses the short forms.

See also print_message/2 and message_hook/3.

ClioPatria (version V3.1.1-59-g7b9a7a3)