From 09178750349ea58ab88ad34a0e1c41f552a99130 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 20 Nov 2023 04:59:40 +0100 Subject: [PATCH] Make all SCI_SETELEMENTCOLOUR message use 32 bits color --- PowerEditor/src/NppCommands.cpp | 4 ++-- .../src/ScintillaComponent/AutoCompletion.cpp | 8 +++---- .../src/ScintillaComponent/FindReplaceDlg.cpp | 2 +- .../ScintillaComponent/ScintillaEditView.cpp | 22 +++++++++---------- .../ScintillaComponent/ScintillaEditView.h | 1 + 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index d81af65c4..c00cf62f9 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -4039,8 +4039,8 @@ void Notepad_plus::command(int id) if (svp._currentLineHiliteMode != LINEHILITE_NONE) { - _mainEditView.execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, bgColour); - _subEditView.execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, bgColour); + _mainEditView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, bgColour); + _subEditView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, bgColour); } else { diff --git a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp index 4cf2b8547..748522c62 100644 --- a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp @@ -1299,10 +1299,10 @@ void AutoCompletion::setColour(COLORREF colour2Set, AutocompleteColorIndex i) void AutoCompletion::drawAutocomplete(ScintillaEditView* pEditView) { - pEditView->execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST, _autocompleteText); - pEditView->execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST_BACK, _autocompleteBg); - pEditView->execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST_SELECTED, _selectedText); - pEditView->execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_LIST_SELECTED_BACK, _selectedBg); + pEditView->setElementColour(SC_ELEMENT_LIST, _autocompleteText); + pEditView->setElementColour(SC_ELEMENT_LIST_BACK, _autocompleteBg); + pEditView->setElementColour(SC_ELEMENT_LIST_SELECTED, _selectedText); + pEditView->setElementColour(SC_ELEMENT_LIST_SELECTED_BACK, _selectedBg); pEditView->execute(SCI_CALLTIPSETBACK, _calltipBg); pEditView->execute(SCI_CALLTIPSETFORE, _calltipText); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index bf10e3791..aa25ea3dd 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -5004,7 +5004,7 @@ void Finder::setFinderStyle() const Style * pStyle = pStyler->findByID(SCE_SEARCHRESULT_CURRENT_LINE); if (pStyle) { - _scintView.execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, pStyle->_bgColor); + _scintView.setElementColour(SC_ELEMENT_CARET_LINE_BACK, pStyle->_bgColor); _scintView.execute(SCI_SETCARETLINEFRAME, 0); _scintView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true); } diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 560b259c4..ad9018660 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -252,7 +252,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) const COLORREF hiddenLinesGreen = RGB(0x77, 0xCC, 0x77); long hiddenLinesGreenWithAlpha = hiddenLinesGreen | 0xFF000000; - execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_HIDDEN_LINE, hiddenLinesGreenWithAlpha); + setElementColour(SC_ELEMENT_HIDDEN_LINE, hiddenLinesGreenWithAlpha); if (NppParameters::getInstance()._dpiManager.scaleX(100) >= 150) { @@ -2888,7 +2888,7 @@ void ScintillaEditView::performGlobalStyles() pStyle = stylers.findByName(TEXT("Current line background colour")); if (pStyle) { - execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, pStyle->_bgColor); + setElementColour(SC_ELEMENT_CARET_LINE_BACK, pStyle->_bgColor); } } @@ -2903,8 +2903,8 @@ void ScintillaEditView::performGlobalStyles() selectColorFore = pStyle->_fgColor; } //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); + setElementColour(SC_ELEMENT_SELECTION_BACK, selectColorBack); // SCI_SETSELBACK is deprecated + setElementColour(SC_ELEMENT_SELECTION_INACTIVE_BACK, selectColorBack); COLORREF selectMultiSelectColorBack = liteGrey; @@ -2913,16 +2913,14 @@ void ScintillaEditView::performGlobalStyles() { selectMultiSelectColorBack = pStyle->_bgColor; } - execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_ADDITIONAL_BACK, selectMultiSelectColorBack | 0xFF000000); + setElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, selectMultiSelectColorBack); 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); + setElementColour(SC_ELEMENT_SELECTION_TEXT, selectColorFore); // SCI_SETSELFORE is deprecated + setElementColour(SC_ELEMENT_SELECTION_INACTIVE_TEXT, selectColorFore); + setElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, selectColorFore); } COLORREF caretColor = black; @@ -2932,7 +2930,7 @@ void ScintillaEditView::performGlobalStyles() caretColor = pStyle->_fgColor; } //execute(SCI_SETCARETFORE, caretColor); - execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET, caretColor | 0xFF000000); // SCI_SETCARETFORE is deprecated + setElementColour(SC_ELEMENT_CARET, caretColor); // SCI_SETCARETFORE is deprecated COLORREF multiEditCaretColor = darkGrey; pStyle = stylers.findByName(L"Multi-edit carets color"); @@ -2940,7 +2938,7 @@ void ScintillaEditView::performGlobalStyles() if (pStyle) multiEditCaretColor = pStyle->_fgColor; - execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_ADDITIONAL, multiEditCaretColor | 0xFF000000); + setElementColour(SC_ELEMENT_CARET_ADDITIONAL, multiEditCaretColor); COLORREF edgeColor = liteGrey; pStyle = stylers.findByName(TEXT("Edge colour")); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 3251508ae..d7bd2f2f0 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -773,6 +773,7 @@ public: void removeAnyDuplicateLines(); bool expandWordSelection(); bool pasteToMultiSelection() const; + void setElementColour(int element, COLORREF color) const { execute(SCI_SETELEMENTCOLOUR, element, color | 0xFF000000); }; protected: static bool _SciInit;