Question about styles for themes
I noticed that a lot of built-in themes are missing style settings for a few languages like PowerShell so I was hoping to submit some PRs to the GitHub source repository to fix this issue.
I found the reply by @PeterJones in the thread theme keywords: “WORD”, “KEYWORD” and “TYPE WORD” etc. very helpful to get a better understanding of how themes/styles work. I have some follow-up questions:
Q 1. Is each style (
COMMENT) for a language (
SQL) in a theme file supposed to have the same
styleIDas defined for that style in
stylers.model.xml? Is it OK to have 2 styles for the same language in a theme with the same
This is an excerpt for Python in
<WordsStyle name="F STRING" styleID="17" fgColor="2AA198" bgColor="002B36" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="F CHARACTER" styleID="17" fgColor="2AA198" bgColor="002B36" fontName="" fontStyle="0" fontSize="" />
Here’s how the same styles are defined in
<WordsStyle name="F STRING" styleID="16" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WordsStyle name="F CHARACTER" styleID="17" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
Both styles in
Solarized.xmlhave the same
F CHARACTERmatches what is in
F STRINGis different: 16 in
Q 2. Are all the styles that are defined for a given language listed in
stylers.model.xml? Or are there any undocumented styles?
A lot of themes (e.g.
Moonokai, etc.) show a
STRINGEOLstyle for Python but there is no corresponding style for Python in
khaki.xmlhas the following styles for SQL:
COMMENT LINE DOC,
IDENTIFIERbut they do not exist in
I would appreciate it if somebody knowledgeable in these matters could reply.
Themes are unfortunately treated stepmotherly, means the fewest, probably none, has all the information. Stylers.xml is the default theme of Npp and is maintained. If something is always different, I would trust the stylers.xml.
No, the style ids have to be unique for each lexer.
If a style ID is used often, the last one will probably overwrite the previous ones.
In general this works like this.
You have a document open and select the appropriate language in the Language Menu.
What happens is that npp now passes the style information defined for this language to Scintilla and the respective lexer only says which area in the code should be colored with which style.
Makes this sense?
Many of the themes are way out of date – they haven’t been updated in years. Since the underlying Scintilla component (which defines the language lexers) has been updated in that timeframe, some old styleIDs have been replaced with new ones.
stylers.xmlis derived) is the canonical source for what is known available. I do not know of any “hidden” styleIDs for a given language.
Two different styles (
F CHARACTER) require two different styleID, so if a theme lists the same ID for both, it is wrong.
(I see that @Ekopalypse beat me to most of these points, but I’ll hit submit anyway. ;-))
would appreciate it if somebody knowledgeable in these matters could reply.
I took my favorite style Obsidian.xml and added missing language and make the stlye IDs match
stylers.model.xmlof course keeping with the color scheme of obsidian. It was a manual process as others described since themes are not updated with Notepad++ the way
Thanks for your reply. It helps clear things up: no duplicate style IDs and if I see the same style for the same lexer has different IDs across themes, I should trust that the style IDs that match the value in
Thanks for your reply and your original post which was super-helpful. Yes, I noticed they are way out of date, e.g. last updated in 2006 for a theme I looked at today :)
Glad I clarified these points before I set off to do any work on this.
Yes, I’ve done this in the past too but when you update NotePad++, then the install won’t overwrite existing themes and you might have to merge changes to your theme if the release also updated the theme.