user defined language and dark backgrounds

  • jdjdjd

    jdjdjd - 2012-03-15

    When using a theme with a dark background, and I switch to a user defined language (for example, the default one called "User-Defined"), the result doesn't look good.  In particular, the text is shown as dark characters on a light background, but all the whitespace is shown using the theme's dark background.  Each word looks like a light colored rectangle floating on a dark background.

    This is not an issue with the built-in languages. 

    Is there any way to make the User-Defined language work as well as the built-in languages in this respect?


    • jeff
  • cchris

    cchris - 2012-03-18

    Actually this is how it is intended to work… What sort of display would you like to achievve?


  • jdjdjd

    jdjdjd - 2012-03-19

    Hi CChris,

    Perhaps I didn't describe this very well.  Take a look at this image and tell me if this looks correct:

    How would l like this to look?  If you switch the language from User Defined to "Normal", it looks much better:

    • Jeff
  • Loreia2

    Loreia2 - 2012-03-19

    Hi Jeff,

    AFAIK the only thing you can do is to create two separate UDL definitions of your language (one for dark, one for light background) and manually select appropriate UDL entry when opening the file.


  • mattsnowboard

    mattsnowboard - 2013-09-19

    Why don't UDL's override the background for whitespace? Seems like the simplest solution to me. I guess I'll just make dark versions of the ones I need though...

  • Spencer Williams

    I've been searching all over the Internet for a solution to this very problem. It would appear that when you make user-defined styles for Notepad++, you have to choose a background color for your words, operators, etc. I've not yet found a way to use a transparent background like all of the pre-defined languages. Basically, users will just have to turn on the global background in the Style Configurator to conform user-defined styles to their current style. But this will disable any custom backgrounds for other language elements.

    Again, the real solution would be for Notepad++ to let you either choose Transparent or No Background or something for the elements of user-defined languages. I'll be on the lookout...

    • Matthew

      Matthew - 2015-01-14

      I'm not sure if this was possible at the time of your post, but it is now, though undocumented apparently.

      Simply open the UDL dialog, click on the relevant "Styler" button, then right-click the background color tile. This will instantly update the style in any corresponding open file you may have showing.

      Note: I know this is an old thread, but it's for the benefit of other Googlers like me. :)

  • Loreia2

    Loreia2 - 2013-09-23

    Hi Spencer,

    I just implemnted this feature this weekend. In version 3.0, UDL will aloow users to select custom or theme background color. If users request so during beta testing phase, I can even extend this to foreground color and font options too.


  • David Piepgrass

    David Piepgrass - 2014-01-05

    If you ask me, the real solution is for Notepad++ to offer a "dark background" option that automatically inverts the luminances of the colors with code like this:

    /// Inverts a color's brightness without changing its hue.
    /// Dark red becomes light red, light brown becomes dark brown, etc.
    public static Color InvertLumOnly (Color c) {
        int r = c.R, g = c.G, b = c.B;
        return Color.FromArgb(
            InvertOne(r,g,b), InvertOne(g,r,b), InvertOne(b,g,r));
    private static int InvertOne (int C, int X, int Y) {
        if (C >= X) { 
            if (X >= Y)
                return 255 - Y;
                return 255 - X + Math.Min(C - Y, 0);
        } else { // C < X
            if (X <= Y)
                return 255 - Y;
                return 255 - X + Math.Max(C - Y, 0);

    Then you could switch to dark colors with a simple checkbox in the options, no need for everyone to create special dark themes (unless they want to). Mind you, this code doesn't work well for all colors (not great performance on yellows and blues) but I'm sure that could be fixed.

    But of course, like mattsnowboard said, the simplest fix would be for Notepad++ to apply the UDL's default background to whitespace.

    Last edit: David Piepgrass 2014-01-05

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks