Re: dark theme
andrew strain <[email protected]> Sat, 6 May 2023 06:20:46 -0700 (PDT)
| Newsgroups | gmane.editors.scite.general |
|---|---|
| Message-ID | <[email protected]> |
Neil :
I am very pleased to see how that is done. It is also remarkable how Scite
can so snappily refresh the theme when my lua script rewrites the
properties. The results of the simple formula was a bit lack luster on the
perl theme but even it would be a relief to users with visual difficulties.
I dug out my pre-lua function that was patched in for conversion and I
think it can do better. It is an odd blob of code but works well to
demonstrate.
https://gist.github.com/strainer/ca20642e9a091634f685915bd6b90e51
In my lua theme adjusting system, numerous styles have been ad-hoc
re/defined from the rest of the properties in my user properties, and the
ones which I use are masked with propertie symbols like $(th.greymauve).
All the specials like, line nos, indent guides, even transparent indication
of selections invert nicely. The transparent selection options may need
tweaked to work nicely. With an inbuilt darkmode though, its much easier to
cope with all the disparate language themes.
Andrew
On Saturday, 6 May 2023 at 00:10:07 UTC+1 Neil Hodgson wrote:
> Andrew:
>
> The way I see it dark mode in its very essence requires a non-literal
> interpretation of config colour strings. If that interpretation can not
> happen within the function which converts the colour strings to Scintilla
> colour type on properties refresh, then all the various colour data would
> need to be chased up and converted after properties refresh, somehow.
>
>
> Colour strings are not always resolved to colour integer values at read
> time. Properties are read and reread at different events in an effort to
> optimize performance.
>
> Its likely that different contexts (edit pane, output pane, windows
> chrome, printing) will have different transformations.
>
> Around scite version 2.20 I had hacked the colour(alpha)fromstring
> functions to adapt to state to enable darkmode, contrast, and saturation
> adjustment. If there was any hack to allow it now, I would think it
> worthwhile to create a darkmode but the StyleDefinition object someways
> seems to guard against it.
>
>
> A non-hacky implementation will need to build infrastructure to support
> colour translations.
>
> Perhaps start from this basic change to style fore and back. It also needs
> the default colours to be set explicitly
> (style.*.32=$(font.base),back:#FFFFFF,fore:#000000) since SciTE's standard
> properties provide differences from Scintilla's built-in black-on-white
> colours. This simple InvertLight function produces poor results in many
> cases.
>
> Neil
>
> diff -r 3b944ea15374 src/SciTEBase.h
> --- a/src/SciTEBase.h Sat Apr 22 18:57:42 2023 +1000
> +++ b/src/SciTEBase.h Sat May 06 08:46:59 2023 +1000
> @@ -392,6 +392,8 @@
> bool wrapOutput;
> SA::Wrap wrapStyle;
> SA::IdleStyling idleStyling;
> + enum class ColourTranslation { none, invertLight } colourTranslation =
> ColourTranslation::invertLight;
> + SA::Colour TranslateColour(SA::Colour colour) const noexcept;
> SA::Alpha alphaIndicator;
> bool underIndicator;
> std::string foldColour;
> diff -r 3b944ea15374 src/SciTEProps.cxx
> --- a/src/SciTEProps.cxx Sat Apr 22 18:57:42 2023 +1000
> +++ b/src/SciTEProps.cxx Sat May 06 08:46:59 2023 +1000
> @@ -342,6 +342,27 @@
> return sd;
> }
>
> +namespace {
> +
> +constexpr Scintilla::Colour InvertLight(Scintilla::Colour c) noexcept {
> + const unsigned int red = c & 0xffU;
> + const unsigned int green = (c >> 8) & 0xffU;
> + const unsigned int blue = (c >> 16) & 0xffU;
> + const unsigned int newRed = (green + blue) / 2;
> + const unsigned int newGreen = (red + blue) / 2;
> + const unsigned int newBlue = (red + green) / 2;
> + return ColourRGB(0xffU - newRed, 0xffU - newGreen, 0xffU - newBlue);
> +}
> +
> +}
> +
> +Scintilla::Colour SciTEBase::TranslateColour(Scintilla::Colour colour)
> const noexcept {
> + if (colourTranslation == ColourTranslation::invertLight) {
> + return InvertLight(colour);
> + }
> + return colour;
> +}
> +
> void SciTEBase::SetOneStyle(GUI::ScintillaWindow &win, int style,
> std::string_view definition) {
> const StyleDefinition sd(definition);
> if (sd.specified & StyleDefinition::sdItalics)
> @@ -357,9 +378,9 @@
> win.StyleSetCheckMonospaced(style, inMonospacedList);
> }
> if (sd.specified & StyleDefinition::sdFore)
> - win.StyleSetFore(style, sd.Fore());
> + win.StyleSetFore(style, TranslateColour(sd.Fore()));
> if (sd.specified & StyleDefinition::sdBack)
> - win.StyleSetBack(style, sd.Back());
> + win.StyleSetBack(style, TranslateColour(sd.Back()));
> if (sd.specified & StyleDefinition::sdSize)
> win.StyleSetSizeFractional(style, sd.FractionalSize());
> if (sd.specified & StyleDefinition::sdEOLFilled)
>
>
--
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scite-interest/1bfc815b-6cc7-4697-b648-a957161ffaben%40googlegroups.com.