From 1bf905e93bfb9226a5f8cd64cbf068c8e66c76dc Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Fri, 27 Aug 2021 12:41:51 +0200 Subject: [PATCH] +fix: don't jump on initial F/R Dialog on empty clipboard +fix: cursor hand on ctrl-keydown hover hyperlink --- scintilla/win32/ScintillaWin.cxx | 11 +++++- src/Edit.c | 2 -- src/Notepad3.c | 58 ++++++++++++++++++++++++++------ src/Notepad3.h | 3 +- src/TypeDefs.h | 3 +- 5 files changed, 61 insertions(+), 16 deletions(-) diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index ba0a5b016..55627e4ff 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -1654,7 +1654,7 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l HorizontalScrollTo(xPos); } return 0; - // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< } return 0; @@ -1685,6 +1685,15 @@ sptr_t ScintillaWin::KeyMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa altDown), &lastKeyDownConsumed); if (!ret && !lastKeyDownConsumed) { + // >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>> + if (hoverIndicatorPos != Sci::invalidPosition) { + POINT pt; + if (::GetCursorPos(&pt)) { + ::ScreenToClient(MainHWND(), &pt); + DisplayCursor(ContextCursor(PointFromPOINT(pt))); + } + } + // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); } break; diff --git a/src/Edit.c b/src/Edit.c index 53e46288f..20617d251 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -6445,8 +6445,6 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar } else { if (s_bIsReplaceDlg) { SciCall_ScrollRange(s_InitialAnchorPos, s_InitialCaretPos); - } else { - EditSetSelectionEx(end, iPos, -1, -1); } if (s_InitialTopLine >= 0) { SciCall_SetFirstVisibleLine(s_InitialTopLine); diff --git a/src/Notepad3.c b/src/Notepad3.c index b9963f286..be4c82253 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1792,6 +1792,9 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: return MsgNotify(hwnd, wParam, lParam); + //~case WM_KEYDOWN: + //~ return MsgKeyDown(hwnd, wParam, lParam); + case WM_FILECHANGEDNOTIFY: return MsgFileChangeNotify(hwnd, wParam, lParam); @@ -4005,6 +4008,28 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) return FALSE; } + +#if 0 +//============================================================================= +// +// MsgKeyDown() - Handles WM_KEYDOWN event +// ~~~ no event from Scintilla ~~~ +// +// +LRESULT MsgKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + UNREFERENCED_PARAMETER(hwnd); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + if (IsKeyDown(VK_CONTROL)) { + SciCall_SetCursor(SC_NP3_CURSORHAND); + } + return FALSE; +} +#endif + + //============================================================================= // // MsgCommand() - Handles WM_COMMAND @@ -6831,7 +6856,7 @@ LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // static DocPos prevCursorPosition = -1; -void HandleDWellStartEnd(const DocPos position, const int modifiers, const UINT uid) +void HandleDWellStartEnd(const DocPos position, const UINT uid) { static DocPos prevStartPosition = -1; static DocPos prevEndPosition = -1; @@ -6881,9 +6906,6 @@ void HandleDWellStartEnd(const DocPos position, const int modifiers, const UINT switch (indicator_id) { case INDIC_NP3_HYPERLINK: - if (modifiers & SCMOD_CTRL) { - SciCall_SetCursor(SC_NP3_CURSORHAND); - } if (!Settings.ShowHypLnkToolTip || SciCall_CallTipActive()) { return; } @@ -7503,7 +7525,10 @@ inline static LRESULT _MsgNotifyLean(const SCNotification *const scn, bool* bMod // --- check only mandatory events (must be fast !!!) --- if (pnmh->idFrom == IDC_EDIT) { - if (pnmh->code == SCN_MODIFIED) { + + switch (pnmh->code) { + + case SCN_MODIFIED: { int const iModType = scn->modificationType; if ((iModType & SC_MULTISTEPUNDOREDO) && !(iModType & SC_LASTSTEPINUNDOREDO)) { return TRUE; @@ -7551,15 +7576,26 @@ inline static LRESULT _MsgNotifyLean(const SCNotification *const scn, bool* bMod _DelaySplitUndoTransaction(bInUndoRedo ? max_dw(_MQ_FAST, timeout) : timeout); } } - } else if (pnmh->code == SCN_SAVEPOINTREACHED) { + } break; + + case SCN_SAVEPOINTREACHED: { SetSavePoint(); - } else if (pnmh->code == SCN_SAVEPOINTLEFT) { + } break; + + case SCN_SAVEPOINTLEFT: { SetSaveNeeded(); - } else if (pnmh->code == SCN_MODIFYATTEMPTRO) { + } break; + + case SCN_MODIFYATTEMPTRO: { if (FocusedView.HideNonMatchedLines) { EditToggleView(Globals.hwndEdit); } - } + } break; + + default: + break; + + } // switch return TRUE; } return FALSE; @@ -7698,7 +7734,7 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const SCNotification* const scn) case SCN_DWELLSTART: case SCN_DWELLEND: { - HandleDWellStartEnd(scn->position, scn->modifiers, pnmh->code); + HandleDWellStartEnd(scn->position, pnmh->code); } break; @@ -11264,7 +11300,7 @@ void SetNotifyIconTitle(HWND hwnd) // void ResetMouseDWellTime() { - if (Settings.HyperlinkHotspot || IsColorDefHotspotEnabled() || Settings.HighlightUnicodePoints) { + if (Settings.ShowHypLnkToolTip || IsColorDefHotspotEnabled() || Settings.HighlightUnicodePoints) { SciCall_SetMouseDWellTime(USER_TIMER_MINIMUM << 4); } else { Sci_DisableMouseDWellNotification(); diff --git a/src/Notepad3.h b/src/Notepad3.h index 88c014647..dcdccc954 100644 --- a/src/Notepad3.h +++ b/src/Notepad3.h @@ -139,7 +139,7 @@ int BeginUndoAction(); void EndUndoAction(int token); bool RestoreAction(int token, DoAction doAct); -void HandleDWellStartEnd(const DocPos position, const int modifiers, const UINT uid); +void HandleDWellStartEnd(const DocPos position, const UINT uid); bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operation); void HandleColorDefClicked(HWND hwnd, const DocPos position); @@ -181,6 +181,7 @@ LRESULT MsgExitMenuLoop(HWND hwnd, WPARAM wParam); LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT MsgFileChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT MsgTrayMessage(HWND hwnd, WPARAM wParam, LPARAM lParam); +//~LRESULT MsgKeyDown(HWND hwnd, WPARAM wParam, LPARAM lParam); LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam); LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index c3b2e3672..00b7bef98 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -337,7 +337,8 @@ typedef struct _encloseselectiondata { // -------------------------------------------------------------------------- -#define SC_NP3_CURSORHAND 8 +#define SC_NP3_CURSORARROW 2 +#define SC_NP3_CURSORHAND 8 //=============================================================================