diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 71cced5d3..3ad4b493f 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -428,6 +428,11 @@ BEGIN MENUITEM "&Select All", IDM_EDIT_SELECTALL MENUITEM "Begin/End &Select", IDM_EDIT_BEGINENDSELECT MENUITEM SEPARATOR + POPUP "Insert" + BEGIN + MENUITEM "Date Time (short)", IDM_EDIT_INSERT_DATETIME_SHORT + MENUITEM "Date Time (long)", IDM_EDIT_INSERT_DATETIME_LONG + END POPUP "Cop&y to Clipboard" BEGIN MENUITEM "Current Full File path to Clipboard", IDM_EDIT_FULLPATHTOCLIP diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 0f6297ba9..aca23d309 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -66,6 +66,28 @@ void Notepad_plus::command(int id) } break; + case IDM_EDIT_INSERT_DATETIME_SHORT: + case IDM_EDIT_INSERT_DATETIME_LONG: + { + SYSTEMTIME st = { 0 }; + ::GetLocalTime(&st); + + wchar_t dateStr[128] = { 0 }; + wchar_t timeStr[128] = { 0 }; + + int dateFlag = (id == IDM_EDIT_INSERT_DATETIME_SHORT) ? DATE_SHORTDATE : DATE_LONGDATE; + GetDateFormatEx(LOCALE_NAME_USER_DEFAULT, dateFlag, &st, NULL, dateStr, sizeof(dateStr) / sizeof(dateStr[0]), NULL); + GetTimeFormatEx(LOCALE_NAME_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, timeStr, sizeof(timeStr) / sizeof(timeStr[0])); + + generic_string dateTimeStr = timeStr; + dateTimeStr += TEXT(" "); + dateTimeStr += dateStr; + + _pEditView->execute(SCI_REPLACESEL, 0, reinterpret_cast("")); + _pEditView->addGenericText(dateTimeStr.c_str()); + } + break; + case IDM_FILE_OPEN: { fileOpen(); diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index ce5864492..3901f4373 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -44,16 +44,17 @@ MenuPosition menuPos[] = { { 0, 13, -1, "file-closeMore" }, { 0, 22, -1, "file-recentFiles" }, - { 1, 10, -1, "edit-copyToClipboard" }, - { 1, 11, -1, "edit-indent" }, - { 1, 12, -1, "edit-convertCaseTo" }, - { 1, 13, -1, "edit-lineOperations" }, - { 1, 14, -1, "edit-comment" }, - { 1, 15, -1, "edit-autoCompletion" }, - { 1, 16, -1, "edit-eolConversion" }, - { 1, 17, -1, "edit-blankOperations" }, - { 1, 18, -1, "edit-pasteSpecial" }, - { 1, 19, -1, "edit-onSelection" }, + { 1, 10, -1, "edit-insert" }, + { 1, 11, -1, "edit-copyToClipboard" }, + { 1, 12, -1, "edit-indent" }, + { 1, 13, -1, "edit-convertCaseTo" }, + { 1, 14, -1, "edit-lineOperations" }, + { 1, 15, -1, "edit-comment" }, + { 1, 16, -1, "edit-autoCompletion" }, + { 1, 17, -1, "edit-eolConversion" }, + { 1, 18, -1, "edit-blankOperations" }, + { 1, 19, -1, "edit-pasteSpecial" }, + { 1, 20, -1, "edit-onSelection" }, { 2, 18, -1, "search-markAll" }, { 2, 19, -1, "search-markOne" }, diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 66ec34caf..4b5ae2037 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -165,6 +165,8 @@ #define IDM_EDIT_SORTLINES_LEXICO_CASE_INSENS_DESCENDING (IDM_EDIT + 81) #define IDM_EDIT_COPY_LINK (IDM_EDIT + 82) #define IDM_EDIT_SORTLINES_REVERSE_ORDER (IDM_EDIT + 83) + #define IDM_EDIT_INSERT_DATETIME_SHORT (IDM_EDIT + 84) + #define IDM_EDIT_INSERT_DATETIME_LONG (IDM_EDIT + 85) #define IDM_EDIT_AUTOCOMPLETE (50000 + 0) #define IDM_EDIT_AUTOCOMPLETE_CURRENTFILE (50000 + 1)