There is now some detection of the system’s dark mode and high contrast mode on Windows and GTK. These are stored into the global properties Appearance and Contrast. Appearance is 0 for light mode and 1 for dark mode. Contrast is 1 for high contrast mode or 0 for normal mode.
These may be used in properties files to choose different colours or other attributes such as making the caret wider in high contrast mode. There could be different ways of using properties but, initially, the “if” statement has been modified to take an expression and an “=“ function added to allow comparisons.
For example, the caret colour can be changed for dark mode with:
if $(= $(Appearance);1)
caret.fore=#FFFFFF
Since “if” statements are evaluated when reading properties files, a change to the Appearance or Contrast properties causes a re-read of all active properties files which is a fairly heavy operation. Its likely that users change these states rarely.
The GTK code reads the gtk-theme-name setting and treats a “-dark” suffix as dark. A HighContrast prefix sets high contrast mode and “HighContrastInverse” sets both dark and high contrast. While name matching is likely to be flakey, it is used by other applications. These are checked when a settings object receives a “notify::gtk-theme-name” signal.
The Win32 code reads the registry at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme for light / dark and the SPI_GETHIGHCONTRAST system parameter for high contrast. These are checked whenever a WM_SETTINGCHANGE or WM_SYSCOLORCHANGE message is received.
The commit:
https://sourceforge.net/p/scintilla/scite/ci/09b21fe9d954ba1b350289fdbe7b16d59f7134ac/
There is no use of this feature in the default properties files as I expect that it will change further and ways to use it will also evolve.
There is no way to force a mode and its likely there should be a way for the user to control it more.
Available from the Mercurial repositories:
hg clone
http://hg.code.sf.net/p/scintilla/code scintilla
hg clone
http://hg.code.sf.net/p/scintilla/scite
and can be tried from
https://www.scintilla.org/scite.zip Source
https://www.scintilla.org/wscite.zip Windows executable (64-bit)
Some settings to experiment with:
# Appearance 0=light, 1=dark
if $(= $(Appearance);0)
text.back=back:#FFFFFF
text.fore=fore:#000000
text.fore.comment=fore:#007F00
text.fore.string=fore:#7F007F
text.fore.operator=fore:#000000
text.fore.other.operator=fore:#B06000
text.fore.preprocessor=fore:#7F7F00
text.fore.brace.good=fore:#0000FF
text.fore.brace.bad=fore:#FF0000
caret.fore=#000000
selection.back=#000000
selection.alpha=32
word.indicator=colour:#0080FF,outlinealpha:100,fillalpha:40
guide.indent=fore:#C0C0C0,back:#FFFFFF
if $(= $(Appearance);1)
text.back=back:#000000
text.fore=fore:#FFFFFF
text.fore.comment=fore:#80FF80
text.fore.string=fore:#FF00FF
text.fore.operator=fore:#FFFFFF
text.fore.other.operator=fore:#E08000
text.fore.preprocessor=fore:#FFFF00
text.fore.brace.good=fore:#20A0FF
text.fore.brace.bad=fore:#FF0000
caret.fore=#FFFFFF
selection.back=#FFFFFF
selection.alpha=64
word.indicator=colour:#20A0FF,outlinealpha:180,fillalpha:120
guide.indent=fore:#606060,back:#000000
# Default
style.props.0=$(text.back),$(text.fore)
# Comment
style.props.1=$(text.back),$(text.fore.comment),$(font.comment)
# Section
style.props.2=$(text.back),$(text.fore.string),eolfilled
# Assignment operator
style.props.3=$(text.back),$(text.fore.other.operator)
# Default value (@)
style.props.4=$(text.back),$(text.fore.preprocessor)
# Key
style.props.5=$(text.back),$(text.fore)
style.props.32=$(font.base),$(text.back),$(text.fore)
Neil