Found text is hard to read

79 views
Skip to first unread message

Andrew Truckle

unread,
May 11, 2024, 12:32:56 PMMay 11
to scintilla-interest
I am using the default XML lexer with the SciTE colour scheme for syntax highlighting.

And, my editor supports Find / Find Next etc. That functionality is fine it itself.

The problem is when it highlights found text. Eg:


Scintilla.png

It is not readable. How can we adjust things so that the highlighted text is always readable for the user?

Thank you.

Neil Hodgson

unread,
May 12, 2024, 7:30:38 PMMay 12
to Scintilla mailing list
Andrew Truckle:

> It is not readable. How can we adjust things so that the highlighted text is always readable for the user?

You should look at selection styling options starting with
https://www.scintilla.org/ScintillaDoc.html#CaretAndSelectionStyles

Neil

Andrew Truckle

unread,
May 13, 2024, 12:11:31 PMMay 13
to scintilla-interest
Thanks for the link to those properties. My concern is that I am rubbish with colours. And it doesn't help with being colourblind. So I was hoping to find one-fits-all solution that would just work for everyone, whatever syntax highlighter is active, no matter what text colour is present.

But I appreciate being made aware of those properties.

marc

unread,
May 13, 2024, 1:10:34 PMMay 13
to scintilla-interest

Neil Hodgson

unread,
May 13, 2024, 6:31:43 PMMay 13
to Scintilla mailing list
Andrew Truckle:

> So I was hoping to find one-fits-all solution that would just work for everyone, whatever syntax highlighter is active, no matter what text colour is present.

A fixed selection colour won't work well with varying background colours, such as when there is a choice between light and dark themes. Mid-scale backgrounds like grey are even harder to find a good matching selection colour.

Neil

Andrew Truckle

unread,
May 15, 2024, 1:01:57 PMMay 15
to scintilla-interest
Neil

Thanks for explanation.

Marc

Thanks for suggestion. Sounds sensible. Will investigate!

Tom Doan

unread,
May 23, 2024, 11:49:50 AMMay 23
to scintilla...@googlegroups.com
According to the docs:

SCI_FORMATRANGE can be used to draw the text onto a display surface which can include a printer display surface. Printed output shows text styling as on the screen, but it hides all margins except a line number margin. Markers do not appear in a margin but will change line background colour. The selection and caret are hidden.


Is there a reason that you can't (optionally) hide the line numbers? I couldn't see any setting that would suppress those.

Tom Doan
---
Estima
2717 Harrison St
Evanston, IL 60201
USA
  

Andrew Truckle

unread,
May 23, 2024, 12:51:46 PMMay 23
to scintilla-interest
@marc

I have now added the following code (using your linked repository as a guide):

auto ConvertColorRefToColorAlpha = [](COLORREF color, uint8_t alpha = 255) -> uint32_t {
// Extract RGB components from the COLORREF value
const uint8_t red = GetRValue(color);
const uint8_t green = GetGValue(color);
const uint8_t blue = GetBValue(color);

// Combine into ARGB format
const uint32_t coloralpha = (alpha << 24) | (blue << 16) | (green << 8) | red;
return coloralpha;
};

// Retrieve the system highlight color
const auto highlightColor = ConvertColorRefToColorAlpha(::GetSysColor(COLOR_HIGHLIGHT));
// Retrieve the system highlight text color
const auto highlightTextColor = ConvertColorRefToColorAlpha(::GetSysColor(COLOR_HIGHLIGHTTEXT));

m_edit.SetSelectionLayer(Scintilla::Layer::UnderText);
m_edit.SetElementColour(Scintilla::Element::SelectionText, highlightTextColor);
m_edit.SetElementColour(Scintilla::Element::SelectionBack, highlightColor);
m_edit.SetElementColour(Scintilla::Element::SelectionAdditionalBack, highlightColor);
m_edit.SetElementColour(Scintilla::Element::SelectionSecondaryBack, highlightColor);
m_edit.SetElementColour(Scintilla::Element::SelectionInactiveBack, highlightColor);


This does appear better:

editor.png

But, I am still not sure about the way I have used highlightTextColor.

Andrew Truckle

unread,
May 24, 2024, 1:18:24 PMMay 24
to scintilla-interest
@marc
Do you also set these colours?

SC_ELEMENT_SELECTION_SECONDARY_TEXT : colouralpha

SC_ELEMENT_SELECTION_INACTIVE_TEXT : colouralpha

?


Neil Hodgson

unread,
May 24, 2024, 6:30:09 PMMay 24
to Scintilla mailing list
Tom Doan:

> Is there a reason that you can't (optionally) hide the line numbers? I couldn't see any setting that would suppress those.

Temporarily turn the line number margin into another type while printing as other types aren't printed. Or make it 0-width while printing.

Neil

Reply all
Reply to author
Forward
0 new messages