From 77a109cbf0669ecc9797f55278c167d379fc5259 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 8 May 2018 18:45:59 +0200 Subject: [PATCH 1/6] + enh: Pad with Spaces in Rectangular Selection --- src/Edit.c | 80 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index edb940ba3..6fd08aa09 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -3097,41 +3097,63 @@ void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup) int const token = (!bNoUndoGroup ? BeginUndoAction() : -1); - if (SciCall_IsSelectionRectangle()) + if (SciCall_IsSelectionRectangle() && !SciCall_IsSelectionEmpty()) { - const DocPos selAnchorMainPos = SciCall_GetRectangularSelectionAnchor(); - const DocPos selCaretMainPos = SciCall_GetRectangularSelectionCaret(); - const DocPos vSpcAnchorMainPos = 0; // SciCall_GetRectangularSelectionAnchorVirtualSpace(); - const DocPos vSpcCaretMainPos = 0; // SciCall_GetRectangularSelectionCaretVirtualSpace(); + DocPos const selAnchorMainPos = SciCall_GetRectangularSelectionAnchor(); + DocPos const selCaretMainPos = SciCall_GetRectangularSelectionCaret(); - const DocLn iRcCurLine = SciCall_LineFromPosition(selCaretMainPos); - const DocLn iRcAnchorLine = SciCall_LineFromPosition(selAnchorMainPos); + //DocPos const vSpcAnchorMainPos = SciCall_GetRectangularSelectionAnchorVirtualSpace(); + //DocPos const vSpcCaretMainPos = SciCall_GetRectangularSelectionCaretVirtualSpace(); - DocLn iStartLine = 0; - DocLn iEndLine = 0; - if (iRcAnchorLine == iRcCurLine) { - iEndLine = SciCall_GetLineCount() - 1; + DocPos const iAnchorColumn = SciCall_GetColumn(SciCall_GetSelectionNAnchor(0)) + SciCall_GetSelectionNAnchorVirtualSpace(0); + DocPos const iCaretColumn = SciCall_GetColumn(SciCall_GetSelectionNCaret(0)) + SciCall_GetSelectionNCaretVirtualSpace(0); + bool const bSelLeft2Right = (iAnchorColumn <= iCaretColumn); + + DocLn iRcAnchorLine = SciCall_LineFromPosition(selAnchorMainPos); + DocLn iRcCaretLine = SciCall_LineFromPosition(selCaretMainPos); + DocLn const iLineCount = abs(iRcCaretLine - iRcAnchorLine) + 1; + + // lots of spaces + FillMemory(g_pTempLineBuffer, COUNTOF(g_pTempLineBuffer) * sizeof(char), ' '); + + DocPos* pVspVec = (int*)AllocMem(iLineCount * sizeof(DocPos), HEAP_ZERO_MEMORY); + + for (DocLn i = 0; i < iLineCount; ++i) { + pVspVec[i] = bSelLeft2Right ? SciCall_GetSelectionNCaretVirtualSpace(i) : SciCall_GetSelectionNAnchorVirtualSpace(i); + } + + DocPosU i = 0; + DocPos iSpcCount = 0; + DocLn const iLnIncr = (iRcAnchorLine <= iRcCaretLine) ? (DocLn)+1 : (DocLn)-1; + DocLn iLine = iRcAnchorLine - iLnIncr; + do { + iLine += iLnIncr; + DocPos const iInsPos = SciCall_GetLineEndPosition(iLine); + DocPos const cntVSp = pVspVec[i++]; + + if ((cntVSp > 0) && (cntVSp < TEMPLINE_BUFFER)) { + g_pTempLineBuffer[cntVSp] = '\0'; + SciCall_InsertText(iInsPos, g_pTempLineBuffer); + g_pTempLineBuffer[cntVSp] = ' '; + iSpcCount += cntVSp; + } + } while (iLine != iRcCaretLine); + + FreeMem(pVspVec); + + if (iRcAnchorLine <= iRcCaretLine) { + if (bSelLeft2Right) + EditSelectEx(hwnd, selAnchorMainPos, selCaretMainPos + iSpcCount, 0, 0); + else + EditSelectEx(hwnd, selAnchorMainPos + pVspVec[0], selCaretMainPos + iSpcCount - pVspVec[iLineCount - 1], 0, 0); } else { - iStartLine = (iRcCurLine < iRcAnchorLine) ? iRcCurLine : iRcAnchorLine; - iEndLine = (iRcCurLine < iRcAnchorLine) ? iRcAnchorLine : iRcCurLine; + if (bSelLeft2Right) + EditSelectEx(hwnd, selAnchorMainPos + iSpcCount - pVspVec[0], selCaretMainPos + pVspVec[iLineCount - 1], 0, 0); + else + EditSelectEx(hwnd, selAnchorMainPos + iSpcCount, selCaretMainPos, 0, 0); } - - DocPos iMaxColumn = 0; - for (DocLn iLine = iStartLine; iLine <= iEndLine; iLine++) { - const DocPos iPos = SciCall_GetLineSelEndPosition(iLine); - if (iPos != INVALID_POSITION) { - iMaxColumn = max(iMaxColumn, SciCall_GetColumn(iPos)); - } - } - if (iMaxColumn <= 0) { return; } - - const DocPos iSpcCount = _AppendSpaces(hwnd, iStartLine, iEndLine, iMaxColumn, bSkipEmpty); - - if (iRcCurLine < iRcAnchorLine) - EditSelectEx(hwnd, selAnchorMainPos + iSpcCount, selCaretMainPos, vSpcAnchorMainPos, vSpcCaretMainPos); - else - EditSelectEx(hwnd, selAnchorMainPos, selCaretMainPos + iSpcCount, vSpcAnchorMainPos, vSpcCaretMainPos); + } else // SC_SEL_LINES | SC_SEL_STREAM { From afa2232e5296bcc6b873872a3a0530e84a08cc4f Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 8 May 2018 19:32:37 +0200 Subject: [PATCH 2/6] + fix: Pad with Spaces in Rectangular Selection (correction for pure virtual space and skip empty lines) --- src/Edit.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 6fd08aa09..fdecfc406 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -3102,9 +3102,6 @@ void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup) DocPos const selAnchorMainPos = SciCall_GetRectangularSelectionAnchor(); DocPos const selCaretMainPos = SciCall_GetRectangularSelectionCaret(); - //DocPos const vSpcAnchorMainPos = SciCall_GetRectangularSelectionAnchorVirtualSpace(); - //DocPos const vSpcCaretMainPos = SciCall_GetRectangularSelectionCaretVirtualSpace(); - DocPos const iAnchorColumn = SciCall_GetColumn(SciCall_GetSelectionNAnchor(0)) + SciCall_GetSelectionNAnchorVirtualSpace(0); DocPos const iCaretColumn = SciCall_GetColumn(SciCall_GetSelectionNCaret(0)) + SciCall_GetSelectionNCaretVirtualSpace(0); bool const bSelLeft2Right = (iAnchorColumn <= iCaretColumn); @@ -3114,12 +3111,16 @@ void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup) DocLn const iLineCount = abs(iRcCaretLine - iRcAnchorLine) + 1; // lots of spaces - FillMemory(g_pTempLineBuffer, COUNTOF(g_pTempLineBuffer) * sizeof(char), ' '); + DocPos const spBufSize = max(iAnchorColumn, selCaretMainPos); + char* pSpaceBuffer = (char*)AllocMem((spBufSize + 1) * sizeof(char), HEAP_ZERO_MEMORY); + FillMemory(pSpaceBuffer, spBufSize * sizeof(char), ' '); - DocPos* pVspVec = (int*)AllocMem(iLineCount * sizeof(DocPos), HEAP_ZERO_MEMORY); + DocPos* pVspAVec = (int*)AllocMem(iLineCount * sizeof(DocPos), HEAP_ZERO_MEMORY); + DocPos* pVspCVec = (int*)AllocMem(iLineCount * sizeof(DocPos), HEAP_ZERO_MEMORY); for (DocLn i = 0; i < iLineCount; ++i) { - pVspVec[i] = bSelLeft2Right ? SciCall_GetSelectionNCaretVirtualSpace(i) : SciCall_GetSelectionNAnchorVirtualSpace(i); + pVspAVec[i] = SciCall_GetSelectionNAnchorVirtualSpace(i); + pVspCVec[i] = SciCall_GetSelectionNCaretVirtualSpace(i); } DocPosU i = 0; @@ -3129,31 +3130,34 @@ void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup) do { iLine += iLnIncr; DocPos const iInsPos = SciCall_GetLineEndPosition(iLine); - DocPos const cntVSp = pVspVec[i++]; + DocPos const cntVSp = bSelLeft2Right ? pVspCVec[i++] : pVspAVec[i++]; + bool const bSkip = (bSkipEmpty && (iInsPos <= SciCall_PositionFromLine(iLine))); - if ((cntVSp > 0) && (cntVSp < TEMPLINE_BUFFER)) { - g_pTempLineBuffer[cntVSp] = '\0'; - SciCall_InsertText(iInsPos, g_pTempLineBuffer); - g_pTempLineBuffer[cntVSp] = ' '; + if ((cntVSp > 0) && !bSkip) { + pSpaceBuffer[cntVSp] = '\0'; + SciCall_InsertText(iInsPos, pSpaceBuffer); + pSpaceBuffer[cntVSp] = ' '; iSpcCount += cntVSp; } } while (iLine != iRcCaretLine); - FreeMem(pVspVec); + FreeMem(pSpaceBuffer); if (iRcAnchorLine <= iRcCaretLine) { if (bSelLeft2Right) - EditSelectEx(hwnd, selAnchorMainPos, selCaretMainPos + iSpcCount, 0, 0); + EditSelectEx(hwnd, selAnchorMainPos + pVspAVec[0], selCaretMainPos + iSpcCount, 0, 0); else - EditSelectEx(hwnd, selAnchorMainPos + pVspVec[0], selCaretMainPos + iSpcCount - pVspVec[iLineCount - 1], 0, 0); + EditSelectEx(hwnd, selAnchorMainPos + pVspAVec[0], selCaretMainPos + pVspCVec[iLineCount - 1] + iSpcCount - pVspAVec[iLineCount - 1], 0, 0); } else { if (bSelLeft2Right) - EditSelectEx(hwnd, selAnchorMainPos + iSpcCount - pVspVec[0], selCaretMainPos + pVspVec[iLineCount - 1], 0, 0); + EditSelectEx(hwnd, selAnchorMainPos + pVspAVec[0] + iSpcCount - pVspCVec[0], selCaretMainPos + pVspCVec[iLineCount - 1], 0, 0); else - EditSelectEx(hwnd, selAnchorMainPos + iSpcCount, selCaretMainPos, 0, 0); + EditSelectEx(hwnd, selAnchorMainPos + iSpcCount, selCaretMainPos + pVspCVec[iLineCount - 1], 0, 0); } - + + FreeMem(pVspCVec); + FreeMem(pVspAVec); } else // SC_SEL_LINES | SC_SEL_STREAM { From 6b469e204429ed749a7ce13ae358ab787aaa771e Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 8 May 2018 23:00:32 +0200 Subject: [PATCH 3/6] + fix: Renaming of UpdateChecker => Administration Tool --- Build/Notepad3.ini | Bin 5388 -> 5398 bytes src/Dialogs.c | 10 +++++----- src/Dialogs.h | 2 +- src/Notepad3.c | 14 +++++++------- src/Notepad3.rc | 4 ++-- src/resource.h | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 9172a51b580140d41d5fd0cd1b8bc3cf7393574b..5ab183cb9018afd3b930658fe6b7f4218a4e068b 100644 GIT binary patch delta 48 ycmeCtnx?g38;7zZLkdGKLncEW5EnC)FcdK)0?AB^!{A3>gfm49N`HK(c7_O%7Wg0GfIUA^-pY diff --git a/src/Dialogs.c b/src/Dialogs.c index 45c01462b..a74254855 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -2783,16 +2783,16 @@ void DialogFileBrowse(HWND hwnd) //============================================================================= // -// DialogUpdateCheck() +// DialogAdminExe() // // -extern WCHAR g_tchUpdateCheckerExe[]; +extern WCHAR g_tchAdministrationExe[]; -void DialogUpdateCheck(HWND hwnd, bool bExecInstaller) +void DialogAdminExe(HWND hwnd, bool bExecInstaller) { WCHAR tchExe[MAX_PATH+2]; - StringCchCopyW(tchExe, COUNTOF(tchExe), g_tchUpdateCheckerExe); + StringCchCopyW(tchExe, COUNTOF(tchExe), g_tchAdministrationExe); if (bExecInstaller && !StringCchLenW(tchExe, COUNTOF(tchExe))) { return; } WCHAR tchExePath[MAX_PATH + 2]; @@ -2818,7 +2818,7 @@ void DialogUpdateCheck(HWND hwnd, bool bExecInstaller) ShellExecuteEx(&sei); if ((INT_PTR)sei.hInstApp < 32) { - if (IDOK == InfoBox(MBOKCANCEL, L"NoUpdateChecker", IDS_ERR_UPDATECHECKER)) + if (IDOK == InfoBox(MBOKCANCEL, L"NoAdminTool", IDS_ERR_ADMINEXE)) { sei.lpFile = VERSION_UPDATE_CHECK; ShellExecuteEx(&sei); diff --git a/src/Dialogs.h b/src/Dialogs.h index e3c379478..15bbd3b23 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -42,7 +42,7 @@ WININFO GetMyWindowPlacement(HWND,MONITORINFO *); void DialogNewWindow(HWND,bool,bool); void DialogFileBrowse(HWND); -void DialogUpdateCheck(HWND,bool); +void DialogAdminExe(HWND,bool); INT_PTR InfoBox(int,LPCWSTR,int,...); diff --git a/src/Notepad3.c b/src/Notepad3.c index 74b525816..30870349d 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -135,7 +135,7 @@ WCHAR g_tchFileDlgFilters[XXXL_BUFFER] = { L'\0' }; WCHAR g_tchLastSaveCopyDir[MAX_PATH] = { L'\0' }; WCHAR g_tchOpenWithDir[MAX_PATH] = { L'\0' }; WCHAR g_tchFavoritesDir[MAX_PATH] = { L'\0' }; -WCHAR g_tchUpdateCheckerExe[MAX_PATH] = { L'\0' }; +WCHAR g_tchAdministrationExe[MAX_PATH] = { L'\0' }; static WCHAR g_tchDefaultExtension[64] = { L'\0' }; static WCHAR g_tchDefaultDir[MAX_PATH] = { L'\0' }; @@ -2753,8 +2753,8 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) } EnableCmd(hmenu, CMD_OPEN_HYPERLINK, bIsHLink); - i = StringCchLenW(g_tchUpdateCheckerExe, COUNTOF(g_tchUpdateCheckerExe)); - EnableCmd(hmenu, IDM_HELP_UPDATEINSTALLER, i); + i = StringCchLenW(g_tchAdministrationExe, COUNTOF(g_tchAdministrationExe)); + EnableCmd(hmenu, IDM_HELP_ADMINEXE, i); UNUSED(lParam); } @@ -5153,12 +5153,12 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) break; - case IDM_HELP_UPDATEINSTALLER: - DialogUpdateCheck(hwnd, true); + case IDM_HELP_ADMINEXE: + DialogAdminExe(hwnd, true); break; case IDM_HELP_UPDATEWEBSITE: - DialogUpdateCheck(hwnd, false); + DialogAdminExe(hwnd, false); break; case CMD_WEBACTION1: @@ -6495,7 +6495,7 @@ void LoadSettings() iCurrentLineVerticalSlop = IniSectionGetInt(pIniSection, L"CurrentLineVerticalSlop", 5); iCurrentLineVerticalSlop = max(min(iCurrentLineVerticalSlop, 200), 0); - IniSectionGetString(pIniSection, L"UpdateChecker.exe", L"", g_tchUpdateCheckerExe, COUNTOF(g_tchUpdateCheckerExe)); + IniSectionGetString(pIniSection, L"AdministrationTool.exe", L"", g_tchAdministrationExe, COUNTOF(g_tchAdministrationExe)); // -------------------------------------------------------------------------- LoadIniSection(L"Statusbar Settings", pIniSection, cchIniSection); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 374207739..a7663b706 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -394,7 +394,7 @@ BEGIN BEGIN MENUITEM "&Online Documentation\tF1", IDM_HELP_ONLINEDOCUMENTATION MENUITEM SEPARATOR - MENUITEM "Launch &Update Installer...", IDM_HELP_UPDATEINSTALLER + MENUITEM "Launch Administration &Tool...", IDM_HELP_ADMINEXE MENUITEM "Check &Website for Update", IDM_HELP_UPDATEWEBSITE MENUITEM SEPARATOR MENUITEM "&Command Line Help...", IDM_HELP_CMD @@ -1574,7 +1574,7 @@ BEGIN IDS_REGEX_INVALID "Error evaluating regular expression. Expression is invalid!" IDS_DROP_NO_FILE "No valid filename retrieved.\nIf dropping from 32-bit application,\nplease drag and drop to Notepad3's tool bar." IDS_APPLY_DEFAULT_FONT "Apply these font settings to current ('%s') scheme's default text also?" - IDS_ERR_UPDATECHECKER "No update installer executable found.\nCheck for update on website https://rizonesoft.com ?" + IDS_ERR_ADMINEXE "No administration executable found.\nCheck website https://rizonesoft.com ?" END STRINGTABLE diff --git a/src/resource.h b/src/resource.h index 936a8f77c..082fad3f0 100644 --- a/src/resource.h +++ b/src/resource.h @@ -167,7 +167,7 @@ #define IDC_EDIT3 412 #define IDS_PASS_FAILURE 413 #define IDS_NOPASS 414 -#define IDM_HELP_UPDATEINSTALLER 415 +#define IDM_HELP_ADMINEXE 415 #define IDM_HELP_UPDATEWEBSITE 416 #define IDS_FR_STATUS_TEXT 417 #define IDC_CHECK4 418 @@ -519,7 +519,7 @@ #define IDS_REGEX_INVALID 50043 #define IDS_DROP_NO_FILE 50044 #define IDS_APPLY_DEFAULT_FONT 50045 -#define IDS_ERR_UPDATECHECKER 50046 +#define IDS_ERR_ADMINEXE 50046 #define IDS_CMDLINEHELP 60000 #define IDM_EDIT_INSERT_GUID 60001 #define IDC_STATIC -1 From 3cff6841c8f2376eb529f925c293e14745e011e4 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 9 May 2018 08:54:55 +0200 Subject: [PATCH 4/6] + fix: issue regarding selection of default and 2nd default styling --- src/Notepad3.c | 2 +- src/Styles.c | 27 +++++++++++---------------- src/Version.h | Bin 26398 -> 26406 bytes 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index 30870349d..2287d4b7a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -7950,7 +7950,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) // ------------------------------------------------------ static bool s_bUse2ndDefault = -1; - bool const bUse2ndDefault = Style_GetUse2ndDefault(); + bool bUse2ndDefault = Style_GetUse2ndDefault(); if (s_bUse2ndDefault != bUse2ndDefault) { if (bUse2ndDefault) { diff --git a/src/Styles.c b/src/Styles.c index 95a03bc68..04a911da8 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -3135,7 +3135,7 @@ void Style_Load() LoadIniSection(L"Styles",pIniSection,cchIniSection); // 2nd default - Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", 0)); + Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", false)); // default scheme g_iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0); @@ -3348,13 +3348,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (!pLexNew) { pLexNew = GetDefaultLexer(); } - if (IsLexerStandard(pLexNew)) { - pLexNew = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard; - } const WCHAR* const wchNewLexerStyleStrg = pLexNew->Styles[STY_DEFAULT].szValue; // first set standard lexer's default values - g_pLexCurrent = GetCurrentStdLexer(); + if (IsLexerStandard(pLexNew)) + g_pLexCurrent = pLexNew; + else + g_pLexCurrent = GetCurrentStdLexer(); + const WCHAR* const wchStandardStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue; // Lexer @@ -4463,7 +4464,7 @@ void Style_SetLexerFromID(HWND hwnd,int id) // void Style_ToggleUse2ndDefault(HWND hwnd) { - bool use2ndDefStyle = Style_GetUse2ndDefault(); + bool const use2ndDefStyle = Style_GetUse2ndDefault(); Style_SetUse2ndDefault(use2ndDefStyle ? false : true); // swap Style_SetLexer(hwnd,g_pLexCurrent); } @@ -4477,8 +4478,8 @@ void Style_SetDefaultFont(HWND hwnd, bool bGlobalDefault) { WCHAR newStyle[BUFSIZE_STYLE_VALUE] = { L'\0' }; - const PEDITLEXER pLexer = bGlobalDefault ? GetCurrentStdLexer() : g_pLexCurrent; - const PEDITSTYLE pLexerDefStyle = &(pLexer->Styles[STY_DEFAULT]); + PEDITLEXER const pLexer = bGlobalDefault ? GetCurrentStdLexer() : g_pLexCurrent; + PEDITSTYLE const pLexerDefStyle = &(pLexer->Styles[STY_DEFAULT]); StringCchCopyW(newStyle, COUNTOF(newStyle), pLexer->Styles[STY_DEFAULT].szValue); @@ -5661,13 +5662,8 @@ int Style_GetCurrentLexerRID() // void Style_GetCurrentLexerName(LPWSTR lpszName, int cchName) { - if (IsLexerStandard(g_pLexCurrent)) { - StringCchPrintfW(lpszName, cchName, L" %s", GetCurrentStdLexer()->pszName); - } - else { - if (!GetString(g_pLexCurrent->resID, lpszName, cchName)) { - StringCchCopyW(lpszName, cchName, g_pLexCurrent->pszName); - } + if (!GetString(g_pLexCurrent->resID, lpszName, cchName)) { + StringCchCopyW(lpszName, cchName, g_pLexCurrent->pszName); } } @@ -6644,7 +6640,6 @@ void Style_SelectLexerDlg(HWND hwnd) MAKEINTRESOURCE(IDD_STYLESELECT), GetParent(hwnd), Style_SelectLexerDlgProc, 0)) - Style_SetUse2ndDefault(g_pLexCurrent == &lexStandard2nd); Style_SetLexer(hwnd, g_pLexCurrent); } diff --git a/src/Version.h b/src/Version.h index 06c6e1af16e97b053a0ab155c6f1e6587477205d..4e5cb6f1f1cb4b01e2add733c8dad8353cba2232 100644 GIT binary patch delta 32 ocmbPtj&a#J#tnypSTz_77<4B)hDc5hh-8`kAl6~COfZuO0LC>6`Tzg` delta 20 ccmZ2>j&a^O#tnyp7!4*DhDB~x31$)j0AE!H%K!iX From ca87fbdea8e3c7e24f4cc6606626dc97015fb331 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 9 May 2018 09:43:06 +0200 Subject: [PATCH 5/6] + fix: clear all occurrences marker on no matching search expression --- src/Edit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index fdecfc406..f30b4df7f 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5280,14 +5280,13 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (EditToggleView(g_hwndEdit, false)) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); } StringCchCopyA(g_lastFind, COUNTOF(g_lastFind), sg_pefrData->szFind); RegExResult_t match = _FindHasMatch(g_hwndEdit, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false); - if (regexMatch != match) { - regexMatch = match; - } + if (regexMatch != match) { regexMatch = match; } // we have to set Sci's regex instance to first find (have substitution in place) DocPos const iStartPos = (DocPos)lParam; _FindHasMatch(g_hwndEdit, sg_pefrData, iStartPos, false, true); sg_pefrData->bStateChanged = false; InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); + if (match != MATCH) { EditClearAllOccurrenceMarkers(g_hwndEdit); } if (EditToggleView(g_hwndEdit, false)) { EditHideNotMarkedLineRange(g_hwndEdit, -1, -1, true); } _OBSERVE_NOTIFY_CHANGE_; } From b1dbcb351a9ab2a6b1cdac7c5b5868cef6c199f4 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 9 May 2018 11:50:27 +0200 Subject: [PATCH 6/6] + fix: restore inital selection on search dialog canceling --- src/Edit.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Edit.c b/src/Edit.c index f30b4df7f..7d192d340 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4936,6 +4936,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA { static LPEDITFINDREPLACE sg_pefrData = NULL; static DocPos s_InitialSearchStart = 0; + static DocPos s_InitialAnchortPos = 0; + static DocPos s_InitialCaretPos = 0; static RegExResult_t regexMatch = INVALID; static COLORREF rgbRed = RGB(255, 170, 170); @@ -5115,6 +5117,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA _SetSearchFlags(hwnd, sg_pefrData); s_InitialSearchStart = SciCall_GetSelectionStart(); + s_InitialAnchortPos = SciCall_GetAnchor(); + s_InitialCaretPos = SciCall_GetCurrentPos(); _DelayMarkAll(hwnd, 50, s_InitialSearchStart); } return true; @@ -5141,6 +5145,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } MarkAllOccurrences(50, true); + EditSelectEx(g_hwndEdit, s_InitialAnchortPos, s_InitialCaretPos, -1, -1); EditEnsureSelectionVisible(g_hwndEdit); CmdMessageQueue_t* pmqc = NULL; @@ -5163,6 +5168,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case WM_ACTIVATE: { s_InitialSearchStart = SciCall_GetSelectionStart(); + s_InitialAnchortPos = SciCall_GetAnchor(); + s_InitialCaretPos = SciCall_GetCurrentPos(); DialogEnableWindow(hwnd, IDC_REPLACEINSEL, !SciCall_IsSelectionEmpty()); @@ -5184,6 +5191,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDC_DOC_MODIFIED: sg_pefrData->bStateChanged = true; s_InitialSearchStart = SciCall_GetSelectionStart(); + s_InitialAnchortPos = SciCall_GetAnchor(); + s_InitialCaretPos = SciCall_GetCurrentPos(); break; case IDC_FINDTEXT: @@ -5286,7 +5295,10 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA _FindHasMatch(g_hwndEdit, sg_pefrData, iStartPos, false, true); sg_pefrData->bStateChanged = false; InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); - if (match != MATCH) { EditClearAllOccurrenceMarkers(g_hwndEdit); } + if (match != MATCH) { + EditClearAllOccurrenceMarkers(g_hwndEdit); + EditSelectEx(g_hwndEdit, s_InitialAnchortPos, s_InitialCaretPos, -1, -1); + } if (EditToggleView(g_hwndEdit, false)) { EditHideNotMarkedLineRange(g_hwndEdit, -1, -1, true); } _OBSERVE_NOTIFY_CHANGE_; } @@ -5502,6 +5514,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (!SciCall_IsSelectionEmpty()) { EditJumpToSelectionEnd(hwnd); } EditFindNext(sg_pefrData->hwnd, sg_pefrData, (LOWORD(wParam) == IDACC_SELTONEXT), HIBYTE(GetKeyState(VK_F3))); s_InitialSearchStart = SciCall_GetSelectionStart(); + s_InitialAnchortPos = SciCall_GetAnchor(); + s_InitialCaretPos = SciCall_GetCurrentPos(); break; case IDC_FINDPREV: // find previous @@ -5510,6 +5524,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (!SciCall_IsSelectionEmpty()) { EditJumpToSelectionStart(hwnd); } EditFindPrev(sg_pefrData->hwnd, sg_pefrData, (LOWORD(wParam) == IDACC_SELTOPREV), HIBYTE(GetKeyState(VK_F3))); s_InitialSearchStart = SciCall_GetSelectionStart(); + s_InitialAnchortPos = SciCall_GetAnchor(); + s_InitialCaretPos = SciCall_GetCurrentPos(); break; case IDC_REPLACE: