View source with formatted comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2019-2025, VU University Amsterdam
    7                              SWI-Prolog Solutions b.v.
    8    All rights reserved.
    9
   10    Redistribution and use in source and binary forms, with or without
   11    modification, are permitted provided that the following conditions
   12    are met:
   13
   14    1. Redistributions of source code must retain the above copyright
   15       notice, this list of conditions and the following disclaimer.
   16
   17    2. Redistributions in binary form must reproduce the above copyright
   18       notice, this list of conditions and the following disclaimer in
   19       the documentation and/or other materials provided with the
   20       distribution.
   21
   22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   23    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   25    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   26    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   27    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   28    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   29    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   30    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   32    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   33    POSSIBILITY OF SUCH DAMAGE.
   34*/
   35
   36:- module(prolog_theme_dark, []).   37
   38/** <module> SWI-Prolog theme file -- dark
   39
   40To enable the dark theme, use
   41
   42    :- use_module(library(theme/dark)).
   43*/
   44
   45:- multifile
   46    prolog:theme/1,
   47    prolog:console_color/2,
   48    pldoc_style:theme/3.   49
   50prolog:theme(dark).                             % make ourselves known
   51
   52:- if(current_predicate(win_window_color/2)).   53set_window_colors :-
   54    win_window_color(background, rgb(0,0,0)),
   55    win_window_color(foreground, rgb(255,255,255)),
   56    win_window_color(selection_background, rgb(0,255,255)),
   57    win_window_color(selection_foreground, rgb(0,0,0)).
   58
   59:- initialization
   60    set_window_colors.   61:- endif.   62
   63		 /*******************************
   64		 *       PROLOG MESSAGES	*
   65		 *******************************/
   66
   67% code embedded in messages (not used much yet)
   68prolog:console_color(var,                    [hfg(cyan)]).
   69prolog:console_color(code,                   [hfg(yellow)]).
   70% Alert level
   71prolog:console_color(comment,                [hfg(green)]).
   72prolog:console_color(warning,                [fg(yellow)]).
   73prolog:console_color(error,                  [bold, fg(red)]).
   74% toplevel truth value (undefined for well founded semantics)
   75prolog:console_color(truth(false),           [bold, fg(red)]).
   76prolog:console_color(truth(true),            [bold]).
   77prolog:console_color(truth(undefined),       [bold, fg(cyan)]).
   78prolog:console_color(wfs(residual_program),  [fg(cyan)]).
   79% trace output
   80prolog:console_color(frame(level),           [bold]).
   81prolog:console_color(port(call),             [bold, fg(green)]).
   82prolog:console_color(port(exit),             [bold, fg(green)]).
   83prolog:console_color(port(fail),             [bold, fg(red)]).
   84prolog:console_color(port(redo),             [bold, fg(yellow)]).
   85prolog:console_color(port(unify),            [bold, fg(blue)]).
   86prolog:console_color(port(exception),        [bold, fg(magenta)]).
   87% print message. the argument for debug(_) is the debug channel.
   88prolog:console_color(message(informational), [hfg(green)]).
   89prolog:console_color(message(information),   [hfg(green)]).
   90prolog:console_color(message(debug(_)),      [hfg(yellow)]).
   91prolog:console_color(message(Level),         Attrs) :-
   92    nonvar(Level),
   93    prolog:console_color(Level, Attrs).
   94
   95
   96		 /*******************************
   97		 *          ONLINE HELP		*
   98		 *******************************/
   99
  100%!  pldoc_style:theme(+Element, +Condition, -CSSAttributes) is semidet.
  101%
  102%   Return a set of CSS properties to modify on the specified Element if
  103%   Condition   holds.   color(Name)   is   mapped   to   fg(Name)   and
  104%   color(bright_Name) to hfg(Name).
  105
  106pldoc_style:theme(var,  true,                  [color(bright_cyan)]).
  107pldoc_style:theme(code, true,                  [color(bright_yellow)]).
  108pldoc_style:theme(pre,  true,                  [color(bright_yellow)]).
  109pldoc_style:theme(p,    class(warning),        [color(yellow)]).
  110pldoc_style:theme(span, class('synopsis-hdr'), [color(bright_green)]).
  111pldoc_style:theme(span, class(autoload),       [color(bright_green)]).
  112
  113
  114		 /*******************************
  115		 *           IDE TOOLS		*
  116		 *******************************/
  117
  118:- multifile
  119    pce:on_load/0,
  120    prolog_colour:style/2.  121
  122prolog_colour:style(Class, Style) :-
  123    style(Class, Style).
  124
  125%!  style(+Class, -Style)
  126%
  127%   Map style classes defined in   library(prolog_colour)  to xpce style
  128%   objects. After making modifications the effect can be tested without
  129%   restarting using this sequence:
  130%
  131%     1. Run ``?- make`` in Prolog
  132%     2. In the editor, use ``M-x reload_styles``
  133
  134style(goal(built_in,_),          [colour(cyan)]).
  135style(goal(imported(_),_),       [colour(cyan)]).
  136style(goal(autoload(_),_),       [colour(dark_cyan)]).
  137style(goal(global,_),            [colour(dark_cyan)]).
  138style(goal(undefined,_),         [colour(orange)]).
  139style(goal(thread_local(_),_),   [colour(magenta), underline(true)]).
  140style(goal(dynamic(_),_),        [colour(magenta)]).
  141style(goal(multifile(_),_),      [colour(pale_green)]).
  142style(goal(expanded,_),          [colour(cyan), underline(true)]).
  143style(goal(extern(_),_),         [colour(cyan), underline(true)]).
  144style(goal(extern(_,private),_), [colour(red)]).
  145style(goal(extern(_,public),_),  [colour(cyan)]).
  146style(goal(recursion,_),         [underline(true)]).
  147style(goal(meta,_),              [colour(red4)]).
  148style(goal(foreign(_),_),        [colour(darkturquoise)]).
  149style(goal(local(_),_),          []).
  150style(goal(constraint(_),_),     [colour(darkcyan)]).
  151style(goal(not_callable,_),      [background(orange)]).
  152
  153style(function,                  [colour(cyan)]).
  154style(no_function,               [colour(orange)]).
  155
  156style(option_name,               [colour('#3434ba')]).
  157style(no_option_name,            [colour(orange)]).
  158
  159style(head(exported,_),          [colour(cyan), bold(true)]).
  160style(head(public(_),_),         [colour('#016300'), bold(true)]).
  161style(head(extern(_),_),         [colour(cyan), bold(true)]).
  162style(head(dynamic,_),           [colour(magenta), bold(true)]).
  163style(head(multifile,_),         [colour(pale_green), bold(true)]).
  164style(head(unreferenced,_),      [colour(red), bold(true)]).
  165style(head(hook,_),              [colour(cyan), underline(true)]).
  166style(head(meta,_),              []).
  167style(head(constraint(_),_),     [colour(darkcyan), bold(true)]).
  168style(head(imported(_),_),       [colour(darkgoldenrod4), bold(true)]).
  169style(head(built_in,_),          [background(orange), bold(true)]).
  170style(head(iso,_),               [background(orange), bold(true)]).
  171style(head(def_iso,_),           [colour(cyan), bold(true)]).
  172style(head(def_swi,_),           [colour(cyan), bold(true)]).
  173style(head(_,_),                 [bold(true)]).
  174
  175style(module(_),                 [colour(light_slate_blue)]).
  176style(comment(_),                [colour(green)]).
  177
  178style(directive,                 [background(grey20)]).
  179style(method(_),                 [bold(true)]).
  180
  181style(var,                       [colour(orangered1)]).
  182style(singleton,                 [bold(true), colour(orangered1)]).
  183style(unbound,                   [colour(red), bold(true)]).
  184style(quoted_atom,               [colour(pale_green)]).
  185style(string,                    [colour(pale_green)]).
  186style(codes,                     [colour(pale_green)]).
  187style(chars,                     [colour(pale_green)]).
  188style(nofile,                    [colour(red)]).
  189style(file(_),                   [colour(cyan), underline(true)]).
  190style(file_no_depend(_),         [colour(cyan), underline(true),
  191                                  background(dark_violet)]).
  192style(directory(_),              [colour(cyan)]).
  193style(class(built_in,_),         [colour(cyan), underline(true)]).
  194style(class(library(_),_),       [colour(pale_green), underline(true)]).
  195style(class(local(_,_,_),_),     [underline(true)]).
  196style(class(user(_),_),          [underline(true)]).
  197style(class(user,_),             [underline(true)]).
  198style(class(undefined,_),        [colour(red), underline(true)]).
  199style(prolog_data,               [colour(cyan), underline(true)]).
  200style(flag_name(_),              [colour(cyan)]).
  201style(no_flag_name(_),           [colour(red)]).
  202style(unused_import,             [colour(cyan), background(pink)]).
  203style(undefined_import,          [colour(red)]).
  204
  205style(constraint(_),             [colour(darkcyan)]).
  206
  207style(keyword(_),                [colour(cyan)]).
  208style(identifier,                [bold(true)]).
  209style(delimiter,                 [bold(true)]).
  210style(expanded,                  [colour(cyan), underline(true)]).
  211style(hook(_),                   [colour(cyan), underline(true)]).
  212style(op_type(_),                [colour(cyan)]).
  213
  214style(qq_type,                   [bold(true)]).
  215style(qq(_),                     [colour(cyan), bold(true)]).
  216style(qq_content(_),             [colour(red4)]).
  217
  218style(dict_tag,                  [bold(true)]).
  219style(dict_key,                  [bold(true)]).
  220style(dict_function(_),          [colour(pale_green)]).
  221style(dict_return_op,            [colour(cyan)]).
  222
  223style(hook,                      [colour(cyan), underline(true)]).
  224style(dcg_right_hand_ctx,        [background('#609080')]).
  225
  226style(error,                     [background(orange)]).
  227style(type_error(_),             [background(orange)]).
  228style(syntax_error(_,_),         [background(orange)]).
  229style(instantiation_error,       [background(orange)]).
  230
  231style(table_option(_),           [bold(true)]).
  232style(table_mode(_),             [bold(true)]).
  233
  234
  235		 /*******************************
  236		 *         GUI DEFAULTS		*
  237		 *******************************/
  238
  239:- op(200, fy,  @).  240:- op(800, xfx, :=).  241
  242pce:on_load :-
  243    pce_set_defaults.
  244
  245pce_set_defaults :-
  246    pce_style(Class, Properties),
  247    member(Prop, Properties),
  248    Prop =.. [Name,Value],
  249    term_string(Value, String),
  250    send(@default_table, append, Name, vector(Class, String)),
  251    fail ; true.
  252
  253%!  pce_style(+Class, -Attributes)
  254%
  255%   Set XPCE class variales for Class. This  is normally done by loading
  256%   a _resource file_, but doing it from   Prolog keeps the entire theme
  257%   in a single file.
  258
  259% Epilog (next generation swipl-win)
  260
  261pce_style(terminal_image,
  262          [ background(black),
  263            colour(white),
  264            selection_style(style(background := yellow, colour := black))
  265          ]).
  266
  267% Dialog
  268
  269/* Needs support in xpce.
  270pce_style(text_item,
  271          [ colour(white),
  272            elevation(elevation('0,25mm', background := black))
  273          ]).
  274*/
  275
  276% PceEmacs
  277
  278pce_style(text_image,
  279          [ background(black),
  280            colour(white)
  281          ]).
  282pce_style(text_margin,
  283          [ background(grey20)
  284          ]).
  285pce_style(editor,
  286          [ selection_style(style(background := yellow, colour := black)),
  287            isearch_style(style(background := green, colour := black)),
  288            isearch_other_style(style(background := pale_turquoise,
  289                                      colour := black))
  290          ]).
  291
  292% Graphical debugger
  293
  294pce_style(prolog_stack_view,
  295          [ background(black)
  296          ]).
  297pce_style(prolog_stack_frame,
  298          [ background(black),
  299            colour(white)
  300          ]).
  301pce_style(prolog_stack_link,
  302          [ colour(white)
  303          ]).
  304pce_style(prolog_bindings_view,
  305          [ background_active(black),
  306            background_inactive(grey50)
  307          ]).
  308pce_style(prolog_source_structure,
  309          [ background(black),
  310            colour(white)
  311          ]).
  312
  313%!  prolog_source_view:port_style(+Port, -StyleAttributes)
  314%
  315%   Override style attributes for indicating  a   specific  port  in the
  316%   source view. Ports are:  `call`,   `break`,  `exit`, `redo`, `fail`,
  317%   `exception`, `unify`, `choice`, `frame and `breakpoint`.
  318
  319:- multifile
  320    prolog_source_view:port_style/2.  321
  322prolog_source_view:port_style(call, [background(forest_green), colour(black)]).
  323prolog_source_view:port_style(fail, [background(indian_red),   colour(black)]).
  324prolog_source_view:port_style(_,    [colour(black)])