From 734cf3c2eb6dac1c102257393d963cea648be9d3 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 1 Jun 2018 17:58:58 +0200 Subject: [PATCH 1/3] + fix: ignore linebrakes for comparision on removing duplicate lines --- src/Edit.c | 16 ++++++++++------ src/SciCall.h | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 5b156d4eb..12d0aee77 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -3676,7 +3676,7 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines) if (iSelEnd <= SciCall_PositionFromLine(iEndLine)) { --iEndLine; } } else { - iEndLine = SciCall_GetLineCount() - 1; // last line + iEndLine = Sci_GetLastDocLine(); } if ((iEndLine - iStartLine) <= 1) { return; } @@ -3697,22 +3697,26 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines) for (DocLn iCurLine = iStartLine; iCurLine < iEndLine; ++iCurLine) { - const DocPos iCurLnLen = SciCall_GetLine(iCurLine, pCurrentLine); + SciCall_GetLine(iCurLine, pCurrentLine); + const DocPos iCurLnLen = Sci_GetNetLineLength(iCurLine); + pCurrentLine[iCurLnLen] = '\0'; + if (bRemoveEmptyLines || (iCurLnLen > iEmptyLnLen)) { - for (DocLn iCompareLine = iCurLine + 1; iCompareLine < iEndLine; ++iCompareLine) + for (DocLn iCompareLine = iCurLine + 1; iCompareLine <= iEndLine; ++iCompareLine) { - const DocPos iCmpLnLen = SciCall_GetLine(iCompareLine, NULL); + const DocPos iCmpLnLen = Sci_GetNetLineLength(iCompareLine); if (bRemoveEmptyLines || (iCmpLnLen > iEmptyLnLen)) { const DocPos iBegCmpLine = SciCall_PositionFromLine(iCompareLine); - const char* pCompareLine = SciCall_GetRangePointer(iBegCmpLine, iCmpLnLen + 2); + const char* pCompareLine = SciCall_GetRangePointer(iBegCmpLine, iCmpLnLen + 1); if (iCurLnLen == iCmpLnLen) { if (StringCchCompareNA(pCurrentLine, iCurLnLen, pCompareLine, iCmpLnLen) == 0) { - SciCall_SetTargetRange(iBegCmpLine, iBegCmpLine + iCmpLnLen); + const DocPos iLenToDel = iCmpLnLen + ((iCompareLine != Sci_GetLastDocLine()) ? Sci_GetEOLLen() : 0); + SciCall_SetTargetRange(iBegCmpLine, iBegCmpLine + iLenToDel); SciCall_ReplaceTarget(0, ""); --iCompareLine; // proactive preventing progress to avoid comparison line skip --iEndLine; diff --git a/src/SciCall.h b/src/SciCall.h index 259c76d0b..9aebf496b 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -390,6 +390,7 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) #define Sci_GetEOLLen() ((SciCall_GetEOLMode() == SC_EOL_CRLF) ? 2 : 1) #define Sci_GetCurrentLine() SciCall_LineFromPosition(SciCall_GetCurrentPos()) +#define Sci_GetLastDocLine() (SciCall_GetLineCount() - 1) // length of line w/o line-end chars (full use SciCall_LineLength() #define Sci_GetNetLineLength(line) (SciCall_GetLineEndPosition(line) - SciCall_PositionFromLine(line)) @@ -397,6 +398,7 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) ///~#define Sci_GetDocEndPosition() (SciCall_GetTextLength() - 1) #define Sci_GetDocEndPosition() SciCall_GetTextLength() + //============================================================================= #endif //_NP3_SCICALL_H_ From 93c0ebfc937365452f17515a4ebbf5a02fdbbaac Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 1 Jun 2018 18:07:29 +0200 Subject: [PATCH 2/3] + fix: calc correct line length to delete on removing duplicate lines --- src/Edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Edit.c b/src/Edit.c index 12d0aee77..e8942b60b 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -3715,7 +3715,7 @@ void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines) if (iCurLnLen == iCmpLnLen) { if (StringCchCompareNA(pCurrentLine, iCurLnLen, pCompareLine, iCmpLnLen) == 0) { - const DocPos iLenToDel = iCmpLnLen + ((iCompareLine != Sci_GetLastDocLine()) ? Sci_GetEOLLen() : 0); + const DocPos iLenToDel = (iCompareLine != Sci_GetLastDocLine() ? SciCall_GetLine(iCompareLine, NULL) : iCmpLnLen); SciCall_SetTargetRange(iBegCmpLine, iBegCmpLine + iLenToDel); SciCall_ReplaceTarget(0, ""); --iCompareLine; // proactive preventing progress to avoid comparison line skip From 5b5f6c5ba57015eee7ac3f88497b94725167744d Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 4 Jun 2018 11:27:52 +0200 Subject: [PATCH 3/3] + fix: center command line help dialogbox + add: Accelerator-Key for "Accelerated Word Navigation" => Ctrl+Alt+A --- src/Dialogs.c | 2 ++ src/Notepad3.rc | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index 3c4f7bcaf..cc4434015 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -287,6 +287,8 @@ void DisplayCmdLineHelp(HWND hwnd) mbp.lpfnMsgBoxCallback = NULL; mbp.dwLanguageId = MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL); + hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId()); + MessageBoxIndirect(&mbp); } diff --git a/src/Notepad3.rc b/src/Notepad3.rc index de216bd27..6ad8b0c7a 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -358,7 +358,7 @@ BEGIN MENUITEM "Auto In&dent Text", IDM_VIEW_AUTOINDENTTEXT MENUITEM "Auto Close &HTML/XML\tCtrl+Shift+H", IDM_VIEW_AUTOCLOSETAGS MENUITEM "A&uto Complete Words", IDM_VIEW_AUTOCOMPLETEWORDS - MENUITEM "Accelerated Word Navi&gation", IDM_VIEW_ACCELWORDNAV + MENUITEM "Accelerated Word Navi&gation\tCtrl+Alt+A", IDM_VIEW_ACCELWORDNAV MENUITEM SEPARATOR MENUITEM "&Reuse Window", IDM_VIEW_REUSEWINDOW MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS @@ -456,6 +456,7 @@ BEGIN "A", IDM_EDIT_SELECTALL, VIRTKEY, CONTROL, NOINVERT "A", IDM_VIEW_MARKOCCUR_ONOFF, VIRTKEY, ALT, NOINVERT "A", CMD_RECODEANSI, VIRTKEY, SHIFT, CONTROL, NOINVERT + "A", IDM_VIEW_ACCELWORDNAV, VIRTKEY, CONTROL, ALT, NOINVERT "B", IDM_EDIT_FINDMATCHINGBRACE, VIRTKEY, CONTROL, NOINVERT "B", IDM_EDIT_PADWITHSPACES, VIRTKEY, ALT, NOINVERT "B", IDM_EDIT_SELTOMATCHINGBRACE, VIRTKEY, SHIFT, CONTROL, NOINVERT