From 97386a4a53a93e5876cd735721ce388c622308d6 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 1 May 2019 01:27:23 +0200 Subject: [PATCH] + fix: Hyperlink and Lexer style update cooperation --- Versions/build.txt | 2 +- np3portableapp/_buildname.txt | 2 +- res/Notepad3.exe.manifest.conf | 4 +-- src/Edit.c | 45 +++++++++++++--------------------- src/Edit.h | 1 - src/Notepad3.c | 16 ++++++------ src/SciCall.h | 2 +- src/Styles.c | 2 +- src/VersionEx.h | 6 ++--- 9 files changed, 34 insertions(+), 46 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index 505c5cc23..e41cd7af5 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1684 +1685 diff --git a/np3portableapp/_buildname.txt b/np3portableapp/_buildname.txt index cfd7d0ca4..ee7531390 100644 --- a/np3portableapp/_buildname.txt +++ b/np3portableapp/_buildname.txt @@ -1 +1 @@ -"develop" +"RC" diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 838fc3f68..d121344b9 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,8 +3,8 @@ - Notepad3 develop + Notepad3 RC diff --git a/src/Edit.c b/src/Edit.c index 7e684c9cf..dd422aca6 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -6166,25 +6166,6 @@ void EditMarkAllOccurrences(HWND hwnd, bool bForceClear) } -//============================================================================= -// -// EditUpdateVisibleUrlHotspot() -// -void EditUpdateVisibleUrlHotspot(bool bEnabled) -{ - if (bEnabled) - { - if (_IsInTargetTransaction()) { return; } // do not block, next event occurs for sure - - DocLn const iStartLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); - DocLn const iEndLine = min_ln((iStartLine + SciCall_LinesOnScreen()), (SciCall_GetLineCount() - 1)); - - _IGNORE_NOTIFY_CHANGE_; - EditUpdateUrlHotspots(Globals.hwndEdit, SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine), bEnabled); - _OBSERVE_NOTIFY_CHANGE_; - } -} - //============================================================================= // // EditApplyVisibleStyle() @@ -6194,10 +6175,12 @@ void EditApplyVisibleStyle(HWND hwnd) DocLn const iStartLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); DocLn const iEndLine = min_ln((iStartLine + SciCall_LinesOnScreen()), (SciCall_GetLineCount() - 1)); if (Settings.HyperlinkHotspot && !_IsInTargetTransaction()) { + _IGNORE_NOTIFY_CHANGE_; EditUpdateUrlHotspots(hwnd, SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine), true); + _OBSERVE_NOTIFY_CHANGE_; } else if (!Globals.bHideNonMatchedLines) { - Sci_ApplyStyle(SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine)); + Sci_ApplyLexerStyle(SciCall_PositionFromLine(iStartLine), SciCall_GetLineEndPosition(iEndLine)); } } @@ -6868,8 +6851,10 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) // void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActiveHotspot) { + if (Globals.bHideNonMatchedLines) { return; } + if (endPos < 0) { - endPos = Sci_GetDocEndPosition(); + endPos = Sci_GetDocEndPosition() - 1; } else if (endPos < startPos) { swapos(&startPos, &endPos); @@ -6890,12 +6875,15 @@ void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActi // 1st apply current lexer style EditFinalizeStyling(startPos); + SciCall_StartStyling(startPos); _ENTER_TARGET_TRANSACTION_; DocPos start = startPos; DocPos end = endPos; do { + SciCall_StartStyling(start); + DocPos const iPos = _FindInTarget(hwnd, pszUrlRegEx, iRegExLen, SCFIND_NP3_REGEX, &start, &end, false, FRMOD_IGNORE); if (iPos < 0) { @@ -6906,6 +6894,7 @@ void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActi break; // wrong match } // mark this match + EditFinalizeStyling(iPos); SciCall_StartStyling(iPos); if (bActiveHotspot) { SciCall_SetStyling((DocPosCR)mlen, Style_GetHotspotStyleID()); @@ -6913,15 +6902,17 @@ void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActi else { EditFinalizeStyling(end); } + // next occurrence - start = end; + start = end + 1; end = endPos; } while (start < end); _LEAVE_TARGET_TRANSACTION_; - SciCall_StartStyling(endPos); + EditFinalizeStyling(endPos); + SciCall_StartStyling(endPos + 1); } @@ -6953,7 +6944,7 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo SciCall_SetFoldFlags(0); Style_SetFolding(hwnd, Globals.bCodeFoldingAvailable && Settings.ShowCodeFolding); SciCall_FoldAll(EXPAND); - Sci_ApplyStyle(0, -1); + Sci_ApplyLexerStyle(0, -1); EditUpdateUrlHotspots(hwnd, 0, -1, Settings.HyperlinkHotspot); EditFinalizeStyling(-1); } @@ -7077,10 +7068,8 @@ static bool _HighlightIfBrace(HWND hwnd, DocPos iPos) void EditFinalizeStyling(DocPos iEndPos) { DocPos const iEndStyled = SciCall_GetEndStyled(); - - if ((iEndPos < 0) || (iEndStyled < iEndPos)) - { - Sci_ApplyStyle(iEndStyled, iEndPos); + if ((iEndPos < 0) || (iEndStyled < iEndPos)) { + Sci_ApplyLexerStyle(iEndStyled, iEndPos); } } diff --git a/src/Edit.h b/src/Edit.h index 4c771f468..fd8181ad3 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -109,7 +109,6 @@ void EditSetBookmarkList(HWND hwnd,LPCWSTR pszBookMarks); void EditFinalizeStyling(DocPos iEndPos); void EditMarkAllOccurrences(HWND hwnd, bool bForceClear); -void EditUpdateVisibleUrlHotspot(bool); void EditApplyVisibleStyle(HWND hwnd); void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, bool); diff --git a/src/Notepad3.c b/src/Notepad3.c index 30a6ad2bf..e0524a95a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -2414,9 +2414,6 @@ LRESULT MsgSize(HWND hwnd, WPARAM wParam, LPARAM lParam) EndDeferWindowPos(hdwp); s_WinCurrentWidth = cx; - - EditEnsureSelectionVisible(Globals.hwndEdit); - UpdateAllBars(false); return 0; @@ -3242,7 +3239,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDT_TIMER_UPDATE_HOTSPOT: - EditUpdateVisibleUrlHotspot(Settings.HyperlinkHotspot); + EditApplyVisibleStyle(Globals.hwndEdit); break; @@ -3534,7 +3531,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (EditSetNewEncoding(Globals.hwndEdit, iNewEncoding, (s_flagSetEncoding != CPI_NONE), StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)) == 0)) { - if (SendMessage(Globals.hwndEdit,SCI_GETLENGTH,0,0) == 0) { + if (SciCall_GetTextLength() == 0) { Encoding_Current(iNewEncoding); Encoding_HasChanged(iNewEncoding); } @@ -3547,6 +3544,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } _OBSERVE_NOTIFY_CHANGE_; EndWaitCursor(); + Sci_ApplyLexerStyle(0, -1); + EditUpdateUrlHotspots(Globals.hwndEdit, 0, -1, Settings.HyperlinkHotspot); + EditFinalizeStyling(-1); UpdateStatusbar(false); } break; @@ -3554,7 +3554,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_ENCODING_RECODE: { - if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) + if (StrIsNotEmpty(Globals.CurrentFile)) { cpi_enc_t iNewEncoding = Encoding_MapUnicode(Encoding_Current(CPI_GET)); @@ -6548,7 +6548,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) else if (iUpd & SC_UPDATE_CONTENT) { // ignoring SC_UPDATE_CONTENT cause Style and Marker are out of scope here // using WM_COMMAND -> SCEN_CHANGE instead! - //~MarkAllOccurrences(Settings2.UpdateDelayMarkAllCoccurrences, false); + //~~~MarkAllOccurrences(Settings2.UpdateDelayMarkAllCoccurrences, false); } } @@ -6566,7 +6566,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) if (Settings.HyperlinkHotspot) { UpdateVisibleUrlHotspot(Settings2.UpdateDelayHyperlinkStyling); } - //@@@~EditApplyVisibleStyle(Globals.hwndEdit); + //~~~EditApplyVisibleStyle(Globals.hwndEdit); } } break; diff --git a/src/SciCall.h b/src/SciCall.h index a520c3799..c9154a272 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -520,7 +520,7 @@ inline DocPos Sci_GetRangeMaxLineLength(DocLn iBeginLine, DocLn iEndLine) { #define Sci_ReplaceTarget(M,L,T) (((M) == SCI_REPLACETARGET) ? SciCall_ReplaceTarget((L),(T)) : SciCall_ReplaceTargetRe((L),(T))) // if iRangeEnd == -1 : apply style from iRangeStart to document end -#define Sci_ApplyStyle(B, E) SciCall_Colourise((B), (E)); +#define Sci_ApplyLexerStyle(B, E) SciCall_Colourise((B), (E)); //============================================================================= diff --git a/src/Styles.c b/src/Styles.c index 6b04a5ada..eb86cb859 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1311,7 +1311,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) Style_SetUrlHotSpot(hwnd, Settings.HyperlinkHotspot); // apply lexer styles - Sci_ApplyStyle(0, -1); + Sci_ApplyLexerStyle(0, -1); EditUpdateUrlHotspots(hwnd, 0, -1, Settings.HyperlinkHotspot); EditFinalizeStyling(-1); diff --git a/src/VersionEx.h b/src/VersionEx.h index fbd912cf5..929cd547e 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 430 -#define VERSION_BUILD 1684 +#define VERSION_REV 501 +#define VERSION_BUILD 1685 #define SCINTILLA_VER 415 #define ONIGMO_REGEX_VER 6.2.0 -#define VERSION_PATCH develop +#define VERSION_PATCH RC