Make multi-select background & caret colour customizable

Fix #14302, close #14350
This commit is contained in:
Don Ho 2023-11-13 04:36:33 +01:00
parent c7e1162f23
commit 812745d850
4 changed files with 30 additions and 13 deletions

View File

@ -2868,25 +2868,45 @@ void ScintillaEditView::performGlobalStyles()
selectColorBack = pStyle->_bgColor; selectColorBack = pStyle->_bgColor;
selectColorFore = pStyle->_fgColor; selectColorFore = pStyle->_fgColor;
} }
execute(SCI_SETSELBACK, 1, selectColorBack); //execute(SCI_SETSELBACK, 1, selectColorBack);
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_BACK, selectColorBack); execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_BACK, selectColorBack | 0xFF000000); // SCI_SETSELBACK is deprecated
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_BACK, selectColorBack | 0xFF000000);
COLORREF selectMultiSelectColorBack = liteGrey;
pStyle = stylers.findByName(TEXT("Multi-selected text color"));
if (pStyle)
{
selectMultiSelectColorBack = pStyle->_bgColor;
}
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_ADDITIONAL_BACK, selectMultiSelectColorBack | 0xFF000000);
if (nppParams.isSelectFgColorEnabled()) if (nppParams.isSelectFgColorEnabled())
{ {
execute(SCI_SETSELFORE, 1, selectColorFore);
long alphaSelectColorFore = selectColorFore; long alphaSelectColorFore = selectColorFore;
alphaSelectColorFore |= 0xFF000000; // add alpha color to make DirectWrite mode work alphaSelectColorFore |= 0xFF000000; // add alpha color to make DirectWrite mode work
//execute(SCI_SETSELFORE, 1, selectColorFore);
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_TEXT, alphaSelectColorFore); // SCI_SETSELFORE is deprecated
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_TEXT, alphaSelectColorFore); execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_TEXT, alphaSelectColorFore);
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, alphaSelectColorFore);
} }
COLORREF caretColor = black; COLORREF caretColor = black;
pStyle = stylers.findByID(SCI_SETCARETFORE); pStyle = stylers.findByName(L"Caret colour");
if (pStyle) if (pStyle)
{ {
caretColor = pStyle->_fgColor; caretColor = pStyle->_fgColor;
} }
execute(SCI_SETCARETFORE, caretColor); //execute(SCI_SETCARETFORE, caretColor);
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET, caretColor | 0xFF000000); // SCI_SETCARETFORE is deprecated
COLORREF multiEditCaretColor = darkGrey;
pStyle = stylers.findByName(L"Multi-edit carets color");
if (pStyle)
multiEditCaretColor = pStyle->_fgColor;
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_ADDITIONAL, multiEditCaretColor | 0xFF000000);
COLORREF edgeColor = liteGrey; COLORREF edgeColor = liteGrey;
pStyle = stylers.findByName(TEXT("Edge colour")); pStyle = stylers.findByName(TEXT("Edge colour"));

View File

@ -422,11 +422,6 @@ public:
static UserDefineDialog * getUserDefineDlg() {return &_userDefineDlg;}; static UserDefineDialog * getUserDefineDlg() {return &_userDefineDlg;};
void setCaretColorWidth(int color, int width = 1) const {
execute(SCI_SETCARETFORE, color);
execute(SCI_SETCARETWIDTH, width);
};
void beSwitched() { void beSwitched() {
_userDefineDlg.setScintilla(this); _userDefineDlg.setScintilla(this);
}; };

View File

@ -1493,7 +1493,9 @@
<WidgetStyle name="Current line background colour" styleID="0" bgColor="E8E8FF" /> <WidgetStyle name="Current line background colour" styleID="0" bgColor="E8E8FF" />
<!-- In below rule 'fgColor' attribute for 'Selected text colour' can be unlocked with a enableSelectFgColor.xml file --> <!-- In below rule 'fgColor' attribute for 'Selected text colour' can be unlocked with a enableSelectFgColor.xml file -->
<WidgetStyle name="Selected text colour" styleID="0" bgColor="C0C0C0" fgColor="000000" /> <WidgetStyle name="Selected text colour" styleID="0" bgColor="C0C0C0" fgColor="000000" />
<WidgetStyle name="Caret colour" styleID="2069" fgColor="8000FF" /> <WidgetStyle name="Multi-selected text color" styleID="0" bgColor="C0C0C0" />
<WidgetStyle name="Caret colour" styleID="0" fgColor="8000FF" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="404040" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="80FFFF" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="80FFFF" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="808080" bgColor="E4E4E4" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="808080" bgColor="E4E4E4" fontName="" fontStyle="0" fontSize="" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="E0E0E0" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="E0E0E0" />