diff --git a/Versions/build.txt b/Versions/build.txt
index 651dd1bb9..25cb6bb15 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-2632
+2633
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index 5a338a463..d064487ab 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,7 +3,7 @@
Notepad3 BETA
diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp
index 6d0e0addb..9be6b3898 100644
--- a/src/Config/Config.cpp
+++ b/src/Config/Config.cpp
@@ -54,8 +54,8 @@ extern "C" int s_flagSingleFileInstance;
extern "C" int s_flagMultiFileArg;
extern "C" int s_flagShellUseSystemMRU;
extern "C" int s_flagPrintFileAndLeave;
-extern "C" bool s_flagDoRelaunchElevated;
+extern "C" THEMEFILES Theme_Files[];
// ----------------------------------------------------------------------------
@@ -71,6 +71,12 @@ static bool const s_bSetSpaces = false;
// ----------------------------------------------------------------------------
+static WCHAR* const _s_RecentFiles = L"Recent Files";
+static WCHAR* const _s_RecentFind = L"Recent Find";
+static WCHAR* const _s_RecentReplace = L"Recent Replace";
+
+// ----------------------------------------------------------------------------
+
static int s_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS;
// ----------------------------------------------------------------------------
@@ -250,8 +256,6 @@ extern "C" size_t IniFileGetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LP
extern "C" bool IniFileSetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString)
{
- if (s_flagDoRelaunchElevated) { return false; }
-
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
SI_Error rc = Ini.LoadFile(lpFilePath);
if (SI_SUCCESS(rc))
@@ -287,8 +291,6 @@ extern "C" int IniFileGetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
extern "C" bool IniFileSetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, int iValue)
{
- if (s_flagDoRelaunchElevated) { return false; }
-
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
SI_Error rc = Ini.LoadFile(lpFilePath);
if (SI_SUCCESS(rc)) {
@@ -319,8 +321,6 @@ extern "C" bool IniFileGetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST
extern "C" bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bValue)
{
- if (s_flagDoRelaunchElevated) { return false; }
-
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
SI_Error rc = Ini.LoadFile(lpFilePath);
if (SI_SUCCESS(rc)) {
@@ -336,8 +336,6 @@ extern "C" bool IniFileSetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST
extern "C" bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName, bool bRemoveEmpty)
{
- if (s_flagDoRelaunchElevated) { return false; }
-
CSimpleIni Ini(s_bIsUTF8, s_bUseMultiKey, s_bUseMultiLine);
SI_Error rc = Ini.LoadFile(lpFilePath);
if (SI_SUCCESS(rc))
@@ -602,172 +600,172 @@ void LoadSettings()
int const _ver = StrIsEmpty(Globals.IniFile) ? CFG_VER_CURRENT : CFG_VER_NONE;
LoadIniFile(Globals.IniFile);
- {
- bool bDirtyFlag = false; // do we have to save the file on done
- // prerequisites
- Globals.iCfgVersionRead = IniSectionGetInt(L"Settings", L"SettingsVersion", _ver);
+ bool bDirtyFlag = false; // do we have to save the file on done
- Defaults.SaveSettings = StrIsNotEmpty(Globals.IniFile);
- Settings.SaveSettings = IniSectionGetBool(L"Settings", L"SaveSettings", Defaults.SaveSettings);
+ // prerequisites
+ Globals.iCfgVersionRead = IniSectionGetInt(L"Settings", L"SettingsVersion", _ver);
- // --------------------------------------------------------------------------
- // first set "hard coded" .ini-Settings
- // --------------------------------------------------------------------------
- const WCHAR* const Settings2_Section = L"Settings2";
+ Defaults.SaveSettings = StrIsNotEmpty(Globals.IniFile);
+ Settings.SaveSettings = IniSectionGetBool(L"Settings", L"SaveSettings", Defaults.SaveSettings);
- Defaults2.PreferredLanguageLocaleName[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"PreferredLanguageLocaleName", Defaults2.PreferredLanguageLocaleName,
- Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName));
+ // --------------------------------------------------------------------------
+ // first set "hard coded" .ini-Settings
+ // --------------------------------------------------------------------------
+ const WCHAR* const Settings2_Section = L"Settings2";
- StringCchCopyW(Defaults2.DefaultExtension, COUNTOF(Defaults2.DefaultExtension), L"txt");
- IniSectionGetString(Settings2_Section, L"DefaultExtension", Defaults2.DefaultExtension,
- Settings2.DefaultExtension, COUNTOF(Settings2.DefaultExtension));
- StrTrim(Settings2.DefaultExtension, L" \t.\"");
+ Defaults2.PreferredLanguageLocaleName[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"PreferredLanguageLocaleName", Defaults2.PreferredLanguageLocaleName,
+ Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName));
- Defaults2.DefaultDirectory[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"DefaultDirectory", Defaults2.DefaultDirectory,
- Settings2.DefaultDirectory, COUNTOF(Settings2.DefaultDirectory));
+ StringCchCopyW(Defaults2.DefaultExtension, COUNTOF(Defaults2.DefaultExtension), L"txt");
+ IniSectionGetString(Settings2_Section, L"DefaultExtension", Defaults2.DefaultExtension,
+ Settings2.DefaultExtension, COUNTOF(Settings2.DefaultExtension));
+ StrTrim(Settings2.DefaultExtension, L" \t.\"");
- Defaults2.FileDlgFilters[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"FileDlgFilters", Defaults2.FileDlgFilters,
- Settings2.FileDlgFilters, COUNTOF(Settings2.FileDlgFilters) - 2);
+ Defaults2.DefaultDirectory[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"DefaultDirectory", Defaults2.DefaultDirectory,
+ Settings2.DefaultDirectory, COUNTOF(Settings2.DefaultDirectory));
- Defaults2.FileCheckInverval = 2000UL;
- Settings2.FileCheckInverval = clampul(IniSectionGetInt(Settings2_Section, L"FileCheckInverval",
- Defaults2.FileCheckInverval), 250UL, 300000UL);
- FileWatching.FileCheckInverval = Settings2.FileCheckInverval;
+ Defaults2.FileDlgFilters[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"FileDlgFilters", Defaults2.FileDlgFilters,
+ Settings2.FileDlgFilters, COUNTOF(Settings2.FileDlgFilters) - 2);
- Defaults2.AutoReloadTimeout = 2000UL;
- Settings2.AutoReloadTimeout = clampul(IniSectionGetInt(Settings2_Section, L"AutoReloadTimeout",
- Defaults2.AutoReloadTimeout), 250UL, 300000UL);
- FileWatching.AutoReloadTimeout = Settings2.AutoReloadTimeout;
+ Defaults2.FileCheckInverval = 2000UL;
+ Settings2.FileCheckInverval = clampul(IniSectionGetInt(Settings2_Section, L"FileCheckInverval",
+ Defaults2.FileCheckInverval), 250UL, 300000UL);
+ FileWatching.FileCheckInverval = Settings2.FileCheckInverval;
- Defaults2.UndoTransactionTimeout = 0UL;
- Settings2.UndoTransactionTimeout = clampul(IniSectionGetInt(Settings2_Section, L"UndoTransactionTimeout",
- Defaults2.UndoTransactionTimeout), 0UL, 86400000UL);
+ Defaults2.AutoReloadTimeout = 2000UL;
+ Settings2.AutoReloadTimeout = clampul(IniSectionGetInt(Settings2_Section, L"AutoReloadTimeout",
+ Defaults2.AutoReloadTimeout), 250UL, 300000UL);
+ FileWatching.AutoReloadTimeout = Settings2.AutoReloadTimeout;
- // deprecated
- Defaults.RenderingTechnology = IniSectionGetInt(Settings2_Section, L"SciDirectWriteTech", -111);
- if ((Defaults.RenderingTechnology != -111) && Settings.SaveSettings) {
- // cleanup
- IniSectionDelete(Settings2_Section, L"SciDirectWriteTech", false);
- bDirtyFlag = true;
- }
- Defaults.RenderingTechnology = clampi(Defaults.RenderingTechnology, 0, 3);
+ Defaults2.UndoTransactionTimeout = 0UL;
+ Settings2.UndoTransactionTimeout = clampul(IniSectionGetInt(Settings2_Section, L"UndoTransactionTimeout",
+ Defaults2.UndoTransactionTimeout), 0UL, 86400000UL);
- // Settings2 deprecated
- Defaults.Bidirectional = IniSectionGetInt(Settings2_Section, L"EnableBidirectionalSupport", -111);
- if ((Defaults.Bidirectional != -111) && Settings.SaveSettings) {
- // cleanup
- IniSectionDelete(Settings2_Section, L"EnableBidirectionalSupport", false);
- bDirtyFlag = true;
- }
- Defaults.Bidirectional = (clampi(Defaults.Bidirectional, SC_BIDIRECTIONAL_DISABLED, SC_BIDIRECTIONAL_R2L) > 0) ? SC_BIDIRECTIONAL_R2L : 0;
+ // deprecated
+ Defaults.RenderingTechnology = IniSectionGetInt(Settings2_Section, L"SciDirectWriteTech", -111);
+ if ((Defaults.RenderingTechnology != -111) && Settings.SaveSettings) {
+ // cleanup
+ IniSectionDelete(Settings2_Section, L"SciDirectWriteTech", false);
+ bDirtyFlag = true;
+ }
+ Defaults.RenderingTechnology = clampi(Defaults.RenderingTechnology, 0, 3);
- Defaults2.IMEInteraction = -1;
- Settings2.IMEInteraction = clampi(IniSectionGetInt(Settings2_Section, L"IMEInteraction", Defaults2.IMEInteraction), -1, SC_IME_INLINE);
- // Korean IME use inline mode by default
- if (Settings2.IMEInteraction == -1) { // auto detection once
- // ScintillaWin::KoreanIME()
- int const codePage = Scintilla_InputCodePage();
- Settings2.IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED);
- }
+ // Settings2 deprecated
+ Defaults.Bidirectional = IniSectionGetInt(Settings2_Section, L"EnableBidirectionalSupport", -111);
+ if ((Defaults.Bidirectional != -111) && Settings.SaveSettings) {
+ // cleanup
+ IniSectionDelete(Settings2_Section, L"EnableBidirectionalSupport", false);
+ bDirtyFlag = true;
+ }
+ Defaults.Bidirectional = (clampi(Defaults.Bidirectional, SC_BIDIRECTIONAL_DISABLED, SC_BIDIRECTIONAL_R2L) > 0) ? SC_BIDIRECTIONAL_R2L : 0;
- Defaults2.SciFontQuality = g_FontQuality[3];
- Settings2.SciFontQuality = clampi(IniSectionGetInt(Settings2_Section, L"SciFontQuality", Defaults2.SciFontQuality), 0, 3);
+ Defaults2.IMEInteraction = -1;
+ Settings2.IMEInteraction = clampi(IniSectionGetInt(Settings2_Section, L"IMEInteraction", Defaults2.IMEInteraction), -1, SC_IME_INLINE);
+ // Korean IME use inline mode by default
+ if (Settings2.IMEInteraction == -1) { // auto detection once
+ // ScintillaWin::KoreanIME()
+ int const codePage = Scintilla_InputCodePage();
+ Settings2.IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED);
+ }
- Defaults2.MarkOccurrencesMaxCount = 2000;
- Settings2.MarkOccurrencesMaxCount = IniSectionGetInt(Settings2_Section, L"MarkOccurrencesMaxCount", Defaults2.MarkOccurrencesMaxCount);
- if (Settings2.MarkOccurrencesMaxCount <= 0) { Settings2.MarkOccurrencesMaxCount = INT_MAX; }
+ Defaults2.SciFontQuality = g_FontQuality[3];
+ Settings2.SciFontQuality = clampi(IniSectionGetInt(Settings2_Section, L"SciFontQuality", Defaults2.SciFontQuality), 0, 3);
- Defaults2.UpdateDelayMarkAllOccurrences = 50;
- Settings2.UpdateDelayMarkAllOccurrences = clampi(IniSectionGetInt(Settings2_Section, L"UpdateDelayMarkAllOccurrences",
- Defaults2.UpdateDelayMarkAllOccurrences), USER_TIMER_MINIMUM, 10000);
- Defaults2.DenyVirtualSpaceAccess = false;
- Settings2.DenyVirtualSpaceAccess = IniSectionGetBool(Settings2_Section, L"DenyVirtualSpaceAccess", Defaults2.DenyVirtualSpaceAccess);
+ Defaults2.MarkOccurrencesMaxCount = 2000;
+ Settings2.MarkOccurrencesMaxCount = IniSectionGetInt(Settings2_Section, L"MarkOccurrencesMaxCount", Defaults2.MarkOccurrencesMaxCount);
+ if (Settings2.MarkOccurrencesMaxCount <= 0) { Settings2.MarkOccurrencesMaxCount = INT_MAX; }
- Defaults2.UseOldStyleBraceMatching = false;
- Settings2.UseOldStyleBraceMatching = IniSectionGetBool(Settings2_Section, L"UseOldStyleBraceMatching", Defaults2.UseOldStyleBraceMatching);
+ Defaults2.UpdateDelayMarkAllOccurrences = 50;
+ Settings2.UpdateDelayMarkAllOccurrences = clampi(IniSectionGetInt(Settings2_Section, L"UpdateDelayMarkAllOccurrences",
+ Defaults2.UpdateDelayMarkAllOccurrences), USER_TIMER_MINIMUM, 10000);
+ Defaults2.DenyVirtualSpaceAccess = false;
+ Settings2.DenyVirtualSpaceAccess = IniSectionGetBool(Settings2_Section, L"DenyVirtualSpaceAccess", Defaults2.DenyVirtualSpaceAccess);
- Defaults2.CurrentLineHorizontalSlop = 40;
- Settings2.CurrentLineHorizontalSlop = clampi(IniSectionGetInt(Settings2_Section, L"CurrentLineHorizontalSlop", Defaults2.CurrentLineHorizontalSlop), 0, 240);
+ Defaults2.UseOldStyleBraceMatching = false;
+ Settings2.UseOldStyleBraceMatching = IniSectionGetBool(Settings2_Section, L"UseOldStyleBraceMatching", Defaults2.UseOldStyleBraceMatching);
- Defaults2.CurrentLineVerticalSlop = 5;
- Settings2.CurrentLineVerticalSlop = clampi(IniSectionGetInt(Settings2_Section, L"CurrentLineVerticalSlop", Defaults2.CurrentLineVerticalSlop), 0, 25);
+ Defaults2.CurrentLineHorizontalSlop = 40;
+ Settings2.CurrentLineHorizontalSlop = clampi(IniSectionGetInt(Settings2_Section, L"CurrentLineHorizontalSlop", Defaults2.CurrentLineHorizontalSlop), 0, 240);
+
+ Defaults2.CurrentLineVerticalSlop = 5;
+ Settings2.CurrentLineVerticalSlop = clampi(IniSectionGetInt(Settings2_Section, L"CurrentLineVerticalSlop", Defaults2.CurrentLineVerticalSlop), 0, 25);
- int const iARCLdef = 50;
- Defaults2.AnalyzeReliableConfidenceLevel = (float)iARCLdef / 100.0f;
- int const iARCLset = clampi(IniSectionGetInt(Settings2_Section, L"AnalyzeReliableConfidenceLevel", iARCLdef), 0, 100);
- Settings2.AnalyzeReliableConfidenceLevel = (float)iARCLset / 100.0f;
+ int const iARCLdef = 50;
+ Defaults2.AnalyzeReliableConfidenceLevel = (float)iARCLdef / 100.0f;
+ int const iARCLset = clampi(IniSectionGetInt(Settings2_Section, L"AnalyzeReliableConfidenceLevel", iARCLdef), 0, 100);
+ Settings2.AnalyzeReliableConfidenceLevel = (float)iARCLset / 100.0f;
- /* ~~~
- int const iRCEDCMdef = 85;
- Defaults2.ReliableCEDConfidenceMapping = (float)iRCEDCMdef / 100.0f;
- int const iRCEDCMset = clampi(IniSectionGetInt(Settings2_Section, L"ReliableCEDConfidenceMapping", iRCEDCMdef), 0, 100);
- Settings2.ReliableCEDConfidenceMapping = (float)iRCEDCMset / 100.0f;
+ /* ~~~
+ int const iRCEDCMdef = 85;
+ Defaults2.ReliableCEDConfidenceMapping = (float)iRCEDCMdef / 100.0f;
+ int const iRCEDCMset = clampi(IniSectionGetInt(Settings2_Section, L"ReliableCEDConfidenceMapping", iRCEDCMdef), 0, 100);
+ Settings2.ReliableCEDConfidenceMapping = (float)iRCEDCMset / 100.0f;
- int const iURCEDCMdef = 20;
- Defaults2.UnReliableCEDConfidenceMapping = (float)iURCEDCMdef / 100.0f;
- int const iURCEDCMset = clampi(IniSectionGetInt(Settings2_Section, L"UnReliableCEDConfidenceMapping", iURCEDCMdef), 0, iRCEDCMset);
- Settings2.UnReliableCEDConfidenceMapping = (float)iURCEDCMset / 100.0f;
- ~~~ */
+ int const iURCEDCMdef = 20;
+ Defaults2.UnReliableCEDConfidenceMapping = (float)iURCEDCMdef / 100.0f;
+ int const iURCEDCMset = clampi(IniSectionGetInt(Settings2_Section, L"UnReliableCEDConfidenceMapping", iURCEDCMdef), 0, iRCEDCMset);
+ Settings2.UnReliableCEDConfidenceMapping = (float)iURCEDCMset / 100.0f;
+ ~~~ */
- Defaults2.AdministrationTool[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"AdministrationTool.exe", Defaults2.AdministrationTool,
- Settings2.AdministrationTool, COUNTOF(Settings2.AdministrationTool));
+ Defaults2.AdministrationTool[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"AdministrationTool.exe", Defaults2.AdministrationTool,
+ Settings2.AdministrationTool, COUNTOF(Settings2.AdministrationTool));
- Defaults2.DefaultWindowPosition[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"DefaultWindowPosition", Defaults2.DefaultWindowPosition,
- Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition));
- bool const bExplicitDefaultWinPos = (StringCchLenW(Settings2.DefaultWindowPosition, 0) != 0);
+ Defaults2.DefaultWindowPosition[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"DefaultWindowPosition", Defaults2.DefaultWindowPosition,
+ Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition));
+ bool const bExplicitDefaultWinPos = (StringCchLenW(Settings2.DefaultWindowPosition, 0) != 0);
- Defaults2.FileLoadWarningMB = 256;
- Settings2.FileLoadWarningMB = clampi(IniSectionGetInt(Settings2_Section, L"FileLoadWarningMB", Defaults2.FileLoadWarningMB), 0, 2048);
+ Defaults2.FileLoadWarningMB = 256;
+ Settings2.FileLoadWarningMB = clampi(IniSectionGetInt(Settings2_Section, L"FileLoadWarningMB", Defaults2.FileLoadWarningMB), 0, 2048);
- Defaults2.OpacityLevel = 75;
- Settings2.OpacityLevel = clampi(IniSectionGetInt(Settings2_Section, L"OpacityLevel", Defaults2.OpacityLevel), 10, 100);
+ Defaults2.OpacityLevel = 75;
+ Settings2.OpacityLevel = clampi(IniSectionGetInt(Settings2_Section, L"OpacityLevel", Defaults2.OpacityLevel), 10, 100);
- Defaults2.FindReplaceOpacityLevel = 50;
- Settings2.FindReplaceOpacityLevel = clampi(IniSectionGetInt(Settings2_Section, L"FindReplaceOpacityLevel", Defaults2.FindReplaceOpacityLevel), 10, 100);
+ Defaults2.FindReplaceOpacityLevel = 50;
+ Settings2.FindReplaceOpacityLevel = clampi(IniSectionGetInt(Settings2_Section, L"FindReplaceOpacityLevel", Defaults2.FindReplaceOpacityLevel), 10, 100);
- Defaults2.FileBrowserPath[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"filebrowser.exe", Defaults2.FileBrowserPath, Settings2.FileBrowserPath, COUNTOF(Settings2.FileBrowserPath));
+ Defaults2.FileBrowserPath[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"filebrowser.exe", Defaults2.FileBrowserPath, Settings2.FileBrowserPath, COUNTOF(Settings2.FileBrowserPath));
- StringCchCopyW(Defaults2.AppUserModelID, COUNTOF(Defaults2.AppUserModelID), _W(SAPPNAME));
- IniSectionGetString(Settings2_Section, L"ShellAppUserModelID", Defaults2.AppUserModelID, Settings2.AppUserModelID, COUNTOF(Settings2.AppUserModelID));
+ StringCchCopyW(Defaults2.AppUserModelID, COUNTOF(Defaults2.AppUserModelID), _W(SAPPNAME));
+ IniSectionGetString(Settings2_Section, L"ShellAppUserModelID", Defaults2.AppUserModelID, Settings2.AppUserModelID, COUNTOF(Settings2.AppUserModelID));
- Defaults2.ExtendedWhiteSpaceChars[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"ExtendedWhiteSpaceChars", Defaults2.ExtendedWhiteSpaceChars,
- Settings2.ExtendedWhiteSpaceChars, COUNTOF(Settings2.ExtendedWhiteSpaceChars));
+ Defaults2.ExtendedWhiteSpaceChars[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"ExtendedWhiteSpaceChars", Defaults2.ExtendedWhiteSpaceChars,
+ Settings2.ExtendedWhiteSpaceChars, COUNTOF(Settings2.ExtendedWhiteSpaceChars));
- Defaults2.AutoCompleteWordCharSet[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"AutoCompleteWordCharSet", Defaults2.AutoCompleteWordCharSet,
- Settings2.AutoCompleteWordCharSet, COUNTOF(Settings2.AutoCompleteWordCharSet));
+ Defaults2.AutoCompleteWordCharSet[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"AutoCompleteWordCharSet", Defaults2.AutoCompleteWordCharSet,
+ Settings2.AutoCompleteWordCharSet, COUNTOF(Settings2.AutoCompleteWordCharSet));
- Defaults2.AutoCompleteFillUpChars[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"AutoCompleteFillUpChars", Defaults2.AutoCompleteFillUpChars,
- Settings2.AutoCompleteFillUpChars, COUNTOF(Settings2.AutoCompleteFillUpChars));
+ Defaults2.AutoCompleteFillUpChars[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"AutoCompleteFillUpChars", Defaults2.AutoCompleteFillUpChars,
+ Settings2.AutoCompleteFillUpChars, COUNTOF(Settings2.AutoCompleteFillUpChars));
- StringCchCopyW(Defaults2.TimeStamp, COUNTOF(Defaults2.TimeStamp), L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $");
- IniSectionGetString(Settings2_Section, L"TimeStamp", Defaults2.TimeStamp, Settings2.TimeStamp, COUNTOF(Settings2.TimeStamp));
+ StringCchCopyW(Defaults2.TimeStamp, COUNTOF(Defaults2.TimeStamp), L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $");
+ IniSectionGetString(Settings2_Section, L"TimeStamp", Defaults2.TimeStamp, Settings2.TimeStamp, COUNTOF(Settings2.TimeStamp));
- Defaults2.DateTimeShort[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort));
+ Defaults2.DateTimeShort[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort));
- Defaults2.DateTimeLong[0] = L'\0';
- IniSectionGetString(Settings2_Section, L"DateTimeLong", Defaults2.DateTimeLong, Settings2.DateTimeLong, COUNTOF(Settings2.DateTimeLong));
+ Defaults2.DateTimeLong[0] = L'\0';
+ IniSectionGetString(Settings2_Section, L"DateTimeLong", Defaults2.DateTimeLong, Settings2.DateTimeLong, COUNTOF(Settings2.DateTimeLong));
- StringCchCopyW(Defaults2.WebTemplate1, COUNTOF(Defaults2.WebTemplate1), L"https://google.com/search?q=%s");
- IniSectionGetString(Settings2_Section, L"WebTemplate1", Defaults2.WebTemplate1, Settings2.WebTemplate1, COUNTOF(Settings2.WebTemplate1));
+ StringCchCopyW(Defaults2.WebTemplate1, COUNTOF(Defaults2.WebTemplate1), L"https://google.com/search?q=%s");
+ IniSectionGetString(Settings2_Section, L"WebTemplate1", Defaults2.WebTemplate1, Settings2.WebTemplate1, COUNTOF(Settings2.WebTemplate1));
- StringCchCopyW(Defaults2.WebTemplate2, COUNTOF(Defaults2.WebTemplate2), L"https://en.wikipedia.org/w/index.php?search=%s");
- IniSectionGetString(Settings2_Section, L"WebTemplate2", Defaults2.WebTemplate2, Settings2.WebTemplate2, COUNTOF(Settings2.WebTemplate2));
+ StringCchCopyW(Defaults2.WebTemplate2, COUNTOF(Defaults2.WebTemplate2), L"https://en.wikipedia.org/w/index.php?search=%s");
+ IniSectionGetString(Settings2_Section, L"WebTemplate2", Defaults2.WebTemplate2, Settings2.WebTemplate2, COUNTOF(Settings2.WebTemplate2));
- // --------------------------------------------------------------------------
- const WCHAR* const Settings_Section = L"Settings";
- // --------------------------------------------------------------------------
+ // --------------------------------------------------------------------------
+ const WCHAR* const Settings_Section = L"Settings";
+ // --------------------------------------------------------------------------
#define GET_BOOL_VALUE_FROM_INISECTION(VARNAME,DEFAULT) \
Defaults.VARNAME = DEFAULT; \
@@ -785,312 +783,312 @@ void LoadSettings()
Defaults.VARNAME = (cpi_enc_t)DEFAULT; \
Settings.VARNAME = (cpi_enc_t)clampi(IniSectionGetInt(Settings_Section, _W(_STRG(VARNAME)), (int)Defaults.VARNAME),(int)MIN,(int)MAX)
- GET_BOOL_VALUE_FROM_INISECTION(SaveRecentFiles, true);
- GET_BOOL_VALUE_FROM_INISECTION(PreserveCaretPos, false);
- GET_BOOL_VALUE_FROM_INISECTION(SaveFindReplace, false);
+ GET_BOOL_VALUE_FROM_INISECTION(SaveRecentFiles, true);
+ GET_BOOL_VALUE_FROM_INISECTION(PreserveCaretPos, false);
+ GET_BOOL_VALUE_FROM_INISECTION(SaveFindReplace, false);
- Defaults.EFR_Data.bFindClose = false;
- Settings.EFR_Data.bFindClose = IniSectionGetBool(Settings_Section, L"CloseFind", Defaults.EFR_Data.bFindClose);
- Defaults.EFR_Data.bReplaceClose = false;
- Settings.EFR_Data.bReplaceClose = IniSectionGetBool(Settings_Section, L"CloseReplace", Defaults.EFR_Data.bReplaceClose);
- Defaults.EFR_Data.bNoFindWrap = false;
- Settings.EFR_Data.bNoFindWrap = IniSectionGetBool(Settings_Section, L"NoFindWrap", Defaults.EFR_Data.bNoFindWrap);
- Defaults.EFR_Data.bTransformBS = false;
- Settings.EFR_Data.bTransformBS = IniSectionGetBool(Settings_Section, L"FindTransformBS", Defaults.EFR_Data.bTransformBS);
- Defaults.EFR_Data.bWildcardSearch = false;
- Settings.EFR_Data.bWildcardSearch = IniSectionGetBool(Settings_Section, L"WildcardSearch", Defaults.EFR_Data.bWildcardSearch);
- Defaults.EFR_Data.bMarkOccurences = true;
- Settings.EFR_Data.bMarkOccurences = IniSectionGetBool(Settings_Section, L"FindMarkAllOccurrences", Defaults.EFR_Data.bMarkOccurences);
- Defaults.EFR_Data.bHideNonMatchedLines = false;
- Settings.EFR_Data.bHideNonMatchedLines = IniSectionGetBool(Settings_Section, L"HideNonMatchedLines", Defaults.EFR_Data.bHideNonMatchedLines);
- Defaults.EFR_Data.bDotMatchAll = false;
- Settings.EFR_Data.bDotMatchAll = IniSectionGetBool(Settings_Section, L"RegexDotMatchesAll", Defaults.EFR_Data.bDotMatchAll);
- Defaults.EFR_Data.fuFlags = 0;
- Settings.EFR_Data.fuFlags = (UINT)IniSectionGetInt(Settings_Section, L"efrData_fuFlags", (int)Defaults.EFR_Data.fuFlags);
+ Defaults.EFR_Data.bFindClose = false;
+ Settings.EFR_Data.bFindClose = IniSectionGetBool(Settings_Section, L"CloseFind", Defaults.EFR_Data.bFindClose);
+ Defaults.EFR_Data.bReplaceClose = false;
+ Settings.EFR_Data.bReplaceClose = IniSectionGetBool(Settings_Section, L"CloseReplace", Defaults.EFR_Data.bReplaceClose);
+ Defaults.EFR_Data.bNoFindWrap = false;
+ Settings.EFR_Data.bNoFindWrap = IniSectionGetBool(Settings_Section, L"NoFindWrap", Defaults.EFR_Data.bNoFindWrap);
+ Defaults.EFR_Data.bTransformBS = false;
+ Settings.EFR_Data.bTransformBS = IniSectionGetBool(Settings_Section, L"FindTransformBS", Defaults.EFR_Data.bTransformBS);
+ Defaults.EFR_Data.bWildcardSearch = false;
+ Settings.EFR_Data.bWildcardSearch = IniSectionGetBool(Settings_Section, L"WildcardSearch", Defaults.EFR_Data.bWildcardSearch);
+ Defaults.EFR_Data.bMarkOccurences = true;
+ Settings.EFR_Data.bMarkOccurences = IniSectionGetBool(Settings_Section, L"FindMarkAllOccurrences", Defaults.EFR_Data.bMarkOccurences);
+ Defaults.EFR_Data.bHideNonMatchedLines = false;
+ Settings.EFR_Data.bHideNonMatchedLines = IniSectionGetBool(Settings_Section, L"HideNonMatchedLines", Defaults.EFR_Data.bHideNonMatchedLines);
+ Defaults.EFR_Data.bDotMatchAll = false;
+ Settings.EFR_Data.bDotMatchAll = IniSectionGetBool(Settings_Section, L"RegexDotMatchesAll", Defaults.EFR_Data.bDotMatchAll);
+ Defaults.EFR_Data.fuFlags = 0;
+ Settings.EFR_Data.fuFlags = (UINT)IniSectionGetInt(Settings_Section, L"efrData_fuFlags", (int)Defaults.EFR_Data.fuFlags);
- Defaults.OpenWithDir[0] = L'\0';
- if (!IniSectionGetString(Settings_Section, L"OpenWithDir", Defaults.OpenWithDir, Settings.OpenWithDir, COUNTOF(Settings.OpenWithDir))) {
- GetKnownFolderPath(FOLDERID_Desktop, Settings.OpenWithDir, COUNTOF(Settings.OpenWithDir));
- }
- else {
- PathAbsoluteFromApp(Settings.OpenWithDir, NULL, COUNTOF(Settings.OpenWithDir), true);
- }
-
- Defaults.FavoritesDir[0] = L'\0';
- //StringCchCopyW(Defaults.FavoritesDir, COUNTOF(Defaults.FavoritesDir), L"%USERPROFILE%");
- if (!IniSectionGetString(Settings_Section, L"Favorites", Defaults.FavoritesDir, Settings.FavoritesDir, COUNTOF(Settings.FavoritesDir))) {
- GetKnownFolderPath(FOLDERID_Favorites, Settings.FavoritesDir, COUNTOF(Settings.FavoritesDir));
- }
- else {
- PathAbsoluteFromApp(Settings.FavoritesDir, NULL, COUNTOF(Settings.FavoritesDir), true);
- }
-
- GET_INT_VALUE_FROM_INISECTION(PathNameFormat, 1, 0, 2);
- GET_INT_VALUE_FROM_INISECTION(WordWrapMode, 0, 0, 1);
- GET_INT_VALUE_FROM_INISECTION(WordWrapIndent, 2, 0, 6);
-
- GET_BOOL_VALUE_FROM_INISECTION(WordWrap, false); Globals.fvBackup.bWordWrap = Settings.WordWrap;
- GET_BOOL_VALUE_FROM_INISECTION(TabsAsSpaces, false); Globals.fvBackup.bTabsAsSpaces = Settings.TabsAsSpaces;
- GET_BOOL_VALUE_FROM_INISECTION(TabIndents, true); Globals.fvBackup.bTabIndents = Settings.TabIndents;
- GET_INT_VALUE_FROM_INISECTION(TabWidth, 4, 1, 1024); Globals.fvBackup.iTabWidth = Settings.TabWidth;
- GET_INT_VALUE_FROM_INISECTION(IndentWidth, 4, 0, 1024); Globals.fvBackup.iIndentWidth = Settings.IndentWidth;
- GET_INT_VALUE_FROM_INISECTION(LongLinesLimit, 80, 0, LONG_LINES_MARKER_LIMIT); Globals.fvBackup.iLongLinesLimit = Settings.LongLinesLimit;
- Globals.iWrapCol = Settings.LongLinesLimit;
-
- Defaults.WordWrapSymbols = 22;
- int const iWS = IniSectionGetInt(Settings_Section, L"WordWrapSymbols", Defaults.WordWrapSymbols);
- Settings.WordWrapSymbols = clampi(iWS % 10, 0, 2) + clampi((iWS % 100 - iWS % 10) / 10, 0, 2) * 10;
-
- GET_BOOL_VALUE_FROM_INISECTION(ShowWordWrapSymbols, true);
- GET_BOOL_VALUE_FROM_INISECTION(MatchBraces, true);
- GET_BOOL_VALUE_FROM_INISECTION(AutoCloseTags, false);
- GET_INT_VALUE_FROM_INISECTION(HighlightCurrentLine, 1, 0, 2);
- GET_BOOL_VALUE_FROM_INISECTION(HyperlinkHotspot, true);
- GET_BOOL_VALUE_FROM_INISECTION(ColorDefHotspot, true);
- GET_BOOL_VALUE_FROM_INISECTION(ScrollPastEOF, false);
- GET_BOOL_VALUE_FROM_INISECTION(ShowHypLnkToolTip, true);
-
- GET_BOOL_VALUE_FROM_INISECTION(AutoIndent, true);
- GET_BOOL_VALUE_FROM_INISECTION(AutoCompleteWords, false);
- GET_BOOL_VALUE_FROM_INISECTION(AutoCLexerKeyWords, false);
- GET_BOOL_VALUE_FROM_INISECTION(AccelWordNavigation, false);
- GET_BOOL_VALUE_FROM_INISECTION(ShowIndentGuides, false);
- GET_BOOL_VALUE_FROM_INISECTION(BackspaceUnindents, false);
- GET_BOOL_VALUE_FROM_INISECTION(WarnInconsistentIndents, false);
- GET_BOOL_VALUE_FROM_INISECTION(AutoDetectIndentSettings, false);
- GET_BOOL_VALUE_FROM_INISECTION(MarkLongLines, (Globals.iCfgVersionRead < CFG_VER_0002)); Defaults.MarkLongLines = false; // new default
- GET_INT_VALUE_FROM_INISECTION(LongLineMode, EDGE_LINE, EDGE_LINE, EDGE_BACKGROUND);
- GET_BOOL_VALUE_FROM_INISECTION(ShowSelectionMargin, true);
- GET_BOOL_VALUE_FROM_INISECTION(ShowLineNumbers, true);
- GET_BOOL_VALUE_FROM_INISECTION(ShowCodeFolding, true); FocusedView.ShowCodeFolding = Settings.ShowCodeFolding;
-
- GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrences, true);
- GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchVisible, false);
- GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchCase, false);
- GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchWholeWords, true);
-
- Defaults.MarkOccurrencesCurrentWord = !Defaults.MarkOccurrencesMatchWholeWords;
- Settings.MarkOccurrencesCurrentWord = IniSectionGetBool(Settings_Section, L"MarkOccurrencesCurrentWord", Defaults.MarkOccurrencesCurrentWord);
- Settings.MarkOccurrencesCurrentWord = Settings.MarkOccurrencesCurrentWord && !Settings.MarkOccurrencesMatchWholeWords;
-
- GET_BOOL_VALUE_FROM_INISECTION(ViewWhiteSpace, false);
- GET_BOOL_VALUE_FROM_INISECTION(ViewEOLs, false);
-
- auto const iPrefEncIniSetting = (cpi_enc_t)Encoding_MapIniSetting(false, (int)CPI_UTF8);
- GET_ENC_VALUE_FROM_INISECTION(DefaultEncoding, iPrefEncIniSetting, CPI_NONE, INT_MAX);
- Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ? CPI_UTF8 : (cpi_enc_t)Encoding_MapIniSetting(true, (int)Settings.DefaultEncoding));
- GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, false);
- GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, true);
- GET_BOOL_VALUE_FROM_INISECTION(UseReliableCEDonly, true);
- GET_BOOL_VALUE_FROM_INISECTION(LoadNFOasOEM, true);
- GET_BOOL_VALUE_FROM_INISECTION(NoEncodingTags, false);
- GET_BOOL_VALUE_FROM_INISECTION(SkipUnicodeDetection, false);
- GET_BOOL_VALUE_FROM_INISECTION(SkipANSICodePageDetection, false);
- GET_INT_VALUE_FROM_INISECTION(DefaultEOLMode, SC_EOL_CRLF, SC_EOL_CRLF, SC_EOL_LF);
- GET_BOOL_VALUE_FROM_INISECTION(WarnInconsistEOLs, true);
- GET_BOOL_VALUE_FROM_INISECTION(FixLineEndings, false);
- GET_BOOL_VALUE_FROM_INISECTION(FixTrailingBlanks, false);
- GET_INT_VALUE_FROM_INISECTION(PrintHeader, 1, 0, 3);
- GET_INT_VALUE_FROM_INISECTION(PrintFooter, 0, 0, 1);
- GET_INT_VALUE_FROM_INISECTION(PrintColorMode, 3, 0, 4);
-
- int const zoomScale = float2int(1000.0f / GetBaseFontSize(Globals.hwndMain));
- Defaults.PrintZoom = (Globals.iCfgVersionRead < CFG_VER_0001) ? (zoomScale / 10) : zoomScale;
- int iPrintZoom = clampi(IniSectionGetInt(Settings_Section, L"PrintZoom", Defaults.PrintZoom), 0, SC_MAX_ZOOM_LEVEL);
- if (Globals.iCfgVersionRead < CFG_VER_0001) { iPrintZoom = 100 + (iPrintZoom - 10) * 10; }
- Settings.PrintZoom = clampi(iPrintZoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL);
-
- WCHAR localeInfo[3];
- GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);
- LONG const _margin = (localeInfo[0] == L'0') ? 2000L : 1000L; // Metric system. L'1' is US System
- Defaults.PrintMargin.left = _margin;
- Settings.PrintMargin.left = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginLeft", Defaults.PrintMargin.left), 0, 40000);
- Defaults.PrintMargin.top = _margin;
- Settings.PrintMargin.top = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginTop", Defaults.PrintMargin.top), 0, 40000);
- Defaults.PrintMargin.right = _margin;
- Settings.PrintMargin.right = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginRight", Defaults.PrintMargin.right), 0, 40000);
- Defaults.PrintMargin.bottom = _margin;
- Settings.PrintMargin.bottom = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginBottom", Defaults.PrintMargin.bottom), 0, 40000);
-
- GET_BOOL_VALUE_FROM_INISECTION(SaveBeforeRunningTools, false);
- GET_CAST_INT_VALUE_FROM_INISECTION(FILE_WATCHING_MODE, FileWatchingMode, FWM_NONE, FWM_NONE, FWM_AUTORELOAD); FileWatching.FileWatchingMode = Settings.FileWatchingMode;
- GET_BOOL_VALUE_FROM_INISECTION(ResetFileWatching, true); FileWatching.ResetFileWatching = Settings.ResetFileWatching;
- GET_INT_VALUE_FROM_INISECTION(EscFunction, 0, 0, 2);
- GET_BOOL_VALUE_FROM_INISECTION(AlwaysOnTop, false);
- GET_BOOL_VALUE_FROM_INISECTION(MinimizeToTray, false);
- GET_BOOL_VALUE_FROM_INISECTION(TransparentMode, false);
- GET_BOOL_VALUE_FROM_INISECTION(FindReplaceTransparentMode, true);
- GET_INT_VALUE_FROM_INISECTION(RenderingTechnology, Defaults.RenderingTechnology, 0, 3); // set before
- GET_INT_VALUE_FROM_INISECTION(Bidirectional, Defaults.Bidirectional, 0, 2); // set before
- GET_BOOL_VALUE_FROM_INISECTION(MuteMessageBeep, false);
- GET_BOOL_VALUE_FROM_INISECTION(SplitUndoTypingSeqOnLnBreak, false);
-
- ///~Settings2.IMEInteraction = clampi(IniSectionGetInt(Settings_Section, L"IMEInteraction", Settings2.IMEInteraction), SC_IME_WINDOWED, SC_IME_INLINE);
-
- // see TBBUTTON s_tbbMainWnd[] for initial/reset set of buttons
- StringCchCopyW(Defaults.ToolbarButtons, COUNTOF(Defaults.ToolbarButtons), (Globals.iCfgVersionRead < CFG_VER_0002) ? TBBUTTON_DEFAULT_IDS_V1 : TBBUTTON_DEFAULT_IDS_V2);
- IniSectionGetString(Settings_Section, L"ToolbarButtons", Defaults.ToolbarButtons, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons));
-
- GET_BOOL_VALUE_FROM_INISECTION(ShowToolbar, true);
- GET_BOOL_VALUE_FROM_INISECTION(ShowStatusbar, true);
-
- GET_INT_VALUE_FROM_INISECTION(EncodingDlgSizeX, 340, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(EncodingDlgSizeY, 292, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(RecodeDlgSizeX, 340, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(RecodeDlgSizeY, 292, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(FileMRUDlgSizeX, 487, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(FileMRUDlgSizeY, 339, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(OpenWithDlgSizeX, 305, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(OpenWithDlgSizeY, 281, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(FavoritesDlgSizeX, 305, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(FavoritesDlgSizeY, 281, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(AddToFavDlgSizeX, 317, INT_MIN, INT_MAX);
-
- GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgSizeX, 494, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgPosX, CW_USEDEFAULT, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgPosY, CW_USEDEFAULT, INT_MIN, INT_MAX);
-
- GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgSizeX, 833, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgSizeY, 515, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgPosX, CW_USEDEFAULT, INT_MIN, INT_MAX);
- GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgPosY, CW_USEDEFAULT, INT_MIN, INT_MAX);
-
- // --------------------------------------------------------------------------
- const WCHAR* const StatusBar_Section = L"Statusbar Settings";
- // --------------------------------------------------------------------------
-
- WCHAR tchStatusBar[MIDSZ_BUFFER] = { L'\0' };
-
- IniSectionGetString(StatusBar_Section, L"SectionPrefixes", STATUSBAR_SECTION_PREFIXES, tchStatusBar, COUNTOF(tchStatusBar));
- ReadStrgsFromCSV(tchStatusBar, s_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_PRFX_");
-
- IniSectionGetString(StatusBar_Section, L"SectionPostfixes", STATUSBAR_SECTION_POSTFIXES, tchStatusBar, COUNTOF(tchStatusBar));
- ReadStrgsFromCSV(tchStatusBar, s_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_POFX_");
-
- IniSectionGetString(StatusBar_Section, L"VisibleSections", STATUSBAR_DEFAULT_IDS, tchStatusBar, COUNTOF(tchStatusBar));
- ReadVectorFromString(tchStatusBar, s_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1);
-
- for (bool & sbv : s_iStatusbarVisible) { sbv = false; }
- int cnt = 0;
- for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {
- s_vSBSOrder[i] = -1;
- int const id = s_iStatusbarSections[i];
- if (id >= 0) {
- s_vSBSOrder[cnt++] = id;
- s_iStatusbarVisible[id] = true;
- }
- }
-
- IniSectionGetString(StatusBar_Section, L"SectionWidthSpecs", STATUSBAR_SECTION_WIDTH_SPECS, tchStatusBar, COUNTOF(tchStatusBar));
- ReadVectorFromString(tchStatusBar, s_iStatusbarWidthSpec, STATUS_SECTOR_COUNT, -4096, 4096, 0);
-
- Globals.bZeroBasedColumnIndex = IniSectionGetBool(StatusBar_Section, L"ZeroBasedColumnIndex", false);
- Globals.bZeroBasedCharacterCount = IniSectionGetBool(StatusBar_Section, L"ZeroBasedCharacterCount", false);
-
-
- // --------------------------------------------------------------------------
- const WCHAR* const ToolbarImg_Section = L"Toolbar Images";
- // --------------------------------------------------------------------------
-
- IniSectionGetString(ToolbarImg_Section, L"BitmapDefault", L"",
- s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap));
- IniSectionGetString(ToolbarImg_Section, L"BitmapHot", L"",
- s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmap));
- IniSectionGetString(ToolbarImg_Section, L"BitmapDisabled", L"",
- s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmap));
-
-
- // --------------------------------------------------------------------------
- const WCHAR* const Window_Section = L"Window";
- // --------------------------------------------------------------------------
-
- int ResX, ResY;
- GetCurrentMonitorResolution(Globals.hwndMain, &ResX, &ResY);
-
- WCHAR tchHighDpiToolBar[32] = { L'\0' };
- StringCchPrintf(tchHighDpiToolBar, COUNTOF(tchHighDpiToolBar), L"%ix%i HighDpiToolBar", ResX, ResY);
- s_iToolBarTheme = IniSectionGetInt(Window_Section, tchHighDpiToolBar, -1);
- s_iToolBarTheme = clampi(s_iToolBarTheme, -1, StrIsEmpty(s_tchToolbarBitmap) ? 1 : 2);
- if (s_iToolBarTheme < 0) { // undefined: determine high DPI (higher than Full-HD)
- s_iToolBarTheme = IsFullHDOrHigher(Globals.hwndMain, ResX, ResY) ? 1 : 0;
- }
-
- // --------------------------------------------------------------
- // startup window (ignore window position if /p was specified)
- // --------------------------------------------------------------
-
- // 1st set default window position
-
- s_DefWinInfo = InitDefaultWndPos(2); // std. default position
-
- if (bExplicitDefaultWinPos) {
- int bMaxi = 0;
- int const itok = swscanf_s(Settings2.DefaultWindowPosition, L"%i,%i,%i,%i,%i",
- &s_DefWinInfo.x, &s_DefWinInfo.y, &s_DefWinInfo.cx, &s_DefWinInfo.cy, &bMaxi);
- if (itok == 4 || itok == 5) { // scan successful
- if (s_DefWinInfo.cx < 1) s_DefWinInfo.cx = CW_USEDEFAULT;
- if (s_DefWinInfo.cy < 1) s_DefWinInfo.cy = CW_USEDEFAULT;
- if (bMaxi) s_DefWinInfo.max = true;
- if (itok == 4) s_DefWinInfo.max = false;
- InitWindowPosition(&s_DefWinInfo, 0);
- }
- else {
- // overwrite bad defined default position
- StringCchPrintf(Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition),
- L"%i,%i,%i,%i,%i", s_DefWinInfo.x, s_DefWinInfo.y, s_DefWinInfo.cx, s_DefWinInfo.cy, s_DefWinInfo.max);
- IniFileSetString(Globals.IniFile, L"Settings2", L"DefaultWindowPosition", Settings2.DefaultWindowPosition);
- }
- }
-
- // 2nd set initial window position
-
- if (!s_flagPosParam /*|| g_bStickyWinPos*/) {
-
- s_WinInfo = s_DefWinInfo;
-
- 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(tchZoom), L"%ix%i Zoom", ResX, ResY);
-
- s_WinInfo.x = IniSectionGetInt(Window_Section, tchPosX, CW_USEDEFAULT);
- s_WinInfo.y = IniSectionGetInt(Window_Section, tchPosY, CW_USEDEFAULT);
- s_WinInfo.cx = IniSectionGetInt(Window_Section, tchSizeX, CW_USEDEFAULT);
- s_WinInfo.cy = IniSectionGetInt(Window_Section, tchSizeY, CW_USEDEFAULT);
- s_WinInfo.max = IniSectionGetBool(Window_Section, tchMaximized, false);
- s_WinInfo.zoom = IniSectionGetInt(Window_Section, tchZoom, (Globals.iCfgVersionRead < CFG_VER_0001) ? 0 : 100);
- if (Globals.iCfgVersionRead < CFG_VER_0001) { s_WinInfo.zoom = (s_WinInfo.zoom + 10) * 10; }
- s_WinInfo.zoom = clampi(s_WinInfo.zoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL);
-
- if ((s_WinInfo.x == CW_USEDEFAULT) || (s_WinInfo.y == CW_USEDEFAULT) ||
- (s_WinInfo.cx == CW_USEDEFAULT) || (s_WinInfo.cy == CW_USEDEFAULT))
- {
- s_flagWindowPos = 2; // std. default position (CmdLn: /pd)
- }
- else
- s_flagWindowPos = 0; // init to g_WinInfo
- }
-
- // ------------------------------------------------------------------------
-
- // --- override by resolution specific settings ---
- WCHAR tchSciDirectWriteTech[64];
- StringCchPrintf(tchSciDirectWriteTech, COUNTOF(tchSciDirectWriteTech), L"%ix%i RenderingTechnology", ResX, ResY);
- Settings.RenderingTechnology = clampi(IniSectionGetInt(Window_Section, tchSciDirectWriteTech, Settings.RenderingTechnology), 0, 3);
-
- WCHAR tchSciFontQuality[64];
- StringCchPrintf(tchSciFontQuality, COUNTOF(tchSciFontQuality), L"%ix%i SciFontQuality", ResX, ResY);
- Settings2.SciFontQuality = clampi(IniSectionGetInt(Window_Section, tchSciFontQuality, Settings2.SciFontQuality), 0, 3);
-
- if (bDirtyFlag) {
- SaveIniFile(Globals.IniFile);
- }
- ReleaseIniFile();
+ Defaults.OpenWithDir[0] = L'\0';
+ if (!IniSectionGetString(Settings_Section, L"OpenWithDir", Defaults.OpenWithDir, Settings.OpenWithDir, COUNTOF(Settings.OpenWithDir))) {
+ GetKnownFolderPath(FOLDERID_Desktop, Settings.OpenWithDir, COUNTOF(Settings.OpenWithDir));
}
+ else {
+ PathAbsoluteFromApp(Settings.OpenWithDir, NULL, COUNTOF(Settings.OpenWithDir), true);
+ }
+
+ Defaults.FavoritesDir[0] = L'\0';
+ //StringCchCopyW(Defaults.FavoritesDir, COUNTOF(Defaults.FavoritesDir), L"%USERPROFILE%");
+ if (!IniSectionGetString(Settings_Section, L"Favorites", Defaults.FavoritesDir, Settings.FavoritesDir, COUNTOF(Settings.FavoritesDir))) {
+ GetKnownFolderPath(FOLDERID_Favorites, Settings.FavoritesDir, COUNTOF(Settings.FavoritesDir));
+ }
+ else {
+ PathAbsoluteFromApp(Settings.FavoritesDir, NULL, COUNTOF(Settings.FavoritesDir), true);
+ }
+
+ GET_INT_VALUE_FROM_INISECTION(PathNameFormat, 1, 0, 2);
+ GET_INT_VALUE_FROM_INISECTION(WordWrapMode, 0, 0, 1);
+ GET_INT_VALUE_FROM_INISECTION(WordWrapIndent, 2, 0, 6);
+
+ GET_BOOL_VALUE_FROM_INISECTION(WordWrap, false); Globals.fvBackup.bWordWrap = Settings.WordWrap;
+ GET_BOOL_VALUE_FROM_INISECTION(TabsAsSpaces, false); Globals.fvBackup.bTabsAsSpaces = Settings.TabsAsSpaces;
+ GET_BOOL_VALUE_FROM_INISECTION(TabIndents, true); Globals.fvBackup.bTabIndents = Settings.TabIndents;
+ GET_INT_VALUE_FROM_INISECTION(TabWidth, 4, 1, 1024); Globals.fvBackup.iTabWidth = Settings.TabWidth;
+ GET_INT_VALUE_FROM_INISECTION(IndentWidth, 4, 0, 1024); Globals.fvBackup.iIndentWidth = Settings.IndentWidth;
+ GET_INT_VALUE_FROM_INISECTION(LongLinesLimit, 80, 0, LONG_LINES_MARKER_LIMIT); Globals.fvBackup.iLongLinesLimit = Settings.LongLinesLimit;
+ Globals.iWrapCol = Settings.LongLinesLimit;
+
+ Defaults.WordWrapSymbols = 22;
+ int const iWS = IniSectionGetInt(Settings_Section, L"WordWrapSymbols", Defaults.WordWrapSymbols);
+ Settings.WordWrapSymbols = clampi(iWS % 10, 0, 2) + clampi((iWS % 100 - iWS % 10) / 10, 0, 2) * 10;
+
+ GET_BOOL_VALUE_FROM_INISECTION(ShowWordWrapSymbols, true);
+ GET_BOOL_VALUE_FROM_INISECTION(MatchBraces, true);
+ GET_BOOL_VALUE_FROM_INISECTION(AutoCloseTags, false);
+ GET_INT_VALUE_FROM_INISECTION(HighlightCurrentLine, 1, 0, 2);
+ GET_BOOL_VALUE_FROM_INISECTION(HyperlinkHotspot, true);
+ GET_BOOL_VALUE_FROM_INISECTION(ColorDefHotspot, true);
+ GET_BOOL_VALUE_FROM_INISECTION(ScrollPastEOF, false);
+ GET_BOOL_VALUE_FROM_INISECTION(ShowHypLnkToolTip, true);
+
+ GET_BOOL_VALUE_FROM_INISECTION(AutoIndent, true);
+ GET_BOOL_VALUE_FROM_INISECTION(AutoCompleteWords, false);
+ GET_BOOL_VALUE_FROM_INISECTION(AutoCLexerKeyWords, false);
+ GET_BOOL_VALUE_FROM_INISECTION(AccelWordNavigation, false);
+ GET_BOOL_VALUE_FROM_INISECTION(ShowIndentGuides, false);
+ GET_BOOL_VALUE_FROM_INISECTION(BackspaceUnindents, false);
+ GET_BOOL_VALUE_FROM_INISECTION(WarnInconsistentIndents, false);
+ GET_BOOL_VALUE_FROM_INISECTION(AutoDetectIndentSettings, false);
+ GET_BOOL_VALUE_FROM_INISECTION(MarkLongLines, (Globals.iCfgVersionRead < CFG_VER_0002)); Defaults.MarkLongLines = false; // new default
+ GET_INT_VALUE_FROM_INISECTION(LongLineMode, EDGE_LINE, EDGE_LINE, EDGE_BACKGROUND);
+ GET_BOOL_VALUE_FROM_INISECTION(ShowSelectionMargin, true);
+ GET_BOOL_VALUE_FROM_INISECTION(ShowLineNumbers, true);
+ GET_BOOL_VALUE_FROM_INISECTION(ShowCodeFolding, true); FocusedView.ShowCodeFolding = Settings.ShowCodeFolding;
+
+ GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrences, true);
+ GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchVisible, false);
+ GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchCase, false);
+ GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchWholeWords, true);
+
+ Defaults.MarkOccurrencesCurrentWord = !Defaults.MarkOccurrencesMatchWholeWords;
+ Settings.MarkOccurrencesCurrentWord = IniSectionGetBool(Settings_Section, L"MarkOccurrencesCurrentWord", Defaults.MarkOccurrencesCurrentWord);
+ Settings.MarkOccurrencesCurrentWord = Settings.MarkOccurrencesCurrentWord && !Settings.MarkOccurrencesMatchWholeWords;
+
+ GET_BOOL_VALUE_FROM_INISECTION(ViewWhiteSpace, false);
+ GET_BOOL_VALUE_FROM_INISECTION(ViewEOLs, false);
+
+ auto const iPrefEncIniSetting = (cpi_enc_t)Encoding_MapIniSetting(false, (int)CPI_UTF8);
+ GET_ENC_VALUE_FROM_INISECTION(DefaultEncoding, iPrefEncIniSetting, CPI_NONE, INT_MAX);
+ Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ? CPI_UTF8 : (cpi_enc_t)Encoding_MapIniSetting(true, (int)Settings.DefaultEncoding));
+ GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, false);
+ GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, true);
+ GET_BOOL_VALUE_FROM_INISECTION(UseReliableCEDonly, true);
+ GET_BOOL_VALUE_FROM_INISECTION(LoadNFOasOEM, true);
+ GET_BOOL_VALUE_FROM_INISECTION(NoEncodingTags, false);
+ GET_BOOL_VALUE_FROM_INISECTION(SkipUnicodeDetection, false);
+ GET_BOOL_VALUE_FROM_INISECTION(SkipANSICodePageDetection, false);
+ GET_INT_VALUE_FROM_INISECTION(DefaultEOLMode, SC_EOL_CRLF, SC_EOL_CRLF, SC_EOL_LF);
+ GET_BOOL_VALUE_FROM_INISECTION(WarnInconsistEOLs, true);
+ GET_BOOL_VALUE_FROM_INISECTION(FixLineEndings, false);
+ GET_BOOL_VALUE_FROM_INISECTION(FixTrailingBlanks, false);
+ GET_INT_VALUE_FROM_INISECTION(PrintHeader, 1, 0, 3);
+ GET_INT_VALUE_FROM_INISECTION(PrintFooter, 0, 0, 1);
+ GET_INT_VALUE_FROM_INISECTION(PrintColorMode, 3, 0, 4);
+
+ int const zoomScale = float2int(1000.0f / GetBaseFontSize(Globals.hwndMain));
+ Defaults.PrintZoom = (Globals.iCfgVersionRead < CFG_VER_0001) ? (zoomScale / 10) : zoomScale;
+ int iPrintZoom = clampi(IniSectionGetInt(Settings_Section, L"PrintZoom", Defaults.PrintZoom), 0, SC_MAX_ZOOM_LEVEL);
+ if (Globals.iCfgVersionRead < CFG_VER_0001) { iPrintZoom = 100 + (iPrintZoom - 10) * 10; }
+ Settings.PrintZoom = clampi(iPrintZoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL);
+
+ WCHAR localeInfo[3];
+ GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);
+ LONG const _margin = (localeInfo[0] == L'0') ? 2000L : 1000L; // Metric system. L'1' is US System
+ Defaults.PrintMargin.left = _margin;
+ Settings.PrintMargin.left = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginLeft", Defaults.PrintMargin.left), 0, 40000);
+ Defaults.PrintMargin.top = _margin;
+ Settings.PrintMargin.top = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginTop", Defaults.PrintMargin.top), 0, 40000);
+ Defaults.PrintMargin.right = _margin;
+ Settings.PrintMargin.right = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginRight", Defaults.PrintMargin.right), 0, 40000);
+ Defaults.PrintMargin.bottom = _margin;
+ Settings.PrintMargin.bottom = clampi(IniSectionGetInt(Settings_Section, L"PrintMarginBottom", Defaults.PrintMargin.bottom), 0, 40000);
+
+ GET_BOOL_VALUE_FROM_INISECTION(SaveBeforeRunningTools, false);
+ GET_CAST_INT_VALUE_FROM_INISECTION(FILE_WATCHING_MODE, FileWatchingMode, FWM_NONE, FWM_NONE, FWM_AUTORELOAD); FileWatching.FileWatchingMode = Settings.FileWatchingMode;
+ GET_BOOL_VALUE_FROM_INISECTION(ResetFileWatching, true); FileWatching.ResetFileWatching = Settings.ResetFileWatching;
+ GET_INT_VALUE_FROM_INISECTION(EscFunction, 0, 0, 2);
+ GET_BOOL_VALUE_FROM_INISECTION(AlwaysOnTop, false);
+ GET_BOOL_VALUE_FROM_INISECTION(MinimizeToTray, false);
+ GET_BOOL_VALUE_FROM_INISECTION(TransparentMode, false);
+ GET_BOOL_VALUE_FROM_INISECTION(FindReplaceTransparentMode, true);
+ GET_INT_VALUE_FROM_INISECTION(RenderingTechnology, Defaults.RenderingTechnology, 0, 3); // set before
+ GET_INT_VALUE_FROM_INISECTION(Bidirectional, Defaults.Bidirectional, 0, 2); // set before
+ GET_BOOL_VALUE_FROM_INISECTION(MuteMessageBeep, false);
+ GET_BOOL_VALUE_FROM_INISECTION(SplitUndoTypingSeqOnLnBreak, false);
+
+ ///~Settings2.IMEInteraction = clampi(IniSectionGetInt(Settings_Section, L"IMEInteraction", Settings2.IMEInteraction), SC_IME_WINDOWED, SC_IME_INLINE);
+
+ // see TBBUTTON s_tbbMainWnd[] for initial/reset set of buttons
+ StringCchCopyW(Defaults.ToolbarButtons, COUNTOF(Defaults.ToolbarButtons), (Globals.iCfgVersionRead < CFG_VER_0002) ? TBBUTTON_DEFAULT_IDS_V1 : TBBUTTON_DEFAULT_IDS_V2);
+ IniSectionGetString(Settings_Section, L"ToolbarButtons", Defaults.ToolbarButtons, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons));
+
+ GET_BOOL_VALUE_FROM_INISECTION(ShowToolbar, true);
+ GET_BOOL_VALUE_FROM_INISECTION(ShowStatusbar, true);
+
+ GET_INT_VALUE_FROM_INISECTION(EncodingDlgSizeX, 340, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(EncodingDlgSizeY, 292, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(RecodeDlgSizeX, 340, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(RecodeDlgSizeY, 292, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(FileMRUDlgSizeX, 487, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(FileMRUDlgSizeY, 339, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(OpenWithDlgSizeX, 305, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(OpenWithDlgSizeY, 281, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(FavoritesDlgSizeX, 305, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(FavoritesDlgSizeY, 281, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(AddToFavDlgSizeX, 317, INT_MIN, INT_MAX);
+
+ GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgSizeX, 494, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgPosX, CW_USEDEFAULT, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgPosY, CW_USEDEFAULT, INT_MIN, INT_MAX);
+
+ GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgSizeX, 833, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgSizeY, 515, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgPosX, CW_USEDEFAULT, INT_MIN, INT_MAX);
+ GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgPosY, CW_USEDEFAULT, INT_MIN, INT_MAX);
+
+ // --------------------------------------------------------------------------
+ const WCHAR* const StatusBar_Section = L"Statusbar Settings";
+ // --------------------------------------------------------------------------
+
+ WCHAR tchStatusBar[MIDSZ_BUFFER] = { L'\0' };
+
+ IniSectionGetString(StatusBar_Section, L"SectionPrefixes", STATUSBAR_SECTION_PREFIXES, tchStatusBar, COUNTOF(tchStatusBar));
+ ReadStrgsFromCSV(tchStatusBar, s_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_PRFX_");
+
+ IniSectionGetString(StatusBar_Section, L"SectionPostfixes", STATUSBAR_SECTION_POSTFIXES, tchStatusBar, COUNTOF(tchStatusBar));
+ ReadStrgsFromCSV(tchStatusBar, s_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_POFX_");
+
+ IniSectionGetString(StatusBar_Section, L"VisibleSections", STATUSBAR_DEFAULT_IDS, tchStatusBar, COUNTOF(tchStatusBar));
+ ReadVectorFromString(tchStatusBar, s_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1);
+
+ for (bool& sbv : s_iStatusbarVisible) { sbv = false; }
+ int cnt = 0;
+ for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) {
+ s_vSBSOrder[i] = -1;
+ int const id = s_iStatusbarSections[i];
+ if (id >= 0) {
+ s_vSBSOrder[cnt++] = id;
+ s_iStatusbarVisible[id] = true;
+ }
+ }
+
+ IniSectionGetString(StatusBar_Section, L"SectionWidthSpecs", STATUSBAR_SECTION_WIDTH_SPECS, tchStatusBar, COUNTOF(tchStatusBar));
+ ReadVectorFromString(tchStatusBar, s_iStatusbarWidthSpec, STATUS_SECTOR_COUNT, -4096, 4096, 0);
+
+ Globals.bZeroBasedColumnIndex = IniSectionGetBool(StatusBar_Section, L"ZeroBasedColumnIndex", false);
+ Globals.bZeroBasedCharacterCount = IniSectionGetBool(StatusBar_Section, L"ZeroBasedCharacterCount", false);
+
+
+ // --------------------------------------------------------------------------
+ const WCHAR* const ToolbarImg_Section = L"Toolbar Images";
+ // --------------------------------------------------------------------------
+
+ IniSectionGetString(ToolbarImg_Section, L"BitmapDefault", L"",
+ s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap));
+ IniSectionGetString(ToolbarImg_Section, L"BitmapHot", L"",
+ s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmap));
+ IniSectionGetString(ToolbarImg_Section, L"BitmapDisabled", L"",
+ s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmap));
+
+
+ // --------------------------------------------------------------------------
+ const WCHAR* const Window_Section = L"Window";
+ // --------------------------------------------------------------------------
+
+ int ResX, ResY;
+ GetCurrentMonitorResolution(Globals.hwndMain, &ResX, &ResY);
+
+ WCHAR tchHighDpiToolBar[32] = { L'\0' };
+ StringCchPrintf(tchHighDpiToolBar, COUNTOF(tchHighDpiToolBar), L"%ix%i HighDpiToolBar", ResX, ResY);
+ s_iToolBarTheme = IniSectionGetInt(Window_Section, tchHighDpiToolBar, -1);
+ s_iToolBarTheme = clampi(s_iToolBarTheme, -1, StrIsEmpty(s_tchToolbarBitmap) ? 1 : 2);
+ if (s_iToolBarTheme < 0) { // undefined: determine high DPI (higher than Full-HD)
+ s_iToolBarTheme = IsFullHDOrHigher(Globals.hwndMain, ResX, ResY) ? 1 : 0;
+ }
+
+ // --------------------------------------------------------------
+ // startup window (ignore window position if /p was specified)
+ // --------------------------------------------------------------
+
+ // 1st set default window position
+
+ s_DefWinInfo = InitDefaultWndPos(2); // std. default position
+
+ if (bExplicitDefaultWinPos) {
+ int bMaxi = 0;
+ int const itok = swscanf_s(Settings2.DefaultWindowPosition, L"%i,%i,%i,%i,%i",
+ &s_DefWinInfo.x, &s_DefWinInfo.y, &s_DefWinInfo.cx, &s_DefWinInfo.cy, &bMaxi);
+ if (itok == 4 || itok == 5) { // scan successful
+ if (s_DefWinInfo.cx < 1) s_DefWinInfo.cx = CW_USEDEFAULT;
+ if (s_DefWinInfo.cy < 1) s_DefWinInfo.cy = CW_USEDEFAULT;
+ if (bMaxi) s_DefWinInfo.max = true;
+ if (itok == 4) s_DefWinInfo.max = false;
+ InitWindowPosition(&s_DefWinInfo, 0);
+ }
+ else {
+ // overwrite bad defined default position
+ StringCchPrintf(Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition),
+ L"%i,%i,%i,%i,%i", s_DefWinInfo.x, s_DefWinInfo.y, s_DefWinInfo.cx, s_DefWinInfo.cy, s_DefWinInfo.max);
+ IniFileSetString(Globals.IniFile, L"Settings2", L"DefaultWindowPosition", Settings2.DefaultWindowPosition);
+ }
+ }
+
+ // 2nd set initial window position
+
+ if (!s_flagPosParam /*|| g_bStickyWinPos*/) {
+
+ s_WinInfo = s_DefWinInfo;
+
+ 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(tchZoom), L"%ix%i Zoom", ResX, ResY);
+
+ s_WinInfo.x = IniSectionGetInt(Window_Section, tchPosX, CW_USEDEFAULT);
+ s_WinInfo.y = IniSectionGetInt(Window_Section, tchPosY, CW_USEDEFAULT);
+ s_WinInfo.cx = IniSectionGetInt(Window_Section, tchSizeX, CW_USEDEFAULT);
+ s_WinInfo.cy = IniSectionGetInt(Window_Section, tchSizeY, CW_USEDEFAULT);
+ s_WinInfo.max = IniSectionGetBool(Window_Section, tchMaximized, false);
+ s_WinInfo.zoom = IniSectionGetInt(Window_Section, tchZoom, (Globals.iCfgVersionRead < CFG_VER_0001) ? 0 : 100);
+ if (Globals.iCfgVersionRead < CFG_VER_0001) { s_WinInfo.zoom = (s_WinInfo.zoom + 10) * 10; }
+ s_WinInfo.zoom = clampi(s_WinInfo.zoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL);
+
+ if ((s_WinInfo.x == CW_USEDEFAULT) || (s_WinInfo.y == CW_USEDEFAULT) ||
+ (s_WinInfo.cx == CW_USEDEFAULT) || (s_WinInfo.cy == CW_USEDEFAULT))
+ {
+ s_flagWindowPos = 2; // std. default position (CmdLn: /pd)
+ }
+ else
+ s_flagWindowPos = 0; // init to g_WinInfo
+ }
+
+ // ------------------------------------------------------------------------
+
+ // --- override by resolution specific settings ---
+ WCHAR tchSciDirectWriteTech[64];
+ StringCchPrintf(tchSciDirectWriteTech, COUNTOF(tchSciDirectWriteTech), L"%ix%i RenderingTechnology", ResX, ResY);
+ Settings.RenderingTechnology = clampi(IniSectionGetInt(Window_Section, tchSciDirectWriteTech, Settings.RenderingTechnology), 0, 3);
+
+ WCHAR tchSciFontQuality[64];
+ StringCchPrintf(tchSciFontQuality, COUNTOF(tchSciFontQuality), L"%ix%i SciFontQuality", ResX, ResY);
+ Settings2.SciFontQuality = clampi(IniSectionGetInt(Window_Section, tchSciFontQuality, Settings2.SciFontQuality), 0, 3);
+
+ // --------------------------------------------------------------------------
+ const WCHAR* const Styles_Section = L"Styles";
+ // --------------------------------------------------------------------------
+ IniSectionGetString(Styles_Section, Constants.StylingThemeName, L"", Globals.SelectedThemeName, COUNTOF(Globals.SelectedThemeName));
+
// define scintilla internal codepage
const int iSciDefaultCodePage = SC_CP_UTF8; // default UTF8
@@ -1114,6 +1112,23 @@ void LoadSettings()
// define default charset
Globals.iDefaultCharSet = (int)CharSetFromCodePage((UINT)iSciDefaultCodePage);
+ // File MRU
+ Globals.pFileMRU = MRU_Create(_s_RecentFiles, MRU_NOCASE, MRU_ITEMSFILE);
+ MRU_Load(Globals.pFileMRU);
+
+ Globals.pMRUfind = MRU_Create(_s_RecentFind, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
+ MRU_Load(Globals.pMRUfind);
+ SetFindPattern(Globals.pMRUfind->pszItems[0]);
+
+ Globals.pMRUreplace = MRU_Create(_s_RecentReplace, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
+ MRU_Load(Globals.pMRUreplace);
+
+
+ if (bDirtyFlag) {
+ SaveIniFile(Globals.IniFile);
+ }
+ ReleaseIniFile();
+
// Scintilla Styles
Style_Load();
}
@@ -1182,6 +1197,29 @@ void LoadFlags()
}
+
+//=============================================================================
+//
+// OpenSettingsFile()
+//
+
+static bool s_bSettingsIniFileOpend = false;
+
+bool OpenSettingsFile()
+{
+ if (StrIsNotEmpty(Globals.IniFile)) {
+ if (!s_bSettingsIniFileOpend) {
+ CreateIniFile();
+ s_bSettingsIniFileOpend = LoadIniFile(Globals.IniFile);
+ }
+ }
+ else {
+ s_bSettingsIniFileOpend = false;
+ }
+ return s_bSettingsIniFileOpend;
+}
+
+
//=============================================================================
//
// SaveSettings()
@@ -1195,15 +1233,13 @@ void LoadFlags()
IniSectionDelete(Settings_Section, _W(_STRG(VARNAME)), false); \
}
-// ----------------------------------------------------------------------------
-
bool SaveSettings(bool bSaveSettingsNow)
{
- if (StrIsEmpty(Globals.IniFile) || s_flagDoRelaunchElevated) { return false; }
+ // update window placement
+ s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL);
- CreateIniFile();
- LoadIniFile(Globals.IniFile);
+ if (!s_bSettingsIniFileOpend) { return false; }
const WCHAR* const Settings_Section = L"Settings";
@@ -1215,12 +1251,9 @@ bool SaveSettings(bool bSaveSettingsNow)
else {
IniSectionDelete(Settings_Section, L"SaveSettings", false);
}
- return SaveIniFile(Globals.IniFile); // at least 'SaveSettings' has to be set
+ return true;
}
- // update window placement
- s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL);
-
IniSectionSetInt(Settings_Section, L"SettingsVersion", CFG_VER_CURRENT); // new settings
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveSettings);
@@ -1444,16 +1477,9 @@ bool SaveSettings(bool bSaveSettingsNow)
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)
+
+ if (Flags.bStickyWindowPosition)
{
- IniSectionSetInt(Window_Section, tchPosX, s_WinInfo.x);
- IniSectionSetInt(Window_Section, tchPosY, s_WinInfo.y);
- IniSectionSetInt(Window_Section, tchSizeX, s_WinInfo.cx);
- IniSectionSetInt(Window_Section, tchSizeY, s_WinInfo.cy);
- 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);
@@ -1461,24 +1487,377 @@ bool SaveSettings(bool bSaveSettingsNow)
IniSectionDelete(Window_Section, tchMaximized, false);
IniSectionDelete(Window_Section, tchZoom, false);
}
+ else {
+ IniSectionSetInt(Window_Section, tchPosX, s_WinInfo.x);
+ IniSectionSetInt(Window_Section, tchPosY, s_WinInfo.y);
+ IniSectionSetInt(Window_Section, tchSizeX, s_WinInfo.cx);
+ IniSectionSetInt(Window_Section, tchSizeY, s_WinInfo.cy);
+ IniSectionSetBool(Window_Section, tchMaximized, s_WinInfo.max);
+ IniSectionSetInt(Window_Section, tchZoom, s_WinInfo.zoom);
+ }
+ const WCHAR* const Styles_Section = L"Styles";
+
+ switch (Globals.idxSelectedTheme) {
+ case 1:
+ Style_ToIniSection(false); // Scintilla Styles
+ // falltrough
+ case 0:
+ IniSectionDelete(Styles_Section, Constants.StylingThemeName, false);
+ break;
+ default:
+ IniSectionSetString(Styles_Section, Constants.StylingThemeName, Theme_Files[Globals.idxSelectedTheme].szName);
+ break;
+ }
+
+ return true;
+}
+
+
+//=============================================================================
+//
+// CloseSettingsFile()
+//
+
+bool CloseSettingsFile()
+{
+ if (!s_bSettingsIniFileOpend || StrIsEmpty(Globals.IniFile)) { return false; }
bool const ok = SaveIniFile(Globals.IniFile);
if (ok) {
- Style_Save(); // Scintilla Styles
Globals.bIniFileFromScratch = false;
}
+ // force filesystem cache to sync
+ LoadIniFile(Globals.IniFile);
ReleaseIniFile();
+ s_bSettingsIniFileOpend = false;
return ok;
}
-//=============================================================================
-
-
-
//=============================================================================
+//=============================================================================
+
+
+//=============================================================================
+//
+// MRU functions
+//
+LPMRULIST MRU_Create(LPCWSTR pszRegKey, int iFlags, int iSize)
+{
+ LPMRULIST pmru = (LPMRULIST)AllocMem(sizeof(MRULIST), HEAP_ZERO_MEMORY);
+ if (pmru) {
+ ZeroMemory(pmru, sizeof(MRULIST));
+ pmru->szRegKey = pszRegKey;
+ pmru->iFlags = iFlags;
+ pmru->iSize = min_i(iSize, MRU_MAXITEMS);
+ }
+ return(pmru);
+}
+
+
+bool MRU_Destroy(LPMRULIST pmru)
+{
+ if (pmru) {
+ for (int i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i])
+ LocalFree(pmru->pszItems[i]); // StrDup()
+ if (pmru->pszBookMarks[i])
+ LocalFree(pmru->pszBookMarks[i]); // StrDup()
+ }
+ ZeroMemory(pmru, sizeof(MRULIST));
+ FreeMem(pmru);
+ return true;
+ }
+ return false;
+}
+
+
+int MRU_Compare(LPMRULIST pmru, LPCWSTR psz1, LPCWSTR psz2)
+{
+ if (pmru) {
+ if (pmru->iFlags & MRU_NOCASE) {
+ return(StringCchCompareXI(psz1, psz2));
+ }
+ return(StringCchCompareX(psz1, psz2));
+ }
+ return 0;
+}
+
+
+bool MRU_Add(LPMRULIST pmru, LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks)
+{
+ if (pmru) {
+ int i = 0;
+ for (; i < pmru->iSize; i++) {
+ if (MRU_Compare(pmru, pmru->pszItems[i], pszNew) == 0) {
+ LocalFree(pmru->pszItems[i]); // StrDup()
+ break;
+ }
+ }
+ i = min_i(i, pmru->iSize - 1);
+ for (; i > 0; i--) {
+ pmru->pszItems[i] = pmru->pszItems[i - 1];
+ pmru->iEncoding[i] = pmru->iEncoding[i - 1];
+ pmru->iCaretPos[i] = pmru->iCaretPos[i - 1];
+ }
+ pmru->pszItems[0] = StrDup(pszNew); // LocalAlloc()
+
+ pmru->iEncoding[0] = iEnc;
+ pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : 0);
+ pmru->pszBookMarks[0] = (pszBookMarks ? StrDup(pszBookMarks) : NULL); // LocalAlloc()
+ return true;
+ }
+ return false;
+}
+
+
+bool MRU_FindFile(LPMRULIST pmru, LPCWSTR pszFile, int* iIndex)
+{
+ *iIndex = 0;
+ if (pmru) {
+ WCHAR wchItem[MAX_PATH] = { L'\0' };
+ int i = 0;
+ for (i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i] == NULL) {
+ *iIndex = i;
+ return false;
+ }
+ if (StringCchCompareXI(pmru->pszItems[i], pszFile) == 0) {
+ *iIndex = i;
+ return true;
+ }
+ PathAbsoluteFromApp(pmru->pszItems[i], wchItem, COUNTOF(wchItem), true);
+ if (StringCchCompareXI(wchItem, pszFile) == 0) {
+ *iIndex = i;
+ return true;
+ }
+ }
+ *iIndex = i;
+ }
+ return false;
+}
+
+
+bool MRU_AddFile(LPMRULIST pmru, LPCWSTR pszFile, bool bRelativePath, bool bUnexpandMyDocs,
+ cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks)
+{
+ if (pmru) {
+ int i = 0;
+ if (MRU_FindFile(pmru, pszFile, &i)) {
+ LocalFree(pmru->pszItems[i]); // StrDup()
+ }
+ else {
+ i = (i < pmru->iSize) ? i : (pmru->iSize - 1);
+ }
+ for (; i > 0; i--) {
+ pmru->pszItems[i] = pmru->pszItems[i - 1];
+ pmru->iEncoding[i] = pmru->iEncoding[i - 1];
+ pmru->iCaretPos[i] = pmru->iCaretPos[i - 1];
+ pmru->pszBookMarks[i] = pmru->pszBookMarks[i - 1];
+ }
+ if (bRelativePath) {
+ WCHAR wchFile[MAX_PATH] = { L'\0' };
+ PathRelativeToApp((LPWSTR)pszFile, wchFile, COUNTOF(wchFile), true, true, bUnexpandMyDocs);
+ pmru->pszItems[0] = StrDup(wchFile); // LocalAlloc()
+ }
+ else {
+ pmru->pszItems[0] = StrDup(pszFile); // LocalAlloc()
+ }
+ pmru->iEncoding[0] = iEnc;
+ pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : 0);
+ pmru->pszBookMarks[0] = (pszBookMarks ? StrDup(pszBookMarks) : NULL); // LocalAlloc()
+ return true;
+ }
+ return false;
+}
+
+
+bool MRU_Delete(LPMRULIST pmru, int iIndex)
+{
+ if (pmru) {
+ int i;
+ if (iIndex < 0 || iIndex > pmru->iSize - 1) {
+ return false;
+ }
+ if (pmru->pszItems[iIndex]) {
+ LocalFree(pmru->pszItems[iIndex]); // StrDup()
+ }
+ if (pmru->pszBookMarks[iIndex]) {
+ LocalFree(pmru->pszBookMarks[iIndex]); // StrDup()
+ }
+ for (i = iIndex; i < pmru->iSize - 1; i++) {
+ pmru->pszItems[i] = pmru->pszItems[i + 1];
+ pmru->iEncoding[i] = pmru->iEncoding[i + 1];
+ pmru->iCaretPos[i] = pmru->iCaretPos[i + 1];
+ pmru->pszBookMarks[i] = pmru->pszBookMarks[i + 1];
+
+ pmru->pszItems[i + 1] = NULL;
+ pmru->iEncoding[i + 1] = 0;
+ pmru->iCaretPos[i + 1] = 0;
+ pmru->pszBookMarks[i + 1] = NULL;
+ }
+ return true;
+ }
+ return false;
+}
+
+
+bool MRU_Empty(LPMRULIST pmru)
+{
+ if (pmru) {
+ for (int i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i]) {
+ LocalFree(pmru->pszItems[i]); // StrDup()
+ pmru->pszItems[i] = NULL;
+ pmru->iEncoding[i] = 0;
+ pmru->iCaretPos[i] = 0;
+ if (pmru->pszBookMarks[i]) {
+ LocalFree(pmru->pszBookMarks[i]); // StrDup()
+ }
+ pmru->pszBookMarks[i] = NULL;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+
+int MRU_Enum(LPMRULIST pmru, int iIndex, LPWSTR pszItem, int cchItem)
+{
+ if (pmru) {
+ if (pszItem == NULL || cchItem == 0) {
+ int i = 0;
+ while (i < pmru->iSize && pmru->pszItems[i]) { ++i; }
+ return(i);
+ }
+ if (iIndex < 0 || iIndex > pmru->iSize - 1 || !pmru->pszItems[iIndex]) {
+ return(-1);
+ }
+ StringCchCopyN(pszItem, cchItem, pmru->pszItems[iIndex], cchItem);
+ return((int)StringCchLen(pszItem, cchItem));
+ }
+ return 0;
+}
+
+
+bool MRU_Load(LPMRULIST pmru)
+{
+ if (pmru)
+ {
+ MRU_Empty(pmru);
+
+ const WCHAR* const RegKey_Section = pmru->szRegKey;
+
+ int n = 0;
+ for (int i = 0; i < pmru->iSize; i++) {
+ WCHAR tchName[32] = { L'\0' };
+ StringCchPrintf(tchName, COUNTOF(tchName), L"%.2i", i + 1);
+ WCHAR tchItem[2048] = { L'\0' };
+ if (IniSectionGetString(RegKey_Section, tchName, L"", tchItem, COUNTOF(tchItem))) {
+ size_t const len = StringCchLen(tchItem, 0);
+ if ((len > 0) && (tchItem[0] == L'"') && (tchItem[len - 1] == L'"')) {
+ MoveMemory(tchItem, (tchItem + 1), len * sizeof(WCHAR));
+ tchItem[len - 2] = L'\0'; // clear dangling '"'
+ }
+ pmru->pszItems[n] = StrDup(tchItem);
+
+ StringCchPrintf(tchName, COUNTOF(tchName), L"ENC%.2i", i + 1);
+ int const iCP = (cpi_enc_t)IniSectionGetInt(RegKey_Section, tchName, 0);
+ pmru->iEncoding[n] = (cpi_enc_t)Encoding_MapIniSetting(true, iCP);
+
+ StringCchPrintf(tchName, COUNTOF(tchName), L"POS%.2i", i + 1);
+ pmru->iCaretPos[n] = (Settings.PreserveCaretPos) ? IniSectionGetInt(RegKey_Section, tchName, 0) : 0;
+
+ StringCchPrintf(tchName, COUNTOF(tchName), L"BMRK%.2i", i + 1);
+
+ WCHAR wchBookMarks[MRU_BMRK_SIZE] = { L'\0' };
+ IniSectionGetString(RegKey_Section, tchName, L"", wchBookMarks, COUNTOF(wchBookMarks));
+ pmru->pszBookMarks[n] = StrDup(wchBookMarks);
+
+ ++n;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+
+bool MRU_Save(LPMRULIST pmru)
+{
+ if (s_bSettingsIniFileOpend) {
+ if (pmru) {
+ WCHAR tchName[32] = { L'\0' };
+ WCHAR tchItem[2048] = { L'\0' };
+
+ const WCHAR* const RegKey_Section = pmru->szRegKey;
+ IniSectionClear(pmru->szRegKey, false);
+
+ for (int i = 0; i < pmru->iSize; i++) {
+ if (pmru->pszItems[i]) {
+ StringCchPrintf(tchName, COUNTOF(tchName), L"%.2i", i + 1);
+ StringCchPrintf(tchItem, COUNTOF(tchItem), L"\"%s\"", pmru->pszItems[i]);
+ IniSectionSetString(RegKey_Section, tchName, tchItem);
+
+ if (pmru->iEncoding[i] > 0) {
+ StringCchPrintf(tchName, COUNTOF(tchName), L"ENC%.2i", i + 1);
+ int const iCP = (int)Encoding_MapIniSetting(false, (int)pmru->iEncoding[i]);
+ IniSectionSetInt(RegKey_Section, tchName, iCP);
+ }
+ if (pmru->iCaretPos[i] > 0) {
+ StringCchPrintf(tchName, COUNTOF(tchName), L"POS%.2i", i + 1);
+ IniSectionSetPos(RegKey_Section, tchName, pmru->iCaretPos[i]);
+ }
+ if (pmru->pszBookMarks[i] && (StringCchLenW(pmru->pszBookMarks[i], MRU_BMRK_SIZE) > 0)) {
+ StringCchPrintf(tchName, COUNTOF(tchName), L"BMRK%.2i", i + 1);
+ IniSectionSetString(RegKey_Section, tchName, pmru->pszBookMarks[i]);
+ }
+ }
+ }
+ }
+ }
+ return s_bSettingsIniFileOpend;
+}
+
+
+bool MRU_MergeSave(LPMRULIST pmru, bool bAddFiles, bool bRelativePath, bool bUnexpandMyDocs)
+{
+ if (pmru) {
+ int i;
+ LPMRULIST pmruBase;
+
+ pmruBase = MRU_Create(pmru->szRegKey, pmru->iFlags, pmru->iSize);
+ MRU_Load(pmruBase);
+
+ if (bAddFiles) {
+ for (i = pmru->iSize - 1; i >= 0; i--) {
+ if (pmru->pszItems[i]) {
+ WCHAR wchItem[MAX_PATH] = { L'\0' };
+ PathAbsoluteFromApp(pmru->pszItems[i], wchItem, COUNTOF(wchItem), true);
+ MRU_AddFile(pmruBase, wchItem, bRelativePath, bUnexpandMyDocs,
+ pmru->iEncoding[i], pmru->iCaretPos[i], pmru->pszBookMarks[i]);
+ }
+ }
+ }
+ else {
+ for (i = pmru->iSize - 1; i >= 0; i--) {
+ if (pmru->pszItems[i])
+ MRU_Add(pmruBase, pmru->pszItems[i],
+ pmru->iEncoding[i], pmru->iCaretPos[i], pmru->pszBookMarks[i]);
+ }
+ }
+
+ MRU_Save(pmruBase);
+ MRU_Destroy(pmruBase);
+ pmruBase = NULL;
+ return true;
+ }
+ return false;
+}
+
diff --git a/src/Config/Config.h b/src/Config/Config.h
index 94e9a805e..92c499917 100644
--- a/src/Config/Config.h
+++ b/src/Config/Config.h
@@ -27,11 +27,15 @@ extern "C" {
bool FindIniFile();
int TestIniFile();
-bool CreateIniFile();
+bool CreateIniFile();
bool CreateIniFileEx(LPCWSTR lpszIniFile);
+
void LoadSettings();
void LoadFlags();
+
+bool OpenSettingsFile();
bool SaveSettings(bool);
+bool CloseSettingsFile();
// ----------------------------------------------------------------------------
@@ -108,10 +112,23 @@ bool IniFileDelete(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR lpKeyName,
typedef void (CALLBACK* IterSectionFunc_t)(LPCWSTR key, LPCWSTR value);
bool IniFileIterateSection(LPCWSTR lpFilePath, LPCWSTR lpSectionName, IterSectionFunc_t callBack);
+//==== MRU Functions ==========================================================
+
+LPMRULIST MRU_Create(LPCWSTR pszRegKey, int iFlags, int iSize);
+bool MRU_Destroy(LPMRULIST pmru);
+bool MRU_Add(LPMRULIST pmru, LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks);
+bool MRU_FindFile(LPMRULIST pmru, LPCWSTR pszFile, int* iIndex);
+bool MRU_AddFile(LPMRULIST pmru, LPCWSTR pszFile, bool, bool, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks);
+bool MRU_Delete(LPMRULIST pmru, int iIndex);
+bool MRU_Empty(LPMRULIST pmru);
+int MRU_Enum(LPMRULIST pmru, int iIndex, LPWSTR pszItem, int cchItem);
+bool MRU_Load(LPMRULIST pmru);
+bool MRU_Save(LPMRULIST pmru);
+bool MRU_MergeSave(LPMRULIST pmru, bool, bool, bool);
+#define MRU_Count(pmru) MRU_Enum((pmru), 0, NULL, 0)
// ----------------------------------------------------------------------------
-
#ifdef __cplusplus
}
#endif
diff --git a/src/Dialogs.c b/src/Dialogs.c
index 1fdcb9c6a..c64fa3714 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -1966,7 +1966,6 @@ static INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM
if ((IDOK == answer) || (IDYES == answer)) {
MRU_Delete(Globals.pFileMRU,lvi.iItem);
- MRU_DeleteFileFromStore(Globals.pFileMRU,tchFileName);
//SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0);
//ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem);
diff --git a/src/Helpers.c b/src/Helpers.c
index b705aa35c..d9bdf244f 100644
--- a/src/Helpers.c
+++ b/src/Helpers.c
@@ -1452,311 +1452,6 @@ UINT CharSetFromCodePage(UINT uCodePage) {
}
-//=============================================================================
-//
-// MRU functions
-//
-LPMRULIST MRU_Create(LPCWSTR pszRegKey,int iFlags,int iSize)
-{
- LPMRULIST pmru = AllocMem(sizeof(MRULIST), HEAP_ZERO_MEMORY);
- if (pmru) {
- ZeroMemory(pmru, sizeof(MRULIST));
- pmru->szRegKey = pszRegKey;
- pmru->iFlags = iFlags;
- pmru->iSize = min_i(iSize, MRU_MAXITEMS);
- }
- return(pmru);
-}
-
-bool MRU_Destroy(LPMRULIST pmru)
-{
- int i;
- for (i = 0; i < pmru->iSize; i++) {
- if (pmru->pszItems[i])
- LocalFree(pmru->pszItems[i]); // StrDup()
- if (pmru->pszBookMarks[i])
- LocalFree(pmru->pszBookMarks[i]); // StrDup()
- }
- ZeroMemory(pmru,sizeof(MRULIST));
- FreeMem(pmru);
- return true;
-}
-
-int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2)
-{
- if (pmru->iFlags & MRU_NOCASE) {
- return(StringCchCompareXI(psz1, psz2));
- }
- return(StringCchCompareX(psz1,psz2));
-}
-
-bool MRU_Add(LPMRULIST pmru, LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks)
-{
- int i;
- for (i = 0; i < pmru->iSize; i++) {
- if (MRU_Compare(pmru,pmru->pszItems[i],pszNew) == 0) {
- LocalFree(pmru->pszItems[i]); // StrDup()
- break;
- }
- }
- i = min_i(i,pmru->iSize-1);
- for (; i > 0; i--) {
- pmru->pszItems[i] = pmru->pszItems[i - 1];
- pmru->iEncoding[i] = pmru->iEncoding[i - 1];
- pmru->iCaretPos[i] = pmru->iCaretPos[i - 1];
- }
- pmru->pszItems[0] = StrDup(pszNew); // LocalAlloc()
-
- pmru->iEncoding[0] = iEnc;
- pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : 0);
- pmru->pszBookMarks[0] = (pszBookMarks ? StrDup(pszBookMarks) : NULL); // LocalAlloc()
- return true;
-}
-
-bool MRU_FindFile(LPMRULIST pmru,LPCWSTR pszFile,int* iIndex) {
- WCHAR wchItem[MAX_PATH] = { L'\0' };
- int i;
- for (i = 0; i < pmru->iSize; i++) {
- if (pmru->pszItems[i] == NULL) {
- *iIndex = i;
- return false;
- }
- if (StringCchCompareXI(pmru->pszItems[i],pszFile) == 0) {
- *iIndex = i;
- return true;
- }
- PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),true);
- if (StringCchCompareXI(wchItem,pszFile) == 0) {
- *iIndex = i;
- return true;
- }
- }
- *iIndex = i;
- return false;
-}
-
-bool MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,bool bRelativePath,bool bUnexpandMyDocs,
- cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks) {
-
- int i = 0;
- if (MRU_FindFile(pmru,pszFile,&i)) {
- LocalFree(pmru->pszItems[i]); // StrDup()
- }
- else {
- i = (i < pmru->iSize) ? i : (pmru->iSize - 1);
- }
- for (; i > 0; i--) {
- pmru->pszItems[i] = pmru->pszItems[i-1];
- pmru->iEncoding[i] = pmru->iEncoding[i-1];
- pmru->iCaretPos[i] = pmru->iCaretPos[i-1];
- pmru->pszBookMarks[i] = pmru->pszBookMarks[i-1];
- }
- if (bRelativePath) {
- WCHAR wchFile[MAX_PATH] = { L'\0' };
- PathRelativeToApp((LPWSTR)pszFile,wchFile,COUNTOF(wchFile),true,true,bUnexpandMyDocs);
- pmru->pszItems[0] = StrDup(wchFile); // LocalAlloc()
- }
- else {
- pmru->pszItems[0] = StrDup(pszFile); // LocalAlloc()
- }
- pmru->iEncoding[0] = iEnc;
- pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : 0);
- pmru->pszBookMarks[0] = (pszBookMarks ? StrDup(pszBookMarks) : NULL); // LocalAlloc()
-
- return true;
-}
-
-bool MRU_Delete(LPMRULIST pmru,int iIndex) {
-
- int i;
- if (iIndex < 0 || iIndex > pmru->iSize - 1) {
- return false;
- }
- if (pmru->pszItems[iIndex]) {
- LocalFree(pmru->pszItems[iIndex]); // StrDup()
- }
- if (pmru->pszBookMarks[iIndex]) {
- LocalFree(pmru->pszBookMarks[iIndex]); // StrDup()
- }
- for (i = iIndex; i < pmru->iSize-1; i++) {
- pmru->pszItems[i] = pmru->pszItems[i+1];
- pmru->iEncoding[i] = pmru->iEncoding[i+1];
- pmru->iCaretPos[i] = pmru->iCaretPos[i+1];
- pmru->pszBookMarks[i] = pmru->pszBookMarks[i+1];
-
- pmru->pszItems[i+1] = NULL;
- pmru->iEncoding[i+1] = 0;
- pmru->iCaretPos[i+1] = 0;
- pmru->pszBookMarks[i+1] = NULL;
- }
- return true;
-}
-
-bool MRU_DeleteFileFromStore(LPMRULIST pmru,LPCWSTR pszFile) {
-
- int i = 0;
- LPMRULIST pmruStore;
- WCHAR wchItem[MAX_PATH] = { L'\0' };
-
- pmruStore = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize);
- MRU_Load(pmruStore);
-
- while (MRU_Enum(pmruStore,i,wchItem,COUNTOF(wchItem)) != -1)
- {
- PathAbsoluteFromApp(wchItem,wchItem,COUNTOF(wchItem),true);
- if (StringCchCompareXI(wchItem,pszFile) == 0)
- MRU_Delete(pmruStore,i);
- else
- i++;
- }
- MRU_Save(pmruStore);
- MRU_Destroy(pmruStore);
- return true;
-}
-
-bool MRU_Empty(LPMRULIST pmru)
-{
- for (int i = 0; i < pmru->iSize; i++) {
- if (pmru->pszItems[i]) {
- LocalFree(pmru->pszItems[i]); // StrDup()
- pmru->pszItems[i] = NULL;
- pmru->iEncoding[i] = 0;
- pmru->iCaretPos[i] = 0;
- if (pmru->pszBookMarks[i]) {
- LocalFree(pmru->pszBookMarks[i]); // StrDup()
- }
- pmru->pszBookMarks[i] = NULL;
- }
- }
- return true;
-}
-
-int MRU_Enum(LPMRULIST pmru, int iIndex, LPWSTR pszItem, int cchItem)
-{
- if (pszItem == NULL || cchItem == 0) {
- int i = 0;
- while (i < pmru->iSize && pmru->pszItems[i]) { ++i; }
- return(i);
- }
- if (iIndex < 0 || iIndex > pmru->iSize - 1 || !pmru->pszItems[iIndex]) {
- return(-1);
- }
- StringCchCopyN(pszItem, cchItem, pmru->pszItems[iIndex], cchItem);
- return((int)StringCchLen(pszItem, cchItem));
-}
-
-
-bool MRU_Load(LPMRULIST pmru)
-{
- MRU_Empty(pmru);
- LoadIniFile(Globals.IniFile);
-
- const WCHAR* const RegKey_Section = pmru->szRegKey;
-
- int n = 0;
- for (int i = 0; i < pmru->iSize; i++) {
- WCHAR tchName[32] = { L'\0' };
- StringCchPrintf(tchName, COUNTOF(tchName), L"%.2i", i + 1);
- WCHAR tchItem[2048] = { L'\0' };
- if (IniSectionGetString(RegKey_Section, tchName, L"", tchItem, COUNTOF(tchItem))) {
- size_t const len = StringCchLen(tchItem, 0);
- if ((len > 0) && (tchItem[0] == L'"') && (tchItem[len-1] == L'"')) {
- MoveMemory(tchItem, (tchItem+1), len * sizeof(WCHAR));
- tchItem[len - 2] = L'\0'; // clear dangling '"'
- }
- pmru->pszItems[n] = StrDup(tchItem);
-
- StringCchPrintf(tchName, COUNTOF(tchName), L"ENC%.2i", i + 1);
- int const iCP = (cpi_enc_t)IniSectionGetInt(RegKey_Section, tchName, 0);
- pmru->iEncoding[n] = (cpi_enc_t)Encoding_MapIniSetting(true, iCP);
-
- StringCchPrintf(tchName, COUNTOF(tchName), L"POS%.2i", i + 1);
- pmru->iCaretPos[n] = (Settings.PreserveCaretPos) ? IniSectionGetInt(RegKey_Section, tchName, 0) : 0;
-
- StringCchPrintf(tchName, COUNTOF(tchName), L"BMRK%.2i", i + 1);
-
- WCHAR wchBookMarks[MRU_BMRK_SIZE] = { L'\0' };
- IniSectionGetString(RegKey_Section, tchName, L"", wchBookMarks, COUNTOF(wchBookMarks));
- pmru->pszBookMarks[n] = StrDup(wchBookMarks);
-
- ++n;
- }
- }
- ReleaseIniFile();
- return true;
-}
-
-bool MRU_Save(LPMRULIST pmru)
-{
- if (LoadIniFile(Globals.IniFile)) {
-
- WCHAR tchName[32] = { L'\0' };
- WCHAR tchItem[2048] = { L'\0' };
-
- const WCHAR* const RegKey_Section = pmru->szRegKey;
- IniSectionClear(pmru->szRegKey, false);
-
- for (int i = 0; i < pmru->iSize; i++) {
- if (pmru->pszItems[i]) {
- StringCchPrintf(tchName, COUNTOF(tchName), L"%.2i", i + 1);
- StringCchPrintf(tchItem, COUNTOF(tchItem), L"\"%s\"", pmru->pszItems[i]);
- IniSectionSetString(RegKey_Section, tchName, tchItem);
-
- if (pmru->iEncoding[i] > 0) {
- StringCchPrintf(tchName, COUNTOF(tchName), L"ENC%.2i", i + 1);
- int const iCP = (int)Encoding_MapIniSetting(false, (int)pmru->iEncoding[i]);
- IniSectionSetInt(RegKey_Section, tchName, iCP);
- }
- if (pmru->iCaretPos[i] > 0) {
- StringCchPrintf(tchName, COUNTOF(tchName), L"POS%.2i", i + 1);
- IniSectionSetPos(RegKey_Section, tchName, pmru->iCaretPos[i]);
- }
- if (pmru->pszBookMarks[i] && (StringCchLenW(pmru->pszBookMarks[i], MRU_BMRK_SIZE) > 0)) {
- StringCchPrintf(tchName, COUNTOF(tchName), L"BMRK%.2i", i + 1);
- IniSectionSetString(RegKey_Section, tchName, pmru->pszBookMarks[i]);
- }
- }
- }
-
- SaveIniFile(Globals.IniFile);
- return true;
- }
- return false;
-}
-
-
-bool MRU_MergeSave(LPMRULIST pmru,bool bAddFiles,bool bRelativePath,bool bUnexpandMyDocs) {
-
- int i;
- LPMRULIST pmruBase;
-
- pmruBase = MRU_Create(pmru->szRegKey,pmru->iFlags,pmru->iSize);
- MRU_Load(pmruBase);
-
- if (bAddFiles) {
- for (i = pmru->iSize-1; i >= 0; i--) {
- if (pmru->pszItems[i]) {
- WCHAR wchItem[MAX_PATH] = { L'\0' };
- PathAbsoluteFromApp(pmru->pszItems[i],wchItem,COUNTOF(wchItem),true);
- MRU_AddFile(pmruBase,wchItem,bRelativePath,bUnexpandMyDocs,
- pmru->iEncoding[i],pmru->iCaretPos[i],pmru->pszBookMarks[i]);
- }
- }
- }
- else {
- for (i = pmru->iSize-1; i >= 0; i--) {
- if (pmru->pszItems[i])
- MRU_Add(pmruBase,pmru->pszItems[i],
- pmru->iEncoding[i],pmru->iCaretPos[i],pmru->pszBookMarks[i]);
- }
- }
-
- MRU_Save(pmruBase);
- MRU_Destroy(pmruBase);
- return true;
-}
-
-
/** ******************************************************************************
*
* UnSlash functions
diff --git a/src/Helpers.h b/src/Helpers.h
index f87dc663c..52827f67b 100644
--- a/src/Helpers.h
+++ b/src/Helpers.h
@@ -20,6 +20,7 @@
#include
#include
+#include
#include
// ============================================================================
@@ -332,22 +333,6 @@ UINT CodePageFromCharSet(UINT uCharSet);
UINT CharSetFromCodePage(UINT uCodePage);
-//==== MRU Functions ==========================================================
-
-LPMRULIST MRU_Create(LPCWSTR pszRegKey,int iFlags,int iSize);
-bool MRU_Destroy(LPMRULIST pmru);
-bool MRU_Add(LPMRULIST pmru, LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks);
-bool MRU_FindFile(LPMRULIST pmru,LPCWSTR pszFile,int* iIndex);
-bool MRU_AddFile(LPMRULIST pmru, LPCWSTR pszFile, bool, bool, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks);
-bool MRU_Delete(LPMRULIST pmru,int iIndex);
-bool MRU_DeleteFileFromStore(LPMRULIST pmru,LPCWSTR pszFile);
-bool MRU_Empty(LPMRULIST pmru);
-int MRU_Enum(LPMRULIST pmru,int iIndex,LPWSTR pszItem,int cchItem);
-bool MRU_Load(LPMRULIST pmru);
-bool MRU_Save(LPMRULIST pmru);
-bool MRU_MergeSave(LPMRULIST pmru,bool,bool,bool);
-#define MRU_Count(pmru) MRU_Enum((pmru), 0, NULL, 0)
-
//==== UnSlash Functions ======================================================
unsigned int UnSlash(char* s, UINT cpEdit);
void TransformBackslashes(char* pszInput,bool,UINT cpEdit,int* iReplaceMsg);
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 023e3f920..ffa94c06a 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -52,6 +52,7 @@ CONSTANTS_T const Constants = {
2 // StdDefaultLexerID
, L"minipath.exe" // FileBrowserMiniPath
, L"Suppressed Messages" // SectionSuppressedMessages
+ , L"ThemeFileName" // StylingThemeName
};
FLAGS_T Flags;
@@ -117,10 +118,6 @@ static LPWSTR s_lpFileList[FILE_LIST_SIZE] = { NULL };
static int s_cFileList = 0;
static int s_cchiFileList = 0;
-static WCHAR* const _s_RecentFiles = L"Recent Files";
-static WCHAR* const _s_RecentFind = L"Recent Find";
-static WCHAR* const _s_RecentReplace = L"Recent Replace";
-
static WCHAR s_tchLastSaveCopyDir[MAX_PATH] = { L'\0' };
static bool s_bRunningWatch = false;
@@ -627,6 +624,9 @@ static void _InitGlobals()
ZeroMemory(&(Globals.fvBackup), sizeof(FILEVARS));
Globals.hMainMenu = NULL;
+ Globals.pFileMRU = NULL;
+ Globals.pMRUfind = NULL;
+ Globals.pMRUreplace = NULL;
Globals.CallTipType = CT_NONE;
Globals.iAvailLngCount = 1;
Globals.iWrapCol = 0;
@@ -643,6 +643,7 @@ static void _InitGlobals()
Globals.bReplaceInitialized = false;
Globals.FindReplaceMatchFoundState = FND_NOP;
Globals.bDocHasInconsistentEOLs = false;
+ Globals.idxSelectedTheme = 1; // Default(0), Standard(1)
Flags.bDevDebugMode = DefaultFlags.bDevDebugMode = false;
Flags.bStickyWindowPosition = DefaultFlags.bStickyWindowPosition = false;
@@ -1605,11 +1606,56 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
//
bool SaveAllSettings(bool bSaveSettingsNow)
{
+ if (s_flagDoRelaunchElevated) { return true; } // already saved before relaunch
+
WCHAR tchMsg[80];
GetLngString(IDS_MUI_SAVINGSETTINGS, tchMsg, COUNTOF(tchMsg));
BeginWaitCursor(tchMsg);
+
+ bool ok = OpenSettingsFile();
- bool const ok = SaveSettings(bSaveSettingsNow);
+ if (ok) {
+
+ ok = SaveSettings(bSaveSettingsNow);
+
+ if (StrIsNotEmpty(Globals.IniFile))
+ {
+ // Cleanup unwanted MRU'selEmpty
+ if (!Settings.SaveRecentFiles) {
+ MRU_Empty(Globals.pFileMRU);
+ MRU_Save(Globals.pFileMRU);
+ }
+ else {
+ MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs);
+ }
+ MRU_Destroy(Globals.pFileMRU);
+ Globals.pFileMRU = NULL;
+
+ if (!Settings.SaveFindReplace) {
+ MRU_Empty(Globals.pMRUfind);
+ MRU_Empty(Globals.pMRUreplace);
+ MRU_Save(Globals.pMRUfind);
+ MRU_Save(Globals.pMRUreplace);
+ }
+ else {
+ MRU_MergeSave(Globals.pMRUfind, false, false, false);
+ MRU_MergeSave(Globals.pMRUreplace, false, false, false);
+ }
+ MRU_Destroy(Globals.pMRUfind);
+ Globals.pMRUfind = NULL;
+ MRU_Destroy(Globals.pMRUreplace);
+ Globals.pMRUreplace = NULL;
+ }
+ }
+
+ if (ok) {
+ ok = CloseSettingsFile();
+ }
+
+ // separate INI files for Style-Themes
+ if (Globals.idxSelectedTheme >= 2) {
+ Style_SaveSettings();
+ }
EndWaitCursor();
return ok;
@@ -2007,17 +2053,6 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam)
pDropTarget = RegisterDragAndDrop(hwnd, &cfDrpF, 1, WM_NULL, DropFilesProc, (void*)Globals.hwndEdit);
#endif
- // File MRU
- Globals.pFileMRU = MRU_Create(_s_RecentFiles, MRU_NOCASE, MRU_ITEMSFILE);
- MRU_Load(Globals.pFileMRU);
-
- Globals.pMRUfind = MRU_Create(_s_RecentFind, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
- MRU_Load(Globals.pMRUfind);
- SetFindPattern(Globals.pMRUfind->pszItems[0]);
-
- Globals.pMRUreplace = MRU_Create(_s_RecentReplace, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
- MRU_Load(Globals.pMRUreplace);
-
if (Globals.hwndEdit == NULL || s_hwndEditFrame == NULL ||
Globals.hwndStatus == NULL || Globals.hwndToolbar == NULL || s_hwndReBar == NULL) {
return -1LL;
@@ -2455,35 +2490,9 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
DestroyWindow(Globals.hwndDlgCustomizeSchemes);
}
- // call SaveSettings() when Globals.hwndToolbar is still valid
+ // call SaveAllSettings() when Globals.hwndToolbar is still valid
SaveAllSettings(false);
- if (StrIsNotEmpty(Globals.IniFile))
- {
- // Cleanup unwanted MRU'selEmpty
- if (!Settings.SaveRecentFiles) {
- MRU_Empty(Globals.pFileMRU);
- MRU_Save(Globals.pFileMRU);
- }
- else {
- MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs);
- }
- MRU_Destroy(Globals.pFileMRU);
-
- if (!Settings.SaveFindReplace) {
- MRU_Empty(Globals.pMRUfind);
- MRU_Empty(Globals.pMRUreplace);
- MRU_Save(Globals.pMRUfind);
- MRU_Save(Globals.pMRUreplace);
- }
- else {
- MRU_MergeSave(Globals.pMRUfind, false, false, false);
- MRU_MergeSave(Globals.pMRUreplace, false, false, false);
- }
- MRU_Destroy(Globals.pMRUfind);
- MRU_Destroy(Globals.pMRUreplace);
- }
-
// Remove tray icon if necessary
ShowNotifyIcon(hwnd, false);
@@ -3596,7 +3605,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_FILE_NEWWINDOW:
case IDM_FILE_NEWWINDOW2:
- //~SaveAllSettings(false);
+ SaveAllSettings(false);
DialogNewWindow(hwnd, Settings.SaveBeforeRunningTools, (iLoWParam != IDM_FILE_NEWWINDOW2));
break;
@@ -9453,7 +9462,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
_END_UNDO_ACTION_
}
else {
- fSuccess = FileIO(true, szFileName, bSkipUnicodeDetect, bSkipANSICPDetection, bForceEncDetection, true, &fioStatus, false, false);
+ fSuccess = FileIO(true, szFileName, bSkipUnicodeDetect, bSkipANSICPDetection, bForceEncDetection, !s_IsThisAnElevatedRelaunch, &fioStatus, false, false);
}
}
@@ -9658,7 +9667,8 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc)
//
bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus)
{
- SaveSettings(false);
+ SaveAllSettings(false);
+
s_flagDoRelaunchElevated = true;
LPWSTR lpCmdLine = GetCommandLine();
diff --git a/src/Styles.c b/src/Styles.c
index 8d6f0adb7..52846093b 100644
--- a/src/Styles.c
+++ b/src/Styles.c
@@ -138,15 +138,7 @@ static int s_cyStyleSelectDlg = STYLESELECTDLG_Y;
//=============================================================================
-typedef struct _themeFiles
-{
- UINT rid;
- WCHAR szName[80];
- WCHAR szFilePath[MAX_PATH];
-
-} THEMEFILES, * PTHEMEFILES;
-
-static THEMEFILES Theme_Files[] =
+THEMEFILES Theme_Files[] =
{
{ 0, L"Default", L"" },
{ 0, L"Standard", L"" },
@@ -176,9 +168,6 @@ static THEMEFILES Theme_Files[] =
{ 0, L"", L"" }
};
unsigned ThemeItems_CountOf() { return COUNTOF(Theme_Files); }
-static unsigned s_idxSelectedTheme = 1; // Default(0), Standard(1)
-
-const WCHAR* const STYLING_THEME_NAME = L"ThemeFileName";
static void _FillThemesMenuTable()
{
@@ -282,17 +271,17 @@ bool Style_InsertThemesMenu(HMENU hMenuBar)
}
// --- insert ---
- WCHAR wchMenuItemStrg[80] = { L'\0' };
+ WCHAR wchMenuItemStrg[128] = { L'\0' };
GetLngString(IDS_MUI_MENU_THEMES, wchMenuItemStrg, COUNTOF(wchMenuItemStrg));
//bool const res = InsertMenu(hMenuBar, pos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)s_hmenuThemes, wchMenuItemStrg);
bool const res = InsertMenu(hMenuBar, IDM_VIEW_SCHEMECONFIG, MF_BYCOMMAND | MF_POPUP | MF_STRING, (UINT_PTR)s_hmenuThemes, wchMenuItemStrg);
- CheckCmd(hMenuBar, Theme_Files[s_idxSelectedTheme].rid, true);
+ CheckCmd(hMenuBar, Theme_Files[Globals.idxSelectedTheme].rid, true);
- if (StrIsEmpty(Theme_Files[s_idxSelectedTheme].szFilePath))
+ if (StrIsEmpty(Theme_Files[Globals.idxSelectedTheme].szFilePath))
{
- EnableCmd(hMenuBar, Theme_Files[s_idxSelectedTheme].rid, false);
+ EnableCmd(hMenuBar, Theme_Files[Globals.idxSelectedTheme].rid, false);
}
return res;
@@ -317,15 +306,15 @@ void Style_DynamicThemesMenuCmd(int cmd, bool bEnableSaveSettings)
if ((iThemeIdx < 0) || (iThemeIdx >= ThemeItems_CountOf())) {
return;
}
- if (iThemeIdx == s_idxSelectedTheme) { return; }
+ if (iThemeIdx == Globals.idxSelectedTheme) { return; }
- CheckCmd(Globals.hMainMenu, Theme_Files[s_idxSelectedTheme].rid, false);
+ CheckCmd(Globals.hMainMenu, Theme_Files[Globals.idxSelectedTheme].rid, false);
if (Settings.SaveSettings) {
- if (s_idxSelectedTheme == 0) {
+ if (Globals.idxSelectedTheme == 0) {
// internal defaults
}
- else if (s_idxSelectedTheme == 1) {
+ else if (Globals.idxSelectedTheme == 1) {
if (bEnableSaveSettings) {
CreateIniFile();
if (StrIsNotEmpty(Globals.IniFile)) {
@@ -333,21 +322,22 @@ void Style_DynamicThemesMenuCmd(int cmd, bool bEnableSaveSettings)
}
}
}
- else if (PathFileExists(Theme_Files[s_idxSelectedTheme].szFilePath))
+ else if (PathFileExists(Theme_Files[Globals.idxSelectedTheme].szFilePath))
{
bool const bIndependentFromStandardSettings = true;
- Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, bIndependentFromStandardSettings);
+ Style_ExportToFile(Theme_Files[Globals.idxSelectedTheme].szFilePath, bIndependentFromStandardSettings);
}
}
- s_idxSelectedTheme = iThemeIdx;
+ Globals.idxSelectedTheme = iThemeIdx;
+ StringCchCopy(Globals.SelectedThemeName, COUNTOF(Globals.SelectedThemeName), Theme_Files[Globals.idxSelectedTheme].szName);
bool result = true;
- if ((s_idxSelectedTheme > 1) && PathFileExists(Theme_Files[s_idxSelectedTheme].szFilePath))
+ if ((Globals.idxSelectedTheme > 1) && PathFileExists(Theme_Files[Globals.idxSelectedTheme].szFilePath))
{
- result = Style_ImportFromFile(Theme_Files[s_idxSelectedTheme].szFilePath);
+ result = Style_ImportFromFile(Theme_Files[Globals.idxSelectedTheme].szFilePath);
}
- else if (s_idxSelectedTheme == 1) {
+ else if (Globals.idxSelectedTheme == 1) {
result = Style_ImportFromFile(Globals.IniFile);
}
else {
@@ -358,11 +348,11 @@ void Style_DynamicThemesMenuCmd(int cmd, bool bEnableSaveSettings)
Style_ResetCurrentLexer(Globals.hwndEdit);
SendWMSize(Globals.hwndMain, NULL);
UpdateUI();
- _EnableSchemeConfig(s_idxSelectedTheme != 0);
+ _EnableSchemeConfig(Globals.idxSelectedTheme != 0);
UpdateAllBars(true);
}
- CheckCmd(Globals.hMainMenu, Theme_Files[s_idxSelectedTheme].rid, true);
+ CheckCmd(Globals.hMainMenu, Theme_Files[Globals.idxSelectedTheme].rid, true);
}
@@ -489,19 +479,18 @@ void Style_Load()
_FillThemesMenuTable();
// get theme name from settings
- WCHAR wchThemeName[80];
- IniFileGetString(Globals.IniFile, L"Styles", STYLING_THEME_NAME, L"", wchThemeName, COUNTOF(wchThemeName));
unsigned iTheme = 1;
- if (StrIsNotEmpty(wchThemeName)) {
+ if (StrIsNotEmpty(Globals.SelectedThemeName)) {
for (; iTheme < ThemeItems_CountOf(); ++iTheme)
{
- if (StringCchCompareXI(wchThemeName, Theme_Files[iTheme].szName) == 0) { break; }
+ if (StringCchCompareXI(Globals.SelectedThemeName, Theme_Files[iTheme].szName) == 0) { break; }
}
}
- s_idxSelectedTheme = (iTheme < ThemeItems_CountOf()) ? iTheme : 1;
+ Globals.idxSelectedTheme = (iTheme < ThemeItems_CountOf()) ? iTheme : 1;
+ StringCchCopy(Globals.SelectedThemeName, COUNTOF(Globals.SelectedThemeName), Theme_Files[Globals.idxSelectedTheme].szName);
- Style_ImportFromFile(Theme_Files[s_idxSelectedTheme].szFilePath);
+ Style_ImportFromFile(Theme_Files[Globals.idxSelectedTheme].szFilePath);
}
@@ -653,18 +642,11 @@ bool Style_ImportFromFile(const WCHAR* szFile)
//=============================================================================
//
-// Style_Save()
+// Style_SaveSettings()
//
-void Style_Save()
+void Style_SaveSettings()
{
- Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, Globals.bIniFileFromScratch);
-
- if (s_idxSelectedTheme > 1) {
- IniFileSetString(Globals.IniFile, L"Styles", STYLING_THEME_NAME, Theme_Files[s_idxSelectedTheme].szName);
- }
- else {
- IniFileDelete(Globals.IniFile, L"Styles", STYLING_THEME_NAME, false);
- }
+ Style_ExportToFile(Theme_Files[Globals.idxSelectedTheme].szFilePath, Globals.bIniFileFromScratch);
}
@@ -705,7 +687,7 @@ bool Style_Export(HWND hwnd)
//=============================================================================
//
-// Style_Export()
+// Style_ToIniSection()
//
#define SAVE_STYLE_IF_NOT_EQ_DEFAULT(TYPE, VARNAME, VALUE, DEFAULT) \
@@ -714,7 +696,6 @@ bool Style_Export(HWND hwnd)
} else { \
IniSectionDelete(Styles_Section, _W(_STRG(VARNAME)), false); \
}
-// ----------------------------------------------------------------------------
void Style_ToIniSection(bool bForceAll)
@@ -818,7 +799,7 @@ void Style_ToIniSection(bool bForceAll)
bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
{
if (StrIsEmpty(szFile)) {
- if (s_idxSelectedTheme != 0) {
+ if (Globals.idxSelectedTheme != 0) {
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SETTINGSNOTSAVED);
}
return false;
@@ -4332,7 +4313,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
{
_ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected);
- if ((!bWarnedNoIniFile && StrIsEmpty(Theme_Files[s_idxSelectedTheme].szFilePath)) && (s_idxSelectedTheme > 0))
+ if ((!bWarnedNoIniFile && StrIsEmpty(Theme_Files[Globals.idxSelectedTheme].szFilePath)) && (Globals.idxSelectedTheme > 0))
{
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SETTINGSNOTSAVED);
bWarnedNoIniFile = true;
diff --git a/src/Styles.h b/src/Styles.h
index 4fb511d3c..9765f376a 100644
--- a/src/Styles.h
+++ b/src/Styles.h
@@ -32,7 +32,7 @@
void Style_Load();
bool Style_Import(HWND hwnd);
bool Style_ImportFromFile(const WCHAR* szFile);
-void Style_Save();
+void Style_SaveSettings();
bool Style_Export(HWND hwnd);
void Style_ToIniSection(bool bForceAll);
bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll);
diff --git a/src/TypeDefs.h b/src/TypeDefs.h
index 5a5db56c5..563f042d6 100644
--- a/src/TypeDefs.h
+++ b/src/TypeDefs.h
@@ -275,6 +275,7 @@ typedef struct _constants_t
int const StdDefaultLexerID; // Pure Text Files
const WCHAR* const FileBrowserMiniPath;
const WCHAR* const SectionSuppressedMessages;
+ const WCHAR* const StylingThemeName;
} CONSTANTS_T, *PCONSTANTS_T;
@@ -326,6 +327,8 @@ typedef struct _globals_t
bool bFindReplCopySelOrClip;
bool bReplaceInitialized;
bool bDocHasInconsistentEOLs;
+ unsigned idxSelectedTheme;
+ WCHAR SelectedThemeName[128];
FR_STATES FindReplaceMatchFoundState;
@@ -433,7 +436,7 @@ typedef struct _settings_t
int CustomSchemesDlgPosY;
bool MuteMessageBeep;
bool SplitUndoTypingSeqOnLnBreak;
-
+
RECT PrintMargin;
EDITFINDREPLACE EFR_Data;
WCHAR OpenWithDir[MAX_PATH];
@@ -596,6 +599,18 @@ typedef struct _docviewpos_t
#define INIT_DOCVIEWPOS { 0, 0, /*0, 0,*/ 0, 0, 0, 0, 0, false }
+//=============================================================================
+
+typedef struct _themeFiles
+{
+ UINT rid;
+ WCHAR szName[80];
+ WCHAR szFilePath[MAX_PATH];
+
+} THEMEFILES, * PTHEMEFILES;
+
+//=============================================================================
+
// --------- common defines --------
diff --git a/src/VersionEx.h b/src/VersionEx.h
index 6271c41ab..89a3d3681 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 913
-#define VERSION_BUILD 2632
+#define VERSION_REV 916
+#define VERSION_BUILD 2633
#define SCINTILLA_VER 420
#define ONIGURUMA_REGEX_VER 6.9.3
#define UCHARDET_VER 2018.09.27