Question about styles for themes
-
Hi,
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 samestyleID
as defined for that style instylers.model.xml
? Is it OK to have 2 styles for the same language in a theme with the samestyleID
?This is an excerpt for Python in
Solarized.xml
:<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
stylers.model.xml
:<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.xml
have the samestyleID
(17). ThestyleID
forF CHARACTER
matches what is instylers.model.xml
but thestyleID
forF STRING
is different: 16 instylers.model.xml
not 17.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.
Bespin
,Moonokai
, etc.) show aSTRINGEOL
style for Python but there is no corresponding style for Python instylers.model.xml
. Similarly,khaki.xml
has the following styles for SQL:COMMENT LINE DOC
,DEFAULT
,IDENTIFIER
but they do not exist instylers.model.xml
.I would appreciate it if somebody knowledgeable in these matters could reply.
Thanks,
Ajay -
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.model.xml
(from whichstylers.xml
is 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 STRING
andF 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. ;-))
-
@AjayKMehta said in Question about styles for themes:
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.xml
of course keeping with the color scheme of obsidian. It was a manual process as others described since themes are not updated with Notepad++ the waystylers.model.xml
is.Cheers.
-
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
stylers.xml
are correct. -
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.