+ convenience: re-introduce "max mark occurrence counter" to avoid lazy UI

(set .ini section [Settings2] MarkOccurrencesMaxCount=-1 for unlimited (MAX_INT))
This commit is contained in:
Rainer Kottenhoff 2018-01-05 16:28:01 +01:00
parent bff0f82e12
commit 02ca738ea4
2 changed files with 22 additions and 14 deletions

View File

@ -87,8 +87,9 @@ extern BOOL bAccelWordNavigation;
extern BOOL bDenyVirtualSpaceAccess;
extern BOOL bHyperlinkHotspot;
extern int iMarkOccurrences;
extern int iMarkOccurrencesCount;
extern int iMarkOccurrences;
extern int iMarkOccurrencesCount;
extern int iMarkOccurrencesMaxCount;
extern BOOL bMarkOccurrencesMatchVisible;
extern NP2ENCODING mEncoding[];
@ -5499,7 +5500,6 @@ void EditClearAllMarks(HWND hwnd, int iRangeStart, int iRangeEnd)
}
SendMessage(hwnd, SCI_SETINDICATORCURRENT, INDIC_NP3_MARK_OCCURANCE, 0);
SendMessage(hwnd, SCI_INDICATORCLEARRANGE, iRangeStart, iRangeEnd);
iMarkOccurrencesCount = -1; // -1 !
}
@ -5586,6 +5586,8 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, int rangeStart, int rangeE
int start = rangeStart;
int end = rangeEnd;
iMarkOccurrencesCount = 0;
SendMessage(hwnd, SCI_SETINDICATORCURRENT, INDIC_NP3_MARK_OCCURANCE, 0);
int iPos = -1;
@ -5593,8 +5595,6 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, int rangeStart, int rangeE
iPos = EditFindInTarget(hwnd, pszText, iFindLength, flags, &start, &end, (start == iPos));
++iMarkOccurrencesCount; // -1 -> 0
if (iPos < 0)
break; // not found
@ -5607,7 +5607,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, int rangeStart, int rangeE
start = end;
end = rangeEnd;
} while (start < end); // < iMarkOccurrencesMaxCount
} while ((start < end) && (++iMarkOccurrencesCount < iMarkOccurrencesMaxCount));
}
}

View File

@ -150,6 +150,7 @@ BOOL bShowSelectionMargin;
BOOL bShowLineNumbers;
int iMarkOccurrences;
int iMarkOccurrencesCount;
int iMarkOccurrencesMaxCount;
BOOL bMarkOccurrencesMatchVisible;
BOOL bMarkOccurrencesMatchCase;
BOOL bMarkOccurrencesMatchWords;
@ -1043,6 +1044,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
if (flagStartAsTrayIcon)
SetNotifyIconTitle(g_hwndMain);
iMarkOccurrencesCount = 0;
UpdateToolbar();
UpdateStatusbar();
UpdateLineNumberWidth();
@ -6228,10 +6230,9 @@ void LoadSettings()
iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality", FontQuality[3]);
iSciFontQuality = max(min(iSciFontQuality, 3), 0);
iMarkOccurrencesCount = -1;
//iMarkOccurrencesMaxCount = IniSectionGetInt(pIniSection,L"MarkOccurrencesMaxCount",2000);
//iMarkOccurrencesMaxCount = max(min(iMarkOccurrencesMaxCount,100000),2);
iMarkOccurrencesMaxCount = IniSectionGetInt(pIniSection,L"MarkOccurrencesMaxCount",2000);
iMarkOccurrencesMaxCount = (iMarkOccurrencesMaxCount <= 0) ? INT_MAX : iMarkOccurrencesMaxCount;
bDenyVirtualSpaceAccess = IniSectionGetBool(pIniSection, L"DenyVirtualSpaceAccess", FALSE);
bUseOldStyleBraceMatching = IniSectionGetBool(pIniSection, L"UseOldStyleBraceMatching", FALSE);
@ -7270,16 +7271,23 @@ void UpdateStatusbar()
StringCchCopy(tchSel, COUNTOF(tchSel), L"--");
}
if ((iMarkOccurrencesCount > 0) && !bMarkOccurrencesMatchVisible) {
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i", iMarkOccurrencesCount);
FormatNumberStr(tchOcc);
// Print number of occurrence marks found
if ((iMarkOccurrencesCount > 0) && !bMarkOccurrencesMatchVisible)
{
if ((iMarkOccurrencesMaxCount < 0) || (iMarkOccurrencesCount < iMarkOccurrencesMaxCount))
{
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i", iMarkOccurrencesCount);
FormatNumberStr(tchOcc);
}
else {
StringCchPrintf(tchOcc, COUNTOF(tchOcc), L">= %i", iMarkOccurrencesMaxCount);
}
}
else {
StringCchCopy(tchOcc, COUNTOF(tchOcc), L"--");
}
// Print number of selected lines in statusbar
const int iLineStart = SciCall_LineFromPosition(iSelStart);
const int iLineEnd = SciCall_LineFromPosition(iSelEnd);
const int iStartOfLinePos = SciCall_PositionFromLine(iLineEnd);