Override Default Style Colors in Custom Language
Paulo Roberto Tomasi last edited by
I would like help to to the following issue:
- I set these parameters in Settings > Style Configurator > Global Styles > Default Styles:
Foreground color = White
Background color = Black
When I open common .TXT files, all looks fine, background is black, all the text is white.
But, when I open. RSC files - that have a Customized User Language (RouterOS), the background follows the Default Style (like the image below).
Is it possible to override the Default Style background in the Customized User Language to force white as background color and keep all the colorized parameters defined in the language file?
PeterJones last edited by
Unfortunately, the design of the User Defined Language styler is such that the blank space (what you have called “the background”) is inherited from Settings > Style Configurator > Global Styles > Default Styles; there is no way to override that on a per-language basis.
The design philosophy of the Notepad++ language-coloring (lexer styles) is that you would want all your different languages (builtin or user-defined) to use basically the same theme, with only a difference in syntax and keywords. As such, that global background doesn’t have an override in the per-langauge settings (whether built-in or UDL).
However, if you are willing to install a scripting plugin, like PythonScript, it might be doable. I will call in an expert: @Ekopalypse (or any other PythonScript guru), is the background style (as compared to a particular style’s background color) indepdently controllable? Could you do one of your PythonScript magics to see that the active file is a RouterOS
.RSCfile, and change that background style on a per-language basis?
@Paulo-Roberto-Tomasi : I don’t know when @Ekopalypse or other PS gurus might next login, so it may be a few days before you get a reply. Plus, we’re getting near end-of-year celebrations, so @Ekopalypse might be busy with family stuff and not reading/answering in the forum. Hopefully, you can be patient. If I find the time, I might play around and try to find a solution, but I have less time for such investigations than I used to, which is why I tagged another regular who can often quickly engineer a PS solution to problems like these
PeterJones last edited by
So, I gave it a shot today… Unfortunately, while I was reminded that there’s a way to get the default background color (NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, I cannot find a Scintilla or Notepad++ message that sets that color; and without that interface, I don’t see how to change the main editor background on-the-fly, dependent on language.
That’s why I originally asked for @Ekopalypse’s help, because he’s got either a better memory and knowledge of what’s available, or is better at searching the docs to find the right command.
For my own experiments, I have not yet found the right command available to be able to accomplish this. But maybe a better expert (or someone who can read better than I can) can step in with a brilliant idea.
Ekopalypse last edited by Ekopalypse
You’re right, I’m very busy at the moment, but admittedly it’s my own fault.
I am experimenting with learning several programming languages at the same time.
Puuhh - I don’t know why I decided to do this …
If I understand correctly, the desire is to use the UDL language
with a different default background colour.
Hmmm … never experimented with that before.
And as you say, that’s actually the opposite of why people use themes.
I imagine this could be solved via the default style id (=32).
Could it be that the reason is that you don’t want to manually
adjust the theme to your own used default theme?
If so, then I can say that the changes are not that difficult.
For example, click with the
rightmouse button in one of the colour boxes,
now shown hatched, which means that the respective theme
back- or foreground colour is used instead of the udf defined colour.
If this is not what you are looking for, would you mind to
explain in detail what you are trying to achieve,
i.e. under what circumstances should what be done?
Ekopalypse last edited by
Something like this might work
from Npp import editor, notepad, NOTIFICATION def on_buffer_activated(args): if notepad.getLanguageName(notepad.getLangType()) == 'udf - RouterOS': editor.styleSetBack(32, (255,255,255)) else: editor.styleSetBack(32, notepad.getEditorDefaultBackgroundColor()) notepad.clearCallbacks() notepad.callback(on_buffer_activated, [NOTIFICATION.BUFFERACTIVATED])
ArkadiuszMichalski last edited by
I remember having a similar problem in the past, I wanted the default colors everywhere except my UDL. Thanks for the tip above, I will check later if it works for me.