diff --git a/src/Edit.c b/src/Edit.c index 123736637..aaae5faef 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -22,9 +22,10 @@ #if !defined(NTDDI_VERSION) #define NTDDI_VERSION 0x06010000 /*NTDDI_WIN7*/ #endif -#define VC_EXTRALEAN 1 +#define VC_EXTRALEAN 1 #include + #include #include #include @@ -48,6 +49,9 @@ #define DEFAULT_SCROLL_WIDTH 4096 // 4K +// find free bits in scintilla.h SCFIND_ defines +#define SCFIND_NP3_REGEX (SCFIND_REGEXP | SCFIND_POSIX) + extern HWND hwndMain; extern HWND hwndEdit; extern HINSTANCE g_hInstance; @@ -85,6 +89,7 @@ extern int iMarkOccurrencesMaxCount; extern NP2ENCODING mEncoding[]; + #define DELIM_BUFFER 258 char DelimChars[DELIM_BUFFER] = { '\0' }; char DelimCharsAccel[DELIM_BUFFER] = { '\0' }; @@ -95,6 +100,7 @@ char WordCharsAccelerated[DELIM_BUFFER] = { '\0' }; char WhiteSpaceCharsAccelerated[DELIM_BUFFER] = { '\0' }; char PunctuationCharsAccelerated[1] = { '\0' }; // empty! + enum AlignMask { ALIGN_LEFT = 0, ALIGN_RIGHT = 1, @@ -116,7 +122,6 @@ enum SortOrderMask { }; - extern LPMRULIST mruFind; extern LPMRULIST mruReplace; @@ -3280,7 +3285,7 @@ void EditStripTrailingBlanks(HWND hwnd,BOOL bIgnoreSelection) { if (SC_SEL_RECTANGLE != SendMessage(hwnd,SCI_GETSELECTIONMODE,0,0)) { - EDITFINDREPLACE efrTrim = { "[ \t]+$", "", "", "", (SCFIND_REGEXP | SCFIND_POSIX), 0, 0, 0, 0, 0, 0, NULL }; + EDITFINDREPLACE efrTrim = { "[ \t]+$", "", "", "", SCFIND_NP3_REGEX, 0, 0, 0, 0, 0, 0, NULL }; efrTrim.hwnd = hwnd; EditReplaceAllInSelection(hwnd,&efrTrim,FALSE); @@ -4339,14 +4344,14 @@ void __fastcall EditSetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr) lpefr->fuFlags |= SCFIND_WORDSTART; if (IsDlgButtonChecked(hwnd, IDC_FINDREGEXP) == BST_CHECKED) - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; if (IsDlgButtonChecked(hwnd, IDC_WILDCARDSEARCH) == BST_CHECKED) { lpefr->bWildcardSearch = TRUE; - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; } - if (!(lpefr->bWildcardSearch || (lpefr->fuFlags & SCFIND_REGEXP))) + if (!(lpefr->fuFlags & SCFIND_REGEXP)) lpefr->bTransformBS = (IsDlgButtonChecked(hwnd, IDC_FINDTRANSFORMBS) == BST_CHECKED) ? TRUE : FALSE; lpefr->bNoFindWrap = (IsDlgButtonChecked(hwnd, IDC_NOWRAP) == BST_CHECKED) ? TRUE : FALSE; @@ -4362,7 +4367,7 @@ void __fastcall EscapeWildcards(char* szFind2, LPCEDITFINDREPLACE lpefr) int iSource = 0; int iDest = 0; - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; while (szFind2[iSource] != '\0') { @@ -4418,17 +4423,12 @@ int __fastcall EditGetFindStrg(HWND hwnd, LPCEDITFINDREPLACE lpefr, LPSTR szFind if (lpefr->bTransformBS || bIsRegEx) TransformBackslashes(szFind, bIsRegEx, Encoding_SciGetCodePage(hwnd),NULL); - int slen = StringCchLenA(szFind, FNDRPL_BUFFER); - - if (slen == 0) { - InfoBox(0, L"MsgNotFound", IDS_NOTFOUND); - } - else { + if (StringCchLenA(szFind, FNDRPL_BUFFER) > 0) { if (lpefr->bWildcardSearch) EscapeWildcards(szFind, lpefr); - } - return slen; + + return StringCchLenA(szFind, FNDRPL_BUFFER); } @@ -4497,6 +4497,7 @@ RegExResult_t __fastcall EditFindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpefr, B } + //============================================================================= // // EditFindReplaceDlgProcW() @@ -4637,7 +4638,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA CheckDlgButton(hwnd,IDC_FINDREGEXP,BST_UNCHECKED); } - if ((lpefr->fuFlags & SCFIND_REGEXP) || (lpefr->bWildcardSearch)) { + if (lpefr->fuFlags & SCFIND_REGEXP) { CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, BST_CHECKED); DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, FALSE); } @@ -4696,7 +4697,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA EditSetSearchFlags(hwnd, lpefr); bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 200, NULL); } return TRUE; @@ -4711,14 +4712,25 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA SendMessage(hwndMain, WM_COMMAND, (WPARAM)MAKELONG(IDM_VIEW_MARKOCCURRENCES_ONOFF, 1), 0); } } + KillTimer(hwnd, IDT_TIMER_MRKALL); } return FALSE; + case WM_TIMER: + { + if (LOWORD(wParam) == IDT_TIMER_MRKALL) + { + PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_MARKALL_OCC, 1), 0); + return TRUE; + } + } + return FALSE; + case WM_ACTIVATE: if (bDoCheckAllOccurrences) { bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); } else { DialogEnableWindow(hwnd, IDC_REPLACEINSEL, !(BOOL)SendMessage(hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0)); @@ -4754,27 +4766,33 @@ 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)); } - - if (bDoCheckAllOccurrences) { - EditSetSearchFlags(hwnd, lpefr); - if (bFlagsChanged || (StringCchCompareXA(lastFind, lpefr->szFind) != 0)) { - BeginWaitCursor(); - StringCchCopyA(lastFind, COUNTOF(lastFind), lpefr->szFind); - RegExResult_t match = NO_MATCH; - match = EditFindHasMatch(hwndEdit, lpefr, (iSaveMarkOcc > 0), FALSE); - if (regexMatch != match) { - regexMatch = match; - InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, TRUE); - } - // we have to set Sci's regex instance to first find (have substitution in place) - EditFindHasMatch(hwndEdit, lpefr, FALSE, TRUE); - bFlagsChanged = FALSE; - EndWaitCursor(); - } - } + bFlagsChanged = TRUE; + SetTimer(hwnd, IDT_TIMER_MRKALL, 200, NULL); } break; + case IDC_MARKALL_OCC: + { + if (bDoCheckAllOccurrences) { + EditSetSearchFlags(hwnd, lpefr); + if (bFlagsChanged || (StringCchCompareXA(lastFind, lpefr->szFind) != 0)) { + BeginWaitCursor(); + StringCchCopyA(lastFind, COUNTOF(lastFind), lpefr->szFind); + RegExResult_t match = NO_MATCH; + match = EditFindHasMatch(hwndEdit, lpefr, (iSaveMarkOcc > 0), FALSE); + if (regexMatch != match) { + regexMatch = match; + InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, TRUE); + } + // we have to set Sci's regex instance to first find (have substitution in place) + EditFindHasMatch(hwndEdit, lpefr, FALSE, TRUE); + bFlagsChanged = FALSE; + EndWaitCursor(); + } + } + } + break; + case IDC_FINDREGEXP: if (IsDlgButtonChecked(hwnd, IDC_FINDREGEXP) == BST_CHECKED) { @@ -4782,23 +4800,23 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, FALSE); CheckDlgButton(hwnd, IDC_WILDCARDSEARCH, BST_UNCHECKED); // Can not use wildcard search together with regexp - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; lpefr->bWildcardSearch = FALSE; } else { if (IsDlgButtonChecked(hwnd, IDC_WILDCARDSEARCH) == BST_CHECKED) { - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, BST_CHECKED); DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, FALSE); } else { - lpefr->fuFlags ^= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags ^= SCFIND_NP3_REGEX; DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, TRUE); CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, (lpefr->bTransformBS) ? BST_CHECKED : BST_UNCHECKED); } } bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; case IDC_WILDCARDSEARCH: @@ -4808,25 +4826,25 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, FALSE); CheckDlgButton(hwnd, IDC_FINDREGEXP, BST_UNCHECKED); - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; lpefr->bWildcardSearch = TRUE; } else { if (IsDlgButtonChecked(hwnd, IDC_FINDREGEXP) == BST_CHECKED) { - lpefr->fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags |= SCFIND_NP3_REGEX; CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, BST_CHECKED); DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, FALSE); } else { DialogEnableWindow(hwnd, IDC_FINDTRANSFORMBS, TRUE); CheckDlgButton(hwnd, IDC_FINDTRANSFORMBS, (lpefr->bTransformBS) ? BST_CHECKED : BST_UNCHECKED); - lpefr->fuFlags ^= (SCFIND_REGEXP | SCFIND_POSIX); + lpefr->fuFlags ^= SCFIND_NP3_REGEX; } lpefr->bWildcardSearch = FALSE; } bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; case IDC_FINDTRANSFORMBS: @@ -4837,22 +4855,22 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA lpefr->bTransformBS = FALSE; } bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; case IDC_FINDCASE: bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; case IDC_FINDWORD: bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; case IDC_FINDSTART: bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; @@ -4989,7 +5007,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } } bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); break; @@ -5007,7 +5025,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA SetDlgItemTextW(hwnd, IDC_FINDTEXT, wszRepl); SetDlgItemTextW(hwnd, IDC_REPLACETEXT, wszFind); bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); } break; @@ -5031,7 +5049,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA iSaveMarkOcc = -1; } bFlagsChanged = TRUE; - PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDTEXT, 1), 0); + SetTimer(hwnd, IDT_TIMER_MRKALL, 100, NULL); } break; diff --git a/src/Helpers.c b/src/Helpers.c index a1fdc472a..925a3fc74 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -2461,12 +2461,11 @@ void TransformBackslashes(char* pszInput, BOOL bRegEx, UINT cpEdit, int* iReplac replTarget = CheckRegExReplTarget(pszInput); } - if (SCI_REPLACETARGET == replTarget) + if ((SCI_REPLACETARGET == replTarget) && !bRegEx) UnSlash(pszInput, cpEdit); if (iReplaceMsg) *iReplaceMsg = replTarget; - } diff --git a/src/Notepad3.c b/src/Notepad3.c index 79d347773..f903125f6 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -651,6 +651,8 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n hAccMain = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_MAINWND)); hAccFindReplace = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCFINDREPLACE)); + + UpdateLineNumberWidth(); while (GetMessage(&msg,NULL,0,0)) { @@ -867,6 +869,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) Style_SetLexerFromFile(hwndEdit,szCurFile); bModified = TRUE; UpdateToolbar(); + UpdateLineNumberWidth(); // check for temp file and delete if (flagIsElevated && PathFileExists(szBufferFile)) { @@ -1013,6 +1016,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) UpdateToolbar(); UpdateStatusbar(); + UpdateLineNumberWidth(); // print file immediately and quit if (flagPrintFileAndLeave) @@ -1039,6 +1043,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow) PostMessage(hwndMain, WM_CLOSE, 0, 0); } + UNUSED(pszCmdLine); return(hwndMain); @@ -1139,11 +1144,12 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { extern PEDITLEXER pLexCurrent; Style_SetLexer(hwndEdit,pLexCurrent); + UpdateLineNumberWidth(); return DefWindowProc(hwnd,umsg,wParam,lParam); } //case WM_TIMER: - // break; + // return DefWindowProc(hwnd,umsg,wParam,lParam); case WM_SIZE: MsgSize(hwnd,wParam,lParam); @@ -1151,10 +1157,9 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) case WM_SETFOCUS: SetFocus(hwndEdit); - - UpdateToolbar(); - UpdateStatusbar(); - + //UpdateToolbar(); + //UpdateStatusbar(); + //UpdateLineNumberWidth(); //if (bPendingChangeNotify) // PostMessage(hwnd,WM_CHANGENOTIFY,0,0); break; @@ -1312,7 +1317,6 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) // Margins Style_SetCurrentMargin(hwndEdit, bShowSelectionMargin); - UpdateLineNumberWidth(); // Code folding SciCall_SetMarginType(MARGIN_FOLD_INDEX, SC_MARGIN_SYMBOL); @@ -1328,6 +1332,8 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) SciCall_MarkerDefine(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER); SciCall_SetFoldFlags(16); + UpdateLineNumberWidth(); + // Nonprinting characters SendMessage(hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); SendMessage(hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0); @@ -1422,7 +1428,6 @@ LRESULT MsgCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) return(-1); UNUSED(wParam); - return(0); } @@ -1730,11 +1735,14 @@ void MsgThemeChanged(HWND hwnd,WPARAM wParam,LPARAM lParam) DestroyWindow(hwndReBar); DestroyWindow(hwndStatus); CreateBars(hwnd,hInstance); - UpdateToolbar(); GetClientRect(hwnd,&rc); SendMessage(hwnd,WM_SIZE,SIZE_RESTORED,MAKELONG(rc.right,rc.bottom)); + + UpdateToolbar(); UpdateStatusbar(); + UpdateLineNumberWidth(); + UNUSED(lParam); UNUSED(wParam); @@ -1813,7 +1821,8 @@ void MsgSize(HWND hwnd,WPARAM wParam,LPARAM lParam) SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth); - //UpdateStatusbar(); + UpdateStatusbar(); + UpdateLineNumberWidth(); UNUSED(hwnd); UNUSED(lParam); @@ -1962,6 +1971,8 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) UpdateToolbar(); UpdateStatusbar(); + UpdateLineNumberWidth(); + } UNUSED(wParam); @@ -3857,6 +3868,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) Style_SetCurrentMargin(hwndEdit, bShowSelectionMargin); // set SendMessage(hwndEdit, SCI_MARKERADD, iLine, MARKER_NP3_BOOKMARK); + UpdateLineNumberWidth(); } break; } @@ -4101,6 +4113,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) case IDM_VIEW_MARGIN: bShowSelectionMargin = (bShowSelectionMargin) ? FALSE : TRUE; Style_SetCurrentMargin(hwndEdit, bShowSelectionMargin); + UpdateLineNumberWidth(); break; case IDM_VIEW_AUTOCOMPLETEWORDS: @@ -4146,9 +4159,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) case IDM_VIEW_FOLDING: bShowCodeFolding = (bShowCodeFolding) ? FALSE : TRUE; SciCall_SetMarginWidth(MARGIN_FOLD_INDEX, (bShowCodeFolding) ? 11 : 0); - UpdateToolbar(); if (!bShowCodeFolding) FoldToggleAll(EXPAND); + UpdateToolbar(); break; @@ -4221,19 +4234,19 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) case IDM_VIEW_ZOOMIN: SendMessage(hwndEdit,SCI_ZOOMIN,0,0); - //UpdateLineNumberWidth(); + UpdateLineNumberWidth(); break; case IDM_VIEW_ZOOMOUT: SendMessage(hwndEdit,SCI_ZOOMOUT,0,0); - //UpdateLineNumberWidth(); + UpdateLineNumberWidth(); break; case IDM_VIEW_RESETZOOM: SendMessage(hwndEdit,SCI_SETZOOM,0,0); - //UpdateLineNumberWidth(); + UpdateLineNumberWidth(); break; @@ -5305,7 +5318,6 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) if (bMatchBraces) { EditMatchBrace(hwndEdit); } - UpdateToolbar(); UpdateStatusbar(); } @@ -5459,8 +5471,12 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) RestoreSelectionAction(scn->token,REDO); } } + if (scn->linesAdded != 0) { + UpdateLineNumberWidth(); + } bModified = TRUE; - // fall through + break; + case SCN_ZOOM: UpdateLineNumberWidth(); break; @@ -6947,19 +6963,18 @@ void UpdateStatusbar() // void UpdateLineNumberWidth() { - char chLines[32] = { '\0' }; - int iLineMarginWidthNow; - int iLineMarginWidthFit; + if (bShowLineNumbers) + { + int iLineCnt = (int)SendMessage(hwndEdit, SCI_GETLINECOUNT, 0, 0); - if (bShowLineNumbers) { + char chLines[32] = { '\0' }; + StringCchPrintfA(chLines, COUNTOF(chLines), "_%i_", iLineCnt); - StringCchPrintfA(chLines,COUNTOF(chLines),"_%i_",SendMessage(hwndEdit,SCI_GETLINECOUNT,0,0)); - - iLineMarginWidthNow = (int)SendMessage(hwndEdit,SCI_GETMARGINWIDTHN, MARGIN_NP3_LINENUM, 0); - iLineMarginWidthFit = (int)SendMessage(hwndEdit,SCI_TEXTWIDTH,STYLE_LINENUMBER,(LPARAM)chLines); + int iLineMarginWidthNow = (int)SendMessage(hwndEdit, SCI_GETMARGINWIDTHN, MARGIN_NP3_LINENUM, 0); + int iLineMarginWidthFit = (int)SendMessage(hwndEdit, SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)chLines); if (iLineMarginWidthNow != iLineMarginWidthFit) { - SendMessage(hwndEdit,SCI_SETMARGINWIDTHN, MARGIN_NP3_LINENUM, iLineMarginWidthFit); + SendMessage(hwndEdit, SCI_SETMARGINWIDTHN, MARGIN_NP3_LINENUM, iLineMarginWidthFit); } } else @@ -7245,7 +7260,6 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp FileVars_Init(NULL,0,&fvCurFile); EditSetNewText(hwndEdit,"",0); Style_SetLexer(hwndEdit,NULL); - UpdateLineNumberWidth(); bModified = FALSE; bReadOnly = FALSE; iEOLMode = iLineEndings[iDefaultEOLMode]; @@ -7254,7 +7268,10 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp Encoding_HasChanged(iDefaultEncoding); Encoding_SciSetCodePage(hwndEdit,iDefaultEncoding); EditSetNewText(hwndEdit,"",0); + UpdateToolbar(); + UpdateStatusbar(); + UpdateLineNumberWidth(); // Terminate file watching if (bResetFileWatching) @@ -7353,11 +7370,13 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp StringCchCopy(szCurFile,COUNTOF(szCurFile),szFileName); SetDlgItemText(hwndMain,IDC_FILENAME,szCurFile); SetDlgItemInt(hwndMain,IDC_REUSELOCK,GetTickCount(),FALSE); + if (!fKeepTitleExcerpt) StringCchCopy(szTitleExcerpt,COUNTOF(szTitleExcerpt),L""); + if (!flagLexerSpecified) // flag will be cleared Style_SetLexerFromFile(hwndEdit,szCurFile); - UpdateLineNumberWidth(); + bModified = FALSE; //bReadOnly = FALSE; SendMessage(hwndEdit,SCI_SETEOLMODE,iEOLMode,0); @@ -7376,8 +7395,6 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp if (flagUseSystemMRU == 2) SHAddToRecentDocs(SHARD_PATHW,szFileName); - UpdateToolbar(); - // Install watching of the current file if (!bReload && bResetFileWatching) iFileWatchingMode = 0; @@ -7409,6 +7426,11 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp EditJumpTo(hwndEdit, iLine+1, iCol+1); } } + + UpdateToolbar(); + UpdateStatusbar(); + UpdateLineNumberWidth(); + // consistent settings file handling (if loaded in editor) bEnableSaveSettings = (StringCchCompareINW(szCurFile, COUNTOF(szCurFile), szIniFile, COUNTOF(szIniFile)) == 0) ? FALSE : TRUE; UpdateSettingsCmds(); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 7548eb4d6..eaede8a2d 100644 Binary files a/src/Notepad3.rc and b/src/Notepad3.rc differ diff --git a/src/Styles.c b/src/Styles.c index aa6193ea8..3bb2b8e1f 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -357,26 +357,30 @@ EDITLEXER lexCSS = { SCLEX_CSS, 63003, L"CSS Style Sheets", L"css; less; sass; s KEYWORDLIST KeyWords_CPP = { - // Primary keywords and identifiers - "alignas alignof auto bool break case catch char char16_t char32_t class const constexpr const_cast " - "continue decltype default defined delete do double dynamic_cast else enum explicit export extern false float " - "for friend goto if inline int long mutable naked namespace new noexcept nullptr operator private protected " - "public register reinterpret_cast return short signed size_t sizeof static static_assert static_cast struct " - "switch template this thread_local throw true try typedef typeid typename union unsigned using " - "virtual void volatile wchar_t while", - // Secondary keywords and identifiers - "__abstract __alignof __asm __assume __based __box __cdecl __declspec __delegate __event " + // Primary keywords + "alignas auto bool break case catch char char16_t char32_t class const constexpr const_cast " + "continue decltype default delete do double dynamic_cast else enum explicit export extern false float " + "for friend goto if inline int long mutable namespace new noexcept nullptr operator " + "private protected public register reinterpret_cast restrict return short signed sizeof static " + "static_assert static_cast struct switch template this thread_local throw true try typedef typeid typename " + "union unsigned using virtual void volatile wchar_t while " + "alignof defined naked noreturn", + // Secondary keywords + "asm __abstract __alignof __asm __assume __based __box __cdecl __declspec __delegate __event " "__except __except__try __fastcall __finally __forceinline __gc __hook __identifier " - "__if_exists __if_not_exists __inline __int16 __int32 __int64 __int8 __interface __leave " - "__m128 __m128d __m128i __m64 __multiple_inheritance __nogc __noop __pin __property __raise " + "__if_exists __if_not_exists __inline __interface __leave " + "__multiple_inheritance __nogc __noop __pin __property __raise " "__sealed __single_inheritance __stdcall __super __try __try_cast __unhook __uuidof __value " - "__virtual_inheritance __wchar_t asm", + "__virtual_inheritance", // Documentation comment keywords "", // Global classes and typedefs - "", + "complex imaginary int8_t int16_t int32_t int64_t intptr_t intmax_t ptrdiff_t size_t " + "uint8_t uint16_t uint32_t uint64_t uintptr_t uintmax_t" + "__int16 __int32 __int64 __int8 __m128 __m128d __m128i __m64 __wchar_t " + "_Alignas _Alignof _Atomic _Bool _Complex _Generic _Imaginary _Noreturn _Pragma _Static_assert _Thread_local", // Preprocessor definitions - "_MSC_VER SCI_NAMESPACE", + "DEBUG NDEBUG UNICODE _DEBUG _UNICODE _MSC_VER", // Task marker and error marker keywords "", "", @@ -387,17 +391,17 @@ KEYWORDLIST KeyWords_CPP = { EDITLEXER lexCPP = { SCLEX_CPP, 63004, L"C/C++ Source Code", L"c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl", L"", &KeyWords_CPP, { { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, L"Default", L"", L"" }, + { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, { SCE_C_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, { SCE_C_WORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" }, - { SCE_C_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { SCE_C_WORD2, 63260, L"Keyword 2nd", L"bold; italic; fore:#3C6CDD", L"" }, + { SCE_C_GLOBALCLASS, 63258, L"Typedefs/Classes", L"bold; italic; fore:#800000", L"" }, { MULTI_STYLE(SCE_C_STRING,SCE_C_CHARACTER,SCE_C_STRINGEOL,SCE_C_VERBATIM), 63131, L"String", L"fore:#008000", L"" }, { SCE_C_NUMBER, 63130, L"Number", L"fore:#FF0000", L"" }, { SCE_C_OPERATOR, 63132, L"Operator", L"fore:#B000B0", L"" }, { MULTI_STYLE(SCE_C_PREPROCESSOR,SCE_C_PREPROCESSORCOMMENT,SCE_C_PREPROCESSORCOMMENTDOC,0), 63133, L"Preprocessor", L"fore:#FF8000", L"" }, //{ SCE_C_UUID, L"UUID", L"", L"" }, //{ SCE_C_REGEX, L"Regex", L"", L"" }, - { SCE_C_WORD2, 63260, L"Keyword 2nd", L"italic; fore:#3C6CDD", L"" }, - //{ SCE_C_GLOBALCLASS, L"Global Class", L"", L"" }, { -1, 00000, L"", L"", L"" } } }; diff --git a/src/resource.h b/src/resource.h index 80628c2c8..0dabab805 100644 --- a/src/resource.h +++ b/src/resource.h @@ -116,6 +116,8 @@ #define IDD_INFOBOX 126 #define IDD_INFOBOX2 127 #define IDD_INFOBOX3 128 +#define IDT_TIMER_MRKALL 130 +#define IDC_MARKALL_OCC 131 #define IDC_BACKSLASHHELP 151 #define IDC_REGEXPHELP 152 #define IDC_WILDCARDHELP 153