Fix "Enable current line highlighting" not working correctly

This is a regression of upgrading Scintilla from 4.x to 5.x due to concerning Scintilla APIs having changed their behaviour.
This PR follows the new instructions of Scintilla documentation to make it work again.

Fix #11433, close #11433
This commit is contained in:
Shridhar Kumar 2022-04-10 20:30:10 -04:00 committed by Don Ho
parent 3afbf0ca14
commit e094e99697
4 changed files with 19 additions and 18 deletions

View File

@ -273,9 +273,6 @@ LRESULT Notepad_plus::init(HWND hwnd)
_mainEditView.setWrapMode(svp._lineWrapMethod);
_subEditView.setWrapMode(svp._lineWrapMethod);
_mainEditView.execute(SCI_SETCARETLINEVISIBLE, svp._currentLineHilitingShow);
_subEditView.execute(SCI_SETCARETLINEVISIBLE, svp._currentLineHilitingShow);
_mainEditView.execute(SCI_SETENDATLASTLINE, !svp._scrollBeyondLastLine);
_subEditView.execute(SCI_SETENDATLASTLINE, !svp._scrollBeyondLastLine);

View File

@ -3744,9 +3744,13 @@ void Notepad_plus::command(int id)
case IDM_VIEW_CURLINE_HILITING:
{
COLORREF colour = (NppParameters::getInstance()).getCurLineHilitingColour();
_mainEditView.setCurrentLineHiLiting(!_pEditView->isCurrentLineHiLiting(), colour);
_subEditView.setCurrentLineHiLiting(!_pEditView->isCurrentLineHiLiting(), colour);
NppParameters& nppParams = NppParameters::getInstance();
COLORREF colour{ nppParams.getCurLineHilitingColour() };
bool hilite{ nppParams.getSVP()._currentLineHilitingShow };
_mainEditView.setCurrentLineHiLiting(hilite, colour);
_subEditView.setCurrentLineHiLiting(hilite, colour);
}
break;

View File

@ -2567,12 +2567,16 @@ void ScintillaEditView::expand(size_t& line, bool doExpand, bool force, intptr_t
void ScintillaEditView::performGlobalStyles()
{
NppParameters& nppParams = NppParameters::getInstance();
StyleArray & stylers = nppParams.getMiscStylerArray();
StyleArray& stylers = nppParams.getMiscStylerArray();
const Style* pStyle{};
const Style * pStyle = stylers.findByName(TEXT("Current line background colour"));
if (pStyle)
if (nppParams.getSVP()._currentLineHilitingShow)
{
execute(SCI_SETCARETLINEBACK, pStyle->_bgColor);
pStyle = stylers.findByName(TEXT("Current line background colour"));
if (pStyle)
{
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, pStyle->_bgColor);
}
}
COLORREF selectColorBack = grey;

View File

@ -469,14 +469,10 @@ public:
void setCurrentLineHiLiting(bool isHiliting, COLORREF bgColor) const {
execute(SCI_SETCARETLINEVISIBLE, isHiliting);
if (!isHiliting)
return;
execute(SCI_SETCARETLINEBACK, bgColor);
};
bool isCurrentLineHiLiting() const {
return (execute(SCI_GETCARETLINEVISIBLE) != 0);
if (isHiliting)
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, bgColor);
else
execute(SCI_RESETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, NULL);
};
void performGlobalStyles();