From 13eebb95a6c57d39136cf4b2b53c6ad1eaf88df5 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 4 May 2018 10:59:27 +0200 Subject: [PATCH 1/5] + fix: insert key into rectangular selection --- src/Edit.c | 19 ++----------------- src/Notepad3.c | 8 +++----- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 3d795fd70..09b5c0260 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -2697,23 +2697,8 @@ void EditIndentBlock(HWND hwnd, int cmd, bool bFormatIndentation) if (SciCall_IsSelectionRectangle()) { - //if (cmd == SCI_TAB) { - // if (g_bTabsAsSpaces) { - // int size = (bFormatIndentation ? g_iIndentWidth : g_iTabWidth); - // char* pPadStr = LocalAlloc(LPTR, size + 1); - // FillMemory(pPadStr, size, ' '); - // EditPaste2RectSel(hwnd, pPadStr); - // LocalFree(pPadStr); - // } - // else { - // EditPaste2RectSel(hwnd, "\t"); - // } - // return; - //} - // better idea: EditPaste2RectSel(hwnd, pPadStr, pText); pText==NULL => copy single sel - - //TODO: workaround for rectangular selection: make stream selection - EditSelectEx(hwnd, SciCall_GetAnchor(), SciCall_GetCurrentPos(), -1, -1); + SendMessage(hwnd, cmd, 0, 0); + return; } const DocPos iCurPos = SciCall_GetCurrentPos(); diff --git a/src/Notepad3.c b/src/Notepad3.c index 17f6c7b46..ec8d24d61 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1427,7 +1427,7 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) SendMessage(hwndEditCtrl, SCI_SETENDATLASTLINE, true, 0); SendMessage(hwndEditCtrl, SCI_SETMOUSESELECTIONRECTANGULARSWITCH, true, 0); SendMessage(hwndEditCtrl, SCI_SETMULTIPLESELECTION, false, 0); - SendMessage(hwndEditCtrl, SCI_SETADDITIONALSELECTIONTYPING, false, 0); + SendMessage(hwndEditCtrl, SCI_SETADDITIONALSELECTIONTYPING, true, 0); SendMessage(hwndEditCtrl, SCI_SETADDITIONALCARETSBLINK, true, 0); SendMessage(hwndEditCtrl, SCI_SETADDITIONALCARETSVISIBLE, true, 0); SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, SCVS_NONE, 0); @@ -2767,6 +2767,8 @@ LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { + UNUSED(lParam); + switch(LOWORD(wParam)) { case SCEN_CHANGE: @@ -5558,10 +5560,6 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) break; } - - UNUSED(wParam); - UNUSED(lParam); - return(0); } From efa7f8927278cc0743bc22f1fb35224e456613f3 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 4 May 2018 12:47:51 +0200 Subject: [PATCH 2/5] + fix: Undo/Redo in case of selection insert/delete --- src/Notepad3.c | 30 ++++++++++++++++++++++++++---- src/SciCall.h | 9 +++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index ec8d24d61..bcbbc6082 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1417,10 +1417,14 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) Encoding_Current(g_iDefaultNewFileEncoding); // general setup + //int const evtMask = SC_MODEVENTMASKALL; + int const evtMask1 = SC_MOD_CONTAINER | SC_PERFORMED_USER | SC_PERFORMED_UNDO | SC_PERFORMED_REDO; + int const evtMask2 = SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT | SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE | SC_STARTACTION; + SendMessage(hwndEditCtrl, SCI_SETMODEVENTMASK, (WPARAM)(evtMask1 | evtMask2), 0); + SendMessage(hwndEditCtrl, SCI_SETCODEPAGE, (WPARAM)SC_CP_UTF8, 0); // fixed internal UTF-8 SendMessage(hwndEditCtrl, SCI_SETEOLMODE, SC_EOL_CRLF, 0); SendMessage(hwndEditCtrl, SCI_SETPASTECONVERTENDINGS, true, 0); - SendMessage(hwndEditCtrl, SCI_SETMODEVENTMASK,/*SC_MODEVENTMASKALL*/SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT | SC_MOD_CONTAINER, 0); SendMessage(hwndEditCtrl, SCI_USEPOPUP, false, 0); SendMessage(hwndEditCtrl, SCI_SETSCROLLWIDTH, 1, 0); SendMessage(hwndEditCtrl, SCI_SETSCROLLWIDTHTRACKING, true, 0); @@ -5661,6 +5665,7 @@ void OpenHotSpotURL(DocPos position, bool bForceBrowser) // // MsgNotify() - Handles WM_NOTIFY // +// !!! Set correct SCI_SETMODEVENTMASK in _InitializeSciEditCtrl() // LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) { @@ -5672,6 +5677,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) // --- check only mandatory events (must be fast !!!) --- if (pnmh->idFrom == IDC_EDIT) { if (pnmh->code == SCN_MODIFIED) { + bool bModified = true; // check for ADDUNDOACTION step if (scn->modificationType & SC_MOD_CONTAINER) { @@ -5682,7 +5688,15 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) RestoreAction(scn->token, REDO); } } - _SetDocumentModified(true); + else if ((scn->modificationType & SC_MOD_BEFOREINSERT) || + (scn->modificationType & SC_MOD_BEFOREDELETE)) { + if (!(scn->modificationType & SC_STARTACTION) && !SciCall_IsSelectionEmpty()) { + int const token = BeginUndoAction(); + if (token >= 0) { EndUndoAction(token); } + } + bModified = false; // not yet + } + if (bModified) { _SetDocumentModified(true); } } else if (pnmh->code == SCN_SAVEPOINTREACHED) { _SetDocumentModified(false); @@ -5780,7 +5794,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) case SCN_MODIFIED: { - // check for ADDUNDOACTION step + bool bModified = true; if (scn->modificationType & SC_MOD_CONTAINER) { if (scn->modificationType & SC_PERFORMED_UNDO) { RestoreAction(scn->token, UNDO); @@ -5789,6 +5803,14 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) RestoreAction(scn->token, REDO); } } + else if ((scn->modificationType & SC_MOD_BEFOREINSERT) || + (scn->modificationType & SC_MOD_BEFOREDELETE)) { + if (!(scn->modificationType & SC_STARTACTION) && !SciCall_IsSelectionEmpty()) { + int const token = BeginUndoAction(); + if (token >= 0) { EndUndoAction(token); } + } + bModified = false; // not yet + } else if (scn->modificationType & SC_MOD_CHANGESTYLE) { const DocPos iStartPos = (DocPos)scn->position; const DocPos iEndPos = (DocPos)(scn->position + scn->length); @@ -5804,7 +5826,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) UpdateLineNumberWidth(); } - _SetDocumentModified(true); + if (bModified) { _SetDocumentModified(true); } UpdateToolbar(); UpdateStatusbar(false); diff --git a/src/SciCall.h b/src/SciCall.h index 61d62d909..64b87ce6e 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -138,11 +138,7 @@ DeclareSciCallR0(GetReadOnly, GETREADONLY, bool) DeclareSciCallV1(SetReadOnly, SETREADONLY, bool, flag) DeclareSciCallR0(CanUndo, CANUNDO, bool) DeclareSciCallR0(CanRedo, CANREDO, bool) - DeclareSciCallR0(IsDocModified, GETMODIFY, bool) -DeclareSciCallR0(IsSelectionEmpty, GETSELECTIONEMPTY, bool) -DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) - DeclareSciCallR0(CanPaste, CANPASTE, bool) DeclareSciCallR0(GetCurrentPos, GETCURRENTPOS, DocPos) @@ -367,11 +363,12 @@ DeclareSciCallV1(SetTechnology, SETTECHNOLOGY, int, technology) // // Utilities // +DeclareSciCallR0(IsSelectionEmpty, GETSELECTIONEMPTY, bool) +DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) #define Sci_IsStreamSelected() (SciCall_GetSelectionMode() == SC_SEL_STREAM) #define Sci_IsFullLineSelected() (SciCall_GetSelectionMode() == SC_SEL_LINES) #define Sci_IsThinRectangleSelected() (SciCall_GetSelectionMode() == SC_SEL_THIN) -#define Sci_IsSingleLineSelection() \ -(SciCall_LineFromPosition(SciCall_GetCurrentPos()) == SciCall_LineFromPosition(SciCall_GetAnchor())) +#define Sci_IsSingleLineSelection() (SciCall_LineFromPosition(SciCall_GetCurrentPos()) == SciCall_LineFromPosition(SciCall_GetAnchor())) #define Sci_GetEOLLen() ((SciCall_GetEOLMode() == SC_EOL_CRLF) ? 2 : 1) From 8405c36b44cc80d86c82aa030320f1b676a0f3bc Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 4 May 2018 15:49:26 +0200 Subject: [PATCH 3/5] + fix: cleanup obsolete rectangular pasting helpers --- src/Edit.c | 205 ++++++++++--------------------------------------- src/Edit.h | 3 +- src/Notepad3.c | 157 ++++++++++++++++++------------------- 3 files changed, 121 insertions(+), 244 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 09b5c0260..b601c6f71 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -570,8 +570,8 @@ bool EditIsRecodingNeeded(WCHAR* pszText, int cchLen) // // EditGetClipboardText() // -char* EditGetClipboardText(HWND hwnd,bool bCheckEncoding,int* pLineCount,int* pLenLastLn) { - +char* EditGetClipboardText(HWND hwnd, bool bCheckEncoding, int* pLineCount, int* pLenLastLn) +{ if (!IsClipboardFormatAvailable(CF_UNICODETEXT) || !OpenClipboard(GetParent(hwnd))) { char* pEmpty = StrDupA(""); return (pEmpty); @@ -613,7 +613,9 @@ char* EditGetClipboardText(HWND hwnd,bool bCheckEncoding,int* pLineCount,int* pL int lineCount = 0; int lenLastLine = 0; - if ((bool)SendMessage(hwnd,SCI_GETPASTECONVERTENDINGS,0,0)) { + + if ((bool)SendMessage(hwnd,SCI_GETPASTECONVERTENDINGS,0,0)) + { char* ptmp = LocalAlloc(LPTR,mlen * 2 + 2); if (ptmp) { char *s = pmch; @@ -731,178 +733,53 @@ bool EditClearClipboard(HWND hwnd) //============================================================================= // -// EditPaste2RectSel() +// EditSwapClipboard() // -void EditPaste2RectSel(HWND hwnd, char* pText) +bool EditSwapClipboard(HWND hwnd, bool bSkipUnicodeCheck) { - if (!SciCall_IsSelectionRectangle()) { return; } - - const DocPos length = lstrlenA(pText); // '\0' terminated - _IGNORE_NOTIFY_CHANGE_; - _ENTER_TARGET_TRANSACTION_; - const DocPosU selCount = (DocPosU)SendMessage(hwnd, SCI_GETSELECTIONS, 0, 0); - - char* pTextLine = pText; - // remove line-break from last line - if (*pTextLine != '\0') { StrTrimA(pTextLine, "\r\n"); } - - for (DocPosU s = 0; s < selCount; ++s) { - // get lines from clip - char *ln = pTextLine; - int lnLen = 0; - while (*ln != '\0') { - if (s < (selCount - 1)) { - if (*ln == '\n' || *ln == '\r') { - if ((*ln == '\r') && (*(ln + 1) == '\n')) { ++ln; } - ++ln; // next line - break; - } - else { ++ln; ++lnLen; } - } - else { ++ln; ++lnLen; } // last line - } - - const DocPos selCaretPos = SciCall_GetSelectionNCaret(s); - const DocPos selAnchorPos = SciCall_GetSelectionNAnchor(s); - const DocPos selCaretVspc = SciCall_GetSelectionNCaretVirtualSpace(s); - const DocPos selAnchorVspc = SciCall_GetSelectionNAnchorVirtualSpace(s); - - DocPos virtualSpaceLen = 0; - DocPos selTargetStart = 0; - DocPos selTargetEnd = 0; - if (selCaretPos < selAnchorPos) { - selTargetStart = selCaretPos; - selTargetEnd = selAnchorPos; - virtualSpaceLen = selCaretVspc; - } - else { - selTargetStart = selAnchorPos; - selTargetEnd = selCaretPos; - virtualSpaceLen = selAnchorVspc; - } - - if (virtualSpaceLen > 0) { - char* pPadStr = LocalAlloc(LPTR, (virtualSpaceLen + length + 1) * sizeof(char)); - if (pPadStr) { - SIZE_T size = LocalSize(pPadStr) - sizeof(char); - FillMemory(pPadStr, virtualSpaceLen, ' '); - pPadStr[virtualSpaceLen] = '\0'; - StringCchCatNA(pPadStr, size, pTextLine, lnLen); - SciCall_SetTargetRange(selTargetStart, selTargetEnd); - SciCall_ReplaceTarget(lstrlenA(pPadStr), pPadStr); - LocalFree(pPadStr); - } - else { - SciCall_SetTargetRange(selTargetStart, selTargetEnd); - SciCall_ReplaceTarget(lnLen, pTextLine); - } - } - else // no virtual space to pad - { - SciCall_SetTargetRange(selTargetStart, selTargetEnd); - SciCall_ReplaceTarget(lnLen, pTextLine); - } - - //SciCall_SetSelectionNAnchor(s, selTargetStart); - //SciCall_SetSelectionNCaret(s, selTargetStart); - //if (virtualSpaceLen > 0) { - // SciCall_SetSelectionNCaretVirtualSpace(s, virtualSpaceLen); - // SciCall_SetSelectionNAnchorVirtualSpace(s, virtualSpaceLen); - //} - - if (*ln != '\0') { - pTextLine = ln; // next clip line - } - //else: rest of rect single selections are filled with last line - - } // for() - - _LEAVE_TARGET_TRANSACTION_; - _OBSERVE_NOTIFY_CHANGE_; -} - - -//============================================================================= -// -// EditPasteClipboard() -// -bool EditPasteClipboard(HWND hwnd, bool bSwapClipBoard, bool bSkipUnicodeCheck) -{ int lineCount = 0; int lenLastLine = 0; - - char* pClip = EditGetClipboardText(hwnd, !bSkipUnicodeCheck, &lineCount, &lenLastLine); + char* const pClip = EditGetClipboardText(hwnd, !bSkipUnicodeCheck, &lineCount, &lenLastLine); if (!pClip) { return false; // recoding canceled } - const DocPos clipLen = lstrlenA(pClip); + DocPos const clipLen = lstrlenA(pClip); - const DocPos iCurPos = SciCall_GetCurrentPos(); - const DocPos iAnchorPos = SciCall_GetAnchor(); + DocPos const iCurPos = SciCall_GetCurrentPos(); + DocPos const iAnchorPos = SciCall_GetAnchor(); + bool const bIsRectSel = SciCall_IsSelectionRectangle(); - if (SciCall_IsSelectionEmpty() || (lineCount <= 1)) - { - _IGNORE_NOTIFY_CHANGE_; - - if (SciCall_IsSelectionEmpty()) // SC_SEL_THIN - { - SciCall_Paste(); - if (bSwapClipBoard) { - EditClearClipboard(hwnd); - EditSelectEx(hwnd, iAnchorPos, SciCall_GetCurrentPos(), -1, -1); - } - //else { - // EditSelectEx(hwnd, SciCall_GetCurrentPos(), SciCall_GetCurrentPos(), -1, -1); - //} - } - else { - char* pszText = LocalAlloc(LPTR, SciCall_GetSelText(NULL)); - SciCall_GetSelText(pszText); - if (clipLen == 0) { SciCall_Clear(); } else { SciCall_Paste(); } - if (bSwapClipBoard) { - EditSetClipboardText(hwnd, pszText); - if (iCurPos < iAnchorPos) - EditSelectEx(hwnd, SciCall_GetCurrentPos(), iCurPos, -1, -1); - else - EditSelectEx(hwnd, iAnchorPos, SciCall_GetCurrentPos(), -1, -1); - } - else { - if (iCurPos < iAnchorPos) - EditSelectEx(hwnd, iCurPos, iCurPos, -1, -1); - } - LocalFree(pszText); - } - _OBSERVE_NOTIFY_CHANGE_; + char* pszText = NULL; + SIZE_T const size = SciCall_GetSelText(NULL); + if (size > 0) { + pszText = LocalAlloc(LPTR, size); + SciCall_GetSelText(pszText); + SciCall_Paste(); //~SciCall_ReplaceSel(pClip); + EditSetClipboardText(hwnd, pszText); } else { - if (SciCall_IsSelectionRectangle()) - { - if (bSwapClipBoard) { SciCall_Copy(); } - EditPaste2RectSel(hwnd, pClip); - //TODO: restore selection in case of swap clipboard - } - else // Selection: SC_SEL_STREAM, SC_SEL_LINES - { - _IGNORE_NOTIFY_CHANGE_; - if (bSwapClipBoard) { - SciCall_Copy(); - SciCall_ReplaceSel(pClip); - if (iCurPos < iAnchorPos) - EditSelectEx(hwnd, iCurPos + clipLen, iCurPos, -1, -1); - else - EditSelectEx(hwnd, iAnchorPos, iAnchorPos + clipLen, -1, -1); - } - else { - SciCall_ReplaceSel(pClip); - if (iCurPos < iAnchorPos) - EditSelectEx(hwnd, iCurPos, iCurPos, -1, -1); - } - _OBSERVE_NOTIFY_CHANGE_; - } + SciCall_Paste(); //~SciCall_ReplaceSel(pClip); + SciCall_Clear(); } + if (pszText) { LocalFree(pszText); } + + if (!bIsRectSel) { + //TODO: check for Rectangular Clipboard and skip selection restore + if (iCurPos < iAnchorPos) + EditSelectEx(hwnd, iCurPos + clipLen, iCurPos, -1, -1); + else + EditSelectEx(hwnd, iAnchorPos, iAnchorPos + clipLen, -1, -1); + } + else { + //TODO: restore selection in case of swap clipboard + } + LocalFree(pClip); + + _OBSERVE_NOTIFY_CHANGE_; + return true; } @@ -3227,7 +3104,7 @@ void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup) { if (SciCall_IsSelectionEmpty() || Sci_IsThinRectangleSelected()) { return; } - const int token = (!bNoUndoGroup ? BeginUndoAction() : -1); + int const token = (!bNoUndoGroup ? BeginUndoAction() : -1); if (SciCall_IsSelectionRectangle()) { @@ -5598,7 +5475,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDC_REPLACE: { bReplaceInitialized = true; - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditReplace(sg_pefrData->hwnd, sg_pefrData); EndUndoAction(token); } @@ -6223,7 +6100,7 @@ bool EditReplaceAll(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowInfo) BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); iReplacedOccurrences = EditReplaceAllInRange(hwnd, lpefr, start, end, &enlargement); @@ -6259,7 +6136,7 @@ bool EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowIn const DocPos anchorPos = SciCall_GetAnchor(); DocPos enlargement = 0; - int token = BeginUndoAction(); + int const token = BeginUndoAction(); bool const bWaitCursor = ((end - start) > (512 * 512)) ? true : false; if (bWaitCursor) { BeginWaitCursor(NULL); } diff --git a/src/Edit.h b/src/Edit.h index 9faedd35e..b4b4a014a 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -30,8 +30,7 @@ bool EditIsRecodingNeeded(WCHAR*,int); char* EditGetClipboardText(HWND,bool,int*,int*); bool EditSetClipboardText(HWND, const char*); bool EditClearClipboard(HWND); -void EditPaste2RectSel(HWND,char*); -bool EditPasteClipboard(HWND,bool,bool); +bool EditSwapClipboard(HWND,bool); bool EditCopyAppend(HWND,bool); int EditDetectEOLMode(HWND,char*,DWORD); bool EditLoadFile(HWND,LPCWSTR,bool,bool,int*,int*,bool*,bool*,bool*); diff --git a/src/Notepad3.c b/src/Notepad3.c index bcbbc6082..144ac39b9 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1063,7 +1063,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) bool bAutoIndent2 = bAutoIndent; bAutoIndent = 0; EditJumpTo(g_hwndEdit, -1, 0); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); if (SendMessage(g_hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { SendMessage(g_hwndEdit, SCI_NEWLINE, 0, 0); } @@ -3145,7 +3145,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) if (g_flagPasteBoard) bLastCopyFromMe = true; - int token = BeginUndoAction(); + int const token = BeginUndoAction(); if (!SciCall_IsSelectionEmpty()) { SciCall_Cut(); @@ -3192,13 +3192,12 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (g_flagPasteBoard) bLastCopyFromMe = true; - int token = BeginUndoAction(); - EditPasteClipboard(g_hwndEdit, false, bSkipUnicodeDetection); + int const token = BeginUndoAction(); + SciCall_Paste(); EndUndoAction(token); - // Updates done by EditPasteClipboard(): - //~UpdateToolbar(); - //~UpdateStatusbar(false); - //~UpdateLineNumberWidth(); + UpdateToolbar(); + UpdateStatusbar(false); + UpdateLineNumberWidth(); } break; @@ -3206,11 +3205,12 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (g_flagPasteBoard) bLastCopyFromMe = true; - int token = BeginUndoAction(); - EditPasteClipboard(g_hwndEdit, true, bSkipUnicodeDetection); + int const token = BeginUndoAction(); + EditSwapClipboard(g_hwndEdit, bSkipUnicodeDetection); EndUndoAction(token); UpdateToolbar(); UpdateStatusbar(false); + UpdateLineNumberWidth(); } break; @@ -3222,6 +3222,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SELECTALL: SendMessage(g_hwndEdit,SCI_SELECTALL,0,0); + UpdateToolbar(); UpdateStatusbar(false); break; @@ -3280,7 +3281,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_MOVELINEUP: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditMoveUp(g_hwndEdit); EndUndoAction(token); } @@ -3289,7 +3290,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_MOVELINEDOWN: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditMoveDown(g_hwndEdit); EndUndoAction(token); } @@ -3305,7 +3306,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (g_flagPasteBoard) bLastCopyFromMe = true; - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_LINECUT,0,0); UpdateToolbar(); EndUndoAction(token); @@ -3315,7 +3316,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_DELETELINE: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit, SCI_LINEDELETE, 0, 0); EndUndoAction(token); } @@ -3324,7 +3325,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_DELETELINELEFT: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit, SCI_DELLINELEFT, 0, 0); EndUndoAction(token); } @@ -3333,7 +3334,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_DELETELINERIGHT: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit, SCI_DELLINERIGHT, 0, 0); EndUndoAction(token); } @@ -3342,7 +3343,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_INDENT: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditIndentBlock(g_hwndEdit, SCI_TAB, true); EndUndoAction(token); } @@ -3350,7 +3351,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_UNINDENT: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditIndentBlock(g_hwndEdit, SCI_BACKTAB, true); EndUndoAction(token); } @@ -3358,7 +3359,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_TAB: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditIndentBlock(g_hwndEdit, SCI_TAB, false); EndUndoAction(token); } @@ -3366,7 +3367,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_BACKTAB: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditIndentBlock(g_hwndEdit, SCI_BACKTAB, false); EndUndoAction(token); } @@ -3374,7 +3375,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_CTRLTAB: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit, SCI_SETUSETABS, true, 0); SendMessage(g_hwndEdit, SCI_SETTABINDENTS, false, 0); EditIndentBlock(g_hwndEdit, SCI_TAB, false); @@ -3386,7 +3387,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_DELETEBACK: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit, SCI_DELETEBACK, 0, 0); EndUndoAction(token); } @@ -3400,7 +3401,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_ENCLOSESELECTION: if (EditEncloseSelectionDlg(hwnd,wchPrefixSelection,wchAppendSelection)) { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit,wchPrefixSelection,wchAppendSelection); EndUndoAction(token); EndWaitCursor(); @@ -3411,7 +3412,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SELECTIONDUPLICATE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_SELECTIONDUPLICATE,0,0); EndUndoAction(token); EndWaitCursor(); @@ -3431,7 +3432,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_STRIP1STCHAR: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditStripFirstCharacter(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3442,7 +3443,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_STRIPLASTCHAR: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditStripLastCharacter(g_hwndEdit, false, false); EndUndoAction(token); EndWaitCursor(); @@ -3453,7 +3454,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_TRIMLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditStripLastCharacter(g_hwndEdit, false, true); EndUndoAction(token); EndWaitCursor(); @@ -3464,7 +3465,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_COMPRESSWS: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditCompressSpaces(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3475,7 +3476,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_MERGEBLANKLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditRemoveBlankLines(g_hwndEdit, true, true); EndUndoAction(token); EndWaitCursor(); @@ -3485,7 +3486,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_MERGEEMPTYLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditRemoveBlankLines(g_hwndEdit, true, false); EndUndoAction(token); EndWaitCursor(); @@ -3496,7 +3497,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_REMOVEBLANKLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditRemoveBlankLines(g_hwndEdit, false, true); EndUndoAction(token); EndWaitCursor(); @@ -3507,7 +3508,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_REMOVEEMPTYLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditRemoveBlankLines(g_hwndEdit, false, false); EndUndoAction(token); EndWaitCursor(); @@ -3518,7 +3519,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_REMOVEDUPLICATELINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditRemoveDuplicateLines(g_hwndEdit, false); EndUndoAction(token); EndWaitCursor(); @@ -3530,7 +3531,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (EditModifyLinesDlg(hwnd,wchPrefixLines,wchAppendLines)) { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditModifyLines(g_hwndEdit,wchPrefixLines,wchAppendLines); EndUndoAction(token); EndWaitCursor(); @@ -3543,7 +3544,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (EditAlignDlg(hwnd,&iAlignMode)) { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditAlignText(g_hwndEdit,iAlignMode); EndUndoAction(token); EndWaitCursor(); @@ -3556,7 +3557,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (EditSortDlg(hwnd,&iSortOptions)) { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditSortLines(g_hwndEdit,iSortOptions); EndUndoAction(token); EndWaitCursor(); @@ -3576,7 +3577,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { iWrapCol = (DocPos)max(min(uWrpCol,(UINT)g_iLongLinesLimit),1); BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditWrapToColumn(g_hwndEdit,iWrapCol); EndUndoAction(token); EndWaitCursor(); @@ -3588,7 +3589,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SPLITLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditSplitLines(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3599,7 +3600,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_JOINLINES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditJoinLinesEx(g_hwndEdit, false, true); EndUndoAction(token); EndWaitCursor(); @@ -3609,7 +3610,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_JOINLN_NOSP: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditJoinLinesEx(g_hwndEdit, false, false); EndUndoAction(token); EndWaitCursor(); @@ -3619,7 +3620,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_JOINLINES_PARA: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditJoinLinesEx(g_hwndEdit, true, true); EndUndoAction(token); EndWaitCursor(); @@ -3630,7 +3631,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CONVERTUPPERCASE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_UPPERCASE,0,0); EndUndoAction(token); EndWaitCursor(); @@ -3641,7 +3642,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CONVERTLOWERCASE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_LOWERCASE,0,0); EndUndoAction(token); EndWaitCursor(); @@ -3652,7 +3653,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_INVERTCASE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditInvertCase(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3663,7 +3664,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_TITLECASE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditTitleCase(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3674,7 +3675,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SENTENCECASE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditSentenceCase(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3685,7 +3686,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CONVERTTABS: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditTabsToSpaces(g_hwndEdit, g_iTabWidth, false); EndUndoAction(token); EndWaitCursor(); @@ -3696,7 +3697,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CONVERTSPACES: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditSpacesToTabs(g_hwndEdit, g_iTabWidth, false); EndUndoAction(token); EndWaitCursor(); @@ -3707,7 +3708,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CONVERTTABS2: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditTabsToSpaces(g_hwndEdit, g_iTabWidth, true); EndUndoAction(token); EndWaitCursor(); @@ -3718,7 +3719,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CONVERTSPACES2: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditSpacesToTabs(g_hwndEdit, g_iTabWidth, true); EndUndoAction(token); EndWaitCursor(); @@ -3731,7 +3732,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) WCHAR wszOpen[256] = { L'\0' }; WCHAR wszClose[256] = { L'\0' }; if (EditInsertTagDlg(hwnd, wszOpen, wszClose)) { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, wszOpen, wszClose); EndUndoAction(token); } @@ -3748,7 +3749,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) char *p = StrChrA(msz, ','); if (p) *p = 0; - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)msz); EndUndoAction(token); } @@ -3794,7 +3795,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) } WideCharToMultiByteStrg(Encoding_SciCP,tchDateTime,mszBuf); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf); EndUndoAction(token); } @@ -3825,7 +3826,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) } WideCharToMultiByteStrg(Encoding_SciCP,pszInsert,mszBuf); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszBuf); EndUndoAction(token); } @@ -3842,7 +3843,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) wszGuid[wcslen(wszGuid) - 1] = L'\0'; // trim last brace char char mszGuid[40 * 4]; // UTF-8 max of 4 bytes per char if (WideCharToMultiByteStrg(Encoding_SciCP,pwszGuid,mszGuid)) { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)mszGuid); EndUndoAction(token); } @@ -3855,7 +3856,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_LINECOMMENT: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); switch (SendMessage(g_hwndEdit, SCI_GETLEXER, 0, 0)) { default: @@ -3922,7 +3923,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_STREAMCOMMENT: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); switch (SendMessage(g_hwndEdit, SCI_GETLEXER, 0, 0)) { default: @@ -3983,7 +3984,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_URLENCODE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditURLEncode(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -3994,7 +3995,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_URLDECODE: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditURLDecode(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -4005,7 +4006,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_ESCAPECCHARS: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEscapeCChars(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -4016,7 +4017,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_UNESCAPECCHARS: { BeginWaitCursor(NULL); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditUnescapeCChars(g_hwndEdit); EndUndoAction(token); EndWaitCursor(); @@ -4026,7 +4027,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CHAR2HEX: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditChar2Hex(g_hwndEdit); EndUndoAction(token); } @@ -4045,7 +4046,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SELTOMATCHINGBRACE: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditSelectToMatchingBrace(g_hwndEdit); EndUndoAction(token); } @@ -4884,7 +4885,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_CTRLENTER: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); const DocPos iPos = SciCall_GetCurrentPos(); const DocLn iLine = SciCall_LineFromPosition(iPos); if (iLine <= 0) { @@ -4912,7 +4913,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CLEAR: case CMD_DEL: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SciCall_Clear(); EndUndoAction(token); } @@ -4938,7 +4939,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) const DocPos iIndentPos = SciCall_GetLineIndentPosition(iLine); if (iPos != iAnchor) { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SciCall_SetSel(iPos, iPos); EndUndoAction(token); } @@ -4963,7 +4964,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) const DocPos iEndPos = SciCall_GetLineEndPosition(iLine); if (iPos != iAnchor) { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SciCall_SetSel(iPos, iPos); EndUndoAction(token); } @@ -5209,7 +5210,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_STRINGIFY: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, L"'", L"'"); EndUndoAction(token); } @@ -5218,7 +5219,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_STRINGIFY2: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, L"\"", L"\""); EndUndoAction(token); } @@ -5227,7 +5228,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, L"(", L")"); EndUndoAction(token); } @@ -5236,7 +5237,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE2: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, L"[", L"]"); EndUndoAction(token); } @@ -5245,7 +5246,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE3: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, L"{", L"}"); EndUndoAction(token); } @@ -5254,7 +5255,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE4: { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); EditEncloseSelection(g_hwndEdit, L"`", L"`"); EndUndoAction(token); } @@ -5881,7 +5882,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) *pPos = '\0'; } if (*pLineBuf) { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SciCall_AddText(lstrlenA(pLineBuf), pLineBuf); EndUndoAction(token); } @@ -5935,7 +5936,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) StringCchCompareINA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "", -1) && StringCchCompareINA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "", -1)) { - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SciCall_ReplaceSel(g_pTempLineBufferMain); SciCall_SetSel(iCurPos, iCurPos); EndUndoAction(token); @@ -8046,7 +8047,7 @@ int BeginUndoAction() break; } - int token = UndoRedoActionMap(-1, &sel); + int const token = UndoRedoActionMap(-1, &sel); if (token >= 0) { SciCall_BeginUndoAction(); @@ -8456,7 +8457,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, SendMessage(g_hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog); if (StringCchCompareXA(tchLog,".LOG") == 0) { EditJumpTo(g_hwndEdit,-1,0); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); SendMessage(g_hwndEdit,SCI_NEWLINE,0,0); SendMessage(g_hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_INSERT_SHORTDATE,1),0); EditJumpTo(g_hwndEdit,-1,0); @@ -9506,7 +9507,7 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) bool bAutoIndent2 = bAutoIndent; bAutoIndent = 0; EditJumpTo(g_hwndEdit,-1,0); - int token = BeginUndoAction(); + int const token = BeginUndoAction(); if (SendMessage(g_hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { SendMessage(g_hwndEdit, SCI_NEWLINE, 0, 0); } From b7293651bdcc7669d775580b07632e9d3dc4f2d6 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 4 May 2018 16:01:14 +0200 Subject: [PATCH 4/5] + fix: ignore notify change event on pasting rectangular selection --- src/Edit.c | 5 ----- src/Notepad3.c | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index b601c6f71..b081acfce 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -737,8 +737,6 @@ bool EditClearClipboard(HWND hwnd) // bool EditSwapClipboard(HWND hwnd, bool bSkipUnicodeCheck) { - _IGNORE_NOTIFY_CHANGE_; - int lineCount = 0; int lenLastLine = 0; char* const pClip = EditGetClipboardText(hwnd, !bSkipUnicodeCheck, &lineCount, &lenLastLine); @@ -777,9 +775,6 @@ bool EditSwapClipboard(HWND hwnd, bool bSkipUnicodeCheck) } LocalFree(pClip); - - _OBSERVE_NOTIFY_CHANGE_; - return true; } diff --git a/src/Notepad3.c b/src/Notepad3.c index 144ac39b9..75d54c82c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -3193,7 +3193,9 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) if (g_flagPasteBoard) bLastCopyFromMe = true; int const token = BeginUndoAction(); + _IGNORE_NOTIFY_CHANGE_; SciCall_Paste(); + _OBSERVE_NOTIFY_CHANGE_; EndUndoAction(token); UpdateToolbar(); UpdateStatusbar(false); @@ -3206,7 +3208,9 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) if (g_flagPasteBoard) bLastCopyFromMe = true; int const token = BeginUndoAction(); + _IGNORE_NOTIFY_CHANGE_; EditSwapClipboard(g_hwndEdit, bSkipUnicodeDetection); + _OBSERVE_NOTIFY_CHANGE_; EndUndoAction(token); UpdateToolbar(); UpdateStatusbar(false); From 43950aaa5ca6b6170b9e0bcf0aeba12db9d14793 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 4 May 2018 20:41:36 +0200 Subject: [PATCH 5/5] + fix: leave Alt-Key-Down mode if keyboard focus lost --- src/Notepad3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Notepad3.c b/src/Notepad3.c index 75d54c82c..dbceb5a79 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1239,6 +1239,12 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) } return DefWindowProc(hwnd, umsg, wParam, lParam); + case WM_KILLFOCUS: + if (bAltKeyIsDown) { + bAltKeyIsDown = false; + SciCall_SetVirtualSpaceOptions(bDenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION); + } + return DefWindowProc(hwnd, umsg, wParam, lParam); case WM_CREATE: return MsgCreate(hwnd,wParam,lParam);