diff --git a/Versions/build.txt b/Versions/build.txt index 90214068f..2095356a4 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2623 +2624 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index d85e9ffd0..dcc6cab00 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 419e1e51e..057556594 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1031,10 +1031,10 @@ void LoadSettings() // 2nd set initial window position - s_WinInfo = s_DefWinInfo; - 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); @@ -1049,7 +1049,6 @@ void LoadSettings() 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.max = clampi(s_WinInfo.max, 0, 1); 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); diff --git a/src/Dialogs.c b/src/Dialogs.c index 7a0f721e9..10adba2b4 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -2065,6 +2065,7 @@ static INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, if (!FileWatching.MonitoringLog) { FileWatching.FileWatchingMode = Settings.FileWatchingMode; } Settings.ResetFileWatching = IsButtonChecked(hwnd, 103); + if (!FileWatching.MonitoringLog) { FileWatching.ResetFileWatching = Settings.ResetFileWatching; } if (FileWatching.MonitoringLog) { PostWMCommand(Globals.hwndMain, IDM_VIEW_CHASING_DOCTAIL); } diff --git a/src/Notepad3.c b/src/Notepad3.c index 54279a668..fb82fd4cc 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -130,7 +130,7 @@ static int s_iSortOptions = 0; static int s_iAlignMode = 0; static bool s_bIsAppThemed = true; static UINT s_msgTaskbarCreated = 0; -static bool s_dwChangeNotifyTime = 0; +static DWORD s_dwChangeNotifyTime = 0; static HANDLE s_hChangeHandle = NULL; static WCHAR s_wchTitleExcerpt[MIDSZ_BUFFER] = { L'\0' }; static UINT s_uidsAppTitle = IDS_MUI_APPTITLE; @@ -1035,7 +1035,10 @@ void InitWindowPosition(WININFO* pWinInfo, const int flagsPos) { WININFO winfo = *pWinInfo; - if (flagsPos == 1) { + if (flagsPos == 0) { + winfo = s_WinInfo; + } + else if (flagsPos == 1) { winfo.x = winfo.y = winfo.cx = winfo.cy = CW_USEDEFAULT; winfo.max = false; winfo.zoom = 100; @@ -2924,13 +2927,15 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) UNUSED(wParam); UNUSED(lParam); + DocPos const iCurPos = SciCall_GetCurrentPos(); + if (FileWatching.FileWatchingMode == FWM_MSGBOX || IsSaveNeeded(ISN_GET)) { SetForegroundWindow(hwnd); } if (PathFileExists(Globals.CurrentFile)) { - bool bRevertFile = (FileWatching.FileWatchingMode == 2 && !IsSaveNeeded(ISN_GET)); + bool bRevertFile = (FileWatching.FileWatchingMode == FWM_AUTORELOAD && !IsSaveNeeded(ISN_GET)); if (!bRevertFile) { INT_PTR const answer = InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_FILECHANGENOTIFY); @@ -2944,7 +2949,8 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) { SciCall_SetReadOnly(FileWatching.MonitoringLog); //SetForegroundWindow(hwnd); - SciCall_ScrollToEnd(); + //~SciCall_ScrollToEnd(); + SciCall_GotoPos(iCurPos); } } } @@ -5238,8 +5244,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) InstallFileWatching(Globals.CurrentFile); // force CheckCmd(GetMenu(Globals.hwndMain), IDM_VIEW_CHASING_DOCTAIL, FileWatching.MonitoringLog); - //~SciCall_DocumentEnd(); - SciCall_ScrollToEnd(); + UpdateToolbar(); } break; @@ -7668,7 +7673,7 @@ void ParseCommandLine() } } else if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) { - WININFO wi; + WININFO wi = INIT_WININFO; int bMaximize = 0; int itok = swscanf_s(lp1, L"%i,%i,%i,%i,%i", &wi.x, &wi.y, &wi.cx, &wi.cy, &bMaximize); if (itok == 4 || itok == 5) { // scan successful @@ -9647,6 +9652,7 @@ bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus) lpArgs = StrCutI(lpArgs, L"-u "); WCHAR wchFlags[32] = { L'\0' }; if (s_flagAppIsClosing) { StringCchCopy(wchFlags, COUNTOF(wchFlags), L"/UC"); } + WININFO wi = GetMyWindowPlacement(Globals.hwndMain, NULL); if (s_lpOrigFileArg) { @@ -10482,36 +10488,33 @@ void CancelCallTip() // InstallFileWatching() // // +static void _TerminateFileWatching() +{ + if (s_bRunningWatch) + { + if (s_hChangeHandle) { + FindCloseChangeNotification(s_hChangeHandle); + s_hChangeHandle = NULL; + } + KillTimer(NULL, ID_WATCHTIMER); + s_bRunningWatch = false; + s_dwChangeNotifyTime = 0; + } +} + + void InstallFileWatching(LPCWSTR lpszFile) { // Terminate if ((FileWatching.FileWatchingMode == FWM_NONE) || StrIsEmpty(lpszFile)) { - if (s_bRunningWatch) - { - if (s_hChangeHandle) { - FindCloseChangeNotification(s_hChangeHandle); - s_hChangeHandle = NULL; - } - KillTimer(NULL,ID_WATCHTIMER); - s_bRunningWatch = false; - s_dwChangeNotifyTime = 0; - } + _TerminateFileWatching(); } else // Install { // Terminate previous watching - if (s_bRunningWatch) { - if (s_hChangeHandle) { - FindCloseChangeNotification(s_hChangeHandle); - s_hChangeHandle = NULL; - } - s_dwChangeNotifyTime = 0; - } - // No previous watching installed, so launch the timer first - else { - SetTimer(NULL, ID_WATCHTIMER, FileWatching.FileCheckInverval, WatchTimerProc); - } + _TerminateFileWatching(); + WCHAR tchDirectory[MAX_PATH] = { L'\0' }; StringCchCopy(tchDirectory,COUNTOF(tchDirectory),lpszFile); PathCchRemoveFileSpec(tchDirectory, COUNTOF(tchDirectory)); @@ -10530,9 +10533,14 @@ void InstallFileWatching(LPCWSTR lpszFile) FILE_NOTIFY_CHANGE_SIZE | \ FILE_NOTIFY_CHANGE_LAST_WRITE); + // No previous watching installed, so launch the timer first + if (!s_bRunningWatch) { + SetTimer(NULL, ID_WATCHTIMER, FileWatching.FileCheckInverval, WatchTimerProc); + } s_bRunningWatch = true; s_dwChangeNotifyTime = 0; } + UpdateToolbar(); } @@ -10551,18 +10559,14 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) if (s_bRunningWatch) { - if ((s_dwChangeNotifyTime > 0) && ((GetTickCount() - s_dwChangeNotifyTime) > FileWatching.AutoReloadTimeout)) - { - if (s_hChangeHandle) { - FindCloseChangeNotification(s_hChangeHandle); - s_hChangeHandle = NULL; + 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); } - KillTimer(NULL,ID_WATCHTIMER); - s_bRunningWatch = false; - s_dwChangeNotifyTime = 0; - SendMessage(Globals.hwndMain,WM_CHANGENOTIFY,0,0); } - // Check Change Notification Handle else if (WAIT_OBJECT_0 == WaitForSingleObject(s_hChangeHandle,0)) { @@ -10579,23 +10583,13 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) // Check if the file has been changed if (CompareFileTime(&s_fdCurFile.ftLastWriteTime,&fdUpdated.ftLastWriteTime) != 0 || s_fdCurFile.nFileSizeLow != fdUpdated.nFileSizeLow || - s_fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh) + s_fdCurFile.nFileSizeHigh != fdUpdated.nFileSizeHigh || + FileWatching.MonitoringLog /* force */) { // Shutdown current watching and give control to main window - if (s_hChangeHandle) { - FindCloseChangeNotification(s_hChangeHandle); - s_hChangeHandle = NULL; - } - if (FileWatching.FileWatchingMode == FWM_AUTORELOAD) { - s_bRunningWatch = true; /* ! */ - s_dwChangeNotifyTime = GetTickCount(); - } - else { - KillTimer(NULL,ID_WATCHTIMER); - s_bRunningWatch = false; - s_dwChangeNotifyTime = 0; - SendMessage(Globals.hwndMain,WM_CHANGENOTIFY,0,0); - } + _TerminateFileWatching(); + //SendMessage(Globals.hwndMain,WM_CHANGENOTIFY,0,0); + MsgChangeNotify(Globals.hwndMain, (WPARAM)NULL, (LPARAM)NULL); } else { FindNextChangeNotification(s_hChangeHandle); diff --git a/src/Version.h b/src/Version.h index d852a173c..0437e3769 100644 --- a/src/Version.h +++ b/src/Version.h @@ -72,7 +72,7 @@ #if defined(_MSC_VER) #if (_MSC_VER >= 1922) #if(_MSC_FULL_VER >= 192227905) - #define VER_CPL MS Visual C++ 2019 v16.2.(0-4) + #define VER_CPL MS Visual C++ 2019 v16.2.(0-5) #endif #elif (_MSC_VER >= 1921) #if(_MSC_FULL_VER >= 192127702) diff --git a/src/VersionEx.h b/src/VersionEx.h index e1ff820af..0deb12523 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 910 -#define VERSION_BUILD 2623 +#define VERSION_REV 911 +#define VERSION_BUILD 2624 #define SCINTILLA_VER 420 #define ONIGURUMA_REGEX_VER 6.9.3 #define UCHARDET_VER 2018.09.27