diff --git a/Build/Changes.txt b/Build/Changes.txt
index 028eec7d2..47085d0d0 100644
--- a/Build/Changes.txt
+++ b/Build/Changes.txt
@@ -13,7 +13,7 @@ LEGEND:
==================================================
==================================================
-Version 5.18.1103.1407 (3 November 2018)
+Version 5.18.1206.1448 (6 December 2018)
==================================================
--------------------------------------------------
@@ -48,6 +48,10 @@ CHANGES:
- Show Zoom Percentage on magnification changes
- Tidy Notepad3.ini to remove all defaulted [Setting] items
- Change Default settings to make the first experience of Notepad3 more attractive...
+- ANSI CodePage detection (CED) - allow less reliable results also
+- Open Find/Replace: Use most recent search pattern instead of clipboard (if selection eis empty)
+- Encoding affinity: UTF-8 instead of local ANSI code-page
+- Replace dialog: tmp disable "mark all occ" in case of multi-line selection
--------------------------------------------------
FIXES:
@@ -62,6 +66,8 @@ FIXES:
- In case of STD lexer only display "Default Text" in statusbar (indicator shows which one).
- Fixed resource file problem (preproc defines).
- Fixed save window Position (Default and Initial switch)
+- Fixed problem with bad brace highlighting (indicator)
+- if activated, ESC will close/minimize program immediately w/o canceling selection/tooltip first.
--------------------------------------------------
TRANSLATIONS (MUI):
diff --git a/language/common_res.rc b/language/common_res.rc
index cc5f6e7fa..3024858d2 100644
--- a/language/common_res.rc
+++ b/language/common_res.rc
@@ -68,12 +68,6 @@ IDR_RIZBITMAP BITMAP "rizonesoft.bmp"
IDC_COPY CURSOR "Copy.cur"
-// NOT able to get "RichEdit Friendly Name Hyperlinks" up and running :-/ (https://blogs.msdn.microsoft.com/murrays/2009/09/24/richedit-friendly-name-hyperlinks/)
-// ... "{\\field{\\*\\fldinst{HYPERLINK \"" VERSIONA_FILEVERSION_LONG "\"}}{\\fldrslt{https://www.rizonesoft.com/downloads/notepad3}}}\\par"
-
-//"\\viewkind4\\uc1\\pard\\cf1\\f0\\fs20\\b1 " VERSIONA_FILEVERSION_LONG " \\cf0\\uc0\\par"
-
-
STRINGTABLE
BEGIN
@@ -105,13 +99,14 @@ IDS_MUI_ABOUT_LIBS "\
\\cf0 Lewis Van Winkle (TinyExpr)\\tab https://github.com/codeplea/tinyexpr\\par\
\\cf0 \\par\
"
+
//
-// Caution: To correctly access the site "https://github.com/craigo-"
-// a No-Break Space " " (alt+0160) is added AFTER the "-" !
+// For "craigo-": to access the right site "https://github.com/craigo-",
+// a slash "/" is voluntarily added after the "craigo-" !
//
IDS_MUI_ABOUT_ACKNOWLEDGES "\
-\\cf0 craigo-\\tab https://github.com/craigo- \\par\
+\\cf0 craigo-\\tab https://github.com/craigo-/\\par\
\\cf0 lhmouse\\tab https://github.com/lhmouse\\par\
\\cf0 hpwamr\\tab https://github.com/hpwamr\\par\
\\cf0 engelhro\\tab https://github.com/engelhro\\par\
@@ -138,13 +133,6 @@ IDS_MUI_ABOUT_LICENSES "\
END
-//"\\trowd\\cellx4000\\cellx8000"
-//"\\intbl cell 1\\cell"
-//"\\intbl lots of text in cell two\\cell\\row"
-//"\\trowd\\cellx4000\\cellx8000"
-//"\\intbl row 2 cell 1\\cell"
-//"\\intbl lots of text in row 2 cell two\\cell\\row"
-
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html
index 9d5379468..0908fcc08 100644
--- a/scintilla/doc/ScintillaHistory.html
+++ b/scintilla/doc/ScintillaHistory.html
@@ -577,6 +577,11 @@
Bug #2054.
+ The C++ lexer interprets continued preprocessor lines correctly by reading all of
+ the logical line.
+ Bug #2062.
+
+
For SciTE's Find in Files, allow case-sensitivity and whole-word options when running
a user defined command.
Bug #2053.
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx
index 4f4a0f648..fbd3186c6 100644
--- a/scintilla/lexers/LexCPP.cxx
+++ b/scintilla/lexers/LexCPP.cxx
@@ -201,17 +201,27 @@ struct EscapeSequence {
std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpace) {
std::string restOfLine;
- Sci_Position i =0;
+ Sci_Position line = styler.GetLine(start);
+ Sci_Position pos = start;
+ Sci_Position endLine = styler.LineEnd(line);
char ch = styler.SafeGetCharAt(start, '\n');
- const Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
- while (((start+i) < endLine) && (ch != '\r')) {
- const char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
- if (ch == '/' && (chNext == '/' || chNext == '*'))
- break;
- if (allowSpace || (ch != ' '))
- restOfLine += ch;
- i++;
- ch = chNext;
+ while (pos < endLine) {
+ if (ch == '\\' && ((pos + 1) == endLine)) {
+ // Continuation line
+ line++;
+ pos = styler.LineStart(line);
+ endLine = styler.LineEnd(line);
+ ch = styler.SafeGetCharAt(pos, '\n');
+ } else {
+ const char chNext = styler.SafeGetCharAt(pos + 1, '\n');
+ if (ch == '/' && (chNext == '/' || chNext == '*'))
+ break;
+ if (allowSpace || (ch != ' ')) {
+ restOfLine += ch;
+ }
+ pos++;
+ ch = chNext;
+ }
}
return restOfLine;
}
diff --git a/src/Edit.c b/src/Edit.c
index 04d73be6b..e4c24369b 100644
--- a/src/Edit.c
+++ b/src/Edit.c
@@ -1054,7 +1054,7 @@ bool EditLoadFile(
size_t const cbNbytes4Analysis = (cbData < 200000L) ? cbData : 200000L;
int iPreferedEncoding = (bNfoDizDetected) ? g_DOSEncoding :
- ((Settings.UseDefaultForFileEncoding || (cbNbytes4Analysis == 0)) ? Settings.DefaultEncoding : CPI_ANSI_DEFAULT);
+ ((Settings.UseDefaultForFileEncoding || (cbNbytes4Analysis == 0)) ? Settings.DefaultEncoding : PREFERRED_DEFAULT_ENCODING);
// --------------------------------------------------------------------------
bool bIsReliable = false;
@@ -4998,7 +4998,7 @@ static void _DelayMarkAll(HWND hwnd, int delay, DocPos iStartPos)
//
// EditFindReplaceDlgProcW()
//
-static char g_lastFind[FNDRPL_BUFFER] = { L'\0' };
+static char s_lastFind[FNDRPL_BUFFER] = { L'\0' };
INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
@@ -5017,11 +5017,12 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
static int iSaveMarkOcc = -1;
static bool bSaveOccVisible = false;
-
static bool bSaveTFBackSlashes = false;
+ static bool _bRestoreMarkOcc = true;
WCHAR tchBuf[FNDRPL_BUFFER] = { L'\0' };
+
switch (umsg)
{
case WM_INITDIALOG:
@@ -5039,6 +5040,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
iSaveMarkOcc = s_bSwitchedFindReplace ? iSaveMarkOcc : Settings.MarkOccurrences;
bSaveOccVisible = s_bSwitchedFindReplace ? bSaveOccVisible : Settings.MarkOccurrencesMatchVisible;
+ _bRestoreMarkOcc = sg_pefrData->bMarkOccurences;
//const WORD wTabSpacing = (WORD)SendMessage(sg_pefrData->hwnd, SCI_GETTABWIDTH, 0, 0);; // dialog box units
//SendDlgItemMessage(hwnd, IDC_FINDTEXT, EM_SETTABSTOPS, 1, (LPARAM)&wTabSpacing);
@@ -5108,6 +5110,12 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
DialogEnableWindow(hwnd, IDC_DOT_MATCH_ALL, false);
}
+ // switch off "mark all occ" in case of initial replace dialog on multiline selection
+ if (GetDlgItem(hwnd, IDC_REPLACE) && !s_bSwitchedFindReplace) {
+ if (Sci_IsMultiLineSelection()) {
+ sg_pefrData->bMarkOccurences = false;
+ }
+ }
if (sg_pefrData->bMarkOccurences) {
Settings.MarkOccurrences = 0;
Settings.MarkOccurrencesMatchVisible = false;
@@ -5209,6 +5217,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
}
}
sg_pefrData->szFind[0] = '\0';
+ sg_pefrData->bMarkOccurences = _bRestoreMarkOcc;
Settings.MarkOccurrences = iSaveMarkOcc;
Settings.MarkOccurrencesMatchVisible = bSaveOccVisible;
@@ -5279,7 +5288,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
EditEnsureSelectionVisible(Globals.hwndEdit);
- DialogEnableWindow(hwnd, IDC_REPLACEINSEL, !SciCall_IsSelectionEmpty());
+ bool const bEnableReplInSel = !(SciCall_IsSelectionEmpty() || SciCall_IsSelectionRectangle());
+ DialogEnableWindow(hwnd, IDC_REPLACEINSEL, bEnableReplInSel);
break;
}
@@ -5315,16 +5325,23 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
}
else { // (cchSelection <= 1)
// nothing is selected in the editor:
- // if first time you bring up find/replace dialog,
- // copy content clipboard to find box
- char* pClip = EditGetClipboardText(hwnd, false, NULL, NULL);
- if (pClip) {
- size_t const len = StringCchLenA(pClip,0);
- if (len) {
- lpszSelection = AllocMem(len + 1, HEAP_ZERO_MEMORY);
- StringCchCopyNA(lpszSelection, len + 1, pClip, len);
+ // if first time you bring up find/replace dialog,
+ // use most recent search pattern to find box
+ GetFindPattern(tchBuf, FNDRPL_BUFFER);
+ if (tchBuf[0] == L'\0') {
+ MRU_Enum(Globals.pMRUfind, 0, tchBuf, COUNTOF(tchBuf));
+ }
+ // no recent find pattern: copy content clipboard to find box
+ if (tchBuf[0] == L'\0') {
+ char* pClip = EditGetClipboardText(hwnd, false, NULL, NULL);
+ if (pClip) {
+ size_t const len = StringCchLenA(pClip, 0);
+ if (len) {
+ lpszSelection = AllocMem(len + 1, HEAP_ZERO_MEMORY);
+ StringCchCopyNA(lpszSelection, len + 1, pClip, len);
+ }
+ FreeMem(pClip);
}
- FreeMem(pClip);
}
}
@@ -5365,13 +5382,13 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
StringCchCopyNA(szFind, FNDRPL_BUFFER, szCmpBuf, FNDRPL_BUFFER);
}
- bool bEnableF = (GetWindowTextLengthW(GetDlgItem(hwnd, IDC_FINDTEXT)) ||
+ bool const bEnableF = (GetWindowTextLengthW(GetDlgItem(hwnd, IDC_FINDTEXT)) ||
CB_ERR != SendDlgItemMessage(hwnd, IDC_FINDTEXT, CB_GETCURSEL, 0, 0));
- bool bEnableR = (GetWindowTextLengthW(GetDlgItem(hwnd, IDC_REPLACETEXT)) ||
+ bool const bEnableR = (GetWindowTextLengthW(GetDlgItem(hwnd, IDC_REPLACETEXT)) ||
CB_ERR != SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_GETCURSEL, 0, 0));
- bool bEnableIS = !(bool)SendMessage(Globals.hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0);
+ bool const bEnableIS = !(SciCall_IsSelectionEmpty() || SciCall_IsSelectionRectangle());
DialogEnableWindow(hwnd, IDOK, bEnableF);
DialogEnableWindow(hwnd, IDC_FINDPREV, bEnableF);
@@ -5398,10 +5415,10 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
{
_SetSearchFlags(hwnd, sg_pefrData);
if (sg_pefrData->bMarkOccurences) {
- if (sg_pefrData->bStateChanged || (StringCchCompareXA(g_lastFind, sg_pefrData->szFind) != 0)) {
+ if (sg_pefrData->bStateChanged || (StringCchCompareXA(s_lastFind, sg_pefrData->szFind) != 0)) {
_IGNORE_NOTIFY_CHANGE_;
if (EditToggleView(Globals.hwndEdit, false)) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); }
- StringCchCopyA(g_lastFind, COUNTOF(g_lastFind), sg_pefrData->szFind);
+ StringCchCopyA(s_lastFind, COUNTOF(s_lastFind), sg_pefrData->szFind);
RegExResult_t match = _FindHasMatch(Globals.hwndEdit, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false);
if (s_anyMatch != match) { s_anyMatch = match; }
// we have to set Sci's regex instance to first find (have substitution in place)
@@ -5438,6 +5455,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
{
iSaveMarkOcc = Settings.MarkOccurrences;
bSaveOccVisible = Settings.MarkOccurrencesMatchVisible;
+ _bRestoreMarkOcc = true;
Settings.MarkOccurrences = 0;
Settings.MarkOccurrencesMatchVisible = false;
@@ -5450,6 +5468,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
else { // switched OFF
Settings.MarkOccurrences = iSaveMarkOcc;
Settings.MarkOccurrencesMatchVisible = bSaveOccVisible;
+ _bRestoreMarkOcc = false;
//DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible);
DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, false);
if (EditToggleView(Globals.hwndEdit, false)) {
@@ -6926,8 +6945,6 @@ static bool _HighlightIfBrace(HWND hwnd, DocPos iPos)
// clear indicator
SciCall_BraceBadLight(INVALID_POSITION);
SciCall_SetHighLightGuide(0);
- if (!Settings2.UseOldStyleBraceMatching)
- SciCall_BraceBadLightIndicator(false, INDIC_NP3_BAD_BRACE);
return true;
}
@@ -6940,16 +6957,10 @@ static bool _HighlightIfBrace(HWND hwnd, DocPos iPos)
DocPos col2 = SciCall_GetColumn(iBrace2);
SciCall_BraceHighLight(iPos, iBrace2);
SciCall_SetHighLightGuide(min_i((int)col1, (int)col2));
- if (!Settings2.UseOldStyleBraceMatching) {
- SciCall_BraceHighLightIndicator(true, INDIC_NP3_MATCH_BRACE);
- }
}
else {
SciCall_BraceBadLight(iPos);
SciCall_SetHighLightGuide(0);
- if (!Settings2.UseOldStyleBraceMatching) {
- SciCall_BraceHighLightIndicator(true, INDIC_NP3_BAD_BRACE);
- }
}
return true;
}
diff --git a/src/Encoding.h b/src/Encoding.h
index dd0f96fbf..743e17bcd 100644
--- a/src/Encoding.h
+++ b/src/Encoding.h
@@ -56,6 +56,8 @@ extern bool g_bForceCompEncDetection;
#define Encoding_IsNONE(enc) ((enc) == CPI_NONE)
+//~#define PREFERRED_DAFAULT_ENCODING CPI_ANSI_DEFAULT
+#define PREFERRED_DEFAULT_ENCODING CPI_UTF8
typedef struct _np2encoding {
UINT uFlags;
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 634a21ac8..448a94d8e 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -85,8 +85,7 @@ static WCHAR s_wchTmpFilePath[MAX_PATH + 1] = { L'\0' };
static WCHAR* const s_tchAvailableLanguages = L"af-ZA be-BY de-DE es-ES en-GB fr-FR ja-JP nl-NL ru-RU zh-CN"; // en-US internal
-static int s_iSettingsVersion = CFG_VER_NONE;
-static bool s_bSaveSettings = true;
+static int s_iSettingsVersion = CFG_VER_CURRENT;
static bool s_bEnableSaveSettings = true;
static prefix_t s_mxSBPrefix[STATUS_SECTOR_COUNT];
@@ -1592,6 +1591,10 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl)
SendMessage(hwndEditCtrl, SCI_INDICSETFORE, INDIC_NP3_BAD_BRACE, RGB(0xFF, 0x00, 0x00));
SendMessage(hwndEditCtrl, SCI_INDICSETALPHA, INDIC_NP3_BAD_BRACE, 120);
SendMessage(hwndEditCtrl, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_BAD_BRACE, 120);
+ if (!Settings2.UseOldStyleBraceMatching) {
+ SendMessage(hwndEditCtrl, SCI_BRACEHIGHLIGHTINDICATOR, true, INDIC_NP3_MATCH_BRACE);
+ SendMessage(hwndEditCtrl, SCI_BRACEBADLIGHTINDICATOR, true, INDIC_NP3_BAD_BRACE);
+ }
// paste into rectangular selection
SendMessage(hwndEditCtrl, SCI_SETMULTIPASTE, SC_MULTIPASTE_EACH, 0);
@@ -2938,7 +2941,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND);
i = (int)StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile));
- CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,s_bSaveSettings && i);
+ CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,Settings.SaveSettings && i);
EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i);
EnableCmd(hmenu,IDM_VIEW_STICKYWINPOS,i);
@@ -4999,11 +5002,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_VIEW_SAVESETTINGS:
if (IsCmdEnabled(hwnd, IDM_VIEW_SAVESETTINGS)) {
- s_bSaveSettings = !s_bSaveSettings;
- if (s_bSaveSettings)
+ Settings.SaveSettings = !Settings.SaveSettings;
+ if (Settings.SaveSettings == Defaults.SaveSettings)
IniSetString(L"Settings", L"SaveSettings", NULL);
else
- IniSetBool(L"Settings", L"SaveSettings", s_bSaveSettings);
+ IniSetBool(L"Settings", L"SaveSettings", Settings.SaveSettings);
}
break;
@@ -5065,26 +5068,21 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case CMD_ESCAPE:
- if (SciCall_CallTipActive()) {
+ if (SciCall_CallTipActive() || SciCall_AutoCActive()) {
SciCall_CallTipCancel();
- break;
- }
- if (SciCall_AutoCActive()) {
SciCall_AutoCCancel();
- break;
}
- if (!SciCall_IsSelectionEmpty()) {
- DocPos const iCurPos = SciCall_GetCurrentPos();
- EditSetSelectionEx(Globals.hwndEdit, iCurPos, iCurPos, -1, -1);
- break;
- }
- if (Settings.EscFunction == 1) {
+ else if (Settings.EscFunction == 1) {
SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
}
else if (Settings.EscFunction == 2) {
PostMessage(hwnd, WM_CLOSE, 0, 0);
}
else {
+ if (!SciCall_IsSelectionEmpty()) {
+ DocPos const iCurPos = SciCall_GetCurrentPos();
+ EditSetSelectionEx(Globals.hwndEdit, iCurPos, iCurPos, -1, -1);
+ }
SciCall_Cancel();
}
break;
@@ -6607,9 +6605,11 @@ void LoadSettings()
if (pIniSection)
{
// prerequisites
- s_bSaveSettings = IniGetBool(L"Settings", L"SaveSettings", true);
s_iSettingsVersion = IniGetInt(L"Settings", L"SettingsVersion", CFG_VER_NONE);
+ Defaults.SaveSettings = true;
+ Settings.SaveSettings = IniGetBool(L"Settings", L"SaveSettings", Defaults.SaveSettings);
+
// first load "hard coded" .ini-Settings
// --------------------------------------------------------------------------
LoadIniSection(L"Settings2", pIniSection, cchIniSection);
@@ -6641,7 +6641,7 @@ void LoadSettings()
// deprecated
Defaults.RenderingTechnology = IniSectionGetInt(pIniSection, L"SciDirectWriteTech", -111);
- if ((Defaults.RenderingTechnology != -111) && s_bSaveSettings) {
+ if ((Defaults.RenderingTechnology != -111) && Settings.SaveSettings) {
// cleanup
IniSetString(L"Settings2", L"SciDirectWriteTech", NULL);
}
@@ -6649,7 +6649,7 @@ void LoadSettings()
// Settings2 deprecated
Defaults.Bidirectional = IniSectionGetInt(pIniSection, L"EnableBidirectionalSupport", -111);
- if ((Defaults.Bidirectional != -111) && s_bSaveSettings) {
+ if ((Defaults.Bidirectional != -111) && Settings.SaveSettings) {
// cleanup
IniSetString(L"Settings2", L"EnableBidirectionalSupport", NULL);
}
@@ -6744,11 +6744,11 @@ void LoadSettings()
// --------------------------------------------------------------------------
#define GET_BOOL_VALUE_FROM_INISECTION(VARNAME,DEFAULT) \
- Defaults.VARNAME = DEFAULT; \
+ Defaults.VARNAME = DEFAULT; \
Settings.VARNAME = IniSectionGetBool(pIniSection, STRGW(VARNAME), Defaults.VARNAME)
#define GET_INT_VALUE_FROM_INISECTION(VARNAME,DEFAULT,MIN,MAX) \
- Defaults.VARNAME = DEFAULT; \
+ Defaults.VARNAME = DEFAULT; \
Settings.VARNAME = clampi(IniSectionGetInt(pIniSection, STRGW(VARNAME), Defaults.VARNAME),MIN,MAX)
GET_BOOL_VALUE_FROM_INISECTION(SaveRecentFiles, true);
@@ -6837,15 +6837,15 @@ void LoadSettings()
GET_BOOL_VALUE_FROM_INISECTION(ViewWhiteSpace, false);
GET_BOOL_VALUE_FROM_INISECTION(ViewEOLs, false);
- GET_INT_VALUE_FROM_INISECTION(DefaultEncoding, CPI_ANSI_DEFAULT, CED_NO_MAPPING, INT_MAX);
- // if DefaultEncoding is not defined set to system's current code-page
+ int const iPrefEncIniSetting = Encoding_MapIniSetting(false, PREFERRED_DEFAULT_ENCODING);
+ GET_INT_VALUE_FROM_INISECTION(DefaultEncoding, iPrefEncIniSetting, CED_NO_MAPPING, Encoding_CountOf()-1);
Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ?
- Encoding_MapIniSetting(true, (int)GetACP()) : Encoding_MapIniSetting(true, Settings.DefaultEncoding));
+ PREFERRED_DEFAULT_ENCODING : Encoding_MapIniSetting(true, Settings.DefaultEncoding));
GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, false);
GET_BOOL_VALUE_FROM_INISECTION(SkipUnicodeDetection, false);
GET_BOOL_VALUE_FROM_INISECTION(SkipANSICodePageDetection, false);
- GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, false);
+ GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, true);
GET_BOOL_VALUE_FROM_INISECTION(LoadNFOasOEM, true);
GET_BOOL_VALUE_FROM_INISECTION(NoEncodingTags, false);
GET_INT_VALUE_FROM_INISECTION(DefaultEOLMode, SC_EOL_CRLF, SC_EOL_CRLF, SC_EOL_LF);
@@ -7077,7 +7077,7 @@ void LoadSettings()
// SaveSettings()
//
-#define SAVE_VALUE_IF_NOT_EQ_DEFAULT(TYPE,VARNAME) \
+#define SAVE_VALUE_IF_NOT_EQ_DEFAULT(TYPE,VARNAME) \
if (Settings.VARNAME != Defaults.VARNAME) { \
IniSectionSet##TYPE(pIniSection, STRGW(VARNAME), Settings.VARNAME); \
}
@@ -7093,8 +7093,11 @@ void SaveSettings(bool bSaveSettingsNow)
CreateIniFile();
- if (!(s_bSaveSettings || bSaveSettingsNow)) {
- IniSetBool(L"Settings", L"SaveSettings", s_bSaveSettings);
+ if (!(Settings.SaveSettings || bSaveSettingsNow)) {
+ IniSetInt(L"Settings", L"SettingsVersion", CFG_VER_CURRENT);
+ if (Settings.SaveSettings != Defaults.SaveSettings) {
+ IniSetBool(L"Settings", L"SaveSettings", Settings.SaveSettings);
+ }
return;
}
// update window placement
@@ -7107,10 +7110,11 @@ void SaveSettings(bool bSaveSettingsNow)
int const cchIniSection = INISECTIONBUFCNT * HUGE_BUFFER;
WCHAR *pIniSection = AllocMem(sizeof(WCHAR) * cchIniSection, HEAP_ZERO_MEMORY);
- if (pIniSection) {
+ if (pIniSection)
+ {
IniSectionSetInt(pIniSection, L"SettingsVersion", CFG_VER_CURRENT);
- IniSectionSetBool(pIniSection, L"SaveSettings", s_bSaveSettings);
+ SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveSettings);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveRecentFiles);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, PreserveCaretPos);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveFindReplace);
@@ -7200,9 +7204,10 @@ void SaveSettings(bool bSaveSettingsNow)
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ViewWhiteSpace);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ViewEOLs);
- if (Settings.DefaultEncoding != Defaults.DefaultEncoding) {
- IniSectionSetInt(pIniSection, L"DefaultEncoding", Encoding_MapIniSetting(false, Settings.DefaultEncoding));
- }
+ Settings.DefaultEncoding = Encoding_MapIniSetting(false, Settings.DefaultEncoding);
+ SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, DefaultEncoding);
+ Settings.DefaultEncoding = Encoding_MapIniSetting(true, Settings.DefaultEncoding);
+
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, UseDefaultForFileEncoding);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SkipUnicodeDetection);
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SkipANSICodePageDetection);
@@ -7905,8 +7910,8 @@ int FindIniFile() {
bFound = _CheckIniFile(tchPath,tchModule);
}
- if (bFound) {
-
+ if (bFound)
+ {
// allow two redirections: administrator -> user -> custom
if (_CheckIniFileRedirect(MKWCS(APPNAME), MKWCS(APPNAME) L".ini", tchPath, tchModule)) {
_CheckIniFileRedirect(MKWCS(APPNAME), MKWCS(APPNAME) L".ini", tchPath, tchModule);
@@ -8834,7 +8839,7 @@ void UpdateSettingsCmds()
{
HMENU hmenu = GetSystemMenu(Globals.hwndMain, false);
bool hasIniFile = (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)) > 0 || StringCchLenW(s_wchIniFile2,COUNTOF(s_wchIniFile2)) > 0);
- CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, s_bSaveSettings && s_bEnableSaveSettings);
+ CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, Settings.SaveSettings && s_bEnableSaveSettings);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && s_bEnableSaveSettings);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && s_bEnableSaveSettings);
if (SciCall_GetZoom() != 100) { EditShowZoomCallTip(Globals.hwndEdit); }
diff --git a/src/TypeDefs.h b/src/TypeDefs.h
index 38bc63a7e..881f478d4 100644
--- a/src/TypeDefs.h
+++ b/src/TypeDefs.h
@@ -95,7 +95,7 @@ typedef enum
XXXL_BUFFER = 4096,
ANSI_CHAR_BUFFER = 258,
- FNDRPL_BUFFER = 1024,
+ FNDRPL_BUFFER = 2048,
LONG_LINES_MARKER_LIMIT = 4096
} BUFFER_SIZES;
@@ -299,6 +299,7 @@ extern GLOBALS_T Globals;
typedef struct _settings_t
{
+ bool SaveSettings;
bool SaveRecentFiles;
bool PreserveCaretPos;
bool SaveFindReplace;