+ fix: 1st part of BeginWaitCursor() cleanup

This commit is contained in:
Rainer Kottenhoff 2018-02-22 18:17:46 +01:00
parent 7016470eb6
commit 01e103bf8b
6 changed files with 38 additions and 28 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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

View File

@ -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

Binary file not shown.