# Questions about IDE themes

**URL:** <https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817>\
**Category:** General\
**Created:** [September 4, 2023, 10:47am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817 "2023-09-04T10:47:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 4, 2023, 10:47am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/1 "2023-09-04T10:47:17Z")

</div>

I’ve included a theme for the SWI-Prolog IDE to my project. The new theme is based on library(theme/dark) and it can be found here:

> <https://github.com/stassa/louise/tree/master/themes>
>
> //github.com/stassa/louise/tree/master/themes

I’m trying to understand how I can change the background colour of highlighted variables in the SWI-Prolog IDE. To clarify, I mean the highlighting that appears when I place the cursor on a variable: all variables unifying with it in the same clause are highlighted with a new background colour. See the image below for an example.

![swi_highlight](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/4/4c41a6405f1036e8ddbf5f6f815d9c3ed65aa632.png)

As can be seen in the image above, the cyan background of the highlighting makes the variables’ text hard to read in combination with the orange colour of variables in my theme.

How can I change the colour of that highlight?

A separate question. To create my theme I simply copied library(theme/dark) into a new file and changed the new file, but this way I also copied the header with the original author’s name. What’s the right way to preserve the name of the original author of library(theme/dark), while not making it look like my own theme was written by the same person? That’s to avoid embarrasment to the original author, obviously.

Btw, thanks for naming the theme after one of my favourite TV series, that can’t be a coincidence 😛

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 4, 2023, 11:35am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/2 "2023-09-04T11:35:30Z")

</div>

> [@stassa.p](#):
>
> To clarify, I mean the highlighting that appears when I place the cursor on a variable

A little search in prolog\_mode.pl shows it uses a class variable `varmark_style` defined on class `emacs_prolog_mode`. In the dark mode file, this is handled using pce\_style/2. So, I  
think you need something like this:

```prolog
pce_style(emacs_prolog_mode, 
          [ varmark_style(style(background := purple,
                                    underline := true))
          ]).

```

> [@stassa.p](#):
>
> A separate question. To create my theme I simply copied library(theme/dark) into a new file and changed the new file, but this way I also copied the header with the original author’s name. What’s the right way to preserve the name of the original author of library(theme/dark), while not making it look like my own theme was written by the same person? That’s to avoid embarrasment to the original author, obviously.

I think the usual practice is to copy the file, add yourself as second author and state in the comment that this is a modified version of \< point at original \> If the modifications are not substantial you typically do not add yourself as author and just add a comment that you modified the file in such and such way.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 4, 2023, 11:42am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/3 "2023-09-04T11:42:22Z")

</div>

> [@jan](#):
>
> A little search in prolog\_mode.pl shows it uses a class variable `varmark_style` defined on class `emacs_prolog_mode`. In the dark mode file, this is handled using pce\_style/2. So, I  
> think you need something like this:

Thanks Jan. I don’t know what prolog\_mode.pl is and I don’t know anything about XPCE. Would it be useful to have the option controlling this background colour accessible through library(theme) files, instead?

> [@jan](#):
>
> I think the usual practice is to copy the file, add yourself as second author and state in the comment that this is a modified version of \< point at original \> If the modifications are not substantial you typically do not add yourself as author and just add a comment that you modified the file in such and such way.

The changes I made are not substantial and the file I copied is essentially a configuration file so I don’t think I need to add myself as an author. I already have comments documenting the changes I made in themes/dork, but I’ll add a note saying where the file was copied from originally.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 4, 2023, 11:49am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/4 "2023-09-04T11:49:12Z")

</div>

Sorry, I see you meant pce\_style, not pce\_type, so I can add that directly in the theme file. Thanks! I thought I had to edit prolog\_mode.pl (since pce\_type is not in the theme file- but then noticed it’s not in prolog\_mode either).

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 4, 2023, 11:57am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/5 "2023-09-04T11:57:03Z")

</div>

As a side node, I wrote the dark theme long ago as a quick hack. Most likely the theme is pretty bad from a color palette point of view. My eyes can’t handle dark themes …

So, if your theme makes more sense than the original, I’m happy to replace the original or add this theme to the core distribution and make it the default dark theme.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 4, 2023, 12:13pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/6 "2023-09-04T12:13:29Z")

</div>

> [@jan](#):
>
> So, if your theme makes more sense than the original, I’m happy to replace the original or add this theme to the core distribution and make it the default dark theme

That’s perfectly fine by me, as long as nobody else thinks my theme is an eyesore.

Btw, the correct syntax seems to be like this:

```prolog
pce_style(emacs_prolog_mode,
          [ varmark_style(style(background := grey30,
                     underline := true))
          ]).

```

Note the boolean.

I can’t find how to change the foreground colour, though. This kind of thing is simply ignored:

```prolog
pce_style(emacs_prolog_mode,
          [ varmark_style(style(background := grey30,
                                colour = yellow,
                                underline := true))
          ]).

```

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 4, 2023, 12:30pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/7 "2023-09-04T12:30:30Z")

