mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ chg: use user locale for date/time insert format, can be menu switched to preferred UI language
+ chg: insert date before time & tab separated
This commit is contained in:
parent
a8f3563173
commit
8318e6fe02
@ -460,6 +460,7 @@
|
||||
#define IDS_MUI_LANG_VI_VN 34523
|
||||
#define IDS_MUI_LANG_ZH_CN 34524
|
||||
#define IDS_MUI_LANG_ZH_TW 34525
|
||||
#define IDS_USE_LOCALE_DATEFMT 34700
|
||||
|
||||
#define IDS_MUI_MENU_THEMES 37000
|
||||
#define IDM_THEMES_DEFAULT 37001
|
||||
|
||||
@ -251,6 +251,7 @@ END
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "&Sprache"
|
||||
IDS_USE_LOCALE_DATEFMT "Sprache bestimmt &Datumsformat"
|
||||
IDS_MUI_MENU_THEMES "&Schema Sammlung"
|
||||
IDM_THEMES_DEFAULT "&Fabrik-Vorgaben"
|
||||
IDM_THEMES_FILE_ITEM "&Standard"
|
||||
|
||||
@ -251,6 +251,7 @@ END
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "&Language"
|
||||
IDS_USE_LOCALE_DATEFMT "Language defines &Date Format"
|
||||
IDS_MUI_MENU_THEMES "&Scheme Collection"
|
||||
IDM_THEMES_DEFAULT "&Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "&Standard"
|
||||
|
||||
@ -1510,6 +1510,7 @@ void LoadSettings()
|
||||
GET_BOOL_VALUE_FROM_INISECTION(SplitUndoTypingSeqOnLnBreak, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(EditLayoutRTL, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(DialogsLayoutRTL, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(PreferredLocale4DateFmt, false);
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
Defaults.WinThemeDarkMode = ShouldAppsUseDarkModeEx();
|
||||
@ -1936,6 +1937,7 @@ static bool _SaveSettings(bool bForceSaveSettings)
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SplitUndoTypingSeqOnLnBreak);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, EditLayoutRTL);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, DialogsLayoutRTL);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, PreferredLocale4DateFmt);
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, WinThemeDarkMode);
|
||||
|
||||
59
src/Edit.c
59
src/Edit.c
@ -2167,35 +2167,6 @@ 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()
|
||||
@ -2207,7 +2178,8 @@ static void _GetCurrentDateTimeString(LPWSTR pwchDateTimeStrg, size_t cchBufLen,
|
||||
|
||||
const WCHAR* const confFormat = bShortFmt ? Settings2.DateTimeFormat : Settings2.DateTimeLongFormat;
|
||||
|
||||
if (StrIsNotEmpty(pwchDateTimeStrg) || StrIsNotEmpty(confFormat)) {
|
||||
if (StrIsNotEmpty(pwchDateTimeStrg) || StrIsNotEmpty(confFormat))
|
||||
{
|
||||
WCHAR wchTemplate[MIDSZ_BUFFER] = {L'\0'};
|
||||
StringCchCopyW(wchTemplate, COUNTOF(wchTemplate), StrIsNotEmpty(pwchDateTimeStrg) ? pwchDateTimeStrg : confFormat);
|
||||
|
||||
@ -2225,18 +2197,27 @@ static void _GetCurrentDateTimeString(LPWSTR pwchDateTimeStrg, size_t cchBufLen,
|
||||
if (cnt == 0) {
|
||||
StringCchCopy(pwchDateTimeStrg, cchBufLen, wchTemplate);
|
||||
}
|
||||
} else { // use configured DateTime Format
|
||||
WCHAR wchFormat[SMALL_BUFFER] = { L'\0' };
|
||||
_DateFmtIdx = 0;
|
||||
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);
|
||||
|
||||
} else { // use configured Language Locale DateTime Format
|
||||
|
||||
WCHAR wchTime[SMALL_BUFFER] = { L'\0' };
|
||||
GetTimeFormatEx(Settings2.PreferredLanguageLocaleName, TIME_NOSECONDS, &st, NULL, wchTime, COUNTOF(wchTime));
|
||||
WCHAR wchDate[SMALL_BUFFER] = { L'\0' };
|
||||
WCHAR wchFormat[SMALL_BUFFER] = { L'\0' };
|
||||
|
||||
StringCchPrintf(pwchDateTimeStrg, cchBufLen, L"%s %s", wchTime, wchDate);
|
||||
LPCWSTR const pLocaleName = Settings.PreferredLocale4DateFmt ? Settings2.PreferredLanguageLocaleName : LOCALE_NAME_USER_DEFAULT;
|
||||
|
||||
GetLocaleInfoEx(pLocaleName, (bShortFmt ? LOCALE_SSHORTDATE : LOCALE_SLONGDATE), wchFormat, COUNTOF(wchFormat));
|
||||
GetDateFormatEx(pLocaleName, DATE_AUTOLAYOUT, &st, wchFormat, wchDate, COUNTOF(wchDate), NULL);
|
||||
StrDelChrW(wchDate, L"\x200E"); // clear off the Left-to-Right Mark (LRM)
|
||||
|
||||
LPCWSTR const tfmt = bShortFmt ? NULL : wchFormat;
|
||||
if (tfmt) {
|
||||
GetLocaleInfoEx(pLocaleName, LOCALE_STIMEFORMAT, wchFormat, COUNTOF(wchFormat));
|
||||
}
|
||||
GetTimeFormatEx(pLocaleName, (bShortFmt ? TIME_NOSECONDS : 0), &st, tfmt, wchTime, COUNTOF(wchTime));
|
||||
StrDelChrW(wchTime, L"\x200E"); // clear off the Left-to-Right Mark (LRM)
|
||||
|
||||
StringCchPrintf(pwchDateTimeStrg, cchBufLen, L"%s\t%s", wchDate, wchTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -723,10 +723,15 @@ static bool _InsertLanguageMenu(HMENU hMenuBar)
|
||||
GetLngString(IDS_MUI_MENU_LANGUAGE, wchMenuItemStrg, COUNTOF(wchMenuItemStrg));
|
||||
//return InsertMenu(hMenuBar, pos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)s_hmenuLanguage, wchMenuItemStrg);
|
||||
bool const res = InsertMenu(hMenuBar, IDM_VIEW_TABSASSPACES, MF_BYCOMMAND | MF_POPUP | MF_STRING, (UINT_PTR)s_hmenuLanguage, wchMenuItemStrg);
|
||||
GetLngString(IDS_USE_LOCALE_DATEFMT, wchMenuItemStrg, COUNTOF(wchMenuItemStrg));
|
||||
InsertMenu(hMenuBar, IDM_VIEW_TABSASSPACES, MF_BYCOMMAND | MF_STRING, (UINT_PTR)IDS_USE_LOCALE_DATEFMT, wchMenuItemStrg);
|
||||
InsertMenu(hMenuBar, IDM_VIEW_TABSASSPACES, MF_BYCOMMAND | MF_SEPARATOR, (UINT_PTR)NULL, NULL);
|
||||
return res;
|
||||
} else {
|
||||
Settings.PreferredLocale4DateFmt = false;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3837,6 +3842,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_L2R, dwr);
|
||||
EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_R2L, dwr);
|
||||
|
||||
CheckCmd(hmenu, IDS_USE_LOCALE_DATEFMT, Settings.PreferredLocale4DateFmt);
|
||||
|
||||
CheckCmd(hmenu, IDM_VIEW_MUTE_MESSAGEBEEP, Settings.MuteMessageBeep);
|
||||
CheckCmd(hmenu, IDM_VIEW_SAVEBEFORERUNNINGTOOLS, Settings.SaveBeforeRunningTools);
|
||||
@ -5337,6 +5343,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
|
||||
case IDS_USE_LOCALE_DATEFMT:
|
||||
Settings.PreferredLocale4DateFmt = !Settings.PreferredLocale4DateFmt;
|
||||
break;
|
||||
|
||||
|
||||
case IDM_VIEW_TABSASSPACES: {
|
||||
Settings.TabsAsSpaces = !Settings.TabsAsSpaces;
|
||||
Globals.fvCurFile.bTabsAsSpaces = Settings.TabsAsSpaces;
|
||||
|
||||
@ -505,6 +505,7 @@ typedef struct _settings_t
|
||||
bool EditLayoutRTL;
|
||||
bool DialogsLayoutRTL;
|
||||
int FocusViewMarkerMode;
|
||||
bool PreferredLocale4DateFmt;
|
||||
|
||||
#ifdef D_NP3_WIN10_DARK_MODE
|
||||
bool WinThemeDarkMode;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user