From 39d7bef4623a3b792b947fb8dd630d7537ba149c Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sun, 26 May 2019 01:13:26 +0200 Subject: [PATCH 1/4] + fix: restore occurrence marker on Find/Replace closing --- src/Edit.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 954efb7d2..5a6c78f5f 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5042,9 +5042,6 @@ static int s_SaveMarkOccurrences = 0; static bool s_SaveMarkMatchVisible = false; static bool s_SaveTFBackSlashes = false; -static inline void SwitchMarkOccurrences_ON() { Settings.MarkOccurrences = max_i(1, s_SaveMarkOccurrences); } -static inline void SwitchMarkOccurrences_OFF() { Settings.MarkOccurrences = 0; } - static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { static LPEDITFINDREPLACE sg_pefrData = NULL; @@ -5252,18 +5249,16 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara } sg_pefrData->szFind[0] = '\0'; - Settings.MarkOccurrences = s_SaveMarkOccurrences; - Settings.MarkOccurrencesMatchVisible = s_SaveMarkMatchVisible; - EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, Settings.MarkOccurrences); - Globals.iReplacedOccurrences = 0; Globals.FindReplaceMatchFoundState = FND_NOP; - if (FocusedView.HideNonMatchedLines) { - SwitchMarkOccurrences_ON(); + if (FocusedView.HideNonMatchedLines) { EditToggleView(sg_pefrData->hwnd); - SwitchMarkOccurrences_OFF(); } + + Settings.MarkOccurrences = s_SaveMarkOccurrences; + Settings.MarkOccurrencesMatchVisible = s_SaveMarkMatchVisible; + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, Settings.MarkOccurrences); MarkAllOccurrences(50, true); if (s_InitialTopLine >= 0) { @@ -5487,9 +5482,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara _IGNORE_NOTIFY_CHANGE_; EditClearAllOccurrenceMarkers(sg_pefrData->hwnd); StringCchCopyA(s_lastFind, COUNTOF(s_lastFind), sg_pefrData->szFind); - SwitchMarkOccurrences_ON(); RegExResult_t match = _FindHasMatch(sg_pefrData->hwnd, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false); - SwitchMarkOccurrences_OFF(); if (s_anyMatch != match) { s_anyMatch = match; } // we have to set Sci's regex instance to first find (have substitution in place) DocPos const iStartPos = (DocPos)lParam; @@ -5509,9 +5502,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara EditSetSelectionEx(sg_pefrData->hwnd, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); } if (FocusedView.HideNonMatchedLines) { - SwitchMarkOccurrences_ON(); EditToggleView(sg_pefrData->hwnd); - SwitchMarkOccurrences_OFF(); } Settings.MarkOccurrences = s_SaveMarkOccurrences; MarkAllOccurrences(4, true); @@ -5551,9 +5542,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara case IDC_TOGGLE_VISIBILITY: - SwitchMarkOccurrences_ON(); EditToggleView(sg_pefrData->hwnd); - SwitchMarkOccurrences_OFF(); if (!FocusedView.HideNonMatchedLines) { sg_pefrData->bStateChanged = true; s_InitialTopLine = -1; // reset From deeac1fa3c8f0dfab19e8c432251d434293d75c7 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sun, 26 May 2019 01:14:28 +0200 Subject: [PATCH 2/4] +upd: version info --- Versions/build.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/VersionEx.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index 9b5f360cc..a858d2d47 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1723 +1724 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 4d5ad0d4c..9ba0e2dde 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 RC diff --git a/src/VersionEx.h b/src/VersionEx.h index 36e65b357..6f6c7ae02 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -7,8 +7,8 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 19 -#define VERSION_REV 525 -#define VERSION_BUILD 1723 +#define VERSION_REV 526 +#define VERSION_BUILD 1724 #define SCINTILLA_VER 415+ #define ONIGMO_REGEX_VER 6.2.0 #define VERSION_PATCH RC From 4bb59f4e1d3c9e9a69005221be20ff1b822ebea6 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sun, 26 May 2019 02:33:01 +0200 Subject: [PATCH 3/4] + fix: switching Find/Replace ON/OFF <-> MarkOccurrences --- src/Edit.c | 26 +++++++++++++++++--------- src/Notepad3.c | 10 ++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 5a6c78f5f..b290f62aa 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5150,6 +5150,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara else { CheckDlgButton(hwnd, IDC_ALL_OCCURRENCES, BST_UNCHECKED); EditClearAllOccurrenceMarkers(sg_pefrData->hwnd); + Globals.iMarkOccurrencesCount = -1; } if (sg_pefrData->fuFlags & SCFIND_REGEXP) { @@ -5252,14 +5253,19 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara Globals.iReplacedOccurrences = 0; Globals.FindReplaceMatchFoundState = FND_NOP; - if (FocusedView.HideNonMatchedLines) { - EditToggleView(sg_pefrData->hwnd); - } - Settings.MarkOccurrences = s_SaveMarkOccurrences; Settings.MarkOccurrencesMatchVisible = s_SaveMarkMatchVisible; - EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, Settings.MarkOccurrences); - MarkAllOccurrences(50, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, true); + if (IsMarkOccurrencesEnabled()) { + MarkAllOccurrences(50, true); + } + else { + if (FocusedView.HideNonMatchedLines) { + EditToggleView(sg_pefrData->hwnd); + } + EditClearAllOccurrenceMarkers(sg_pefrData->hwnd); + Globals.iMarkOccurrencesCount = -1; + } if (s_InitialTopLine >= 0) { SciCall_SetFirstVisibleLine(s_InitialTopLine); @@ -5504,7 +5510,6 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara if (FocusedView.HideNonMatchedLines) { EditToggleView(sg_pefrData->hwnd); } - Settings.MarkOccurrences = s_SaveMarkOccurrences; MarkAllOccurrences(4, true); } _OBSERVE_NOTIFY_CHANGE_; @@ -5534,7 +5539,11 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara } else { // switched OFF DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, false); + if (FocusedView.HideNonMatchedLines) { + EditToggleView(sg_pefrData->hwnd); + } EditClearAllOccurrenceMarkers(sg_pefrData->hwnd); + Globals.iMarkOccurrencesCount = -1; InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); } } @@ -6427,8 +6436,7 @@ bool EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowIn void EditClearAllOccurrenceMarkers(HWND hwnd) { UNUSED(hwnd); - - Globals.iMarkOccurrencesCount = IsMarkOccurrencesEnabled() ? 0 : -1; + Globals.iMarkOccurrencesCount = 0; _IGNORE_NOTIFY_CHANGE_; diff --git a/src/Notepad3.c b/src/Notepad3.c index da364ce50..d0f751b81 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -4952,8 +4952,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if ((Settings.MarkOccurrences <= 0) && FocusedView.HideNonMatchedLines) { EditToggleView(Globals.hwndEdit); } - EnableCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, (Settings.MarkOccurrences > 0)); - MarkAllOccurrences(0, true); + EnableCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, IsMarkOccurrencesEnabled()); + if (IsMarkOccurrencesEnabled()) { + MarkAllOccurrences(0, true); + } + else { + EditClearAllOccurrenceMarkers(Globals.hwndEdit); + Globals.iMarkOccurrencesCount = IsMarkOccurrencesEnabled() ? 0 : -1; + } UpdateToolbar(); break; From 81edad20add1b082dc08685af5986ca914335a31 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sun, 26 May 2019 02:35:30 +0200 Subject: [PATCH 4/4] + upd: version info --- Versions/build.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/VersionEx.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index a858d2d47..1c38c9071 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1724 +1725 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 9ba0e2dde..fe8cf872f 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 RC diff --git a/src/VersionEx.h b/src/VersionEx.h index 6f6c7ae02..36e921a78 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -8,7 +8,7 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 19 #define VERSION_REV 526 -#define VERSION_BUILD 1724 +#define VERSION_BUILD 1725 #define SCINTILLA_VER 415+ #define ONIGMO_REGEX_VER 6.2.0 #define VERSION_PATCH RC