From d2e8537e254af1d5e8ed4e02b8da38311ac94cfc Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Thu, 13 May 2021 15:29:00 +0200 Subject: [PATCH] + fix: minor enhancements for selection scroll to view --- src/Edit.c | 11 +++-------- src/Notepad3.c | 5 ++--- src/Notepad3.h | 5 +---- src/SciCall.h | 2 +- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index a10a99826..956e9efe6 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1431,7 +1431,9 @@ bool EditSaveFile( // ensure consistent line endings if (Settings.FixLineEndings) { + BeginWaitCursorUID(true, IDS_MUI_SB_CONV_LNBRK); EditEnsureConsistentLineEndings(hwnd); + EndWaitCursor(); } // strip trailing blanks @@ -3255,11 +3257,8 @@ void EditIndentBlock(HWND hwnd, int cmd, bool bFormatIndentation, bool bForceAll //~~~UndoTransActionBegin(); ~ do outside - DocPos const iInitialPos = SciCall_GetCurrentPos(); - if (bForceAll) { SciCall_SelectAll(); - SciCall_SwapMainAnchorCaret(); } DocPos const iCurPos = SciCall_GetCurrentPos(); @@ -3323,9 +3322,8 @@ void EditIndentBlock(HWND hwnd, int cmd, bool bFormatIndentation, bool bForceAll } EditSetSelectionEx(SciCall_GetLineEndPosition(iAnchorLine) - iDiffAnchor, SciCall_GetLineEndPosition(iCurLine) - iDiffCurrent, -1, -1); } - //EditScrollSelectionToView(); } else { - Sci_GotoPosChooseCaret(iInitialPos); + Sci_ScrollChooseCaret(); } //~~~EndUndoTransAction(); ~ do outside @@ -5362,10 +5360,7 @@ void EditSetSelectionEx(DocPos iAnchorPos, DocPos iCurrentPos, DocPos vSpcAnchor // void EditEnsureConsistentLineEndings(HWND hwnd) { - IgnoreNotifyDocChangedEvent(true); SciCall_ConvertEOLs(SciCall_GetEOLMode()); - ObserveNotifyDocChangedEvent(); - Globals.bDocHasInconsistentEOLs = false; EditFixPositions(hwnd); } diff --git a/src/Notepad3.c b/src/Notepad3.c index 29e69393a..ed84b1cb7 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -4310,8 +4310,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_LINEENDINGS_CRLF: case IDM_LINEENDINGS_CR: case IDM_LINEENDINGS_LF: { - BeginWaitCursorUID(true, IDS_MUI_SB_CONV_LNBRK); int const _eol_mode = (iLoWParam - IDM_LINEENDINGS_CRLF); // SC_EOL_CRLF(0), SC_EOL_CR(1), SC_EOL_LF(2) + BeginWaitCursorUID(true, IDS_MUI_SB_CONV_LNBRK); SciCall_SetEOLMode(_eol_mode); EditEnsureConsistentLineEndings(Globals.hwndEdit); EndWaitCursor(); @@ -9561,7 +9561,6 @@ bool RestoreAction(int token, DoAction doAct) PostMessage(hwndedit, SCI_ENSUREVISIBLE, currPosLine, 0); } - int const selectionMode = (UNDO == doAct) ? pSel->selMode_undo : pSel->selMode_redo; PostMessage(hwndedit, SCI_SETSELECTIONMODE, (WPARAM)((selectionMode == NP3_SEL_MULTI) ? SC_SEL_STREAM : selectionMode), 0); @@ -9620,7 +9619,7 @@ bool RestoreAction(int token, DoAction doAct) break; } } - PostMessage(hwndedit, SCI_SCROLLCARET, 0, 0); + PostMessage(hwndedit, SCI_SCROLLRANGE, (WPARAM)(*pPosAnchor), (LPARAM)(*pPosCur)); PostMessage(hwndedit, SCI_CHOOSECARETX, 0, 0); } return true; diff --git a/src/Notepad3.h b/src/Notepad3.h index 1eda96131..b44580b6c 100644 --- a/src/Notepad3.h +++ b/src/Notepad3.h @@ -191,10 +191,7 @@ void ObserveNotifyDocChangedEvent(); // ---------------------------------------------------------------------------- -#define DocChangeTransactionBegin() \ - __try { \ - SciCall_BeginUndoAction(); \ - IgnoreNotifyDocChangedEvent(false); +#define DocChangeTransactionBegin() __try { SciCall_BeginUndoAction(); IgnoreNotifyDocChangedEvent(false); #define EndDocChangeTransaction() } __finally { ObserveNotifyDocChangedEvent(); SciCall_EndUndoAction(); } // ---------------------------------------------------------------------------- diff --git a/src/SciCall.h b/src/SciCall.h index 2e8b42e5c..d9bd6c1c5 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -758,7 +758,7 @@ inline void Sci_ScrollToLine(const DocLn line) if (!SciCall_GetLineVisible(line)) { SciCall_EnsureVisible(line); } - SciCall_ScrollRange(SciCall_PositionFromLine(line), SciCall_GetLineEndPosition(line)); + SciCall_ScrollRange(SciCall_GetLineEndPosition(line), SciCall_PositionFromLine(line)); } inline void Sci_ScrollToCurrentLine() {