From 812745d850965d8113e7377fe11c0dd758a36ad7 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 13 Nov 2023 04:36:33 +0100 Subject: [PATCH] Make multi-select background & caret colour customizable Fix #14302, close #14350 --- PowerEditor/src/NppBigSwitch.cpp | 2 +- .../ScintillaComponent/ScintillaEditView.cpp | 32 +++++++++++++++---- .../ScintillaComponent/ScintillaEditView.h | 5 --- PowerEditor/src/stylers.model.xml | 4 ++- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 08a8c03f68d0..150fd32b4b78 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -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(); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index dae26dade5c6..078593bb58ec 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -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")); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index c1ba9a31be9f..3251508aeac2 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -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); }; diff --git a/PowerEditor/src/stylers.model.xml b/PowerEditor/src/stylers.model.xml index fcf62b566472..f2fe17f344a9 100644 --- a/PowerEditor/src/stylers.model.xml +++ b/PowerEditor/src/stylers.model.xml @@ -1493,7 +1493,9 @@ - + + +