| Did you know ... | Search Documentation: |
| UI Themes |
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.
The IDE uses xpce theme colours: colours whose name describes
their role, such as
syntax_comment for comments in PceEmacs. A theme defines
the values of these colours. The IDE can switch between themes while it
is running. See the section Themes of the XPCE User Guide and
the library library(pce_theme) for details.
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).swipl-win -Dtheme=dark, or set
display.theme in the xpce Defaults file. The
console colours (prolog:console_color/2)
of a theme file only apply while its theme is active, so the console
follows switching themes. Text that is already written keeps its
colours.
Theme support was added in SWI-Prolog 8.1.11. The xpce user interface
and the development tools use theme colours, which allows switching
themes at runtime. The themes light (the default) and
dark are provided. A new theme is a file in
library(theme) that defines the theme colours. The
predicate
check_theme/1
from library library(pce_theme) verifies that a theme
defines all theme colours of xpce and the development tools. Please
contribute themes or improvements to the existing themes.