From d619b337e6043459fa9e48becda2f70ccd8cf354 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Thu, 5 Apr 2018 10:21:19 +0200 Subject: [PATCH] + fix: minor correction + fix: ScrollTo bug in case of wrapped lines --- src/Edit.c | 87 ++++++++++++++++++++++++++++--------------------- src/Edit.h | 5 +-- src/Helpers.c | 2 +- src/Notepad3.c | 53 ++++++++++++------------------ src/Notepad3.rc | 12 +++---- src/SciCall.h | 9 +++++ src/Styles.c | 10 ++++-- 7 files changed, 95 insertions(+), 83 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index b1e94d52c..bcfca5c5c 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1340,7 +1340,7 @@ bool EditSaveFile( cbData = WideCharToMultiByte(uCodePage,WC_NO_BEST_FIT_CHARS,lpDataWide,cbDataWide,lpData,(int)SizeOfMem(lpData),NULL,&bCancelDataLoss); if (!bCancelDataLoss) { cbData = WideCharToMultiByte(uCodePage,0,lpDataWide,cbDataWide,lpData,(int)SizeOfMem(lpData),NULL,NULL); - bCancelDataLoss = false; + bCancelDataLoss = FALSE; } } FreeMem(lpDataWide); @@ -4322,7 +4322,7 @@ void EditSelectEx(HWND hwnd, DocPos iAnchorPos, DocPos iCurrentPos, int vSpcAnch if (abs(iNewLine - iAnchorLine) < SciCall_LinesOnScreen()) { - EditScrollTo(hwnd, (iAnchorLine + iNewLine) / 2, true); // center small selection + EditScrollTo(hwnd, (iAnchorLine + iNewLine) / 2, -1); // center small selection } // remember x-pos for moving caret vertically SciCall_ChooseCaretX(); @@ -4364,26 +4364,16 @@ void EditEnsureSelectionVisible(HWND hwnd) // // EditScrollTo() // -void EditScrollTo(HWND hwnd, DocLn iScrollToLine, bool bForceCenter) +void EditScrollTo(HWND hwnd, DocLn iScrollToLine, int iSlop) { UNUSED(hwnd); - const DocLn iVisTopLine = SciCall_GetFirstVisibleLine(); const int iXoff = SciCall_GetXoffset(); - const DocLn iMaxLine = SciCall_GetLineCount() - 1; + const int iLinesOnScreen = SciCall_LinesOnScreen(); + const DocLn iSlopLines = ((iSlop < 0) || (iSlop >= iLinesOnScreen)) ? (iLinesOnScreen/2) : iSlop; - iScrollToLine = min(iScrollToLine, iMaxLine); - const DocPos iViewPos = SciCall_PositionFromLine(iScrollToLine); - - SciCall_ScrollRange(iViewPos, iViewPos); - - // center line in view (if not already in view) - const DocLn iNewVisTopLine = SciCall_GetFirstVisibleLine(); - if ((iNewVisTopLine != iVisTopLine) || bForceCenter) { - const DocLn iScrollLines = SciCall_LinesOnScreen() / 2; - const int iScrollCnt = (iScrollToLine - iNewVisTopLine - iScrollLines); - if (iScrollCnt != 0) { SciCall_LineScroll(0, iScrollCnt); } - } + SciCall_SetVisiblePolicy((VISIBLE_SLOP | VISIBLE_STRICT), iSlopLines); + SciCall_EnsureVisibleEnforcePolicy(iScrollToLine); SciCall_SetXoffset(iXoff); } @@ -4408,7 +4398,7 @@ void EditJumpTo(HWND hwnd, DocLn iNewLine, DocPos iNewCol) const DocPos iNewPos = SciCall_FindColumn(iNewLine, iNewCol); SciCall_GotoPos(iNewPos); - EditScrollTo(hwnd, iNewLine, false); + EditScrollTo(hwnd, iNewLine, -1); // remember x-pos for moving caret vertically SciCall_ChooseCaretX(); @@ -4552,9 +4542,7 @@ static void __fastcall _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr) } lpefr->bTransformBS = (IsDlgButtonChecked(hwnd, IDC_FINDTRANSFORMBS) == BST_CHECKED) ? true : false; - lpefr->bMarkOccurences = (IsDlgButtonChecked(hwnd, IDC_ALL_OCCURRENCES) == BST_CHECKED) ? true : false; - lpefr->bNoFindWrap = (IsDlgButtonChecked(hwnd, IDC_NOWRAP) == BST_CHECKED) ? true : false; } @@ -4621,6 +4609,7 @@ static int __fastcall _EditGetFindStrg(HWND hwnd, LPCEDITFINDREPLACE lpefr, LPST } else { GetFindPatternMB(szFind, cchCnt); + StringCchCopyA(lpefr->szFind, COUNTOF(lpefr->szFind), szFind); } if (!StringCchLenA(szFind, cchCnt)) { return 0; } @@ -4712,12 +4701,24 @@ static RegExResult_t __fastcall _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpef DocPos end = iTextLength; const DocPos iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, false, FRMOD_IGNORE); + static DocLn lastScrollToLn = -1; + if (bFirstMatchOnly && !bReplaceInitialized) { - if (iPos >= 0) { - EditScrollTo(hwnd, SciCall_LineFromPosition(iPos), true); - } - else { - EditScrollTo(hwnd, SciCall_LineFromPosition(iStart), false); + if (GetForegroundWindow() == g_hwndDlgFindReplace) { + if (iPos >= 0) { + const DocLn scrollToLn = SciCall_LineFromPosition(iPos); + if (scrollToLn != lastScrollToLn) { + EditScrollTo(hwnd, scrollToLn, -1); + lastScrollToLn = scrollToLn; + } + } + else { + const DocLn scrollToLn = SciCall_LineFromPosition(iStart); + if (scrollToLn != lastScrollToLn) { + EditScrollTo(hwnd, scrollToLn, -1); + lastScrollToLn = scrollToLn; + } + } } } else // mark all matches @@ -4734,7 +4735,7 @@ static RegExResult_t __fastcall _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpef //============================================================================= // -// EditFindReplaceDlgProcW() +// _SetTimerMarkAll() // static void __fastcall _SetTimerMarkAll(HWND hwnd, int delay) { @@ -4949,13 +4950,13 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA iReplacedOccurrences = 0; g_FindReplaceMatchFoundState = FND_NOP; - //EditScrollTo(hwnd, Sci_GetCurrentLine(), false); - EditEnsureSelectionVisible(hwnd); + //EditScrollTo(g_hwndEdit, Sci_GetCurrentLine(), false); + EditEnsureSelectionVisible(g_hwndEdit); } + KillTimer(hwnd, IDT_TIMER_MRKALL); DeleteObject(hBrushRed); DeleteObject(hBrushGreen); DeleteObject(hBrushBlue); - KillTimer(hwnd, IDT_TIMER_MRKALL); } return false; @@ -4965,8 +4966,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (LOWORD(wParam) == IDT_TIMER_MRKALL) { if (TEST_AND_RESET(TIMER_BIT_MARK_OCC)) { - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_MARKALL_OCC, 1), 0); KillTimer(hwnd, IDT_TIMER_MRKALL); + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_MARKALL_OCC, 1), 0); } return true; } @@ -4980,7 +4981,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA lpefr = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd, DWLP_USER); if (lpefr->bMarkOccurences) { - bFlagsChanged = true; + bFlagsChanged = true; // main window has been edited maybe _SetTimerMarkAll(hwnd,50); } //if (LOWORD(wParam) == WA_INACTIVE) { @@ -5048,6 +5049,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA SetDlgItemText(hwnd, IDC_FINDTEXT, tchBuf); } bFindReplCopySelOrClip = false; + + bFlagsChanged = true; } bool bEnableF = (GetWindowTextLengthW(GetDlgItem(hwnd, IDC_FINDTEXT)) || @@ -5070,8 +5073,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETEDITSEL, 0, (LPARAM)&lSelEnd); SendDlgItemMessage(hwnd, LOWORD(wParam), CB_SETEDITSEL, 0, MAKELPARAM(lSelEnd, lSelEnd)); } - bFlagsChanged = true; - _SetTimerMarkAll(hwnd,50); + + _SetTimerMarkAll(hwnd, 50); } break; @@ -5080,6 +5083,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA { if (IsDlgButtonChecked(hwnd, IDC_ALL_OCCURRENCES) == BST_CHECKED) { + bFlagsChanged = !(lpefr->bMarkOccurences); lpefr->bMarkOccurences = true; iSaveMarkOcc = iMarkOccurrences; EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, false); @@ -5102,8 +5106,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA bSaveOccVisible = false; EditClearAllMarks(g_hwndEdit, 0, -1); InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); + bFlagsChanged = true; } - bFlagsChanged = true; _SetTimerMarkAll(hwnd,0); } break; @@ -5124,9 +5128,9 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA _FindHasMatch(g_hwndEdit, lpefr, false, true); bFlagsChanged = false; InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); + UpdateToolbar(); + UpdateStatusbar(); } - UpdateToolbar(); - UpdateStatusbar(); } } break; @@ -5719,10 +5723,13 @@ bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo // void EditMarkAllOccurrences() { - if (iMarkOccurrences != 0) { + if (iMarkOccurrences > 0) { if (EditIsInTargetTransaction()) { return; } // do not block, next event occurs for sure + IgnoreNotifyChangeEvent(); + EditEnterTargetTransaction(); + if (bMarkOccurrencesMatchVisible) { // get visible lines for update @@ -5743,6 +5750,8 @@ void EditMarkAllOccurrences() UpdateStatusbar(); } EditLeaveTargetTransaction(); + ObserveNotifyChangeEvent(); + } else { iMarkOccurrencesCount = 0; @@ -5760,6 +5769,8 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled) { if (EditIsInTargetTransaction()) { return; } // do not block, next event occurs for sure + EditEnterTargetTransaction(); + // get visible lines for update DocLn iFirstVisibleLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); @@ -6148,7 +6159,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos if (iPos < 0) break; // not found - //// mark this match if not done before + // mark this match if not done before SciCall_IndicatorFillRange(iPos, (end - start)); start = end; diff --git a/src/Edit.h b/src/Edit.h index 2c6c96a4c..7da7dbc7d 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -45,7 +45,8 @@ typedef struct _editfindreplace #define IDMSG_SWITCHTOFIND 300 #define IDMSG_SWITCHTOREPLACE 301 -#define MARKER_NP3_BOOKMARK 0 +#define MARKER_NP3_BOOKMARK 1 + #define INDIC_NP3_MARK_OCCURANCE 1 #define INDIC_NP3_MATCH_BRACE 2 @@ -103,7 +104,7 @@ void EditJoinLinesEx(HWND,bool,bool); void EditSortLines(HWND,int); void EditJumpTo(HWND, DocLn, DocPos); -void EditScrollTo(HWND, DocLn, bool); +void EditScrollTo(HWND, DocLn, int); void EditSelectEx(HWND, DocPos, DocPos, int, int); void EditFixPositions(HWND); void EditEnsureSelectionVisible(HWND); diff --git a/src/Helpers.c b/src/Helpers.c index 6a954804d..5aec6eb24 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -465,7 +465,7 @@ bool VerifyContrast(COLORREF cr1,COLORREF cr2) // int CALLBACK EnumFontsProc(CONST LOGFONT *plf,CONST TEXTMETRIC *ptm,DWORD FontType,LPARAM lParam) { - *((BOOL*)lParam) = TRUE; + *((PBOOL)lParam) = true; UNUSED(plf); UNUSED(ptm); UNUSED(FontType); diff --git a/src/Notepad3.c b/src/Notepad3.c index bcd250106..3a13f3823 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1074,15 +1074,15 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) case WM_TIMER: if (LOWORD(wParam) == IDT_TIMER_MAIN_MRKALL) { if (TEST_AND_RESET(TIMER_BIT_MARK_OCC)) { - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_MAIN_MARKALL_OCC, 1), 0); KillTimer(hwnd, IDT_TIMER_MAIN_MRKALL); + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_MAIN_MARKALL_OCC, 1), 0); } return true; } else if (LOWORD(wParam) == IDT_TIMER_UPDATE_HOTSPOT) { if (TEST_AND_RESET(TIMER_BIT_UPDATE_HYPER)) { - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_CALL_UPDATE_HOTSPOT, 1), 0); KillTimer(hwnd, IDT_TIMER_UPDATE_HOTSPOT); + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_CALL_UPDATE_HOTSPOT, 1), 0); } return true; } @@ -2413,7 +2413,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,bAutoCompleteWords); CheckCmd(hmenu,IDM_VIEW_ACCELWORDNAV,bAccelWordNavigation); - CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_ONOFF, iMarkOccurrences != 0); + CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_ONOFF, (iMarkOccurrences > 0)); CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_VISIBLE, bMarkOccurrencesMatchVisible); CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_CASE, bMarkOccurrencesMatchCase); @@ -2427,7 +2427,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) CheckMenuRadioItem(hmenu, IDM_VIEW_MARKOCCUR_WNONE, IDM_VIEW_MARKOCCUR_CURRENT, i, MF_BYCOMMAND); CheckCmdPos(GetSubMenu(GetSubMenu(GetMenu(g_hwndMain), 2), 17), 5, (i != IDM_VIEW_MARKOCCUR_WNONE)); - i = (int)(iMarkOccurrences != 0); + i = (int)(iMarkOccurrences > 0); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_VISIBLE, i); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_CASE, i); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_WNONE, i); @@ -2594,11 +2594,6 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case IDM_FILE_READONLY: - //bReadOnly = (bReadOnly) ? false : true; - //SendMessage(g_hwndEdit,SCI_SETREADONLY,bReadOnly,0); - //UpdateToolbar(); - //UpdateStatusbar(); - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { DWORD dwFileAttributes = GetFileAttributes(g_wchCurFile); @@ -3852,7 +3847,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) const DocPos iPos = SciCall_GetCurrentPos(); const DocLn iLine = SciCall_LineFromPosition(iPos); - int bitmask = 1; + int bitmask = (1 << MARKER_NP3_BOOKMARK); DocLn iNextLine = (DocLn)SendMessage( g_hwndEdit , SCI_MARKERPREVIOUS , iLine-1 , bitmask ); if (iNextLine == (DocLn)-1) { @@ -3873,22 +3868,23 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) const DocPos iPos = SciCall_GetCurrentPos(); const DocLn iLine = SciCall_LineFromPosition(iPos); - int bitmask = (int)SendMessage(g_hwndEdit, SCI_MARKERGET, iLine, MARKER_NP3_BOOKMARK); + int bitmask = SciCall_MarkerGet(iLine); + if (bitmask & (1 << MARKER_NP3_BOOKMARK)) { // unset - SendMessage(g_hwndEdit, SCI_MARKERDELETE, iLine, MARKER_NP3_BOOKMARK); + SciCall_MarkerDelete(iLine, MARKER_NP3_BOOKMARK); } else { Style_SetBookmark(g_hwndEdit, g_bShowSelectionMargin); // set - SendMessage(g_hwndEdit, SCI_MARKERADD, iLine, MARKER_NP3_BOOKMARK); + SciCall_MarkerAdd(iLine, MARKER_NP3_BOOKMARK); UpdateLineNumberWidth(); } break; } case BME_EDIT_BOOKMARKCLEAR: - SendMessage(g_hwndEdit,SCI_MARKERDELETEALL, (WPARAM)MARKER_NP3_BOOKMARK, 0); + SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK); break; @@ -4111,7 +4107,6 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) else SendMessage(g_hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR,0); bWordWrapG = bWordWrap; - //EditApplyLexerStyle(g_hwndEdit, 0, -1); UpdateToolbar(); break; @@ -5451,7 +5446,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) EditMatchBrace(g_hwndEdit); } - if (iMarkOccurrences) { + if (iMarkOccurrences > 0) { // clear marks only, if caret/selection changed if (scn->updated & SC_UPDATE_SELECTION) { EditClearAllMarks(g_hwndEdit, 0, -1); @@ -5470,7 +5465,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) } else if (scn->updated & SC_UPDATE_V_SCROLL) { - if (iMarkOccurrences) { + if (iMarkOccurrences > 0) { MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences); } if (bHyperlinkHotspot) { @@ -5492,10 +5487,12 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) } } else if (scn->modificationType & SC_MOD_CHANGESTYLE) { - EditUpdateUrlHotspots(g_hwndEdit, (int)scn->position, (int)(scn->position + scn->length), bHyperlinkHotspot); + const DocPos iStartPos = (DocPos)scn->position; + const DocPos iEndPos = (DocPos)(scn->position + scn->length); + EditUpdateUrlHotspots(g_hwndEdit, iStartPos, iEndPos, bHyperlinkHotspot); } - if (iMarkOccurrences) { + if (iMarkOccurrences > 0) { EditClearAllMarks(g_hwndEdit, 0, -1); MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences); } @@ -5529,11 +5526,11 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) //const DocPos iPrevLineLength = Sci_GetNetLineLength(iCurLine - 1); if (SciCall_GetLineEndPosition(iCurLine - 1) == SciCall_GetLineIndentPosition(iCurLine - 1)) { - int bitmask = (int)SendMessage(g_hwndEdit, SCI_MARKERGET, iCurLine - 1, 0); + int bitmask = SciCall_MarkerGet(iCurLine - 1); if (bitmask & (1 << MARKER_NP3_BOOKMARK)) { - SendMessage(g_hwndEdit, SCI_MARKERDELETE, iCurLine - 1, MARKER_NP3_BOOKMARK); - SendMessage(g_hwndEdit, SCI_MARKERADD, iCurLine, MARKER_NP3_BOOKMARK); + SciCall_MarkerDelete(iCurLine - 1, MARKER_NP3_BOOKMARK); + SciCall_MarkerAdd(iCurLine, MARKER_NP3_BOOKMARK); } } } @@ -5873,27 +5870,17 @@ void LoadSettings() bEnableSaveSettings = true; bSaveSettings = IniSectionGetBool(pIniSection,L"SaveSettings",true); - bSaveRecentFiles = IniSectionGetBool(pIniSection,L"SaveRecentFiles",false); - bPreserveCaretPos = IniSectionGetBool(pIniSection, L"PreserveCaretPos",false); - bSaveFindReplace = IniSectionGetBool(pIniSection,L"SaveFindReplace",false); g_efrData.bFindClose = IniSectionGetBool(pIniSection,L"CloseFind", false); - g_efrData.bReplaceClose = IniSectionGetBool(pIniSection,L"CloseReplace", false); - g_efrData.bNoFindWrap = IniSectionGetBool(pIniSection,L"NoFindWrap", false); - g_efrData.bTransformBS = IniSectionGetBool(pIniSection,L"FindTransformBS", false); - g_efrData.bWildcardSearch = IniSectionGetBool(pIniSection,L"WildcardSearch",false); - g_efrData.bMarkOccurences = IniSectionGetBool(pIniSection, L"FindMarkAllOccurrences", false); - g_efrData.bDotMatchAll = IniSectionGetBool(pIniSection, L"RegexDotMatchesAll", false); - g_efrData.fuFlags = IniSectionGetUInt(pIniSection, L"efrData_fuFlags", 0); if (!IniSectionGetString(pIniSection, L"OpenWithDir", L"", tchOpenWithDir, COUNTOF(tchOpenWithDir))) { @@ -8199,7 +8186,7 @@ BOOL CALLBACK EnumWndProc(HWND hwnd,LPARAM lParam) if (StringCchCompareINW(szClassName,COUNTOF(szClassName),wchWndClass,COUNTOF(wchWndClass)) == 0) { - DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,false); + DWORD dwReuseLock = GetDlgItemInt(hwnd,IDC_REUSELOCK,NULL,FALSE); if (GetTickCount() - dwReuseLock >= REUSEWINDOWLOCKTIMEOUT) { *(HWND*)lParam = hwnd; diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 8c8bd4e42..b89772c6c 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -169,10 +169,10 @@ BEGIN MENUITEM "Move &Up\tCtrl+Shift+Up", IDM_EDIT_MOVELINEUP MENUITEM "&Move Down\tCtrl+Shift+Down", IDM_EDIT_MOVELINEDOWN MENUITEM SEPARATOR - MENUITEM "Cut &Line\tCtrl[+Shift]+X", IDM_EDIT_CUTLINE - MENUITEM "&Copy Line\tCtrl[+Shift]+C", IDM_EDIT_COPYLINE + MENUITEM "Cut &Line\tCtrl[+Shift]+X", IDM_EDIT_CUTLINE + MENUITEM "&Copy Line\tCtrl[+Shift]+C", IDM_EDIT_COPYLINE MENUITEM "&Duplicate Line\tCtrl+D", IDM_EDIT_DUPLICATELINE - MENUITEM "D&elete Line\tCtrl+Shift+D", IDM_EDIT_DELETELINE + MENUITEM "D&elete Line\tCtrl+Shift+D", IDM_EDIT_DELETELINE MENUITEM SEPARATOR MENUITEM "Delete Line Left\tCtrl+Shift+Back", IDM_EDIT_DELETELINELEFT MENUITEM "Delete Line Right\tCtrl+Shift+Del", IDM_EDIT_DELETELINERIGHT @@ -185,7 +185,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Mer&ge Empty Lines\tAlt+Y", IDM_EDIT_MERGEEMPTYLINES MENUITEM "Merge Whitespace Lines\tCtrl+Alt+Y", IDM_EDIT_MERGEBLANKLINES - MENUITEM "&Remove Empty Lines\tAlt+R", IDM_EDIT_REMOVEEMPTYLINES + MENUITEM "&Remove Empty Lines\tAlt+R", IDM_EDIT_REMOVEEMPTYLINES MENUITEM "Remove Whitespace Lines\tCtrl+Alt+B", IDM_EDIT_REMOVEBLANKLINES MENUITEM "Rem&ove Duplicate Lines\tCtrl+Alt+D", IDM_EDIT_REMOVEDUPLICATELINES END @@ -340,8 +340,8 @@ BEGIN MENUITEM "Zoom &Out\tCtrl+-", IDM_VIEW_ZOOMOUT MENUITEM "Reset &Zoom\tCtrl+0", IDM_VIEW_RESETZOOM MENUITEM SEPARATOR - MENUITEM "Copy Position Args\tCtrl+Shift+K", CMD_COPYWINPOS - MENUITEM "Snap to Default Position\tCtrl+Shift+P", CMD_DEFAULTWINPOS + MENUITEM "Copy Position Args\tCtrl+Shift+K", CMD_COPYWINPOS + MENUITEM "Snap to Default Position\tCtrl+Shift+P", CMD_DEFAULTWINPOS MENUITEM "Scroll Past End of &File", IDM_VIEW_SCROLLPASTEOF END POPUP "&Settings" diff --git a/src/SciCall.h b/src/SciCall.h index 8b970daa2..5f9c9a3e8 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -236,6 +236,7 @@ DeclareSciCallV0(NewLine, NEWLINE) // // Scrolling and automatic scrolling // +DeclareSciCallV2(SetVisiblePolicy, SETVISIBLEPOLICY, int, flags, DocLn, lines) DeclareSciCallV0(ChooseCaretX, CHOOSECARETX) DeclareSciCallV0(ScrollCaret, SCROLLCARET) DeclareSciCallV2(LineScroll, LINESCROLL, DocPos, columns, DocLn, lines) @@ -278,9 +279,13 @@ DeclareSciCallV2(SetFoldMarginHiColour, SETFOLDMARGINHICOLOUR, bool, useSetting, // // Markers // +DeclareSciCallR1(MarkerGet, MARKERGET, int, DocLn, line) DeclareSciCallV2(MarkerDefine, MARKERDEFINE, int, markerNumber, int, markerSymbols) DeclareSciCallV2(MarkerSetFore, MARKERSETFORE, int, markerNumber, COLORREF, colour) DeclareSciCallV2(MarkerSetBack, MARKERSETBACK, int, markerNumber, COLORREF, colour) +DeclareSciCallR2(MarkerAdd, MARKERADD, int, DocLn, line, int, markerNumber) +DeclareSciCallV2(MarkerDelete, MARKERDELETE, DocLn, line, int, markerNumber) +DeclareSciCallV1(MarkerDeleteAll, MARKERDELETEALL, int, markerNumber) //============================================================================= @@ -297,12 +302,16 @@ DeclareSciCallV2(IndicatorFillRange, INDICATORFILLRANGE, DocPos, position, DocPo // // DeclareSciCallR1(GetLineVisible, GETLINEVISIBLE, bool, DocLn, line) +DeclareSciCallV2(SetFoldLevel, SETFOLDLEVEL, DocLn, line, int, flags) DeclareSciCallR1(GetFoldLevel, GETFOLDLEVEL, int, DocLn, line) DeclareSciCallV1(SetFoldFlags, SETFOLDFLAGS, int, flags) +DeclareSciCallV1(FoldDisplayTextSetStyle, FOLDDISPLAYTEXTSETSTYLE, int, flags) DeclareSciCallR1(GetFoldParent, GETFOLDPARENT, int, DocLn, line) DeclareSciCallR1(GetFoldExpanded, GETFOLDEXPANDED, int, DocLn, line) DeclareSciCallV1(ToggleFold, TOGGLEFOLD, DocLn, line) +DeclareSciCallV1(FoldAll, FOLDALL, int, flags) DeclareSciCallV1(EnsureVisible, ENSUREVISIBLE, DocLn, line) +DeclareSciCallV1(EnsureVisibleEnforcePolicy, ENSUREVISIBLEENFORCEPOLICY, DocLn, line) //============================================================================= diff --git a/src/Styles.c b/src/Styles.c index 75b9af51a..98f0f04f5 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -3836,13 +3836,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // apply lexer styles Style_SetUrlHotSpot(hwnd, false); - EditApplyLexerStyle(g_hwndEdit, 0, -1); + EditApplyLexerStyle(hwnd, 0, -1); // update UI for hotspots if (bHyperlinkHotspot) { Style_SetUrlHotSpot(hwnd, bHyperlinkHotspot); EditUpdateUrlHotspots(hwnd, 0, SciCall_GetTextLength(), bHyperlinkHotspot); } + UpdateLineNumberWidth(); } @@ -3976,16 +3977,17 @@ void Style_SetFolding(HWND hwnd, bool bShowCodeFolding) // void Style_SetBookmark(HWND hwnd, bool bShowSelMargin) { + UNUSED(hwnd); float fSize = INITIAL_BASE_FONT_SIZE + 1.0; Style_StrGetSize(GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue, &fSize); SciCall_SetMarginWidth(MARGIN_SCI_BOOKMRK, (bShowSelMargin) ? (int)fSize + 4 : 0); // Depending on if the margin is visible or not, choose different bookmark indication if (bShowSelMargin) { - SendMessage(hwnd, SCI_MARKERDEFINE, MARKER_NP3_BOOKMARK, SC_MARK_BOOKMARK); + SciCall_MarkerDefine(MARKER_NP3_BOOKMARK, SC_MARK_BOOKMARK); } else { - SendMessage(hwnd, SCI_MARKERDEFINE, MARKER_NP3_BOOKMARK, SC_MARK_BACKGROUND); + SciCall_MarkerDefine(MARKER_NP3_BOOKMARK, SC_MARK_BACKGROUND); } } @@ -4090,6 +4092,8 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle) SciCall_SetFoldMarginColour(true, clrBack); // background SciCall_SetFoldMarginHiColour(true, clrBack); // (!) + //SciCall_FoldDisplayTextSetStyle(SC_FOLDDISPLAYTEXT_HIDDEN); + for (int i = 0; i < COUNTOF(iMarkerIDs); ++i) { SciCall_MarkerSetBack(iMarkerIDs[i], bmkFore); SciCall_MarkerSetFore(iMarkerIDs[i], bmkBack);