diff --git a/.editorconfig b/.editorconfig
index 776d87258..eb8c2e580 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -21,6 +21,9 @@ indent_style = space
indent_size = 2
tab_width = 2
+[**.{ini}]
+charset = utf-8-sig
+
[language/**.{h,rc}]
charset = utf-8
# space (w=4) indentation
diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini
index 4bbf08c5e..bfa274b71 100644
--- a/Build/Notepad3.ini
+++ b/Build/Notepad3.ini
@@ -51,6 +51,7 @@ SettingsVersion=4
;DevDebugMode=0
;AnalyzeReliableConfidenceLevel=50
;LexerSQLNumberSignAsComment=1
+;ExitOnESCSkipLevel=2
[Statusbar Settings]
;VisibleSections=0 1 12 14 2 4 5 6 7 8 9 10 11
;SectionPrefixes=Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,Ch ,Repl ,Eval ,
diff --git a/Versions/build.txt b/Versions/build.txt
index 064256798..cf33eaf58 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-2678
+2679
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index 81c0fc545..207f5f628 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 8c90ccb2e..c986b2352 100644
--- a/src/Config/Config.cpp
+++ b/src/Config/Config.cpp
@@ -638,10 +638,11 @@ void LoadSettings()
Defaults.SaveSettings = StrIsNotEmpty(Globals.IniFile);
Settings.SaveSettings = IniSectionGetBool(L"Settings", L"SaveSettings", Defaults.SaveSettings);
- // --------------------------------------------------------------------------
- // first set "hard coded" .ini-Settings
// --------------------------------------------------------------------------
const WCHAR* const Settings2_Section = L"Settings2";
+ // --------------------------------------------------------------------------
+
+ // --- first set "hard coded" .ini-Settings ---
Flags.bDevDebugMode = IniSectionGetBool(Settings2_Section, L"DevDebugMode", DefaultFlags.bDevDebugMode);
Flags.bStickyWindowPosition = IniSectionGetBool(Settings2_Section, L"StickyWindowPosition", DefaultFlags.bStickyWindowPosition);
@@ -855,6 +856,8 @@ void LoadSettings()
Defaults2.LexerSQLNumberSignAsComment = true;
Settings2.LexerSQLNumberSignAsComment = IniSectionGetBool(Settings2_Section, L"LexerSQLNumberSignAsComment", Defaults2.LexerSQLNumberSignAsComment);
+ Defaults2.ExitOnESCSkipLevel = 2;
+ Settings2.ExitOnESCSkipLevel = clampi(IniSectionGetInt(Settings2_Section, L"ExitOnESCSkipLevel", Defaults2.ExitOnESCSkipLevel), 0, 2);
// --------------------------------------------------------------------------
const WCHAR* const Settings_Section = L"Settings";
@@ -1005,7 +1008,7 @@ void LoadSettings()
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_CAST_INT_VALUE_FROM_INISECTION(FILE_WATCHING_MODE, FileWatchingMode, FWM_DONT_CARE, FWM_DONT_CARE, 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);
diff --git a/src/Dialogs.c b/src/Dialogs.c
index 8b0d3b127..ed0a72d63 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -2062,7 +2062,7 @@ static INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam,
switch (LOWORD(wParam)) {
case IDOK:
if (IsButtonChecked(hwnd, 100)) {
- Settings.FileWatchingMode = FWM_NONE;
+ Settings.FileWatchingMode = FWM_DONT_CARE;
}
else if (IsButtonChecked(hwnd, 101)) {
Settings.FileWatchingMode = FWM_MSGBOX;
diff --git a/src/EncodingDetection.cpp b/src/EncodingDetection.cpp
index b2d6de2e9..69e7765ac 100644
--- a/src/EncodingDetection.cpp
+++ b/src/EncodingDetection.cpp
@@ -731,10 +731,6 @@ cpi_enc_t AnalyzeText_UCHARDET(
// ============================================================================
// ============================================================================
-inline float max_f(float x, float y) { return (x > y) ? x : y; }
-
-// --------------------------------------------------------------------------
-
//extern "C" cpi_enc_t Encoding_AnalyzeText
cpi_enc_t Encoding_AnalyzeText
(
diff --git a/src/Helpers.h b/src/Helpers.h
index cb5f81906..bd7dc8576 100644
--- a/src/Helpers.h
+++ b/src/Helpers.h
@@ -87,23 +87,29 @@ void DbgLog(const char *fmt, ...);
// ============================================================================
// min/max
-#define _min_(x,y) (((x) < (y)) ? (x) : (y))
-inline int min_i(const int x, const int y) { return (x < y) ? x : y; }
-inline unsigned int min_u(const unsigned int x, const unsigned int y) { return (x < y) ? x : y; }
-inline long min_l(const long x, const long y) { return (x < y) ? x : y; }
-inline size_t min_s(const size_t x, const size_t y) { return (x < y) ? x : y; }
-inline DocPos min_p(const DocPos x, const DocPos y) { return (x < y) ? x : y; }
-inline DocLn min_ln(const DocLn x, const DocLn y) { return (x < y) ? x : y; }
-inline DocPosCR min_cr(const DocPosCR x, const DocPosCR y) { return (x < y) ? x : y; }
+#define _min_(x,y) (((x) > (y)) ? (y) : (x))
+#define _RETCMPMIN_ { return (x > y) ? y : x; }
+inline int min_i(const int x, const int y) _RETCMPMIN_
+inline unsigned int min_u(const unsigned int x, const unsigned int y) _RETCMPMIN_
+inline long min_l(const long x, const long y) _RETCMPMIN_
+inline long min_dw(const DWORD x, const DWORD y) _RETCMPMIN_
+inline size_t min_s(const size_t x, const size_t y) _RETCMPMIN_
+inline DocPos min_p(const DocPos x, const DocPos y) _RETCMPMIN_
+inline DocLn min_ln(const DocLn x, const DocLn y) _RETCMPMIN_
+inline DocPosCR min_cr(const DocPosCR x, const DocPosCR y) _RETCMPMIN_
+inline float min_f(float x, float y) _RETCMPMIN_
-#define _max_(x,y) (((x) > (y)) ? (x) : (y))
-inline int max_i(int x, int y) { return (x > y) ? x : y; }
-inline unsigned int max_u(unsigned int x, unsigned int y) { return (x > y) ? x : y; }
-inline long max_l(const long x, const long y) { return (x > y) ? x : y; }
-inline size_t max_s(const size_t x, const size_t y) { return (x > y) ? x : y; }
-inline DocPos max_p(const DocPos x, const DocPos y) { return (x > y) ? x : y; }
-inline DocLn max_ln(const DocLn x, const DocLn y) { return (x > y) ? x : y; }
-inline DocPosCR max_cr(const DocPosCR x, const DocPosCR y) { return (x > y) ? x : y; }
+#define _max_(x,y) (((x) < (y)) ? (y) : (x))
+#define _RETCMPMAX_ { return (x < y) ? y : x; }
+inline int max_i(int x, int y) _RETCMPMAX_
+inline unsigned int max_u(unsigned int x, unsigned int y) _RETCMPMAX_
+inline long max_l(const long x, const long y) _RETCMPMAX_
+inline long max_dw(const DWORD x, const DWORD y) _RETCMPMAX_
+inline size_t max_s(const size_t x, const size_t y) _RETCMPMAX_
+inline DocPos max_p(const DocPos x, const DocPos y) _RETCMPMAX_
+inline DocLn max_ln(const DocLn x, const DocLn y) _RETCMPMAX_
+inline DocPosCR max_cr(const DocPosCR x, const DocPosCR y) _RETCMPMAX_
+inline float max_f(float x, float y) _RETCMPMAX_
inline DocPos abs_p(const DocPos x) { return (x >= 0LL) ? x : (0LL - x); }
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 6445a1983..c70e1b957 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -535,27 +535,27 @@ static void CALLBACK MQ_ExecuteNext(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR
//
// CommandLine Parsing Flags
//
-static LPWSTR s_lpSchemeArg = NULL;
-static LPWSTR s_lpOrigFileArg = NULL;
-static LPWSTR s_lpMatchArg = NULL;
-static WCHAR s_lpFileArg[MAX_PATH+1];
+static LPWSTR s_lpSchemeArg = NULL;
+static LPWSTR s_lpOrigFileArg = NULL;
+static LPWSTR s_lpMatchArg = NULL;
+static WCHAR s_lpFileArg[MAX_PATH+1];
-static cpi_enc_t s_flagSetEncoding = CPI_NONE;
-static int s_flagSetEOLMode = 0;
-static bool s_IsThisAnElevatedRelaunch = false;
-static bool s_flagStartAsTrayIcon = false;
-static int s_flagAlwaysOnTop = 0;
-static bool s_flagKeepTitleExcerpt = false;
-static bool s_flagNewFromClipboard = false;
-static bool s_flagPasteBoard = false;
-static bool s_flagJumpTo = false;
-static int s_flagMatchText = 0;
-static int s_flagChangeNotify = 0;
-static bool s_flagQuietCreate = false;
-static bool s_flagLexerSpecified = false;
-static bool s_flagAppIsClosing = false;
-static bool s_flagSearchPathIfRelative = false;
-static bool s_flagDisplayHelp = false;
+static cpi_enc_t s_flagSetEncoding = CPI_NONE;
+static int s_flagSetEOLMode = 0;
+static bool s_IsThisAnElevatedRelaunch = false;
+static bool s_flagStartAsTrayIcon = false;
+static int s_flagAlwaysOnTop = 0;
+static bool s_flagKeepTitleExcerpt = false;
+static bool s_flagNewFromClipboard = false;
+static bool s_flagPasteBoard = false;
+static bool s_flagJumpTo = false;
+static int s_flagMatchText = 0;
+static FILE_WATCHING_MODE s_flagChangeNotify = FWM_DONT_CARE;
+static bool s_flagQuietCreate = false;
+static bool s_flagLexerSpecified = false;
+static bool s_flagAppIsClosing = false;
+static bool s_flagSearchPathIfRelative = false;
+static bool s_flagDisplayHelp = false;
//==============================================================================
@@ -672,8 +672,8 @@ static void _InitGlobals()
FocusedView.CodeFoldingAvailable = false;
FocusedView.ShowCodeFolding = true;
- FileWatching.flagChangeNotify = FWM_NONE;
- FileWatching.FileWatchingMode = FWM_NONE;
+ FileWatching.flagChangeNotify = FWM_DONT_CARE;
+ FileWatching.FileWatchingMode = FWM_DONT_CARE;
FileWatching.ResetFileWatching = true;
FileWatching.MonitoringLog = false;
@@ -1234,8 +1234,7 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow)
if (bOpened) {
if (s_IsThisAnElevatedRelaunch) {
if (StrIsNotEmpty(s_lpFileArg)) {
- InstallFileWatching(NULL); // Terminate file watching
- StringCchCopy(Globals.CurrentFile,COUNTOF(Globals.CurrentFile),s_lpFileArg);
+ StringCchCopy(Globals.CurrentFile, COUNTOF(Globals.CurrentFile), s_lpFileArg);
InstallFileWatching(Globals.CurrentFile);
}
else {
@@ -1275,27 +1274,33 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow)
s_lpFileArg[0] = L'\0';
if (bOpened) {
- if (s_flagChangeNotify == 1) {
- FileWatching.FileWatchingMode = FWM_NONE;
- FileWatching.ResetFileWatching = true;
- InstallFileWatching(Globals.CurrentFile);
- }
- else if (s_flagChangeNotify == 2) {
- if (!FileWatching.MonitoringLog) {
- SendWMCommand(Globals.hwndMain, IDM_VIEW_CHASING_DOCTAIL);
- }
- else {
- FileWatching.FileWatchingMode = FWM_AUTORELOAD;
+ switch (s_flagChangeNotify) {
+ case FWM_MSGBOX:
+ FileWatching.FileWatchingMode = FWM_DONT_CARE;
FileWatching.ResetFileWatching = true;
InstallFileWatching(Globals.CurrentFile);
- }
+ break;
+ case FWM_AUTORELOAD:
+ if (!FileWatching.MonitoringLog) {
+ SendWMCommand(Globals.hwndMain, IDM_VIEW_CHASING_DOCTAIL);
+ }
+ else {
+ FileWatching.FileWatchingMode = FWM_AUTORELOAD;
+ FileWatching.ResetFileWatching = true;
+ InstallFileWatching(Globals.CurrentFile);
+ }
+ break;
+ case FWM_DONT_CARE:
+ default:
+ break;
}
}
}
else {
- if (Encoding_IsValid(Encoding_Forced(CPI_GET))) {
- Encoding_Current(Encoding_Forced(CPI_GET));
- Encoding_HasChanged(Encoding_Forced(CPI_GET));
+ cpi_enc_t const forcedEncoding = Encoding_Forced(CPI_GET);
+ if (Encoding_IsValid(forcedEncoding)) {
+ Encoding_Current(forcedEncoding);
+ Encoding_HasChanged(forcedEncoding);
}
}
@@ -2830,7 +2835,7 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam)
if (bOpened) {
if (params->flagChangeNotify == FWM_MSGBOX)
{
- FileWatching.FileWatchingMode = FWM_NONE;
+ FileWatching.FileWatchingMode = FWM_DONT_CARE;
FileWatching.ResetFileWatching = true;
InstallFileWatching(Globals.CurrentFile);
}
@@ -5602,8 +5607,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;
case IDM_VIEW_CHANGENOTIFY:
- if (ChangeNotifyDlg(hwnd))
+ if (ChangeNotifyDlg(hwnd)) {
InstallFileWatching(Globals.CurrentFile);
+ }
break;
@@ -5688,12 +5694,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
DocPos const iCurPos = SciCall_GetCurrentPos();
+ int skipLevel = Settings2.ExitOnESCSkipLevel;
+
if (SciCall_AutoCActive()) {
SciCall_AutoCCancel();
+ --skipLevel;
}
else if (SciCall_CallTipActive()) {
CancelCallTip();
s_bCallTipEscDisabled = true;
+ --skipLevel;
}
else if (s_bIndicMultiEdit) {
_BEGIN_UNDO_ACTION_
@@ -5702,22 +5712,31 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
SciCall_ClearSelections();
_END_UNDO_ACTION_
s_bIndicMultiEdit = false;
+ --skipLevel;
}
- else if (!SciCall_IsSelectionEmpty()) {
+
+ if (!SciCall_IsSelectionEmpty() && (skipLevel == Settings2.ExitOnESCSkipLevel)) {
_BEGIN_UNDO_ACTION_
EditSetSelectionEx(Globals.hwndEdit, iCurPos, iCurPos, -1, -1);
_END_UNDO_ACTION_
+ skipLevel -= Defaults2.ExitOnESCSkipLevel;
}
- else if (Settings.EscFunction == 1) {
- SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
- break;
- }
- else if (Settings.EscFunction == 2) {
- CloseApplication(true);
- break;
- }
- else {
- EditSetSelectionEx(Globals.hwndEdit, iCurPos, iCurPos, -1, -1);
+
+ if ((skipLevel < 0) || (skipLevel == Settings2.ExitOnESCSkipLevel))
+ {
+ switch (Settings.EscFunction) {
+ case 1:
+ SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+ break;
+
+ case 2:
+ CloseApplication(true);
+ break;
+
+ default:
+ EditSetSelectionEx(Globals.hwndEdit, iCurPos, iCurPos, -1, -1);
+ break;
+ }
}
SciCall_Cancel();
}
@@ -7915,9 +7934,9 @@ void ParseCommandLine()
case L'L':
if (*(lp1 + 1) == L'0' || *(lp1 + 1) == L'-' || *CharUpper(lp1 + 1) == L'O')
- s_flagChangeNotify = 1;
+ s_flagChangeNotify = FWM_MSGBOX;
else
- s_flagChangeNotify = 2;
+ s_flagChangeNotify = FWM_AUTORELOAD;
break;
case L'Q':
@@ -10279,9 +10298,9 @@ bool ActivatePrevInst()
// Make sure the previous window won't pop up a change notification message
//SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0);
- if (IsIconic(hwnd))
- ShowWindowAsync(hwnd,SW_RESTORE);
-
+ if (IsIconic(hwnd)) {
+ ShowWindowAsync(hwnd, SW_RESTORE);
+ }
if (!IsWindowVisible(hwnd)) {
SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK);
SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP);
@@ -10295,7 +10314,7 @@ bool ActivatePrevInst()
}
LPnp3params params = AllocMem(cb, HEAP_ZERO_MEMORY);
params->flagFileSpecified = false;
- params->flagChangeNotify = FWM_NONE;
+ params->flagChangeNotify = FWM_DONT_CARE;
params->flagQuietCreate = false;
params->flagLexerSpecified = s_flagLexerSpecified ? 1 : 0;
if (s_flagLexerSpecified && s_lpSchemeArg) {
@@ -10346,9 +10365,9 @@ bool ActivatePrevInst()
// Make sure the previous window won't pop up a change notification message
//SendMessage(hwnd,WM_CHANGENOTIFYCLEAR,0,0);
- if (IsIconic(hwnd))
- ShowWindowAsync(hwnd,SW_RESTORE);
-
+ if (IsIconic(hwnd)) {
+ ShowWindowAsync(hwnd, SW_RESTORE);
+ }
if (!IsWindowVisible(hwnd)) {
SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONDBLCLK);
SendMessage(hwnd,WM_TRAYMESSAGE,0,WM_LBUTTONUP);
@@ -10708,48 +10727,52 @@ void CancelCallTip()
//=============================================================================
//
-// InstallFileWatching()
+// TerminateFileWatching()
//
-//
-static void _TerminateFileWatching()
+static void TerminateFileWatching()
{
if (s_bRunningWatch)
{
+ KillTimer(NULL, ID_WATCHTIMER);
if (s_hChangeHandle) {
FindCloseChangeNotification(s_hChangeHandle);
s_hChangeHandle = NULL;
}
- KillTimer(NULL, ID_WATCHTIMER);
s_bRunningWatch = false;
- s_dwChangeNotifyTime = 0;
+ s_dwChangeNotifyTime = 0UL; // reset
}
}
-
+//=============================================================================
+//
+// InstallFileWatching()
+//
void InstallFileWatching(LPCWSTR lpszFile)
{
// Terminate
- if ((FileWatching.FileWatchingMode == FWM_NONE) || StrIsEmpty(lpszFile))
+ if (StrIsEmpty(lpszFile) || (FileWatching.FileWatchingMode == FWM_DONT_CARE))
{
- _TerminateFileWatching();
+ TerminateFileWatching();
}
else // Install
{
// Terminate previous watching
- _TerminateFileWatching();
+ TerminateFileWatching();
WCHAR tchDirectory[MAX_PATH] = { L'\0' };
StringCchCopy(tchDirectory,COUNTOF(tchDirectory),lpszFile);
PathCchRemoveFileSpec(tchDirectory, COUNTOF(tchDirectory));
// Save data of current file
- HANDLE hFind = FindFirstFile(Globals.CurrentFile,&s_fdCurFile);
- if (hFind != INVALID_HANDLE_VALUE)
+ HANDLE hFind = FindFirstFile(Globals.CurrentFile, &s_fdCurFile);
+ if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
- else
- ZeroMemory(&s_fdCurFile,sizeof(WIN32_FIND_DATA));
-
- s_hChangeHandle = FindFirstChangeNotification(tchDirectory,false,
+ }
+ else {
+ ZeroMemory(&s_fdCurFile, sizeof(WIN32_FIND_DATA));
+ }
+ s_hChangeHandle = FindFirstChangeNotification(
+ tchDirectory,false,
FILE_NOTIFY_CHANGE_FILE_NAME | \
FILE_NOTIFY_CHANGE_DIR_NAME | \
FILE_NOTIFY_CHANGE_ATTRIBUTES | \
@@ -10758,16 +10781,44 @@ void InstallFileWatching(LPCWSTR lpszFile)
// No previous watching installed, so launch the timer first
if (!s_bRunningWatch) {
- SetTimer(NULL, ID_WATCHTIMER, FileWatching.FileCheckInverval, WatchTimerProc);
+ SetTimer(NULL, ID_WATCHTIMER,
+ min_dw(FileWatching.FileCheckInverval, FileWatching.AutoReloadTimeout),
+ WatchTimerProc);
+ s_bRunningWatch = true;
}
- s_bRunningWatch = true;
- s_dwChangeNotifyTime = 0;
+ s_dwChangeNotifyTime = GetTickCount(); // init
}
-
UpdateToolbar();
}
+static inline bool CurrentFileChanged()
+{
+ if (StrIsEmpty(Globals.CurrentFile)) { return false; }
+
+ // Check if the file has been changed
+ WIN32_FIND_DATA fdUpdated;
+ ZeroMemory(&fdUpdated, sizeof(WIN32_FIND_DATA));
+
+ //~HANDLE const hFind = FindFirstFile(Globals.CurrentFile, &fdUpdated);
+ //~if (hFind != INVALID_HANDLE_VALUE)
+ //~ FindClose(hFind);
+ //~else
+ //~ return true;
+
+ if (!GetFileAttributesEx(Globals.CurrentFile, GetFileExInfoStandard, &fdUpdated)) {
+ return true; // The current file has been removed
+ }
+
+ bool const changed = (s_fdCurFile.nFileSizeLow != fdUpdated.nFileSizeLow)
+ || (s_fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh)
+ //|| (CompareFileTime(&s_fdCurFile.ftLastWriteTime, &fdUpdated.ftLastWriteTime) != 0)
+ || (s_fdCurFile.ftLastWriteTime.dwLowDateTime != fdUpdated.ftLastWriteTime.dwLowDateTime)
+ || (s_fdCurFile.ftLastWriteTime.dwHighDateTime != fdUpdated.ftLastWriteTime.dwHighDateTime);
+
+ return changed;
+}
+
//=============================================================================
//
// WatchTimerProc()
@@ -10782,48 +10833,39 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
if (s_bRunningWatch)
{
- if (FileWatching.MonitoringLog) {
- if ((s_dwChangeNotifyTime > 0) && ((GetTickCount() - s_dwChangeNotifyTime) > FileWatching.AutoReloadTimeout))
- {
- _TerminateFileWatching();
- //SendMessage(Globals.hwndMain, WM_CHANGENOTIFY, 0, 0);
- MsgChangeNotify(Globals.hwndMain, (WPARAM)NULL, (LPARAM)NULL);
- }
- }
- // Check Change Notification Handle
- else if (WAIT_OBJECT_0 == WaitForSingleObject(s_hChangeHandle,0))
+ switch (FileWatching.FileWatchingMode)
{
- bool const bHasFileName = StrIsNotEmpty(Globals.CurrentFile);
-
- // Check if the changes affect the current file
- WIN32_FIND_DATA fdUpdated;
- ZeroMemory(&fdUpdated, sizeof(WIN32_FIND_DATA));
-
- HANDLE const hFind = bHasFileName ? FindFirstFile(Globals.CurrentFile, &fdUpdated) : INVALID_HANDLE_VALUE;
- if (INVALID_HANDLE_VALUE != hFind) {
- FindClose(hFind);
- }
- else {
- // The current file has been removed
- ZeroMemory(&fdUpdated, sizeof(WIN32_FIND_DATA));
- }
-
- // Check if the file has been changed
- if (bHasFileName) {
- if (CompareFileTime(&s_fdCurFile.ftLastWriteTime, &fdUpdated.ftLastWriteTime) != 0 ||
- s_fdCurFile.nFileSizeLow != fdUpdated.nFileSizeLow ||
- s_fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh ||
- FileWatching.MonitoringLog /* force */)
+ case FWM_AUTORELOAD:
+ if (((GetTickCount() - s_dwChangeNotifyTime) > FileWatching.AutoReloadTimeout)
+ && //|| // TODO: OR for read only auto reload without save requester
+ CurrentFileChanged())
{
- // Shutdown current watching and give control to main window
- _TerminateFileWatching();
- //SendMessage(Globals.hwndMain,WM_CHANGENOTIFY,0,0);
- MsgChangeNotify(Globals.hwndMain, (WPARAM)NULL, (LPARAM)NULL);
+ TerminateFileWatching();
+ PostMessage(Globals.hwndMain, WM_CHANGENOTIFY, 0, 0);
}
- else {
- FindNextChangeNotification(s_hChangeHandle);
+ break;
+
+ case FWM_MSGBOX:
+ {
+ if (s_hChangeHandle)
+ {
+ while (WaitForSingleObject(s_hChangeHandle, 0) == WAIT_OBJECT_0) {
+ // Check if the changes affect the current file
+ if (CurrentFileChanged()) {
+ // Shutdown current watching and give control to main window
+ TerminateFileWatching();
+ PostMessage(Globals.hwndMain, WM_CHANGENOTIFY, 0, 0);
+ break; // while
+ }
+ FindNextChangeNotification(s_hChangeHandle);
+ }
+ }
}
- }
+ break;
+
+ case FWM_DONT_CARE:
+ default:
+ break;
}
}
}
diff --git a/src/Notepad3.h b/src/Notepad3.h
index 27293ce45..c23db8072 100644
--- a/src/Notepad3.h
+++ b/src/Notepad3.h
@@ -86,32 +86,28 @@ typedef enum {
//==== Ids ====================================================================
-#define IDC_STATUSBAR 0xFB00
-#define IDC_TOOLBAR 0xFB01
-#define IDC_REBAR 0xFB02
-#define IDC_EDIT 0xFB03
-#define IDC_EDITFRAME 0xFB04
-#define IDC_FILENAME 0xFB05
-#define IDC_REUSELOCK 0xFB06
+#define IDC_STATUSBAR (0xFB00)
+#define IDC_TOOLBAR (0xFB01)
+#define IDC_REBAR (0xFB02)
+#define IDC_EDIT (0xFB03)
+#define IDC_EDITFRAME (0xFB04)
+#define IDC_FILENAME (0xFB05)
+#define IDC_REUSELOCK (0xFB06)
-//==== Change Notifications ===================================================
-#define ID_WATCHTIMER 0xA000
-#define WM_CHANGENOTIFY WM_USER+1
-//#define WM_CHANGENOTIFYCLEAR WM_USER+2
+//==== Notifications ==========================================================
+#define WM_TRAYMESSAGE WM_USER // Callback Message from System Tray
+#define WM_CHANGENOTIFY (WM_USER+1) // Change Notifications
+//#define WM_CHANGENOTIFYCLEAR (WM_USER+2)
-
-//==== Callback Message from System Tray ======================================
-#define WM_TRAYMESSAGE WM_USER
-
-
-//==== Paste Board Timer ======================================================
-#define ID_PASTEBOARDTIMER 0xA001
+//==== Timer ==================================================================
+#define ID_WATCHTIMER (0xA000) // File Watching
+#define ID_PASTEBOARDTIMER (0xA001) // Paste Board
//==== Reuse Window Lock Timeout ==============================================
-#define REUSEWINDOWLOCKTIMEOUT 1000
+#define REUSEWINDOWLOCKTIMEOUT (1000)
//==== Function Declarations ==================================================
diff --git a/src/TypeDefs.h b/src/TypeDefs.h
index 85c489063..b77a9f48e 100644
--- a/src/TypeDefs.h
+++ b/src/TypeDefs.h
@@ -94,7 +94,7 @@ inline RECT RectFromWinInfo(const WININFO* const pWinInfo) {
typedef enum { BACKGROUND_LAYER = 0, FOREGROUND_LAYER = 1 } COLOR_LAYER; // Style_GetColor()
typedef enum { OPEN_WITH_BROWSER = 1, OPEN_WITH_NOTEPAD3 = 2, COPY_HYPERLINK = 4 } HYPERLINK_OPS; // Hyperlink Operations
-typedef enum { FWM_NONE = 0, FWM_MSGBOX = 1, FWM_AUTORELOAD = 2 } FILE_WATCHING_MODE;
+typedef enum { FWM_DONT_CARE = 0, FWM_MSGBOX = 1, FWM_AUTORELOAD = 2 } FILE_WATCHING_MODE;
// ----------------------------------------------------------------------------
@@ -510,6 +510,7 @@ typedef struct _settings2_t
bool NoCopyLineOnEmptySelection;
bool NoCutLineOnEmptySelection;
bool LexerSQLNumberSignAsComment;
+ int ExitOnESCSkipLevel;
float AnalyzeReliableConfidenceLevel;
//~float ReliableCEDConfidenceMapping; // = 0.85f;
diff --git a/src/VersionEx.h b/src/VersionEx.h
index f67584fad..869dd9386 100644
--- a/src/VersionEx.h
+++ b/src/VersionEx.h
@@ -8,8 +8,8 @@
#define SAPPNAME "Notepad3"
#define VERSION_MAJOR 5
#define VERSION_MINOR 19
-#define VERSION_REV 1118
-#define VERSION_BUILD 2678
+#define VERSION_REV 1119
+#define VERSION_BUILD 2679
#define SCINTILLA_VER 421
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27