Skip to content

Commit

Permalink
Make multi-select background & caret colour customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Nov 14, 2023
1 parent c7e1162 commit 812745d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion PowerEditor/src/NppBigSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3081,7 +3081,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
_subEditView.setCRLF();
return TRUE;
}

case NPPM_INTERNAL_NPCFORMCHANGED:
{
_mainEditView.setNpcAndCcUniEOL();
Expand Down
32 changes: 26 additions & 6 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2868,25 +2868,45 @@ void ScintillaEditView::performGlobalStyles()
selectColorBack = pStyle->_bgColor;
selectColorFore = pStyle->_fgColor;
}
execute(SCI_SETSELBACK, 1, selectColorBack);
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_BACK, selectColorBack);
//execute(SCI_SETSELBACK, 1, selectColorBack);
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_BACK, selectColorBack | 0xFF000000); // SCI_SETSELBACK is deprecated
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_BACK, selectColorBack | 0xFF000000);

if (nppParams.isSelectFgColorEnabled())

COLORREF selectMultiSelectColorBack = liteGrey;
pStyle = stylers.findByName(TEXT("Multi-selected text color"));
if (pStyle)
{
execute(SCI_SETSELFORE, 1, selectColorFore);
selectMultiSelectColorBack = pStyle->_bgColor;
}
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_ADDITIONAL_BACK, selectMultiSelectColorBack | 0xFF000000);

if (nppParams.isSelectFgColorEnabled())
{
long alphaSelectColorFore = selectColorFore;
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_ADDITIONAL_TEXT, alphaSelectColorFore);
}

COLORREF caretColor = black;
pStyle = stylers.findByID(SCI_SETCARETFORE);
pStyle = stylers.findByName(L"Caret colour");
if (pStyle)
{
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;
pStyle = stylers.findByName(TEXT("Edge colour"));
Expand Down
5 changes: 0 additions & 5 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,6 @@ friend class Finder;

static UserDefineDialog * getUserDefineDlg() {return &_userDefineDlg;};

void setCaretColorWidth(int color, int width = 1) const {
execute(SCI_SETCARETFORE, color);
execute(SCI_SETCARETWIDTH, width);
};

void beSwitched() {
_userDefineDlg.setScintilla(this);
};
Expand Down
4 changes: 3 additions & 1 deletion PowerEditor/src/stylers.model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,9 @@
<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 -->
<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="Line number margin" styleID="33" fgColor="808080" bgColor="E4E4E4" fontName="" fontStyle="0" fontSize="" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="E0E0E0" />
Expand Down

0 comments on commit 812745d

Please sign in to comment.