</div>

> [@stassa.p](#):
>
> Note the boolean.

Thanks. Modifying the xpce styles through Prolog is somewhat hacky ☹

> [@stassa.p](#):
>
> `colour = yellow`

Should be `colour := yellow`. Might still have no effect as there is also the highlighting from the variable. I don’t recall the disambiguation rules.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 4, 2023, 1:15pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/8 "2023-09-04T13:15:38Z")

</div>

> [@jan](#):
>
> Should be `colour := yellow`. Might still have no effect as there is also the highlighting from the variable. I don’t recall the disambiguation rules.

Thanks - I can’t get that to work either.

Never mind, it’s not important. I can live with a grey background with underlining. That should be fine.

What would you like me to do? Make a pull request with the new dark theme?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 4, 2023, 1:32pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/9 "2023-09-04T13:32:21Z")

</div>

> [@stassa.p](#):
>
> What would you like me to do? Make a pull request with the new dark theme?

I guess we have two options. Ask people whether they think this theme is better first or simply add it to the distribution and see how people react.

Who is using the dark theme and are there people willing to evaluate @stassa.p’s version?

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 11, 2023, 11:17am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/10 "2023-09-11T11:17:11Z")

</div>

> [@jan](#):
>
> Who is using the dark theme and are there people willing to evaluate @stassa.p’s version?

Nobody I guess 🙂

I’m the opposite from you: I have to use a dark theme in everything because bright light hurts my eyes 😕

---

<div class="post-metadata">

**Author:** ![anon419083](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon419083](https://swi-prolog.discourse.group/u/anon419083)\
**Post date:** [September 11, 2023, 11:28am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/11 "2023-09-11T11:28:54Z")

</div>

I prefer dark themes as well. At the moment I usually use Visual Studio Code and not the built-in editor, but I did in the past, and maybe I could reuse it in the future, so I think it would be nice if your dark theme option could be available to users. It didn’t look bad from the preview-screenshot that you posted here

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 11, 2023, 12:09pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/12 "2023-09-11T12:09:13Z")

</div>

I’m tempted to simply add @stassa.p’s theme to the theme directory and leave it to the user to decide 🙂

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 11, 2023, 12:22pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/13 "2023-09-11T12:22:06Z")

</div>

Great! But I was trying to find how to change the style of arithmetic functions because they’re blue-on-black and that’s not very readable:

![functions](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/6/6b797ad2fd78d3426bf6ddfcfb62e0bc90426c51.png)

Any idea? I think everything else is probably OK to read (disregarding the awful taste).

EDIT: I’m looking in prolog\_mode, but not finding anything. I’m kind of lost in there to be honest 😕

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 11, 2023, 12:29pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/14 "2023-09-11T12:29:36Z")

</div>

