From 5f900213d395944a1ef8e29e33e608ac215c3e76 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 4 Aug 2021 20:30:38 +0200 Subject: [PATCH] +fix: incomplete default Dark Mode Scheme +fix: config version dependent "FileWatchingMode" settings value --- src/Config/Config.cpp | 9 ++++++++- src/Styles.c | 13 +++++++++++++ src/TypeDefs.h | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 3fedc4f18..2005eef7e 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1554,9 +1554,16 @@ void LoadSettings() Defaults.PrintMargin.bottom = _margin; Settings.PrintMargin.bottom = clampi(IniSectionGetInt(IniSecSettings, L"PrintMarginBottom", Defaults.PrintMargin.bottom), 0, 40000); + if (Globals.iCfgVersionRead < CFG_VER_0005) { + int const fwm_mode = IniSectionGetInt(IniSecSettings, L"FileWatchingMode", -1); + if (fwm_mode > (int)FWM_DONT_CARE) { + IniSectionSetInt(IniSecSettings, L"FileWatchingMode", fwm_mode + 1); + } + } + GET_CAST_INT_VALUE_FROM_INISECTION(FILE_WATCHING_MODE, FileWatchingMode, FWM_MSGBOX, FWM_DONT_CARE, FWM_EXCLUSIVELOCK); + GET_BOOL_VALUE_FROM_INISECTION(SaveBeforeRunningTools, false); GET_BOOL_VALUE_FROM_INISECTION(EvalTinyExprOnSelection, true); - GET_CAST_INT_VALUE_FROM_INISECTION(FILE_WATCHING_MODE, FileWatchingMode, FWM_MSGBOX, FWM_DONT_CARE, FWM_EXCLUSIVELOCK); GET_BOOL_VALUE_FROM_INISECTION(ResetFileWatching, true); GET_INT_VALUE_FROM_INISECTION(EscFunction, 0, 0, 2); GET_BOOL_VALUE_FROM_INISECTION(AlwaysOnTop, false); diff --git a/src/Styles.c b/src/Styles.c index bdd38d111..655420440 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -766,6 +766,19 @@ static void _DefaultsToTmpCache() { StringCchCat(wchDefaultStyle, COUNTOF(wchDefaultStyle), wchColor); } TmpCacheSetString(Lexer_Section, pszDfltName, wchDefaultStyle); + + // in case of "pStdDarkModeIniStyles" is incomplete (new Lexer, etc.) + unsigned i = 1; + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { + LPCWSTR const pszKeyName = g_pLexArray[iLexer]->Styles[i].pszName; + LPCWSTR const pszDefault = g_pLexArray[iLexer]->Styles[i].pszDefault; + wchDefaultStyle[0] = L'\0'; // empty + TmpCacheGetString(Lexer_Section, pszKeyName, L"", wchDefaultStyle, COUNTOF(wchDefaultStyle)); + if (StrIsEmpty(wchDefaultStyle) && StrIsNotEmpty(pszDefault)) { + TmpCacheSetString(Lexer_Section, pszKeyName, pszDefault); + } + ++i; + } } } else { diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 337039fd4..78911cf78 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -124,8 +124,9 @@ typedef enum CFG_VER_0002 = 2, /// LongLine Marker Off by default CFG_VER_0003 = 3, /// SimpleIni UTF-8 BOM CFG_VER_0004 = 4, /// Text Files lexer vs. Default Text => (2nd) Common Style + CFG_VER_0005 = 5, /// FileWatchingMode numbering changed - CFG_VER_CURRENT = CFG_VER_0004 + CFG_VER_CURRENT = CFG_VER_0005 } CFG_VERSION;