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 same styleID as 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 styleID?

    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 same styleID (17). The styleID for F CHARACTER matches what is in stylers.model.xml but the styleID for F STRING is different: 16 in stylers.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 a STRINGEOL style for Python but there is no corresponding style for Python in stylers.model.xml. Similarly, khaki.xml has the following styles for SQL: COMMENT LINE DOC, DEFAULT, IDENTIFIER but they do not exist in stylers.model.xml.

    I would appreciate it if somebody knowledgeable in these matters could reply.


  • @AjayKMehta

    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?

  • @AjayKMehta ,

    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 which stylers.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 and 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. ;-))

  • @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 matchstylers.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 way stylers.model.xml is.


  • @Ekopalypse

    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.

  • @PeterJones

    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.

  • @Michael-Vincent

    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.

Log in to reply