Code enhancement: remove unnecessary hidden lines separator marker

Let Scintilla manage hidden lines separator and free marker 17 for plugins use.

Fix #12109, close #13223
This commit is contained in:
Alan Kilborn 2023-02-24 14:48:24 -05:00 committed by Don Ho
parent 399a8f3020
commit 5251d8477a
2 changed files with 13 additions and 16 deletions

View File

@ -227,7 +227,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
execute(SCI_SETMARGINMASKN, _SC_MARGE_FOLDER, SC_MASK_FOLDERS);
showMargin(_SC_MARGE_FOLDER, true);
execute(SCI_SETMARGINMASKN, _SC_MARGE_SYMBOL, (1 << MARK_BOOKMARK) | (1 << MARK_HIDELINESBEGIN) | (1 << MARK_HIDELINESEND) | (1 << MARK_HIDELINESUNDERLINE));
execute(SCI_SETMARGINMASKN, _SC_MARGE_SYMBOL, (1 << MARK_BOOKMARK) | (1 << MARK_HIDELINESBEGIN) | (1 << MARK_HIDELINESEND));
execute(SCI_SETMARGINMASKN, _SC_MARGE_CHANGEHISTORY, (1 << SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN) | (1 << SC_MARKNUM_HISTORY_SAVED) | (1 << SC_MARKNUM_HISTORY_MODIFIED) | (1 << SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED));
COLORREF modifiedColor = RGB(255, 128, 0);
@ -241,8 +241,9 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
execute(SCI_MARKERSETALPHA, MARK_BOOKMARK, 70);
execute(SCI_MARKERDEFINE, MARK_HIDELINESUNDERLINE, SC_MARK_UNDERLINE);
execute(SCI_MARKERSETBACK, MARK_HIDELINESUNDERLINE, 0x77CC77);
const COLORREF hiddenLinesGreen = RGB(0x77, 0xCC, 0x77);
long hiddenLinesGreenWithAlpha = hiddenLinesGreen | 0xFF000000;
execute(SCI_SETELEMENTCOLOUR, SC_ELEMENT_HIDDEN_LINE, hiddenLinesGreenWithAlpha);
if (NppParameters::getInstance()._dpiManager.scaleX(100) >= 150)
{
@ -3521,8 +3522,8 @@ void ScintillaEditView::hideLines()
auto removeMarker = [this, &scope, &recentMarkerWasOpen](size_t line)
{
auto state = execute(SCI_MARKERGET, line);
bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0);
bool openPresent = ((state & (1 << MARK_HIDELINESBEGIN | 1 << MARK_HIDELINESUNDERLINE)) != 0);
bool closePresent = (state & (1 << MARK_HIDELINESEND)) != 0;
bool openPresent = (state & (1 << MARK_HIDELINESBEGIN)) != 0;
if (closePresent)
{
@ -3534,7 +3535,6 @@ void ScintillaEditView::hideLines()
if (openPresent)
{
execute(SCI_MARKERDELETE, line, MARK_HIDELINESBEGIN);
execute(SCI_MARKERDELETE, line, MARK_HIDELINESUNDERLINE);
recentMarkerWasOpen = true;
++scope;
}
@ -3574,7 +3574,6 @@ void ScintillaEditView::hideLines()
}
execute(SCI_MARKERADD, startMarker, MARK_HIDELINESBEGIN);
execute(SCI_MARKERADD, startMarker, MARK_HIDELINESUNDERLINE);
execute(SCI_MARKERADD, endMarker, MARK_HIDELINESEND);
_currentBuffer->setHideLineChanged(true, startMarker);
@ -3583,8 +3582,8 @@ void ScintillaEditView::hideLines()
bool ScintillaEditView::markerMarginClick(intptr_t lineNumber)
{
auto state = execute(SCI_MARKERGET, lineNumber);
bool openPresent = ((state & (1 << MARK_HIDELINESBEGIN | 1 << MARK_HIDELINESUNDERLINE)) != 0);
bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0);
bool openPresent = (state & (1 << MARK_HIDELINESBEGIN)) != 0;
bool closePresent = (state & (1 << MARK_HIDELINESEND)) != 0;
if (!openPresent && !closePresent)
return false;
@ -3601,7 +3600,7 @@ bool ScintillaEditView::markerMarginClick(intptr_t lineNumber)
for (lineNumber--; lineNumber >= 0 && !openPresent; lineNumber--)
{
state = execute(SCI_MARKERGET, lineNumber);
openPresent = ((state & (1 << MARK_HIDELINESBEGIN | 1 << MARK_HIDELINESUNDERLINE)) != 0);
openPresent = (state & (1 << MARK_HIDELINESBEGIN)) != 0;
}
if (openPresent)
@ -3670,7 +3669,7 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
}
isInSection = false;
}
if ( ((state & (1 << MARK_HIDELINESBEGIN | 1 << MARK_HIDELINESUNDERLINE)) != 0) )
if ((state & (1 << MARK_HIDELINESBEGIN)) != 0)
{
isInSection = true;
startHiding = i+1;
@ -3716,12 +3715,11 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
isInSection = false;
}
}
if ( ((state & (1 << MARK_HIDELINESBEGIN | 1 << MARK_HIDELINESUNDERLINE)) != 0) )
if ((state & (1 << MARK_HIDELINESBEGIN)) != 0)
{
if (doDelete)
{
execute(SCI_MARKERDELETE, i, MARK_HIDELINESBEGIN);
execute(SCI_MARKERDELETE, i, MARK_HIDELINESUNDERLINE);
}
else
{

View File

@ -116,9 +116,8 @@ const UCHAR BASE_02 = 0x03; // Bin
const int MARK_BOOKMARK = 20;
const int MARK_HIDELINESBEGIN = 19;
const int MARK_HIDELINESEND = 18;
const int MARK_HIDELINESUNDERLINE = 17;
// 20 - 17 reserved for Notepad++ internal used
// 16 - 0 are free to use for plugins
// 20 - 18 reserved for Notepad++ internal used
// 17 - 0 are free to use for plugins
const std::vector<std::vector<const char*>> g_nonPrintingChars =
{