UI (colour) themes play a role in two parts: when writing to the console and for the xpce-based development tools such as PceEmacs or the graphical debugger. Coloured console output is based on ansi_format/3. The central message infra structure based on print_message/2 labels message (components) with a Prolog term that specifies the role. This is mapped to concrete colours by means of the hook prolog:console_color/2. Theming the IDE uses xpce class variables that are initialised from Prolog when xpce is loaded.
Themes are implemented as a Prolog file in the file search path library/theme. A theme can be loaded using (for example) the directive below in the user's initialization file (see section 2.2).
:- use_module(library(theme/dark)).
The theme file library(theme/auto) is provided to
automatically choose a reasonable theme based on the environment. The
current version detects the background color on xterm compatible
terminal emulators (found on most Unix systems) and loads the dark
theme if the background is ‘darkish’.
The console classes that are used by the interactive top level are
listed below. They are only defined by the dark and
light themes because a background colour can only be chosen
if the background colour of the terminal is known. The default only
makes the prompt and the variable names bold.
prompt | The ?- prompt and its |
continuation |
input | The text typed by the user. These attributes remain in effect while the user is typing |
answer(Parity) | An
answer that shows bindings, residual goals or delays. Parity
is odd or even and alternates over the answers
of a single query. Using a different background colour for both this
stripes the answers of a non-deterministic query. true., false.
and the empty line before the next query are not decorated |
binding(name) | The variable name in a
binding such as
X = 1 |
Messages that list predicates to choose from, for example the
alternatives for an unknown procedure, tag each predicate with its
kind. These tags use the class
predicate(Kind), where Kind
is one of
iso, built_in, foreign,
library(Name), module(Module),
user or undefined.
If one of these classes defines a background colour the remainder of
the line is painted using \e[K (Erase in Line),
which makes the coloured block extend to the right margin. This requires
a terminal that implements background colour erase, which most
modern terminal emulators do.
The following notes apply to the different platforms on which SWI-Prolog is supported:
library(theme/auto).Theme support was added in SWI-Prolog 8.1.11. Only part of the IDE
tools are covered and the only additional theme (dark) is
not net well balanced. The interfaces between the theme file and notably
the IDE components is not very well established. Please contribute by
improving the dark theme. Once that is complete and
properly functioning we can start adding new themes.