Skip to content

Commit

Permalink
Allow File/Replace dialog options to be saved
Browse files Browse the repository at this point in the history
This fix will helps in saving the options checked/unchecked
in File/Replace dialog to be persisted to notepad2.ini
  • Loading branch information
vineelkovvuri committed Jul 4, 2018
1 parent 7d3b464 commit 0575e74
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -5352,6 +5352,29 @@ void LoadSettings(void) {
xFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosX", 0);
yFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosY", 0);

if (bSaveFindReplace) {
efrData.fuFlags = 0;
if (IniSectionGetBool(pIniSection, L"FindReplaceMatchCase", 0)) {
efrData.fuFlags |= SCFIND_MATCHCASE;
}
if (IniSectionGetBool(pIniSection, L"FindReplaceMatchWholeWorldOnly", 0)) {
efrData.fuFlags |= SCFIND_WHOLEWORD;
}
if (IniSectionGetBool(pIniSection, L"FindReplaceMatchBeginingWordOnly", 0)) {
efrData.fuFlags |= SCFIND_WORDSTART;
}
if (IniSectionGetBool(pIniSection, L"FindReplaceRegExpSearch", 0)) {
efrData.fuFlags |= SCFIND_REGEXP | SCFIND_POSIX;
}
efrData.bTransformBS = IniSectionGetBool(pIniSection, L"FindReplaceTransformBackslash", 0);
efrData.bNoFindWrap = IniSectionGetBool(pIniSection, L"FindReplaceDontWrapRound", 0);
efrData.bFindClose = IniSectionGetBool(pIniSection, L"FindReplaceCloseAfterFind", 0);
efrData.bReplaceClose = IniSectionGetBool(pIniSection, L"FindReplaceCloseAfterReplace", 0);
#ifdef BOOKMARK_EDITION
efrData.bWildcardSearch = IniSectionGetBool(pIniSection, L"FindReplaceWildcardSearch", 0);
#endif
}

//////////////////////////////// Settings2 ///////////////////////////////////////////

LoadIniSection(L"Settings2", pIniSection, cchIniSection);
Expand Down Expand Up @@ -5533,6 +5556,20 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetInt(pIniSection, L"FindReplaceDlgPosX", xFindReplaceDlg);
IniSectionSetInt(pIniSection, L"FindReplaceDlgPosY", yFindReplaceDlg);

if (bSaveFindReplace) {
IniSectionSetBool(pIniSection, L"FindReplaceMatchCase", (efrData.fuFlags & SCFIND_MATCHCASE) ? 1 : 0 );
IniSectionSetBool(pIniSection, L"FindReplaceMatchWholeWorldOnly", (efrData.fuFlags & SCFIND_WHOLEWORD) ? 1 : 0 );
IniSectionSetBool(pIniSection, L"FindReplaceMatchBeginingWordOnly", (efrData.fuFlags & SCFIND_WORDSTART) ? 1 : 0 );
IniSectionSetBool(pIniSection, L"FindReplaceRegExpSearch", (efrData.fuFlags & (SCFIND_REGEXP | SCFIND_POSIX)) ? 1 : 0 );
IniSectionSetBool(pIniSection, L"FindReplaceTransformBackslash", efrData.bTransformBS);
IniSectionSetBool(pIniSection, L"FindReplaceDontWrapRound", efrData.bNoFindWrap);
IniSectionSetBool(pIniSection, L"FindReplaceCloseAfterFind", efrData.bFindClose);
IniSectionSetBool(pIniSection, L"FindReplaceCloseAfterReplace", efrData.bReplaceClose);
#ifdef BOOKMARK_EDITION
IniSectionSetBool(pIniSection, L"FindReplaceWildcardSearch", efrData.bWildcardSearch);
#endif
}

SaveIniSection(L"Settings", pIniSection);
LocalFree(pIniSection);

Expand Down
2 changes: 1 addition & 1 deletion src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ BEGIN
END
MENUITEM "Sa&ve Before Running Tools", IDM_VIEW_SAVEBEFORERUNNINGTOOLS
MENUITEM "Remember Recent F&iles", IDM_VIEW_NOSAVERECENT
MENUITEM "Remember S&earch Strings", IDM_VIEW_NOSAVEFINDREPL
MENUITEM "Remember S&earch Options", IDM_VIEW_NOSAVEFINDREPL
MENUITEM SEPARATOR
MENUITEM "Sh&ow Toolbar", IDM_VIEW_TOOLBAR
MENUITEM "C&ustomize Toolbar...", IDM_VIEW_CUSTOMIZETB
Expand Down

0 comments on commit 0575e74

Please sign in to comment.