Merge branch 'RC1' into DevNewFeatures

This commit is contained in:
Rainer Kottenhoff 2020-02-16 17:38:51 +01:00
commit 44c946cccd
8 changed files with 73 additions and 61 deletions

View File

@ -1 +1 @@
1
2

View File

@ -3,7 +3,7 @@
<assemblyIdentity
name="Notepad3"
processorArchitecture="*"
version="5.20.216.1"
version="5.20.216.2"
type="win32"
/>
<description>Notepad3 RC1</description>

View File

@ -74,7 +74,9 @@ static int s_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS;
// ----------------------------------------------------------------------------
constexpr bool SI_Success(const SI_Error rc) noexcept { return (rc >= SI_Error::SI_OK); };
constexpr bool SI_Success(const SI_Error rc) noexcept {
return ((rc == SI_Error::SI_OK) || (rc == SI_Error::SI_UPDATED) || (rc == SI_Error::SI_INSERTED));
};
// ============================================================================
@ -97,26 +99,21 @@ extern "C" bool IsIniFileLoaded()
return s_INI_Loaded;
}
extern "C" void ReleaseIniFile()
{
s_INI.Reset();
s_INI_Loaded = false;
}
extern "C" bool SaveIniFile(LPCWSTR lpIniFilePath)
{
s_INI.SetSpaces(s_bSetSpaces);
s_INI.SetMultiLine(s_bUseMultiLine);
SI_Error const rc = s_INI.SaveFile(lpIniFilePath, s_bWriteSIG);
if (SI_Success(rc)) {
s_INI.Reset(); // done
s_INI_Loaded = false;
}
ReleaseIniFile();
return SI_Success(rc);
}
extern "C" void ReleaseIniFile()
{
s_INI.Reset();
s_INI_Loaded = false;
s_INI.SetSpaces(s_bSetSpaces);
s_INI.SetMultiLine(s_bUseMultiLine);
}
//=============================================================================
//
@ -291,6 +288,7 @@ extern "C" size_t IniFileGetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LP
else {
StringCchCopyW(lpReturnedString, cchReturnedString, lpDefault);
}
Ini.Reset();
return StringCchLenW(lpReturnedString, cchReturnedString);
}
// ============================================================================
@ -308,8 +306,8 @@ extern "C" bool IniFileSetString(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCW
if (SI_Success(rc)) {
rc = Ini.SaveFile(lpFilePath, s_bWriteSIG);
}
Ini.Reset();
}
Ini.Reset();
return SI_Success(rc);
}
// ============================================================================
@ -325,6 +323,7 @@ extern "C" int IniFileGetInt(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWSTR
//assert(!bHasMultiple);
return iValue;
}
Ini.Reset();
return iDefault;
}
// ============================================================================
@ -355,6 +354,7 @@ extern "C" bool IniFileGetBool(LPCWSTR lpFilePath, LPCWSTR lpSectionName, LPCWST
//assert(!bHasMultiple);
return bValue;
}
Ini.Reset();
return bDefault;
}
// ============================================================================
@ -633,6 +633,22 @@ extern "C" bool CreateIniFileEx(LPWSTR lpszIniFile)
//=============================================================================
//=============================================================================
//
// OpenSettingsFile()
//
bool OpenSettingsFile()
{
if (StrIsNotEmpty(Globals.IniFile)) {
if (!IsIniFileLoaded()) {
CreateIniFile();
LoadIniFile(Globals.IniFile);
}
}
return IsIniFileLoaded();
}
//=============================================================================
//
@ -643,7 +659,7 @@ void LoadSettings()
{
CFG_VERSION const _ver = StrIsEmpty(Globals.IniFile) ? CFG_VER_CURRENT : CFG_VER_NONE;
LoadIniFile(Globals.IniFile);
OpenSettingsFile();
bool bDirtyFlag = false; // do we have to save the file on done
@ -1226,10 +1242,7 @@ void LoadSettings()
Globals.pMRUreplace = MRU_Create(_s_RecentReplace, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
MRU_Load(Globals.pMRUreplace);
if (bDirtyFlag) {
SaveIniFile(Globals.IniFile);
}
ReleaseIniFile();
CloseSettingsFile(bDirtyFlag);
// Scintilla Styles
Style_Load();
@ -1238,23 +1251,6 @@ void LoadSettings()
//=============================================================================
//
// OpenSettingsFile()
//
bool OpenSettingsFile()
{
if (StrIsNotEmpty(Globals.IniFile)) {
if (!IsIniFileLoaded()) {
CreateIniFile();
LoadIniFile(Globals.IniFile);
}
}
return IsIniFileLoaded();
}
//=============================================================================
//
// _SaveSettings()
@ -1268,6 +1264,13 @@ bool OpenSettingsFile()
IniSectionDelete(IniSecSettings, _W(_STRG(VARNAME)), false); \
}
#define SAVE_VALUE2_IF_NOT_EQ_DEFAULT2(TYPE, VARNAME) \
if (Settings2.VARNAME != Defaults2.VARNAME) { \
IniSectionSet##TYPE(IniSecSettings2, _W(_STRG(VARNAME)), Settings.VARNAME); \
} \
else { \
IniSectionDelete(IniSecSettings2, _W(_STRG(VARNAME)), false); \
}
static bool _SaveSettings(bool bForceSaveSettings)
{
@ -1500,6 +1503,10 @@ static bool _SaveSettings(bool bForceSaveSettings)
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, CustomSchemesDlgPosX);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, CustomSchemesDlgPosY);
// --------------------------------------------------------------------------
//const WCHAR* const IniSecSettings2 = Constants.Settings2_Section;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
const WCHAR* const IniSecWindow = Constants.Window_Section;
// --------------------------------------------------------------------------
@ -1594,7 +1601,7 @@ bool SaveAllSettings(bool bForceSaveSettings)
}
if (ok) {
ok = CloseSettingsFile();
ok = CloseSettingsFile(true);
}
// separate INI files for Style-Themes
@ -1612,20 +1619,16 @@ bool SaveAllSettings(bool bForceSaveSettings)
// CloseSettingsFile()
//
bool CloseSettingsFile()
bool CloseSettingsFile(bool bSaveChanges)
{
if (!IsIniFileLoaded() || StrIsEmpty(Globals.IniFile)) { return false; }
bool const ok = SaveIniFile(Globals.IniFile);
bool const ok = bSaveChanges ? SaveIniFile(Globals.IniFile) : true;
if (ok) {
Globals.bIniFileFromScratch = false;
}
// force filesystem cache to sync
FILE* fp = nullptr;
_wfopen_s(&fp, Globals.IniFile, L"rb");
if (fp) { fclose(fp); }
ReleaseIniFile();
return ok;
@ -1936,7 +1939,7 @@ void MRU_Save(LPMRULIST pmru)
}
}
if (bOpendByMe) {
CloseSettingsFile();
CloseSettingsFile(true);
}
}
}
@ -1976,7 +1979,7 @@ bool MRU_MergeSave(LPMRULIST pmru, bool bAddFiles, bool bRelativePath, bool bUne
pmruBase = NULL;
if (bOpendByMe) {
CloseSettingsFile();
CloseSettingsFile(true);
}
return true;
}

