diff --git a/Versions/build.txt b/Versions/build.txt index 38d2d9429..8515a20bc 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2385 +2392 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 0f36aee6d..d2cf9c424 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 DEV diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 021d940f8..26b0339da 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1169,6 +1169,9 @@ bool SaveSettings(bool bSaveSettingsNow) if (Settings.SaveSettings != Defaults.SaveSettings) { IniSectionSetBool(Settings_Section, L"SaveSettings", Settings.SaveSettings); } + else { + IniSectionDelete(Settings_Section, L"SaveSettings", false); + } return SaveIniFile(Globals.IniFile); } @@ -1186,40 +1189,73 @@ bool SaveSettings(bool bSaveSettingsNow) if (Settings.EFR_Data.bFindClose != Defaults.EFR_Data.bFindClose) { IniSectionSetBool(Settings_Section, L"CloseFind", Settings.EFR_Data.bFindClose); } + else { + IniSectionDelete(Settings_Section, L"CloseFind", false); + } if (Settings.EFR_Data.bReplaceClose != Defaults.EFR_Data.bReplaceClose) { IniSectionSetBool(Settings_Section, L"CloseReplace", Settings.EFR_Data.bReplaceClose); } + else { + IniSectionDelete(Settings_Section, L"CloseReplace", false); + } if (Settings.EFR_Data.bNoFindWrap != Defaults.EFR_Data.bNoFindWrap) { IniSectionSetBool(Settings_Section, L"NoFindWrap", Settings.EFR_Data.bNoFindWrap); } + else { + IniSectionDelete(Settings_Section, L"NoFindWrap", false); + } if (Settings.EFR_Data.bTransformBS != Defaults.EFR_Data.bTransformBS) { IniSectionSetBool(Settings_Section, L"FindTransformBS", Settings.EFR_Data.bTransformBS); } + else { + IniSectionDelete(Settings_Section, L"FindTransformBS", false); + } if (Settings.EFR_Data.bWildcardSearch != Defaults.EFR_Data.bWildcardSearch) { IniSectionSetBool(Settings_Section, L"WildcardSearch", Settings.EFR_Data.bWildcardSearch); } + else { + IniSectionDelete(Settings_Section, L"WildcardSearch", false); + } if (Settings.EFR_Data.bMarkOccurences != Defaults.EFR_Data.bMarkOccurences) { IniSectionSetBool(Settings_Section, L"FindMarkAllOccurrences", Settings.EFR_Data.bMarkOccurences); } + else { + IniSectionDelete(Settings_Section, L"FindMarkAllOccurrences", false); + } if (Settings.EFR_Data.bHideNonMatchedLines != Defaults.EFR_Data.bHideNonMatchedLines) { IniSectionSetBool(Settings_Section, L"HideNonMatchedLines", Settings.EFR_Data.bHideNonMatchedLines); } + else { + IniSectionDelete(Settings_Section, L"HideNonMatchedLines", false); + } if (Settings.EFR_Data.bDotMatchAll != Defaults.EFR_Data.bDotMatchAll) { IniSectionSetBool(Settings_Section, L"RegexDotMatchesAll", Settings.EFR_Data.bDotMatchAll); } + else { + IniSectionDelete(Settings_Section, L"RegexDotMatchesAll", false); + } if (Settings.EFR_Data.fuFlags != Defaults.EFR_Data.fuFlags) { IniSectionSetInt(Settings_Section, L"efrData_fuFlags", Settings.EFR_Data.fuFlags); } + else { + IniSectionDelete(Settings_Section, L"efrData_fuFlags", false); + } WCHAR wchTmp[MAX_PATH] = { L'\0' }; if (StringCchCompareXIW(Settings.OpenWithDir, Defaults.OpenWithDir) != 0) { PathRelativeToApp(Settings.OpenWithDir, wchTmp, COUNTOF(wchTmp), false, true, Flags.PortableMyDocs); IniSectionSetString(Settings_Section, L"OpenWithDir", wchTmp); } + else { + IniSectionDelete(Settings_Section, L"OpenWithDir", false); + } if (StringCchCompareXIW(Settings.FavoritesDir, Defaults.FavoritesDir) != 0) { PathRelativeToApp(Settings.FavoritesDir, wchTmp, COUNTOF(wchTmp), false, true, Flags.PortableMyDocs); IniSectionSetString(Settings_Section, L"Favorites", wchTmp); } + else { + IniSectionDelete(Settings_Section, L"Favorites", false); + } SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PathNameFormat); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, WordWrap); @@ -1283,15 +1319,27 @@ bool SaveSettings(bool bSaveSettingsNow) if (Settings.PrintMargin.left != Defaults.PrintMargin.left) { IniSectionSetInt(Settings_Section, L"PrintMarginLeft", Settings.PrintMargin.left); } + else { + IniSectionDelete(Settings_Section, L"PrintMarginLeft", false); + } if (Settings.PrintMargin.top != Defaults.PrintMargin.top) { IniSectionSetInt(Settings_Section, L"PrintMarginTop", Settings.PrintMargin.top); } + else { + IniSectionDelete(Settings_Section, L"PrintMarginTop", false); + } if (Settings.PrintMargin.right != Defaults.PrintMargin.right) { IniSectionSetInt(Settings_Section, L"PrintMarginRight", Settings.PrintMargin.right); } + else { + IniSectionDelete(Settings_Section, L"PrintMarginRight", false); + } if (Settings.PrintMargin.bottom != Defaults.PrintMargin.bottom) { IniSectionSetInt(Settings_Section, L"PrintMarginBottom", Settings.PrintMargin.bottom); } + else { + IniSectionDelete(Settings_Section, L"PrintMarginBottom", false); + } SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveBeforeRunningTools); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FileWatchingMode); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ResetFileWatching); @@ -1307,11 +1355,11 @@ bool SaveSettings(bool bSaveSettingsNow) ///~IniSectionSetInt(Settings_Section, L"IMEInteraction", Settings2.IMEInteraction); Toolbar_GetButtons(Globals.hwndToolbar, IDT_FILE_NEW, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons)); - if (StringCchCompareX(Settings.ToolbarButtons, Defaults.ToolbarButtons) == 0) { - IniSectionDelete(Settings_Section, L"ToolbarButtons", false); + if (StringCchCompareX(Settings.ToolbarButtons, Defaults.ToolbarButtons) != 0) { + IniSectionSetString(Settings_Section, L"ToolbarButtons", Settings.ToolbarButtons); } else { - IniSectionSetString(Settings_Section, L"ToolbarButtons", Settings.ToolbarButtons); + IniSectionDelete(Settings_Section, L"ToolbarButtons", false); } SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowToolbar); SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowStatusbar); @@ -1347,17 +1395,15 @@ bool SaveSettings(bool bSaveSettingsNow) StringCchPrintf(tchHighDpiToolBar, COUNTOF(tchHighDpiToolBar), L"%ix%i HighDpiToolBar", ResX, ResY); IniSectionSetInt(Window_Section, tchHighDpiToolBar, s_iToolBarTheme); - if (!Flags.bStickyWindowPosition) { - - WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; - - StringCchPrintf(tchPosX, COUNTOF(tchPosX), L"%ix%i PosX", ResX, ResY); - StringCchPrintf(tchPosY, COUNTOF(tchPosY), L"%ix%i PosY", ResX, ResY); - StringCchPrintf(tchSizeX, COUNTOF(tchSizeX), L"%ix%i SizeX", ResX, ResY); - StringCchPrintf(tchSizeY, COUNTOF(tchSizeY), L"%ix%i SizeY", ResX, ResY); - StringCchPrintf(tchMaximized, COUNTOF(tchMaximized), L"%ix%i Maximized", ResX, ResY); - StringCchPrintf(tchZoom, COUNTOF(tchMaximized), L"%ix%i Zoom", ResX, ResY); - + WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; + StringCchPrintf(tchPosX, COUNTOF(tchPosX), L"%ix%i PosX", ResX, ResY); + StringCchPrintf(tchPosY, COUNTOF(tchPosY), L"%ix%i PosY", ResX, ResY); + StringCchPrintf(tchSizeX, COUNTOF(tchSizeX), L"%ix%i SizeX", ResX, ResY); + StringCchPrintf(tchSizeY, COUNTOF(tchSizeY), L"%ix%i SizeY", ResX, ResY); + StringCchPrintf(tchMaximized, COUNTOF(tchMaximized), L"%ix%i Maximized", ResX, ResY); + StringCchPrintf(tchZoom, COUNTOF(tchMaximized), L"%ix%i Zoom", ResX, ResY); + if (!Flags.bStickyWindowPosition) + { IniSectionSetInt(Window_Section, tchPosX, s_WinInfo.x); IniSectionSetInt(Window_Section, tchPosY, s_WinInfo.y); IniSectionSetInt(Window_Section, tchSizeX, s_WinInfo.cx); @@ -1365,6 +1411,14 @@ bool SaveSettings(bool bSaveSettingsNow) IniSectionSetBool(Window_Section, tchMaximized, s_WinInfo.max); IniSectionSetInt(Window_Section, tchZoom, s_WinInfo.zoom); } + else { + IniSectionDelete(Window_Section, tchPosX, false); + IniSectionDelete(Window_Section, tchPosY, false); + IniSectionDelete(Window_Section, tchSizeX, false); + IniSectionDelete(Window_Section, tchSizeY, false); + IniSectionDelete(Window_Section, tchMaximized, false); + IniSectionDelete(Window_Section, tchZoom, false); + } bool const ok = SaveIniFile(Globals.IniFile); diff --git a/src/Notepad3.c b/src/Notepad3.c index 3328dc2e6..85c70d359 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1996,9 +1996,9 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) MRU_Load(Globals.pMRUreplace); if (Globals.hwndEdit == NULL || s_hwndEditFrame == NULL || - Globals.hwndStatus == NULL || Globals.hwndToolbar == NULL || s_hwndReBar == NULL) + Globals.hwndStatus == NULL || Globals.hwndToolbar == NULL || s_hwndReBar == NULL) { return -1LL; - + } Style_SetDefaultLexer(Globals.hwndEdit); ObserveNotifyChangeEvent(); @@ -2771,12 +2771,12 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), ¶ms->wchData)) bOpened = FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, tchFile); } - - else + else { bOpened = FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, ¶ms->wchData); - + } if (bOpened) { - if (params->flagChangeNotify == FWM_MSGBOX) { + if (params->flagChangeNotify == FWM_MSGBOX) + { FileWatching.FileWatchingMode = FWM_NONE; FileWatching.ResetFileWatching = true; InstallFileWatching(Globals.CurrentFile); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 2eda823de..ceba27ed0 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -156,9 +156,9 @@ BEGIN "O", IDM_EDIT_SENTENCECASE, VIRTKEY, CONTROL, ALT, NOINVERT "O", CMD_RECODEOEM, VIRTKEY, SHIFT, CONTROL, NOINVERT "P", IDM_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT - "P", IDM_EDIT_COMPRESS_BLANKS, VIRTKEY, ALT, NOINVERT + "P", IDM_EDIT_COMPRESS_BLANKS, VIRTKEY, CONTROL, ALT, NOINVERT "P", CMD_DEFAULTWINPOS, VIRTKEY, SHIFT, CONTROL, NOINVERT - //~"P", MMMMMMMMMMMMMMMMMM, VIRTKEY, ALT, NOINVERT /// Menu(Appearance) + //~"P", IDM_EDIT_COMPRESS_BLANKS VIRTKEY, ALT, NOINVERT /// Menu(Appearance) "Q", IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT "Q", IDM_EDIT_ENCLOSESELECTION, VIRTKEY, ALT, NOINVERT /// NO Menu "Q", IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT diff --git a/src/Styles.c b/src/Styles.c index 4e7e78bc5..0b9c14400 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -683,6 +683,16 @@ bool Style_Export(HWND hwnd) // // Style_ExportToFile() // + +#define SAVE_STYLE_IF_NOT_EQ_DEFAULT(TYPE, VARNAME, VALUE, DEFAULT) \ + if ((VALUE) != (DEFAULT)) { \ + IniSectionSet##TYPE(Styles_Section, _W(_STRG(VARNAME)), (VALUE)); \ + } else { \ + IniSectionDelete(Styles_Section, _W(_STRG(VARNAME)), false); \ + } +// ---------------------------------------------------------------------------- + + bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll) { if (StrIsEmpty(szFile)) { @@ -698,56 +708,36 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll) const WCHAR* const CustomColors_Section = L"Custom Colors"; for (int i = 0; i < 16; i++) { - if (bForceAll || (g_colorCustom[i] != s_colorDefault[i])) { - WCHAR tch[32] = { L'\0' }; - WCHAR wch[32] = { L'\0' }; - StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1); + WCHAR tch[32] = { L'\0' }; + WCHAR wch[32] = { L'\0' }; + StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1); + if (bForceAll || (g_colorCustom[i] != s_colorDefault[i])) + { StringCchPrintf(wch, COUNTOF(wch), L"#%02X%02X%02X", (int)GetRValue(g_colorCustom[i]), (int)GetGValue(g_colorCustom[i]), (int)GetBValue(g_colorCustom[i])); + IniSectionSetString(CustomColors_Section, tch, wch); } + else { + IniSectionDelete(CustomColors_Section, tch, false); + } } const WCHAR* const Styles_Section = L"Styles"; // auto select bool const bUse2ndSty = Style_GetUse2ndDefault(); - if (bUse2ndSty) { - IniSectionSetBool(Styles_Section, L"Use2ndDefaultStyle", bUse2ndSty); - } - else { - IniSectionDelete(Styles_Section, L"Use2ndDefaultStyle", false); - } + SAVE_STYLE_IF_NOT_EQ_DEFAULT(Bool, Use2ndDefaultStyle, bUse2ndSty, false); // default scheme - if (s_iDefaultLexer != 0) { - IniSectionSetInt(Styles_Section, L"DefaultScheme", s_iDefaultLexer); - } - else { - IniSectionDelete(Styles_Section, L"DefaultScheme", false); - } + SAVE_STYLE_IF_NOT_EQ_DEFAULT(Int, DefaultScheme, s_iDefaultLexer, 0); // auto select - if (!s_bAutoSelect) { - IniSectionSetBool(Styles_Section, L"AutoSelect", s_bAutoSelect); - } - else { - IniSectionDelete(Styles_Section, L"AutoSelect", false); - } + SAVE_STYLE_IF_NOT_EQ_DEFAULT(Bool, AutoSelect, s_bAutoSelect, true); // scheme select dlg dimensions - if (s_cxStyleSelectDlg != STYLESELECTDLG_X) { - IniSectionSetInt(Styles_Section, L"SelectDlgSizeX", s_cxStyleSelectDlg); - } - else { - IniSectionDelete(Styles_Section, L"SelectDlgSizeX", false); - } - if (s_cyStyleSelectDlg != STYLESELECTDLG_Y) { - IniSectionSetInt(Styles_Section, L"SelectDlgSizeY", s_cyStyleSelectDlg); - } - else { - IniSectionDelete(Styles_Section, L"SelectDlgSizeY", false); - } + SAVE_STYLE_IF_NOT_EQ_DEFAULT(Int, SelectDlgSizeX, s_cxStyleSelectDlg, STYLESELECTDLG_X); + SAVE_STYLE_IF_NOT_EQ_DEFAULT(Int, SelectDlgSizeY, s_cyStyleSelectDlg, STYLESELECTDLG_Y); // create canonical order of lexer sections if (bForceAll) { @@ -761,6 +751,7 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll) } bForceAll = !Globals.bIniFileFromScratch; } + // ---------------------------------------------------------------- WCHAR szTmpStyle[BUFSIZE_STYLE_VALUE]; diff --git a/src/VersionEx.h b/src/VersionEx.h index a2d6445df..538f57f0c 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -7,8 +7,8 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 19 -#define VERSION_REV 706 -#define VERSION_BUILD 2385 -#define SCINTILLA_VER 417 -#define ONIGURUMA_REGEX_VER 6.9.2 +#define VERSION_REV 712 +#define VERSION_BUILD 2392 +#define SCINTILLA_VER 420 +#define ONIGURUMA_REGEX_VER 6.9.3 #define VERSION_PATCH DEV