mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-28 21:02:59 +08:00
Merge pull request #511 from RaiKoHoff/Dev_0601
Changing behavior of removing duplicate lines (ignore EOL/EOF chars)
This commit is contained in:
commit
eac671cf50
@ -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);
|
||||
}
|
||||
|
||||
|
||||
16
src/Edit.c
16
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 = (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
|
||||
--iEndLine;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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_
|
||||
|
||||
Loading…
Reference in New Issue
Block a user