View File

@ -34,7 +34,7 @@ bool CreateIniFileEx(LPWSTR lpszIniFile);
bool OpenSettingsFile();
void LoadSettings();
bool SaveAllSettings(bool bForceSaveSettings);
bool CloseSettingsFile();
bool CloseSettingsFile(bool bSaveChanges);
// ----------------------------------------------------------------------------

View File

@ -2624,6 +2624,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::SaveFile(
#endif // __STDC_WANT_SECURE_LIB__
if (!fp) return SI_FILE;
SI_Error rc = SaveFile(fp, a_bAddSignature);
fflush(fp);
fclose(fp);
return rc;
}
@ -2684,6 +2685,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::SaveFile(
#endif // __STDC_WANT_SECURE_LIB__
if (!fp) return SI_Error::SI_FILE;
SI_Error rc = SaveFile(fp, a_bAddSignature);
fflush(fp);
fclose(fp);
return rc;
#else // !_WIN32 (therefore SI_CONVERT_ICU)

View File

@ -2168,7 +2168,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance)
if (Globals.hwndToolbar) { DestroyWindow(Globals.hwndToolbar); }
LoadIniFile(Globals.IniFile);
OpenSettingsFile();
bool bDirtyFlag = false;
Globals.hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle,
@ -2436,9 +2436,7 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance)
s_cyReBarFrame = s_bIsAppThemed ? 0 : 2;
if (bDirtyFlag) {
SaveIniFile(Globals.IniFile);
}
CloseSettingsFile(bDirtyFlag);
}
@ -5449,7 +5447,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
StringCchPrintf(tchMaximized, COUNTOF(tchMaximized), L"%ix%i Maximized", ResX, ResY);
StringCchPrintf(tchZoom, COUNTOF(tchZoom), L"%ix%i Zoom", ResX, ResY);
if (LoadIniFile(Globals.IniFile)) {
if (OpenSettingsFile()) {
const WCHAR* const IniSecWindow = Constants.Window_Section;
@ -5482,9 +5480,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
else {
IniSectionDelete(Constants.Settings2_Section, L"StickyWindowPosition", false);
}
SaveIniFile(Globals.IniFile);
}
CloseSettingsFile(true);
}
break;

View File

@ -799,7 +799,6 @@ void Style_ToIniSection(bool bForceAll)
//
// Style_ExportToFile()
//
bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
{
if (StrIsEmpty(szFile)) {
@ -809,11 +808,22 @@ bool Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
return false;
}
LoadIniFile(szFile); // reset
WCHAR szFilePathNorm[MAX_PATH] = { L'\0' };
StringCchCopy(szFilePathNorm, COUNTOF(szFilePathNorm), szFile);
NormalizePathEx(szFilePathNorm, COUNTOF(szFilePathNorm), true, false);
Style_ToIniSection(bForceAll);
return SaveIniFile(szFile);
bool ok = false;
if (StringCchCompareXI(szFilePathNorm, Globals.IniFile) == 0) {
ok = OpenSettingsFile();
Style_ToIniSection(bForceAll);
ok = CloseSettingsFile(true);
}
else {
LoadIniFile(szFilePathNorm); // reset
Style_ToIniSection(bForceAll);
SaveIniFile(szFilePathNorm);
}
return ok;
}

View File

@ -9,7 +9,7 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_REV 216
#define VERSION_BUILD 1
#define VERSION_BUILD 2
#define SCINTILLA_VER 430
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27