diff --git a/src/Edit.c b/src/Edit.c index 0eb096d03..6acf1c06b 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -477,10 +477,7 @@ BOOL EditSetNewEncoding(HWND hwnd,int iNewEncoding,BOOL bNoUI,BOOL bSetSavePoint BOOL doNewEncoding = (!bNoUI) ? (InfoBox(MBYESNO, L"MsgConv1", IDS_ASK_ENCODING) == IDYES) : TRUE; if (doNewEncoding) { - BeginWaitCursor(NULL); - BOOL result = EditConvertText(hwnd,iCurrentEncoding,iNewEncoding,FALSE); - EndWaitCursor(); - return result; + return EditConvertText(hwnd,iCurrentEncoding,iNewEncoding,FALSE); } } } @@ -3680,7 +3677,6 @@ void EditRemoveBlankLines(HWND hwnd,BOOL bMerge) if (iSelStart > SciCall_PositionFromLine(iLineStart)) { ++iLineStart; } if ((iSelEnd <= SciCall_PositionFromLine(iLineEnd)) && (iLineEnd != SciCall_GetLineCount() - 1)) { --iLineEnd; } - IgnoreNotifyChangeEvent(); EditEnterTargetTransaction(); for (DocLn iLine = iLineStart; iLine <= iLineEnd; ) @@ -3705,7 +3701,6 @@ void EditRemoveBlankLines(HWND hwnd,BOOL bMerge) } EditLeaveTargetTransaction(); - ObserveNotifyChangeEvent(); } @@ -5764,8 +5759,6 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowInfo, D DocPos start = iStartPos; DocPos end = iEndPos; - BeginWaitCursor(NULL); - DocPos iPos = EditFindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, FALSE); if ((iPos < -1) && (lpefr->fuFlags & SCFIND_REGEXP)) { @@ -5821,10 +5814,6 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowInfo, D EditLeaveTargetTransaction(); } - ObserveNotifyChangeEvent(); - - EndWaitCursor(); - utarray_clear(ReplPosUTArray); utarray_free(ReplPosUTArray); LocalFree(pszReplace); @@ -5846,8 +5835,10 @@ int EditReplaceAllInRange(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowInfo, D // BOOL EditReplaceAll(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowInfo) { - DocPos start = 0; - DocPos end = SciCall_GetTextLength(); + const DocPos start = 0; + const DocPos end = SciCall_GetTextLength(); + + BeginWaitCursor(NULL); int token = BeginUndoAction(); @@ -5855,6 +5846,8 @@ BOOL EditReplaceAll(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowInfo) EndUndoAction(token); + EndWaitCursor(); + return (iReplacedOccurrences > 0) ? TRUE : FALSE; } @@ -5870,8 +5863,14 @@ BOOL EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowIn return FALSE; } - DocPos start = SciCall_GetSelectionStart(); - DocPos end = SciCall_GetSelectionEnd(); + const DocPos start = SciCall_GetSelectionStart(); + const DocPos end = SciCall_GetSelectionEnd(); + bool bWaitCursor = false; + + if ((end - start) > (512 * 512)) { + BeginWaitCursor(NULL); + bWaitCursor = true; + } int token = BeginUndoAction(); @@ -5879,9 +5878,12 @@ BOOL EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, BOOL bShowIn EndUndoAction(token); - if (iReplacedOccurrences <= 0) + if (bWaitCursor) { + EndWaitCursor(); + } + if (iReplacedOccurrences <= 0) { return FALSE; - + } return TRUE; } diff --git a/src/Helpers.h b/src/Helpers.h index 5a8f836bd..228dd753e 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -78,11 +78,10 @@ __inline BOOL IniSectionSetBool(LPWSTR lpCachedIniSection, LPCWSTR lpName, BOOL return IniSectionSetInt(lpCachedIniSection, lpName, (b ? 1 : 0)); } - //extern HWND g_hwndEdit; -#define BeginWaitCursor(TCH) { SendMessage(g_hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORWAIT,0); StatusSetText(g_hwndStatus,STATUS_HELP,(TCH)); } -#define BeginWaitCursorID(UID) { SendMessage(g_hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORWAIT,0); StatusSetTextID(g_hwndStatus,STATUS_HELP,(UID)); } -#define EndWaitCursor() { POINT pt; SendMessage(g_hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORNORMAL,0); GetCursorPos(&pt); SetCursorPos(pt.x,pt.y); StatusSetSimple(g_hwndStatus,FALSE); UpdateStatusbar(); } +#define BeginWaitCursor(TCH) { SciCall_SetCursor(SC_CURSORWAIT); StatusSetText(g_hwndStatus,STATUS_HELP,(TCH)); IgnoreNotifyChangeEvent(); } +#define BeginWaitCursorID(UID) { SciCall_SetCursor(SC_CURSORWAIT); StatusSetTextID(g_hwndStatus,STATUS_HELP,(UID)); IgnoreNotifyChangeEvent(); } +#define EndWaitCursor() { POINT pt; SciCall_SetCursor(SC_CURSORNORMAL); GetCursorPos(&pt); SetCursorPos(pt.x,pt.y); StatusSetSimple(g_hwndStatus,FALSE); ObserveNotifyChangeEvent(); UpdateStatusbar(); } //#define Is2k() (g_uWinVer >= 0x0500) diff --git a/src/Notepad3.c b/src/Notepad3.c index 472b4c748..75f8f013b 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -2683,6 +2683,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) } } + BeginWaitCursor(NULL); if (EditSetNewEncoding(g_hwndEdit, iNewEncoding, (flagSetEncoding), @@ -2697,10 +2698,10 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) Encoding_HasChanged(CPI_NONE); Encoding_Current(iNewEncoding); } - UpdateToolbar(); - UpdateStatusbar(); } + EndWaitCursor(); + } break; @@ -4613,7 +4614,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) WideCharToMultiByteStrg(cp,wchReplace,efrTS.szReplace); if (!SendMessage(g_hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0)) - EditReplaceAllInSelection(g_hwndEdit,&efrTS,TRUE); + EditReplaceAllInSelection(g_hwndEdit, &efrTS, TRUE); else EditReplaceAll(g_hwndEdit,&efrTS,TRUE); } diff --git a/src/Notepad3.rc b/src/Notepad3.rc index e22b73ef0..aad3f2eda 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -178,7 +178,10 @@ BEGIN MENUITEM "&Join Lines\tCtrl+J", IDM_EDIT_JOINLINES MENUITEM "&Fuse Lines\tCtrl+Alt+J", IDM_EDIT_JOINLN_NOSP MENUITEM "&Preserve Paragraphs\tCtrl+Shift+J", IDM_EDIT_JOINLINES_PARA - END + MENUITEM SEPARATOR + MENUITEM "Merge &Blank Lines\tAlt+Y", IDM_EDIT_MERGEBLANKLINES + MENUITEM "&Remove Blank Lines\tAlt+R", IDM_EDIT_REMOVEBLANKLINES + END POPUP "&Block" BEGIN MENUITEM "&Indent", IDM_EDIT_INDENT @@ -204,8 +207,6 @@ BEGIN MENUITEM "Strip &Last Character\tAlt+U", IDM_EDIT_STRIPLASTCHAR MENUITEM "Strip &Trailing Blanks\tAlt+W", IDM_EDIT_TRIMLINES MENUITEM "Compress &Whitespace\tAlt+P", IDM_EDIT_COMPRESSWS - MENUITEM "Merge &Blank Lines\tAlt+Y", IDM_EDIT_MERGEBLANKLINES - MENUITEM "&Remove Blank Lines\tAlt+R", IDM_EDIT_REMOVEBLANKLINES MENUITEM SEPARATOR MENUITEM "&Modify Lines...\tAlt+M", IDM_EDIT_MODIFYLINES MENUITEM "&Align Lines...\tAlt+J", IDM_EDIT_ALIGN diff --git a/src/SciCall.h b/src/SciCall.h index 29be7f646..d991c5265 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -220,6 +220,13 @@ DeclareSciCallV1(EnsureVisible, ENSUREVISIBLE, DocLn, line); DeclareSciCallV2(SetProperty, SETPROPERTY, const char *, key, const char *, value); +//============================================================================= +// +// Cursor +// +DeclareSciCallV1(SetCursor, SETCURSOR, int, flags); + + //============================================================================= // // Undo/Redo Stack