Scintilla and Dark mode

I wanted to use a Scintilla text editor. That works fine, thanks to Christian.
But… the authors of Scintilla seem to ignore what is Dark mode…

I can change many colors but…
I don’t see how to change the background color of the markers’s margin.
I can’t change the color of the caret despite the fact we have properties to do that.

Is there someone who succeeded in using Scintilla in dark mode (with correct colors) ?

Yes. It’s still early days for me in a new project I’m playing with, but I’m able to have Scintilla switch between light & dark mode, on macOS (note: I don’t do windows).

If you’re switching between light & dark on the fly (whether through code, or System Settings > Appearance), I found that you have to “refresh” your colour assignments deliberately, because Scintilla doesn’t detect the change on it’s own.

I just woke up, so I’ll see about adding some snippets of code for your other questions a little later.

OK, thanks
But how do you set the margin color (the one where there is a dot, not the line numbers) ?

Self.SetFoldMarginColor(True, &cE0E0E000)
Self.SetFoldMarginHighlightColor(True, &cE0E0E000)

In my case, I set the above two methods to the same colour value, because I don’t like the cross-hatch highlight background pattern. I also use the same colour for the line number background to make both gutters blend together (which I think is easier to look at).

// caret (cursor) visibility, colour and behaviour
Self.CaretForeColor = &c00000000
Self.CaretWidth = 2
Self.CaretStyle = DesktopScintillaControlMBS.kCaretStyleLine

Note: the above is called after Self.StyleClearAll() and when most of the other colour assignments are applied.

Oh yes : Self.CaretForeColor = &c00000000 is the default setting
but if you want to set it in white Self.CaretForeColor = &cffffff (in DarkMode), well… it is still in black…
CaretForeColor = color.TextColor → still in black
CaretForeColor = whatever you want → still in black

In fact, whatever the caret property you set, it does absolutely nothing :
self.CaretStyle = DesktopScintillaControlMBS.kCaretStyleLine
self.CaretForeColor = &cff000000
self.CaretLineVisible = True
self.CaretLineBackColor = &c7f0000ff
self.CaretWidth = 4

the caret is still black, 1 pixel width and without background

Oh yes : this is ok ! Thanks !

Without seeing the code of your project it is hard to say why it’s not working. I suspect it is where/when you are setting these properties.

I slightly modified @Christian_Schmitz’s ScintillaTest example project to enable some of the Caret properties in the following download. See the SetupXojo() method - near the bottom of the code window.

Note: I used Xojo 2024r1.1 on macOS 14.6.1 to edit the example. I hope this helps.

Edited: I used MBS 24.3 to edit & test the example, but I’m also using Scintilla with MBS 24.4pr2 with Xojo 2024r2.1

ScintillaTest.xojo_binary_project.zip (30.8 KB)

Thanks for your help Scott
That’s OK now for me.

Just one problem
Setting this color works only the first time :

if color.IsDarkMode then
self.Style(SCE_MYSQL_DEFAULT).ForeColor = &cFFFFFF00
else
self.Style(SCE_MYSQL_DEFAULT).ForeColor = &c00000000
end if

—> App launched in dark mode : That’s OK


—> Switch to light mode : the color remains white

I have to quit the application and relaunch it to get the correct color.