> [@stassa.p](#):
>
> Any idea? I think everything else is probably OK to read (disregarding the awful taste).
> 
> EDIT: I’m looking in prolog\_mode, but not finding anything. I’m kind of lost in there to be honest 😕

You need to look into library(prolog\_colour). There you find colourise\_expression/3, which `calls colour_item(function, TB, FF-FT)` or `colour_item(no_function, TB, FF-FT)` for known/unknown functions. And at the end of the file we find

```prolog
def_style(function, [colour(blue)]).
def_style(no_function, [colour(red)]).

```

Redefining works like all the other things. They are not defined in the dark theme either. I should fix that (done; i’ll commit in a sec).

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [September 11, 2023, 12:29pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/15 "2023-09-11T12:29:39Z")

</div>

> [@stassa.p](#):
>
> how to change the style of arithmetic functions

You probably just need to define a style rule for `function` fragments, does that work?

> [@stassa.p](#):
>
> blue-on-black and that’s not very readable

Yup, it’s best to try maintaining a contrast ratio of at least 4.5 between the foreground and background colors ([Web Content Accessibility Guidelines (WCAG) 2.1](https://www.w3.org/TR/WCAG21/#contrast-minimum)), although that’s sometimes easier said than done 🙂

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 11, 2023, 12:41pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/16 "2023-09-11T12:41:16Z")

</div>

Aha, that’s where they all are :0

OK, here’s a screenshot with a good spread of different types of syntax in case anyone wants to chip in some ideas:

 ![spread](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/8/8559ebbcedb34b573e6cc6feeae72998a5c2e3b3.png)

I’ll update my repository in a sec, then feel free to add the dork theme to the official SWI themes. I chose the name very carefully 😛

EDIT: Done. Now we can all go back to taking over the world with logic-based AI \<3

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 12, 2023, 3:04pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/17 "2023-09-12T15:04:54Z")

</div>

Nice! There are a whole lot more colors though. I tried to write some code that illustrates most of them. This only covers the core though and is probably incomplete. Libraries may define additional style. Some with extensive style support are library(http/html\_write) and library(chr).

> **Code**
>
> ```prolog
> :- module(colour_demo, % module name
> [ colour_demo/2, % defined export
> no_colour_demo/2, % undefined export
> op(500, fx, &&) % exported operator
> ]).
> :- use_module(library(record)). % existing library, used
> :- use_module(library(utf8)). % existing library, not used
> :- use_module(no_such_file). % non-existing library
> 
> /** <module> Show PceEmacs colors for all syntactic elements
> 
> This code does not run. It is just to show syntax highlighting elements.
> */
> 
> %! colour_demo(+In, -Out) is det.
> %
> % Very simple demo clause trying to show as many as possible colors.
> 
> colour_demo(In, Out) :- % exported predicate
> must_be(atom, In), % autoloaded
> some_module:some_pred(SingleTon), % qualified call, singleton
> var(Out), % built-in
> not_defined, % call to undefined predicate
> format('From ~w~n', [In]), % Quoted atom
> current_prolog_flag(bounded, _), % existing flag
> current_prolog_flag(no_flag, _), % non-existing flag
> Out is sin(1r3) + % function, rational
> nofunc(42) * % undefined function, integer
> exp(2.7), % function, float
> p, % call to local predicate
> open(In, read, Stream,
> [ type(binary), % ok option
> type(error), % illegal value
> nooption(value) % no such option
> ]).
> 
> p :- % local predicate
> q,
> p. % recursive call
> 
> ssu(Head),
> var(Head) => % SSU guard, SSH neck
> Head = 42.
> 
> dcg(Head), [A] --> [A], more(Head). % DCG push back, DCG neck
> 
> not_called. % not called predicate
> 
> :- record
> point(x:integer,
> y:integer).
> 
> :- multifile
> prolog:message//1. % known hook
> 
> prolog:message(something(X)) -->
> ['Just some message: ~p'-[X] ].
> 
> ```

 ![image](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/b/b181541671b8f23786e4ea8fa4413a21b13ad7e3.png)

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 12, 2023, 5:00pm UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/18 "2023-09-12T17:00:43Z")

</div>

Oh, that’s nice! That could hopefully help others create their own themes also.

Another option is to look at popular themes for other editors and convert them to SWI themes. For example, I’ve seen a theme called “solarized” in pretty much every IDE I’ve worked with. I bet there must be some sort of archetypal theme that everybody is copying. I’ll see if I can find something about it (after work).

It might even be possible to automatically translate some popular themes into SWI’s format.

EDIT Oh, right. “Solarized” has its own wikipedia page:

> **[Solarized](https://en.wikipedia.org/wiki/Solarized)**
>
> Solarized is a color scheme for code editors and terminal emulators created by Ethan Schoonover. The scheme is available in a light and a dark mode. Packages that implement the color scheme have been published for many major applications, with some including the scheme pre-installed.
> Ethan Schoonover—a designer and software developer—began working on Solarized in 2010 after he installed a new code editor and could not find a color scheme he liked. He found the default white-on-black schemes of m...

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 13, 2023, 8:47am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/19 "2023-09-13T08:47:30Z")

</div>

Ok. Added the colour demo file into the repo, so we can extend it. You find it at [https://github.com/SWI-Prolog/swipl-devel/blob/cb1353db5087a860b2a07cc71b0db51c83278644/demo/colours.pl](https://github.com/SWI-Prolog/swipl-devel/blob/cb1353db5087a860b2a07cc71b0db51c83278644/demo/colours.pl).

If I read it correctly, Solarized is primarily a color palette, no? We have quite a few styles. Whether or not that is good or bad, I don’t know. Personally, I like all these styles. Even if you do not know the exact meaning, it tells you Prolog thinks these are different things and clicking on them should give you a basic idea what Prolog thinks about the role of a particular term. But, there seem to be people that like a lot less different styles. Possibly we need some (multiple) hierarchy?

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 14, 2023, 11:53am UTC](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817/20 "2023-09-14T11:53:04Z")

</div>

> [@jan](#):
>
> If I read it correctly, Solarized is primarily a color palette, no?

I think you’re right. I really don’t know anything about that sort of thing. But a colour palette might also be useful. When I was putting together that dork theme I struggled to find colours that went together well and made the text easy to read.

Are there any UX designers in the SWI community, people with experience of designing fetching but accessible interfaces and so on?

> [@jan](#):
>
> Possibly we need some (multiple) hierarchy?

How do you mean?

[Next page](https://swi-prolog.discourse.group/t/questions-about-ide-themes/6817.md?page=2)
