Skip to content
Jan Wielemaker edited this page Sep 2, 2026 · 7 revisions

Epilog: the SWI-Prolog console

SWI-Prolog console
Epilog after splitting the console
The top window shows an ongoing trace. Goals are links that can be activated using Ctrl-left-click. They link to the call site. The bottom-left window runs ?- help(append). and the bottom-right window runs shell. Screenshot on Fedora Linux using the GNOME desktop.

Starting Epilog

Epilog provides the main application window if Prolog was started using the swipl-win executable. This is the default for the app, i.e., on Windows it is the default shortcut, it is the main executable of the MacOS bundle as well as the Linux flatpak. Alternatively, the SWI-Prolog REPL loop may be used on an OS terminal by starting swipl. If XPCE is present and there is a GUI context (always on MacOS and Windows, optional on most other Unix-derived OSes), an additional REPL loop can be started by running

?- epilog.

Using Epilog

An Epilog window is a terminal that runs a SWI-Prolog REPL loop in a dedicated thread. The terminal is implemented in XPCE. It uses the BSD libedit library to provide Emacs-style editing and history for the Prolog command line. Epilog provides an menu for several common tasks for managing the SWI-Prolog environment as well as a context menu (right click). Below are a few tips. Note that these also works in the OS terminal except that links to locations in Prolog files are in general not clickable.

  • TAB completes on files, atoms, variables and toplevel variables ($Var). This provides completion on modules, predicate names, (long) constants, etc. TAB extends to the next choice. Using TAB TAB or ESC-? shows all still available alternatives.
  • Ctrl-D is end-of-file, also on Windows. This terminates the console or ?- [user]. session.
  • Messages that are related to source locations are clickable links. Ctrl-left-click these links calls edit/1 to open the built-in editor or user configured editor.
  • ls/0 lists files. .pl files are links that may be edited by clicking or compiled using the context menu.
  • explain/1 explains the argument. Using a predicate indicator (e.g., append/3) lists (clickable) locations where the predicate is defined and where it is called.

The Epilog terminal

The Epilog terminal implements the full xterm-256color profile. This allows Prolog to exploit terminal based styling both in Epilog and when running on an external modern terminal. Epilog notably implements OSC 8 escapes that allow for embedded links and OSC 133 semantic marks that allow distinguishing the prompt, user input and process (Prolog) output. The terminal always operates using UTF-8 character encoding, supporting the full Unicode character set. On non-Windows systems, it uses a pty (Pseudo Terminal) to connect the Prolog thread I/O to the terminal. This implies that programs executed using shell/1 function normally. On Windows it uses named pipes to realise the communication between the Prolog thread and the Epilog console. Both shell/0,1 and process_create/3 exploit an API that causes Epilog under Windows to use Window the ConPTY API for connecting child processes. Key features:

  • OSC 133 semantic marks allow theming the the prompt, input and output as well as folding the output and copying the input, output or both. The resource prolog_terminal.fold_previous: @on or Settings/Fold previous command allow automatic folding of old commands, showing only the commands. The triangle next to a command and associated menu can be used to fold, unfold, copy, etc.
  • OSC 8 links connect messages to source locations through edit/1. Help pages displayed using help/1 may contain links. These too can be clicked, opening the related manual section.
  • Left-click can be used to set the caret in the current input line. Epilog also supports making a selection in the input line and delete, paste or type to replace the selection. This causes Epilog to send edit commands to the libedit commandline editor to achieve the desired effect.

Epilog profiles

Epilog terminals can be created using epilog/1. In addition, profiles may be defined using the multifile predicate epilog:profile/2. The system predefines two profiles: prolog for running a normal Prolog console and shell for running shell/0. epilog:profile/2 can be used to change properties of these built-in profiles or define new profiles.
The menu option File/New window with profile can be used to open a new console window. Below are some examples. Note that we can use the profile(Name) as first option to refine an existing profile.

:- multifile
   epilog:profile/2.

epilog:profile(shell,
               [ background(lemonchiffon)
               ]).
epilog:profile(top,
               [ profile(shell),
                 title('Process top'),
                 inject("top")
               ]).
epilog:profile(chat80,
               [ title('Run CHAT80'),
                 init(true),
                 inject(test_chat)
               ]).

Theme selection

The development tools define two themes: light and dark. If the SDL3 library reports that the system theme is dark, the dark theme is selected by default. Otherwise the light theme is the default. This can be overruled using the Settings/GUI Preferences menu which opens the editor on the XPCE defaults file. Ensure the file contains a line as below, where <theme> is one of light or dark or a user specified theme. A user specified theme is a file loadable as library(theme/<theme>).

display.theme: <theme>

The theme can also be controlled using the generic -D<flag>=<value> command line option of swipl and swipl-win, e.g.

swipl-win -Dtheme=dark

Clone this wiki locally