From 463b9360c2a3ff9129fbeae5f7b2755faf17122d Mon Sep 17 00:00:00 2001 From: maboroshin <41102508+maboroshin@users.noreply.github.com> Date: Sat, 21 Mar 2020 13:13:16 +0900 Subject: [PATCH 1/6] Translation: strings_ja_jp.rc window size --- language/np3_ja_jp/strings_ja_jp.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/np3_ja_jp/strings_ja_jp.rc b/language/np3_ja_jp/strings_ja_jp.rc index 2e1e1f0cc..ffb8539e8 100644 --- a/language/np3_ja_jp/strings_ja_jp.rc +++ b/language/np3_ja_jp/strings_ja_jp.rc @@ -278,7 +278,7 @@ Notepad3 \t[/?] [...[文字コード]] [...[改行コード]] [/e] [/g] [/m] [/l /n\t新しいウィンドウで開く (/ns ファイルは単一のインスタンス)\r\n\ /r\tひとつウインドウを再利用 (/rs 同じく単一のインスタンス\r\n\ /p\tウィンドウの位置とサイズを指定 [/p x,y,sizex,y[,max]] (/p0, /ps,\r\n\t/pf,l,t,r,b,m)\r\n\ -\tor /p ,,,, [all integers]\r\n\ +\tor /p ,,,, [すべて整数]\r\n\ /t\tタイトルバーの文字列を指定 [/t text]\r\n\ /i\tシステムトレイ内に起動\r\n\ /o\t常に手前に表示\r\n\ From c4d57363cfc72a60af9108a23eb58409121c718e Mon Sep 17 00:00:00 2001 From: maboroshin <41102508+maboroshin@users.noreply.github.com> Date: Sat, 21 Mar 2020 13:22:51 +0900 Subject: [PATCH 2/6] Correct to IME Behaver based on Scintilla 4.3.3 (beta) --- scintilla/win32/ScintillaWin.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 99107caee..ff44d7980 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -1319,7 +1319,6 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { if (lParam & GCS_RESULTSTR) { AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::imeResult); - initialCompose = true; } if (lParam & GCS_COMPSTR) { From f97b1379e7df68c793817474a102e9ddff714f9d Mon Sep 17 00:00:00 2001 From: Pairi Daiza Date: Sat, 21 Mar 2020 05:41:18 +0100 Subject: [PATCH 3/6] + upd: Version files for Japanese translation --- Versions/build.txt | 2 +- Versions/day.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/VersionEx.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index 00750edc0..d00491fd7 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -3 +1 diff --git a/Versions/day.txt b/Versions/day.txt index 18eed1357..3ae0b938f 100644 --- a/Versions/day.txt +++ b/Versions/day.txt @@ -1 +1 @@ -320 +321 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index c93044b48..28f485d08 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 RC3 diff --git a/src/VersionEx.h b/src/VersionEx.h index 2fafd84e2..b267788c8 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -8,8 +8,8 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 20 -#define VERSION_REV 320 -#define VERSION_BUILD 3 +#define VERSION_REV 321 +#define VERSION_BUILD 1 #define SCINTILLA_VER 432 #define ONIGURUMA_REGEX_VER 6.9.4 #define UCHARDET_VER 2018.09.27 From aa2aedf12367358f44bf5a6961daba96ed4e5d4d Mon Sep 17 00:00:00 2001 From: Pairi Daiza Date: Sat, 21 Mar 2020 10:33:34 +0100 Subject: [PATCH 4/6] MUI - Minor translation for "Polish" language. + modify "Environment" of "build_np3portableapp.cmd" --- Versions/build.txt | 2 +- language/np3_pl_pl/menu_pl_pl.rc | 2 +- language/np3_pl_pl/strings_pl_pl.rc | 2 +- np3portableapp/build_np3portableapp.cmd | 27 ++++++++++++++++--------- res/Notepad3.exe.manifest.conf | 2 +- src/VersionEx.h | 2 +- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index d00491fd7..0cfbf0888 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1 +2 diff --git a/language/np3_pl_pl/menu_pl_pl.rc b/language/np3_pl_pl/menu_pl_pl.rc index 1af8101e7..880a4c226 100644 --- a/language/np3_pl_pl/menu_pl_pl.rc +++ b/language/np3_pl_pl/menu_pl_pl.rc @@ -282,7 +282,7 @@ BEGIN MENUITEM "Zaznacz wyraz lub wiersz\tCtrl+Spc", IDM_EDIT_SELECTWORD MENUITEM "Multiwybór-wszystko pasujące\tCtrl+Shift+Spc", IDM_EDIT_SELECTALLMATCHES MENUITEM SEPARATOR - MENUITEM "Split Undo &Transaction at Line-Breaks", IDM_VIEW_SPLIT_UNDOTYPSEQ_LNBRK + MENUITEM "Podział operacji cofania przy przenoszeniu wierszy", IDM_VIEW_SPLIT_UNDOTYPSEQ_LNBRK END MENUITEM SEPARATOR POPUP "Zakładki" diff --git a/language/np3_pl_pl/strings_pl_pl.rc b/language/np3_pl_pl/strings_pl_pl.rc index 14cf42e0d..8a4758f51 100644 --- a/language/np3_pl_pl/strings_pl_pl.rc +++ b/language/np3_pl_pl/strings_pl_pl.rc @@ -278,7 +278,7 @@ Options:\r\n\ /n\tAlways open a new window (/ns single file instance).\r\n\ /r\tReuse window (/rs single file instance).\r\n\ /p\tSet window position and size (/p0, /ps, /pf,l,t,r,b,m)\r\n\ -\tor /p ,,,, [all integers].\r\n\ +\tor /p ,,,, [wszystkie liczby].\r\n\ /t\tSet window title.\r\n\ /i\tStart as tray icon.\r\n\ /o\tKeep window on top.\r\n\ diff --git a/np3portableapp/build_np3portableapp.cmd b/np3portableapp/build_np3portableapp.cmd index c99daf883..1959e1cfc 100644 --- a/np3portableapp/build_np3portableapp.cmd +++ b/np3portableapp/build_np3portableapp.cmd @@ -36,9 +36,18 @@ set NP3_LANGUAGE_SET=af-ZA be-BY de-DE en-GB es-ES fr-FR hu-HU it-IT ja-JP ko-KR :: ==================================================================================================================== :: --- Environment --- + +if exist D:\PortableApps\PortableApps.comInstaller\ ( + set PORTAPP_ROOT_DIR=D:\PortableApps +) else ( + if exist D:\Rizonesoft\PortableApps\PortableApps\PortableApps.comInstaller\ ( + set PORTAPP_ROOT_DIR=D:\Rizonesoft\PortableApps\PortableApps + ) else ( + goto :END + ) +) + set SCRIPT_DIR=%~dp0 -set PORTAPP_ROOT_DIR=D:\PortableApps -::set PORTAPP_ROOT_DIR=D:\Rizonesoft\PortableApps\PortableApps set PORTAPP_APP_COMPACTOR=%PORTAPP_ROOT_DIR%\PortableApps.comAppCompactor\PortableApps.comAppCompactor.exe set PORTAPP_LAUNCHER_CREATOR=%PORTAPP_ROOT_DIR%\PortableApps.comLauncher\PortableApps.comLauncherGenerator.exe set PORTAPP_INSTALLER_CREATOR=%PORTAPP_ROOT_DIR%\PortableApps.comInstaller\PortableApps.comInstaller.exe @@ -189,7 +198,7 @@ goto :END >> "%~4" echo(!modified! endlocal ) - goto:EOF + goto :EOF :: -------------------------------------------------------------------------------------------------------------------- :GETDATE @@ -203,19 +212,19 @@ goto :END ::echo datestamp: "%datestamp%" ::echo timestamp: "%timestamp%" ::echo fullstamp: "%fullstamp%" - goto:EOF + goto :EOF :: -------------------------------------------------------------------------------------------------------------------- :GETFILEVER set "file=%~1" - if not defined file goto:EOF - if not exist "%file%" goto:EOF + if not defined file goto :EOF + if not exist "%file%" goto :EOF set "FILEVER=" for /F "tokens=2 delims==" %%a in (' wmic datafile where name^="%file:\=\\%" Get Version /value ') do set "FILEVER=%%a" ::echo %file% = %FILEVER% - goto:EOF + goto :EOF :: -------------------------------------------------------------------------------------------------------------------- :GETBUILD @@ -223,7 +232,7 @@ goto :END set /a BUILD = %nxbuild% - 1 set /p DEVNAME=<%NP3_BUILD_NAME% set DEVNAME=%DEVNAME:"=% - goto:EOF + goto :EOF :: -------------------------------------------------------------------------------------------------------------------- rem Resolve path to absolute. @@ -232,7 +241,7 @@ rem Param 2: Path to resolve. rem Return: Resolved absolute path. :RESOLVEPATH set %1=%~dpfn2 - goto:EOF + goto :EOF :: -------------------------------------------------------------------------------------------------------------------- :: ==================================================================================================================== diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 28f485d08..3da502a5d 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 RC3 diff --git a/src/VersionEx.h b/src/VersionEx.h index b267788c8..5f4bb56b5 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -9,7 +9,7 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 20 #define VERSION_REV 321 -#define VERSION_BUILD 1 +#define VERSION_BUILD 2 #define SCINTILLA_VER 432 #define ONIGURUMA_REGEX_VER 6.9.4 #define UCHARDET_VER 2018.09.27 From dd9bc1fef79c4a9afb62fd768d1fe42e389f8649 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 21 Mar 2020 15:52:01 +0100 Subject: [PATCH 5/6] + fix: insert selected language correspondig short & long DateTime format + different RegEx search pattern spec for Update TimeStamps --- Build/Notepad3.ini | 3 +- Versions/build.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/Config/Config.cpp | 18 ++-- src/Edit.c | 171 +++++++++++++++++++++++++++++++++ src/Edit.h | 4 +- src/Notepad3.c | 96 +----------------- src/TypeDefs.h | 10 +- src/VersionEx.h | 4 +- 9 files changed, 201 insertions(+), 109 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index fa7f6d059..7064b0f71 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -7,7 +7,9 @@ SettingsVersion=4 ;IMEInteraction=0 ;AutoReloadTimeout=2000 ;DateTimeLong= +;TimeStampRegExLong= ;DateTimeShort= +;TimeStampRegExShort= ;DefaultDirectory= ;DefaultExtension=txt ;DefaultWindowPosition= @@ -35,7 +37,6 @@ SettingsVersion=4 ;ShellAppUserModelID=Rizonesoft.Notepad3 ;ShellUseSystemMRU=1 ;StickyWindowPosition=0 -;TimeStamp=\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $ ;UseOldStyleBraceMatching=0 ;WebTemplate1=https://google.com/search?q=%s ;WebTemplate2=https://en.wikipedia.org/w/index.php?search=%s diff --git a/Versions/build.txt b/Versions/build.txt index 0cfbf0888..00750edc0 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2 +3 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 3da502a5d..dce1a2318 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 RC3 diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 571da5f63..052d2eb17 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -933,8 +933,6 @@ void LoadSettings() IniSectionGetString(IniSecSettings2, L"PreferredLanguageLocaleName", Defaults2.PreferredLanguageLocaleName, Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName)); - StringCchCopyW(Globals.InitialPreferredLanguage, COUNTOF(Globals.InitialPreferredLanguage), Settings2.PreferredLanguageLocaleName); - // -------------------------------------------------------------------------- StringCchCopyW(Defaults2.DefaultExtension, COUNTOF(Defaults2.DefaultExtension), L"txt"); @@ -1080,14 +1078,20 @@ void LoadSettings() Settings2.LineCommentPostfixStrg, COUNTOF(Settings2.LineCommentPostfixStrg)); StrTrimW(Settings2.LineCommentPostfixStrg, L"\""); - StringCchCopyW(Defaults2.TimeStamp, COUNTOF(Defaults2.TimeStamp), L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $"); - IniSectionGetString(IniSecSettings2, L"TimeStamp", Defaults2.TimeStamp, Settings2.TimeStamp, COUNTOF(Settings2.TimeStamp)); - - Defaults2.DateTimeShort[0] = L'\0'; - IniSectionGetString(IniSecSettings2, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort)); + //Defaults2.DateFormatLong = 0; + //Settings2.DateFormatLong = clampi(IniSectionGetInt(IniSecSettings2, L"DateFormatLong", Defaults2.DateFormatLong), 0, 100); + //Defaults2.DateFormatShort = 0; + //Settings2.DateFormatShort = clampi(IniSectionGetInt(IniSecSettings2, L"DateFormatShort", Defaults2.DateFormatShort), 0, 100); Defaults2.DateTimeLong[0] = L'\0'; IniSectionGetString(IniSecSettings2, L"DateTimeLong", Defaults2.DateTimeLong, Settings2.DateTimeLong, COUNTOF(Settings2.DateTimeLong)); + Defaults2.TimeStampRegExLong[0] = L'\0'; + IniSectionGetString(IniSecSettings2, L"TimeStampRegExLong", Defaults2.TimeStampRegExLong, Settings2.TimeStampRegExLong, COUNTOF(Settings2.TimeStampRegExLong)); + + Defaults2.DateTimeShort[0] = L'\0'; + IniSectionGetString(IniSecSettings2, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort)); + Defaults2.TimeStampRegExShort[0] = L'\0'; + IniSectionGetString(IniSecSettings2, L"TimeStampRegExShort", Defaults2.TimeStampRegExShort, Settings2.TimeStampRegExShort, COUNTOF(Settings2.TimeStampRegExShort)); StringCchCopyW(Defaults2.WebTemplate1, COUNTOF(Defaults2.WebTemplate1), L"https://google.com/search?q=%s"); IniSectionGetString(IniSecSettings2, L"WebTemplate1", Defaults2.WebTemplate1, Settings2.WebTemplate1, COUNTOF(Settings2.WebTemplate1)); diff --git a/src/Edit.c b/src/Edit.c index 3e52484bf..805e07707 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "Styles.h" #include "Dialogs.h" @@ -2226,6 +2227,176 @@ void EditModifyNumber(HWND hwnd,bool bIncrease) { } +//============================================================================= +// +// _GetDateFormatProc() - date format information provided by the EnumDateFormatsExEx() +// +static unsigned int _DateFmtIdx = 0; + +static BOOL CALLBACK _GetDateFormatProc(LPWSTR lpDateFormatString, CALID CalendarID, LPARAM lParam) +{ + UNUSED(CalendarID); + static unsigned int count = 0; + + LPWSTR const pwchFind = (LPWSTR)lParam; + + if (StrIsEmpty(pwchFind)) { + count = 0; // begin + StringCchCopy(pwchFind, SMALL_BUFFER, lpDateFormatString); // default + if (count == _DateFmtIdx) { return FALSE; } // found + } + else if (count == _DateFmtIdx) { + StringCchCopy(pwchFind, SMALL_BUFFER, lpDateFormatString); + return FALSE; // found + } + + ++count; + return TRUE; +} + + + +//============================================================================= +// +// _GetCurrentDateTimeString() +// +static void _GetCurrentDateTimeString(LPWSTR pwchDateTimeStrg, size_t cchBufLen, bool bShortFmt) +{ + WCHAR wchTemplate[SMALL_BUFFER] = { L'\0' }; + StringCchCopyW(wchTemplate, COUNTOF(wchTemplate), bShortFmt ? Settings2.DateTimeShort : Settings2.DateTimeLong); + + SYSTEMTIME st; + GetLocalTime(&st); + + if (StrIsNotEmpty(wchTemplate)) + { + struct tm sst; + sst.tm_isdst = -1; + sst.tm_sec = (int)st.wSecond; + sst.tm_min = (int)st.wMinute; + sst.tm_hour = (int)st.wHour; + sst.tm_mday = (int)st.wDay; + sst.tm_mon = (int)st.wMonth - 1; + sst.tm_year = (int)st.wYear - 1900; + sst.tm_wday = (int)st.wDayOfWeek; + mktime(&sst); + wcsftime(pwchDateTimeStrg, cchBufLen, wchTemplate, &sst); + } + else { + WCHAR wchFormat[SMALL_BUFFER] = { L'\0' }; + _DateFmtIdx = 0; // (bShortFmt ? Settings2.DateFormatShort : Settings2.DateFormatLong); + EnumDateFormatsExEx(_GetDateFormatProc, Settings2.PreferredLanguageLocaleName, (bShortFmt ? DATE_SHORTDATE : DATE_LONGDATE), (LPARAM)wchFormat); + + WCHAR wchDate[SMALL_BUFFER] = { L'\0' }; + GetDateFormatEx(Settings2.PreferredLanguageLocaleName, DATE_AUTOLAYOUT, &st, wchFormat, wchDate, COUNTOF(wchDate), NULL); + + WCHAR wchTime[SMALL_BUFFER] = { L'\0' }; + GetTimeFormatEx(Settings2.PreferredLanguageLocaleName, TIME_NOSECONDS, &st, NULL, wchTime, COUNTOF(wchTime)); + + StringCchPrintf(pwchDateTimeStrg, cchBufLen, L"%s %s", wchTime, wchDate); + } +} + + + +//============================================================================= +// +// EditInsertTimestamps() +// +void EditInsertTimestamps(bool bShortFmt) +{ + //~~~_BEGIN_UNDO_ACTION_; + + + WCHAR wchDateTime[SMALL_BUFFER] = { L'\0' }; + _GetCurrentDateTimeString(wchDateTime, COUNTOF(wchDateTime), bShortFmt); + + char chDateTime[MIDSZ_BUFFER] = { '\0' }; + WideCharToMultiByteEx(Encoding_SciCP, 0, wchDateTime, -1, chDateTime, COUNTOF(chDateTime), NULL, NULL); + EditReplaceSelection(chDateTime, false); + + //~~~_END_UNDO_ACTION_; +} + + +//============================================================================= +// +// EditUpdateTimestamps() +// +void EditUpdateTimestamps() +{ + //WCHAR wchTempBuf[SMALL_BUFFER] = { L'\0' }; + WCHAR wchFindLong[SMALL_BUFFER] = { L'\0' }; + WCHAR wchFindShort[SMALL_BUFFER] = { L'\0' }; + if (StrIsNotEmpty(Settings2.TimeStampRegExLong)) { + StringCchCopy(wchFindLong, COUNTOF(wchFindLong), Settings2.TimeStampRegExLong); + StrTrim(wchFindLong, L" "); + } + if (StrIsNotEmpty(Settings2.TimeStampRegExShort)) { + StringCchCopy(wchFindShort, COUNTOF(wchFindShort), Settings2.TimeStampRegExShort); + StrTrim(wchFindShort, L" "); + } + + if (StrIsEmpty(wchFindLong)) + { + _DateFmtIdx = 0; // Settings2.DateFormatLong; + EnumDateFormatsExEx(_GetDateFormatProc, Settings2.PreferredLanguageLocaleName, DATE_LONGDATE, (LPARAM)wchFindLong); + + // TODO: replace Format by corresponding RegEx Pattern + //StringCchCopy(wchFindLong, COUNTOF(wchFindLong), wchTempBuf); + } + + if (StrIsEmpty(wchFindShort)) + { + _DateFmtIdx = 0; // Settings2.DateFormatShort; + EnumDateFormatsExEx(_GetDateFormatProc, Settings2.PreferredLanguageLocaleName, DATE_SHORTDATE, (LPARAM)wchFindShort); + + // TODO: replace Format by corresponding RegEx Pattern + //StringCchCopy(wchFindShort, COUNTOF(wchFindShort), wchTempBuf); + } + + // ----------------------------------------------- + + WCHAR wchReplaceLong[SMALL_BUFFER] = { L'\0' }; + _GetCurrentDateTimeString(wchReplaceLong, COUNTOF(wchReplaceLong), false); + + EDITFINDREPLACE efrTS_L = EFR_INIT_DATA; + efrTS_L.hwnd = Globals.hwndEdit; + efrTS_L.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX); + WideCharToMultiByteEx(Encoding_SciCP, 0, wchFindLong, -1, efrTS_L.szFind, COUNTOF(efrTS_L.szFind), NULL, NULL); + WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplaceLong, -1, efrTS_L.szReplace, COUNTOF(efrTS_L.szReplace), NULL, NULL); + + if (!SciCall_IsSelectionEmpty()) + { + EditReplaceAllInSelection(Globals.hwndEdit, &efrTS_L, true); + } + else { + EditReplaceAll(Globals.hwndEdit, &efrTS_L, true); + } + + // ----------------------------------------------- + + WCHAR wchReplaceShort[SMALL_BUFFER] = { L'\0' }; + _GetCurrentDateTimeString(wchReplaceLong, COUNTOF(wchReplaceLong), true); + + EDITFINDREPLACE efrTS_S = EFR_INIT_DATA; + efrTS_S.hwnd = Globals.hwndEdit; + efrTS_S.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX); + WideCharToMultiByteEx(Encoding_SciCP, 0, wchFindShort, -1, efrTS_S.szFind, COUNTOF(efrTS_S.szFind), NULL, NULL); + WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplaceShort, -1, efrTS_S.szReplace, COUNTOF(efrTS_S.szReplace), NULL, NULL); + + if (!SciCall_IsSelectionEmpty()) + { + EditReplaceAllInSelection(Globals.hwndEdit, &efrTS_S, true); + } + else { + EditReplaceAll(Globals.hwndEdit, &efrTS_S, true); + } + +} + + + //============================================================================= // // EditTabsToSpaces() diff --git a/src/Edit.h b/src/Edit.h index eef2adbec..d96ab93cf 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -52,7 +52,9 @@ void EditChar2Hex(HWND hwnd); void EditHex2Char(HWND hwnd); void EditFindMatchingBrace(); void EditSelectToMatchingBrace(); -void EditModifyNumber(HWND hwnd,bool); +void EditModifyNumber(HWND hwnd, bool bIncrease); +void EditUpdateTimestamps(); +void EditInsertTimestamps(bool bShortFmt); void EditTabsToSpaces(int nTabWidth,bool); void EditSpacesToTabs(int nTabWidth,bool); diff --git a/src/Notepad3.c b/src/Notepad3.c index 485b18290..7ac149730 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -26,7 +26,6 @@ #include //#include //#include -#include #include "Edit.h" #include "Styles.h" @@ -966,7 +965,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, SetTimer(hwnd, IDT_TIMER_MRKALL, USER_TIMER_MINIMUM, (TIMERPROC)MQ_ExecuteNext); if (Globals.bPrefLngNotAvail) { - InfoBoxLng(MB_ICONWARNING, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Globals.InitialPreferredLanguage); + InfoBoxLng(MB_ICONWARNING, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Settings2.PreferredLanguageLocaleName); } MSG msg; @@ -4471,49 +4470,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_INSERT_SHORTDATE: case IDM_EDIT_INSERT_LONGDATE: - { - //~~~_BEGIN_UNDO_ACTION_; - - WCHAR tchDateTime[128] = { L'\0' }; - WCHAR tchTemplate[128] = { L'\0' }; - SYSTEMTIME st; - //int iSelStart; - - GetLocalTime(&st); - - StringCchCopyW(tchTemplate, COUNTOF(tchTemplate), - (iLoWParam == IDM_EDIT_INSERT_SHORTDATE) ? Settings2.DateTimeShort : Settings2.DateTimeLong); - - if (StringCchLenW(tchTemplate,0) > 0) - { - struct tm sst; - sst.tm_isdst = -1; - sst.tm_sec = (int)st.wSecond; - sst.tm_min = (int)st.wMinute; - sst.tm_hour = (int)st.wHour; - sst.tm_mday = (int)st.wDay; - sst.tm_mon = (int)st.wMonth - 1; - sst.tm_year = (int)st.wYear - 1900; - sst.tm_wday = (int)st.wDayOfWeek; - mktime(&sst); - wcsftime(tchDateTime,COUNTOF(tchDateTime),tchTemplate,&sst); - } - else { - WCHAR tchDate[64] = { L'\0' }; - WCHAR tchTime[64] = { L'\0' }; - GetDateFormat(LOCALE_USER_DEFAULT,( - iLoWParam == IDM_EDIT_INSERT_SHORTDATE) ? DATE_SHORTDATE : DATE_LONGDATE, - &st,NULL,tchDate,COUNTOF(tchDate)); - GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,tchTime,COUNTOF(tchTime)); - - StringCchPrintf(tchDateTime,COUNTOF(tchDateTime),L"%s %s",tchTime,tchDate); - } - char chDateTime[128] = { '\0' }; - WideCharToMultiByteEx(Encoding_SciCP,0,tchDateTime,-1,chDateTime,COUNTOF(chDateTime),NULL,NULL); - EditReplaceSelection(chDateTime, false); - - //~~~_END_UNDO_ACTION_; - } + EditInsertTimestamps((iLoWParam == IDM_EDIT_INSERT_SHORTDATE)); break; @@ -5902,54 +5859,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_TIMESTAMPS: - { - WCHAR wchFind[128] = { L'\0' }; - WCHAR wchTemplate[128] = { L'\0' }; - WCHAR wchReplace[128] = { L'\0' }; - - SYSTEMTIME st; - struct tm sst; - - EDITFINDREPLACE efrTS = EFR_INIT_DATA; - efrTS.hwnd = Globals.hwndEdit; - efrTS.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX); - - StringCchCopyW(wchFind, COUNTOF(wchFind), Settings2.TimeStamp); - - WCHAR *pwchSep = StrChr(wchFind, L'|'); - if (pwchSep) { - StringCchCopy(wchTemplate,COUNTOF(wchTemplate),pwchSep + 1); - *pwchSep = 0; - } - - StrTrim(wchFind,L" "); - StrTrim(wchTemplate,L" "); - - if (StringCchLenW(wchFind,COUNTOF(wchFind)) == 0 || StringCchLenW(wchTemplate,COUNTOF(wchTemplate)) == 0) - break; - - GetLocalTime(&st); - sst.tm_isdst = -1; - sst.tm_sec = (int)st.wSecond; - sst.tm_min = (int)st.wMinute; - sst.tm_hour = (int)st.wHour; - sst.tm_mday = (int)st.wDay; - sst.tm_mon = (int)st.wMonth - 1; - sst.tm_year = (int)st.wYear - 1900; - sst.tm_wday = (int)st.wDayOfWeek; - mktime(&sst); - wcsftime(wchReplace,COUNTOF(wchReplace),wchTemplate,&sst); - - WideCharToMultiByteEx(Encoding_SciCP, 0, wchFind, -1, efrTS.szFind,COUNTOF(efrTS.szFind),NULL,NULL); - WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplace, -1, efrTS.szReplace, COUNTOF(efrTS.szReplace), NULL, NULL); - - if (!SciCall_IsSelectionEmpty()) { - EditReplaceAllInSelection(Globals.hwndEdit, &efrTS, true); - } - else { - EditReplaceAll(Globals.hwndEdit, &efrTS, true); - } - } + EditUpdateTimestamps(); break; diff --git a/src/TypeDefs.h b/src/TypeDefs.h index a2e94749a..ebadb29bc 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -353,7 +353,6 @@ typedef struct _globals_t unsigned idxSelectedTheme; WCHAR SelectedThemeName[128]; - WCHAR InitialPreferredLanguage[LOCALE_NAME_MAX_LENGTH + 1]; FR_STATES FindReplaceMatchFoundState; @@ -544,16 +543,21 @@ typedef struct _settings2_t WCHAR DefaultExtension[64]; WCHAR DefaultDirectory[MAX_PATH]; WCHAR FileDlgFilters[XHUGE_BUFFER]; - WCHAR FileBrowserPath[MAX_PATH]; + WCHAR AppUserModelID[128]; WCHAR AutoCompleteFillUpChars[64]; WCHAR LineCommentPostfixStrg[64]; WCHAR ExtendedWhiteSpaceChars[ANSI_CHAR_BUFFER + 1]; WCHAR AutoCompleteWordCharSet[ANSI_CHAR_BUFFER + 1]; - WCHAR TimeStamp[128]; + + //int DateFormatLong; + //int DateFormatShort; WCHAR DateTimeShort[128]; + WCHAR TimeStampRegExShort[256]; WCHAR DateTimeLong[128]; + WCHAR TimeStampRegExLong[256]; + WCHAR WebTemplate1[MAX_PATH]; WCHAR WebTemplate2[MAX_PATH]; WCHAR AdministrationTool[MAX_PATH]; diff --git a/src/VersionEx.h b/src/VersionEx.h index 5f4bb56b5..7de862dd7 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -9,11 +9,11 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 20 #define VERSION_REV 321 -#define VERSION_BUILD 2 +#define VERSION_BUILD 3 #define SCINTILLA_VER 432 #define ONIGURUMA_REGEX_VER 6.9.4 #define UCHARDET_VER 2018.09.27 #define TINYEXPR_VER 2018.05.11 #define UTHASH_VER 2.1.0 #define VERSION_PATCH RC3 -#define VERSION_COMMIT_ID dkt1-amr +#define VERSION_COMMIT_ID nebukadn From 199342059640772c7e17752b94c8b9f3bf9f98dc Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 21 Mar 2020 16:27:17 +0100 Subject: [PATCH 6/6] + fix: concurrency issue on .ini-file access while (nearly) parallel start --- Versions/build.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/Config/Config.cpp | 17 +++++++++-------- src/VersionEx.h | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index 00750edc0..b8626c4cf 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -3 +4 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index dce1a2318..4b2835165 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 RC3 diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 052d2eb17..14e28c68c 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -809,17 +809,18 @@ extern "C" bool CreateIniFile() HANDLE hFile = CreateFile(Globals.IniFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); - if (hFile == INVALID_HANDLE_VALUE) { - Globals.dwLastError = GetLastError(); - MsgBoxLastError(L"Read Access to Settings-File failed!", Globals.dwLastError); - return result; + + if (hFile != INVALID_HANDLE_VALUE) { + DWORD dwFSHigh = 0UL; + dwFileSize = GetFileSize(hFile, &dwFSHigh); + CloseHandle(hFile); + } + else { + dwFileSize = INVALID_FILE_SIZE; } - DWORD dwFSHigh = 0UL; - dwFileSize = GetFileSize(hFile, &dwFSHigh); - CloseHandle(hFile); } - if ((dwFileSize == 0) && (dwFileSize != INVALID_FILE_SIZE)) { + if (dwFileSize == 0) { result = IniFileSetString(Globals.IniFile, L"Notepad3", NULL, NULL); Globals.bIniFileFromScratch = true; } diff --git a/src/VersionEx.h b/src/VersionEx.h index 7de862dd7..813c0eb4a 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -9,7 +9,7 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 20 #define VERSION_REV 321 -#define VERSION_BUILD 3 +#define VERSION_BUILD 4 #define SCINTILLA_VER 432 #define ONIGURUMA_REGEX_VER 6.9.4 #define UCHARDET_VER 2018.09.27