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