From b13ab0a7414bf98b18d110db8a159c127af08fa3 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Wed, 19 Aug 2020 12:40:03 +0200 Subject: [PATCH] + fix: find any next/prev. bookmark (std or word) --- Versions/build.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/Edit.c | 30 +++++++++++++++++++++--------- src/Edit.h | 3 ++- src/Notepad3.c | 30 ++++++++++++++++++++---------- src/VersionEx.h | 4 ++-- 6 files changed, 47 insertions(+), 24 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index d00491fd7..0cfbf0888 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1 +2 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index e1331cc59..ad218f1d2 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 beta diff --git a/src/Edit.c b/src/Edit.c index 03cea6ad3..8f27027d1 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -328,11 +328,7 @@ void EditSetNewText(HWND hwnd, const char* lpstrText, DocPosU lenText, bool bCle _IGNORE_NOTIFY_CHANGE_; SciCall_Cancel(); if (SciCall_GetReadOnly()) { SciCall_SetReadOnly(false); } - SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK); - for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) { - SciCall_MarkerDeleteAll(m); - WordBookMarks[m].in_use = false; - } + EditClearAllBookMarks(hwnd); EditClearAllOccurrenceMarkers(hwnd); SciCall_SetScrollWidth(1); SciCall_SetXOffset(0); @@ -7101,6 +7097,22 @@ void EditClearAllOccurrenceMarkers(HWND hwnd) } +//============================================================================= +// +// EditClearAllBookMarks() +// +void EditClearAllBookMarks(HWND hwnd) +{ + UNUSED(hwnd); + + SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK); + for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) { + SciCall_MarkerDeleteAll(m); + WordBookMarks[m].in_use = false; + } +} + + //============================================================================= // // EditToggleView() @@ -8709,7 +8721,7 @@ void EditGetBookmarkList(HWND hwnd, LPWSTR pszBookMarks, int cchLength) UNUSED(hwnd); WCHAR tchLine[32]; StringCchCopyW(pszBookMarks, cchLength, L""); - int bitmask = (1 << MARKER_NP3_BOOKMARK); + int const bitmask = (1 << MARKER_NP3_BOOKMARK); DocLn iLine = -1; do { iLine = SciCall_MarkerNext(iLine + 1, bitmask); @@ -8734,7 +8746,7 @@ void EditSetBookmarkList(HWND hwnd, LPCWSTR pszBookMarks) const WCHAR* p1 = pszBookMarks; if (!p1) return; - const DocLn iLineMax = SciCall_GetLineCount() - 1; + DocLn const iLineMax = SciCall_GetLineCount() - 1; while (*p1) { const WCHAR* p2 = StrChr(p1, L';'); @@ -8754,9 +8766,9 @@ void EditSetBookmarkList(HWND hwnd, LPCWSTR pszBookMarks) //============================================================================= // -// EditBookmarkClick() +// EditBookmarkToggle() // -void EditBookmarkClick(const DocLn ln, const int modifiers) +void EditBookmarkToggle(const DocLn ln, const int modifiers) { UNUSED(modifiers); diff --git a/src/Edit.h b/src/Edit.h index b9d0db3ae..48d4b4914 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -108,6 +108,7 @@ void EditPrintInit(); bool EditSetDocumentBuffer(const char* lpstrText, DocPosU lenText); void EditMatchBrace(HWND hwnd); void EditClearAllOccurrenceMarkers(HWND hwnd); +void EditClearAllBookMarks(HWND hwnd); void EditToggleView(HWND hwnd); void EditSelectWordAtPos(const DocPos iPos, const bool bForceWord); int EditAddSearchFlags(int flags, bool bRegEx, bool bWordStart, bool bMatchCase, bool bMatchWords, bool bDotMatchAll); @@ -122,7 +123,7 @@ bool EditCheckNewLineInACFillUps(); void EditShowZeroLengthCallTip(HWND hwnd, DocPos iPosition); void EditGetBookmarkList(HWND hwnd,LPWSTR pszBookMarks,int cchLength); void EditSetBookmarkList(HWND hwnd,LPCWSTR pszBookMarks); -void EditBookmarkClick(const DocLn ln, const int modifiers); +void EditBookmarkToggle(const DocLn ln, const int modifiers); void EditMarkAllOccurrences(HWND hwnd, bool bForceClear); void EditHideNotMarkedLineRange(HWND hwnd, bool bHideLines); void EditSelectionMultiSelectAll(); diff --git a/src/Notepad3.c b/src/Notepad3.c index 3d4f35bdf..c32792502 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -4807,7 +4807,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) DocLn iNextLine = SciCall_MarkerNext(iLine + 1, bitmask); if (iNextLine == (DocLn)-1) { - iNextLine = SciCall_MarkerNext(0, bitmask); + iNextLine = SciCall_MarkerNext(0, bitmask); // wrap around + } + if (iNextLine == (DocLn)-1) { + bitmask = bitmask32_n(MARKER_NP3_BOOKMARK + 1); + iNextLine = SciCall_MarkerNext(iLine + 1, bitmask); //find any bookmark + } + if (iNextLine == (DocLn)-1) { + iNextLine = SciCall_MarkerNext(0, bitmask); // wrap around } if (iNextLine != (DocLn)-1) { SciCall_GotoLine(iNextLine); @@ -4824,9 +4831,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) bitmask = (1 << MARKER_NP3_BOOKMARK); } - DocLn iNextLine = SciCall_MarkerPrevious(iLine - 1, bitmask); + DocLn iNextLine = SciCall_MarkerPrevious(max_ln(0, iLine - 1), bitmask); if (iNextLine == (DocLn)-1) { - iNextLine = SciCall_MarkerPrevious(SciCall_GetLineCount(), bitmask); + iNextLine = SciCall_MarkerPrevious(SciCall_GetLineCount(), bitmask); // wrap around + } + if (iNextLine == (DocLn)-1) { + bitmask = bitmask32_n(MARKER_NP3_BOOKMARK + 1); + iNextLine = SciCall_MarkerPrevious(max_ln(0, iLine - 1), bitmask); //find any bookmark + } + if (iNextLine == (DocLn)-1) { + iNextLine = SciCall_MarkerPrevious(SciCall_GetLineCount(), bitmask); // wrap around } if (iNextLine != (DocLn)-1) { SciCall_GotoLine(iNextLine); @@ -4837,16 +4851,12 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case BME_EDIT_BOOKMARKTOGGLE: - EditBookmarkClick(Sci_GetCurrentLineNumber(), 0); + EditBookmarkToggle(Sci_GetCurrentLineNumber(), 0); break; case BME_EDIT_BOOKMARKCLEAR: - SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK); - for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) { - SciCall_MarkerDeleteAll(m); - WordBookMarks[m].in_use = false; - } + EditClearAllBookMarks(Globals.hwndEdit); break; @@ -7476,7 +7486,7 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const LPNMHDR pnmh, const SCNotific EditFoldClick(SciCall_LineFromPosition(scn->position), scn->modifiers); break; case MARGIN_SCI_BOOKMRK: - EditBookmarkClick(SciCall_LineFromPosition(scn->position), scn->modifiers); + EditBookmarkToggle(SciCall_LineFromPosition(scn->position), scn->modifiers); break; case MARGIN_SCI_LINENUM: default: diff --git a/src/VersionEx.h b/src/VersionEx.h index b0d920d10..054a03ef6 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -9,11 +9,11 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 20 #define VERSION_REV 819 -#define VERSION_BUILD 1 +#define VERSION_BUILD 2 #define SCINTILLA_VER 444 #define ONIGURUMA_REGEX_VER 6.9.5 #define UCHARDET_VER 2018.09.27 #define TINYEXPR_VER 2018.05.11 #define UTHASH_VER 2.1.0 #define VERSION_PATCH beta -#define VERSION_COMMIT_ID dkt1-amr +#define VERSION_COMMIT_ID t7820-rk