From 8a677b24b6db567cd7567bbae339999b547ceed7 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 6 Jul 2019 09:46:15 +0200 Subject: [PATCH] + fix: .ini-file - remove some keys with default values (styles) --- Version_develop.cmd => Version_DEV.cmd | 2 +- Versions/build.txt | 2 +- np3portableapp/_buildname.txt | 2 +- res/Notepad3.exe.manifest.conf | 4 +-- src/Config/Config.cpp | 16 ++++++------ src/Config/Config.h | 8 ++---- src/Notepad3.c | 36 +++++++++++++------------- src/StyleLexers/styleLexStandard.c | 2 +- src/Styles.c | 27 +++++++++++++++++-- src/VersionEx.h | 6 ++--- 10 files changed, 62 insertions(+), 43 deletions(-) rename Version_develop.cmd => Version_DEV.cmd (83%) diff --git a/Version_develop.cmd b/Version_DEV.cmd similarity index 83% rename from Version_develop.cmd rename to Version_DEV.cmd index 86ebae7ac..633cda52a 100644 --- a/Version_develop.cmd +++ b/Version_DEV.cmd @@ -1,6 +1,6 @@ @echo off setlocal -set _VERPATCH_=develop +set _VERPATCH_=DEV echo."%_VERPATCH_%">.\np3portableapp\_buildname.txt Version -VerPatch "%_VERPATCH_%" endlocal diff --git a/Versions/build.txt b/Versions/build.txt index cd59a34b2..38d2d9429 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2384 +2385 diff --git a/np3portableapp/_buildname.txt b/np3portableapp/_buildname.txt index e698eff6a..bd83a700c 100644 --- a/np3portableapp/_buildname.txt +++ b/np3portableapp/_buildname.txt @@ -1 +1 @@ -"Oniguruma" +"DEV" diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 83be3f1d0..0f36aee6d 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,8 +3,8 @@ - Notepad3 Oniguruma + Notepad3 DEV diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 8c6568c6c..ad34a5364 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -190,9 +190,9 @@ extern "C" bool IniSectionSetBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool // ============================================================================ -extern "C" bool IniSectionDeleteValue(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpValue, bool bRemoveEmpty) +extern "C" bool IniSectionDelete(LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty) { - return s_INI.DeleteValue(lpSectionName, lpKeyName, lpValue, bRemoveEmpty); + return s_INI.Delete(lpSectionName, lpKeyName, bRemoveEmpty); } // ============================================================================ @@ -318,13 +318,13 @@ extern "C" bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST // ============================================================================ -extern "C" bool IniFileDeleteValue(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpValue, bool bRemoveEmpty) +extern "C" bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty) { CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine); SI_Error rc = Ini.LoadFile(lpFilePath); if (SI_SUCCESS(rc)) { - Ini.DeleteValue(lpSectionName, lpKeyName, lpValue, bRemoveEmpty); + Ini.Delete(lpSectionName, lpKeyName, bRemoveEmpty); Ini.SetSpaces(s_bSetSpaces); rc = Ini.SaveFile(Globals.IniFile, true); } @@ -604,7 +604,7 @@ void LoadSettings() Defaults.RenderingTechnology = IniSectionGetInt(Settings2_Section, L"SciDirectWriteTech", -111); if ((Defaults.RenderingTechnology != -111) && Settings.SaveSettings) { // cleanup - IniSectionDeleteValue(Settings2_Section, L"SciDirectWriteTech", NULL, false); + IniSectionDelete(Settings2_Section, L"SciDirectWriteTech", false); bDirtyFlag = true; } Defaults.RenderingTechnology = clampi(Defaults.RenderingTechnology, 0, 3); @@ -613,7 +613,7 @@ void LoadSettings() Defaults.Bidirectional = IniSectionGetInt(Settings2_Section, L"EnableBidirectionalSupport", -111); if ((Defaults.Bidirectional != -111) && Settings.SaveSettings) { // cleanup - IniSectionDeleteValue(Settings2_Section, L"EnableBidirectionalSupport", NULL, false); + IniSectionDelete(Settings2_Section, L"EnableBidirectionalSupport", false); bDirtyFlag = true; } Defaults.Bidirectional = (clampi(Defaults.Bidirectional, SC_BIDIRECTIONAL_DISABLED, SC_BIDIRECTIONAL_R2L) > 0) ? SC_BIDIRECTIONAL_R2L : 0; @@ -1143,7 +1143,7 @@ void LoadFlags() IniSectionSet##TYPE(Settings_Section, _W(_STRG(VARNAME)), Settings.VARNAME); \ } \ else { \ - IniSectionDeleteValue(Settings_Section, _W(_STRG(VARNAME)), NULL, false); \ + IniSectionDelete(Settings_Section, _W(_STRG(VARNAME)), false); \ } // ---------------------------------------------------------------------------- @@ -1302,7 +1302,7 @@ bool SaveSettings(bool bSaveSettingsNow) Toolbar_GetButtons(Globals.hwndToolbar, IDT_FILE_NEW, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons)); if (StringCchCompareX(Settings.ToolbarButtons, Defaults.ToolbarButtons) == 0) { - IniSectionDeleteValue(Settings_Section, L"ToolbarButtons", NULL, false); + IniSectionDelete(Settings_Section, L"ToolbarButtons", false); } else { IniSectionSetString(Settings_Section, L"ToolbarButtons", Settings.ToolbarButtons); diff --git a/src/Config/Config.h b/src/Config/Config.h index f58350552..22f17f802 100644 --- a/src/Config/Config.h +++ b/src/Config/Config.h @@ -69,12 +69,10 @@ inline bool IniSectionSetPos(LPCWSTR lpSectionName, LPCWSTR lpKeyName, DocPos po // a_pKey is NULL, the section to remove. // lpKeyName Key to remove from the section.Set to // NULL to remove the entire section. -// lpValue Value of key to remove from the section. -// Set to NULL to remove all keys. // bRemoveEmpty If the section is empty after this key has // been deleted, should the empty section be removed ? // -bool IniSectionDeleteValue(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpValue, bool bRemoveEmpty); +bool IniSectionDelete(LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty); bool IniSectionClear(LPCWSTR lpSectionName, bool bRemoveEmpty); bool IniClearAllSections(LPCWSTR lpPrefix, bool bRemoveEmpty); @@ -100,12 +98,10 @@ bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName // a_pKey is NULL, the section to remove. // lpKeyName Key to remove from the section.Set to // NULL to remove the entire section. -// lpValue Value of key to remove from the section. -// Set to NULL to remove all keys. // bRemoveEmpty If the section is empty after this key has // been deleted, should the empty section be removed ? // -bool IniFileDeleteValue(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpValue, bool bRemoveEmpty); +bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty); // ---------------------------------------------------------------------------- diff --git a/src/Notepad3.c b/src/Notepad3.c index aec1bb5e8..9f8d0b9d6 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -2081,7 +2081,7 @@ bool SelectExternalToolBar(HWND hwnd) } else { StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L""); - IniFileDeleteValue(Globals.IniFile, L"Toolbar Images", L"BitmapHot", NULL, false); + IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapHot", false); } StringCchCopy(szFile, COUNTOF(szFile), s_tchToolbarBitmap); @@ -2093,14 +2093,14 @@ bool SelectExternalToolBar(HWND hwnd) } else { StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L""); - IniFileDeleteValue(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", NULL, false); + IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", false); } s_iToolBarTheme = 2; return true; } else { - IniFileDeleteValue(Globals.IniFile, L"Toolbar Images", L"BitmapHot", NULL, false); - IniFileDeleteValue(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", NULL, false); + IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapHot", false); + IniFileDelete(Globals.IniFile, L"Toolbar Images", L"BitmapDisabled", false); } return false; } @@ -2143,7 +2143,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmap, (bmp.bmHeight * NUMTOOLBITMAPS), bmp.bmHeight, NUMTOOLBITMAPS); StringCchCopy(s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap), L""); - IniSectionDeleteValue(L"Toolbar Images", L"BitmapDefault", NULL, false); + IniSectionDelete(L"Toolbar Images", L"BitmapDefault", false); bDirtyFlag = true; DeleteObject(hbmp); hbmp = NULL; @@ -2198,7 +2198,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmapHot, (bmp.bmHeight * NUMTOOLBITMAPS), bmp.bmHeight, NUMTOOLBITMAPS); StringCchCopy(s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmapHot), L""); - IniSectionDeleteValue(L"Toolbar Images", L"BitmapHot", NULL, false); + IniSectionDelete(L"Toolbar Images", L"BitmapHot", false); bDirtyFlag = true; DeleteObject(hbmp); hbmp = NULL; @@ -2246,7 +2246,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_ERR_BITMAP, s_tchToolbarBitmapDisabled, (bmp.bmHeight * NUMTOOLBITMAPS), bmp.bmHeight, NUMTOOLBITMAPS); StringCchCopy(s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmapDisabled), L""); - IniSectionDeleteValue(L"Toolbar Images", L"BitmapDisabled", NULL, false); + IniSectionDelete(L"Toolbar Images", L"BitmapDisabled", false); bDirtyFlag = true; DeleteObject(hbmp); hbmp = NULL; @@ -5434,19 +5434,19 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } else { // clear entries - IniSectionDeleteValue(Window_Section, tchPosX, NULL, false); - IniSectionDeleteValue(Window_Section, tchPosY, NULL, false); - IniSectionDeleteValue(Window_Section, tchSizeX, NULL, false); - IniSectionDeleteValue(Window_Section, tchSizeY, NULL, false); - IniSectionDeleteValue(Window_Section, tchMaximized, NULL, false); - IniSectionDeleteValue(Window_Section, tchZoom, NULL, false); + 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); } if (Flags.bStickyWindowPosition != DefaultFlags.bStickyWindowPosition) { IniSectionSetBool(L"Settings2", L"StickyWindowPosition", Flags.bStickyWindowPosition); } else { - IniSectionDeleteValue(L"Settings2", L"StickyWindowPosition", NULL, false); + IniSectionDelete(L"Settings2", L"StickyWindowPosition", false); } SaveIniFile(Globals.IniFile); } @@ -5460,7 +5460,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) IniFileSetBool(Globals.IniFile, L"Settings2", L"ReuseWindow", Flags.bReuseWindow); } else { - IniFileDeleteValue(Globals.IniFile, L"Settings2", L"ReuseWindow", NULL, false); + IniFileDelete(Globals.IniFile, L"Settings2", L"ReuseWindow", false); } break; @@ -5471,7 +5471,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) IniFileSetInt(Globals.IniFile, L"Settings2", L"SingleFileInstance", Flags.bSingleFileInstance); } else { - IniFileDeleteValue(Globals.IniFile, L"Settings2", L"SingleFileInstance", NULL, false); + IniFileDelete(Globals.IniFile, L"Settings2", L"SingleFileInstance", false); } break; @@ -5584,7 +5584,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd, IDM_VIEW_SAVESETTINGS)) { Settings.SaveSettings = !Settings.SaveSettings; if (Settings.SaveSettings == Defaults.SaveSettings) { - IniFileDeleteValue(Globals.IniFile, L"Settings", L"SaveSettings", NULL, false); + IniFileDelete(Globals.IniFile, L"Settings", L"SaveSettings", false); } else { IniFileSetBool(Globals.IniFile, L"Settings", L"SaveSettings", Settings.SaveSettings); @@ -6180,7 +6180,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_CLEARSAVEDWINPOS: s_DefWinInfo = InitDefaultWndPos(2); - IniFileDeleteValue(Globals.IniFile, L"Settings2", L"DefaultWindowPosition", NULL, false); + IniFileDelete(Globals.IniFile, L"Settings2", L"DefaultWindowPosition", false); break; case CMD_OPENINIFILE: diff --git a/src/StyleLexers/styleLexStandard.c b/src/StyleLexers/styleLexStandard.c index d677f38a9..28bff0c2d 100644 --- a/src/StyleLexers/styleLexStandard.c +++ b/src/StyleLexers/styleLexStandard.c @@ -43,7 +43,7 @@ SCLEX_NULL, IDS_LEX_STR_63266, L"2nd Default Text", L"", L"", /* 10 */ { {_STYLE_GETSTYLEID(STY_LONG_LN_MRK)}, IDS_LEX_2ND_LONG_LN, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" }, /* 11 */ { {_STYLE_GETSTYLEID(STY_X_LN_SPACE)}, IDS_LEX_2ND_X_SPC, L"2nd Extra Line Spacing (Size)", L"", L"" }, /* 12 */ { {_STYLE_GETSTYLEID(STY_BOOK_MARK)}, IDS_LEX_2ND_BKMRK, L"2nd Bookmarks and Folding (Colors, Size)", L"size:+2; fore:#000000; back:#00DC00; charset:2; case:U; alpha:100", L"" }, - /* 13 */ { {_STYLE_GETSTYLEID(STY_MARK_OCC)}, IDS_LEX_STR_63263, L"2nd Mark Occurrences (Indicator)", L"fore:#0000FF; indic_box", L"" }, + /* 13 */ { {_STYLE_GETSTYLEID(STY_MARK_OCC)}, IDS_LEX_STR_63263, L"2nd Mark Occurrences (Indicator)", L"fore:#0000FF; alpha:60; alpha2:60; indic_box", L"" }, /* 14 */ { {_STYLE_GETSTYLEID(STY_URL_HOTSPOT)}, IDS_LEX_STR_63265, L"2nd Hyperlink Hotspots", L"fore:#00D000; back:#009C00; alpha:180; indic_compositionthin", L"" }, /* 15 */ { {_STYLE_GETSTYLEID(STY_MULTI_EDIT)}, IDS_LEX_STR_63355, L"Multi Edit Indicator", L"fore:#00A5FF; indic_box", L"" }, /* 16 */ { {_STYLE_GETSTYLEID(STY_IME_COLOR)}, IDS_LEX_STR_63353, L"2nd Inline-IME Color", L"fore:#FF0000", L"" }, diff --git a/src/Styles.c b/src/Styles.c index 4bd1d89ce..8241fbb00 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -639,7 +639,7 @@ void Style_Save() IniFileSetString(Globals.IniFile, L"Styles", STYLING_THEME_NAME, Theme_Files[s_idxSelectedTheme].szName); } else { - IniFileDeleteValue(Globals.IniFile, L"Styles", STYLING_THEME_NAME, NULL, false); + IniFileDelete(Globals.IniFile, L"Styles", STYLING_THEME_NAME, false); } } @@ -719,22 +719,39 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll) if (bUse2ndSty) { IniSectionSetBool(Styles_Section, L"Use2ndDefaultStyle", bUse2ndSty); } + else { + IniSectionDelete(Styles_Section, L"Use2ndDefaultStyle", false); + } + // default scheme if (s_iDefaultLexer != 0) { IniSectionSetInt(Styles_Section, L"DefaultScheme", s_iDefaultLexer); } + else { + IniSectionDelete(Styles_Section, L"DefaultScheme", false); + } + // auto select if (!s_bAutoSelect) { - IniSectionSetInt(Styles_Section, L"AutoSelect", s_bAutoSelect); + IniSectionSetBool(Styles_Section, L"AutoSelect", s_bAutoSelect); + } + else { + IniSectionDelete(Styles_Section, L"AutoSelect", false); } // 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); + } // create canonical order of lexer sections if (bForceAll) { @@ -758,6 +775,9 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll) { IniSectionSetString(Lexer_Section, L"FileNameExtensions", g_pLexArray[iLexer]->szExtensions); } + else { + IniSectionDelete(Lexer_Section, L"FileNameExtensions", false); + } unsigned i = 0; while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) @@ -773,6 +793,9 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll) Style_CopyStyles_IfNotDefined(g_pLexArray[iLexer]->Styles[i].szValue, szTmpStyle, COUNTOF(szTmpStyle), true, true); IniSectionSetString(Lexer_Section, g_pLexArray[iLexer]->Styles[i].pszName, szTmpStyle); } + else { + IniSectionDelete(Lexer_Section, g_pLexArray[iLexer]->Styles[i].pszName, false); + } ++i; } } diff --git a/src/VersionEx.h b/src/VersionEx.h index 31be072bd..a2d6445df 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 704 -#define VERSION_BUILD 2384 +#define VERSION_REV 706 +#define VERSION_BUILD 2385 #define SCINTILLA_VER 417 #define ONIGURUMA_REGEX_VER 6.9.2 -#define VERSION_PATCH Oniguruma +#define VERSION_PATCH DEV