|
1 | 1 | // edit_commands.mm — Edit menu commands (case, line ops, comments, sort, join) |
2 | 2 | // Part of the Notepad++ macOS port modular refactor. |
3 | 3 |
|
| 4 | +#import <Foundation/Foundation.h> |
4 | 5 | #include "edit_commands.h" |
5 | 6 | #include "npp_constants.h" |
6 | 7 | #include "app_state.h" |
@@ -351,3 +352,34 @@ void doSpacesToTabs() |
351 | 352 | } |
352 | 353 | ScintillaBridge_sendMessage(sci, SCI_ENDUNDOACTION, 0, 0); |
353 | 354 | } |
| 355 | + |
| 356 | +void insertDateTimeShort() |
| 357 | +{ |
| 358 | + void* sci = ctx().activeScintillaView(); |
| 359 | + if (!sci) return; |
| 360 | + |
| 361 | + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; |
| 362 | + [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; |
| 363 | + NSString* dateStr = [formatter stringFromDate:[NSDate date]]; |
| 364 | + const char* utf8 = [dateStr UTF8String]; |
| 365 | + |
| 366 | + ScintillaBridge_sendMessage(sci, SCI_BEGINUNDOACTION, 0, 0); |
| 367 | + ScintillaBridge_sendMessage(sci, SCI_REPLACESEL, 0, reinterpret_cast<intptr_t>(utf8)); |
| 368 | + ScintillaBridge_sendMessage(sci, SCI_ENDUNDOACTION, 0, 0); |
| 369 | +} |
| 370 | + |
| 371 | +void insertDateTimeLong() |
| 372 | +{ |
| 373 | + void* sci = ctx().activeScintillaView(); |
| 374 | + if (!sci) return; |
| 375 | + |
| 376 | + NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; |
| 377 | + [formatter setDateStyle:NSDateFormatterFullStyle]; |
| 378 | + [formatter setTimeStyle:NSDateFormatterMediumStyle]; |
| 379 | + NSString* dateStr = [formatter stringFromDate:[NSDate date]]; |
| 380 | + const char* utf8 = [dateStr UTF8String]; |
| 381 | + |
| 382 | + ScintillaBridge_sendMessage(sci, SCI_BEGINUNDOACTION, 0, 0); |
| 383 | + ScintillaBridge_sendMessage(sci, SCI_REPLACESEL, 0, reinterpret_cast<intptr_t>(utf8)); |
| 384 | + ScintillaBridge_sendMessage(sci, SCI_ENDUNDOACTION, 0, 0); |
| 385 | +} |
0 commit comments