Repository navigation
Expand file tree
/
Copy pathSource.cpp
More file actions
6937 lines (6646 loc) · 835 KB
/
Copy pathSource.cpp
File metadata and controls
6937 lines (6646 loc) · 835 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#define NOMINMAX
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shobjidl.h>
#include <propkey.h>
#include <propvarutil.h>
#pragma comment(lib, "propsys.lib")
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
#include <d3d11.h>
#include <dxgi1_2.h>
#include <d2d1_1.h>
#include <d2d1.h>
#include <dwrite.h>
#include <dcomp.h>
#include <initguid.h>
#include <d2d1effects.h>
#include <imm.h>
#include <commdlg.h>
#include <commctrl.h>
#include <dwmapi.h>
#include <uxtheme.h>
#include <string>
#include <vector>
#include <memory>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <regex>
#include <cstring>
#include <cstdint>
#include <mutex>
#include <thread>
#include <atomic>
#include <emmintrin.h>
#include <intrin.h>
#include "compact_enc_det/compact_enc_det.h"
#include "resource.h"
#include "include/Pele.h"
#include "include/MiuCore.h"
#include "include/MiuSyntax.h"
#include "include/MiuEmmet.h"
#include "include/MiuPreview.h"
#pragma comment(lib, "d2d1.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "dcomp.lib")
#pragma comment(lib, "dwrite.lib")
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "imm32.lib")
#pragma comment(lib, "comdlg32.lib")
#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "dwmapi.lib")
#pragma comment(lib, "uxtheme.lib")
#pragma comment(lib, "ced.lib")
const std::wstring APP_VERSION = L"miu v1.0.49";
enum MiuEncoding { ENC_UTF8_NOBOM = 0, ENC_UTF8_BOM, ENC_UTF16LE, ENC_UTF16BE, ENC_LOCAL };
struct DetectResult { MiuEncoding type; UINT codePage; };
static void SwapBytes(wchar_t* buf, size_t count) {
for (size_t i = 0; i < count; ++i) { unsigned short x = (unsigned short)buf[i]; buf[i] = (wchar_t)((x >> 8) | (x << 8)); }
}
using MiuCore::IsValidUtf8;
static UINT MapCedEncodingToCodePage(Encoding enc) {
switch (enc) {
case JAPANESE_SHIFT_JIS:
case JAPANESE_CP932:
case KDDI_SHIFT_JIS:
case DOCOMO_SHIFT_JIS:
case SOFTBANK_SHIFT_JIS: return 932;
case JAPANESE_EUC_JP: return 20932;
case JAPANESE_JIS:
case KDDI_ISO_2022_JP:
case SOFTBANK_ISO_2022_JP: return 50220;
case CHINESE_GB:
case GBK:
case HZ_GB_2312:
case ISO_2022_CN: return 936;
case GB18030: return 54936;
case CHINESE_BIG5:
case CHINESE_BIG5_CP950:
case BIG5_HKSCS: return 950;
case KOREAN_EUC_KR:
case ISO_2022_KR: return 949;
case RUSSIAN_CP1251: return 1251;
case RUSSIAN_KOI8_R: return 20866;
case RUSSIAN_KOI8_RU: return 21866;
case ISO_8859_5: return 28595;
case RUSSIAN_CP866: return 866;
case LATIN1:
case MSFT_CP1252: return 1252;
case ISO_8859_15: return 28605;
case MACINTOSH_ROMAN: return 10000;
case MSFT_CP1250: return 1250;
case ISO_8859_2: return 28592;
case CZECH_CP852: return 852;
case MSFT_CP1253: return 1253;
case ISO_8859_7: return 28597;
case MSFT_CP1254: return 1254;
case ISO_8859_9: return 28599;
case MSFT_CP1255: return 1255;
case ISO_8859_8:
case ISO_8859_8_I:
case HEBREW_VISUAL: return 28598;
case MSFT_CP1256: return 1256;
case ISO_8859_6: return 28596;
case MSFT_CP1257: return 1257;
case ISO_8859_4: return 28594;
case ISO_8859_13: return 28603;
case ISO_8859_11:
case MSFT_CP874: return 874;
case UTF7: return 65000;
case UTF8:
case UTF8UTF8:
case ASCII_7BIT: return CP_UTF8;
default: return CP_ACP;
}
}
static DetectResult DetectEncodingEx(const char* buf, size_t len) {
DetectResult res = { ENC_UTF8_NOBOM, CP_UTF8 };
if (len >= 3 && (unsigned char)buf[0] == 0xEF && (unsigned char)buf[1] == 0xBB && (unsigned char)buf[2] == 0xBF) { res.type = ENC_UTF8_BOM; return res; }
if (len >= 2) {
if ((unsigned char)buf[0] == 0xFF && (unsigned char)buf[1] == 0xFE) { res.type = ENC_UTF16LE; return res; }
if ((unsigned char)buf[0] == 0xFE && (unsigned char)buf[1] == 0xFF) { res.type = ENC_UTF16BE; return res; }
}
if (IsValidUtf8(buf, len)) { res.type = ENC_UTF8_NOBOM; return res; }
int bomless16 = MiuCore::DetectBomlessUtf16(buf, len);
if (bomless16 == 1) { res.type = ENC_UTF16LE; return res; }
if (bomless16 == 2) { res.type = ENC_UTF16BE; return res; }
const char* sampleBuf = buf;
size_t sampleLen = len;
MiuCore::SelectCedSampleWindow(buf, len, sampleBuf, sampleLen);
int bytes_consumed = 0; bool is_reliable = false;
Encoding ced_enc = CompactEncDet::DetectEncoding(sampleBuf, static_cast<int>(sampleLen), nullptr, nullptr, nullptr, UNKNOWN_ENCODING, UNKNOWN_LANGUAGE, CompactEncDet::WEB_CORPUS, false, &bytes_consumed, &is_reliable);
if (ced_enc == UTF16LE) { res.type = ENC_UTF16LE; return res; }
if (ced_enc == UTF16BE) { res.type = ENC_UTF16BE; return res; }
res.type = ENC_LOCAL; res.codePage = MapCedEncodingToCodePage(ced_enc);
return res;
}
static std::wstring UTF8ToW(const std::string& s) {
if (s.empty()) return {};
int n = MultiByteToWideChar(CP_UTF8, 0, s.data(), (int)s.size(), NULL, 0);
if (n <= 0) return {};
std::wstring w; w.resize(n);
MultiByteToWideChar(CP_UTF8, 0, s.data(), (int)s.size(), &w[0], n);
return w;
}
static void UTF8ToW(const std::string& s, std::wstring& out) {
out.clear();
if (s.empty()) return;
int n = MultiByteToWideChar(CP_UTF8, 0, s.data(), (int)s.size(), NULL, 0);
if (n <= 0) return;
out.resize(n);
MultiByteToWideChar(CP_UTF8, 0, s.data(), (int)s.size(), &out[0], n);
}
using MiuCore::SanitizeUtf8;
static std::string LocalToUtf8(const char* data, size_t len, UINT cp) {
if (len == 0) return "";
int wLen = MultiByteToWideChar(cp, 0, data, (int)len, NULL, 0);
if (wLen <= 0) return SanitizeUtf8(data, len);
std::vector<wchar_t> wBuf(wLen);
MultiByteToWideChar(cp, 0, data, (int)len, wBuf.data(), wLen);
for (wchar_t& wc : wBuf) { if (wc == 0) wc = L'?'; }
int uLen = WideCharToMultiByte(CP_UTF8, 0, wBuf.data(), wLen, NULL, 0, NULL, NULL);
if (uLen <= 0) return SanitizeUtf8(data, len);
std::string ret; ret.resize(uLen);
WideCharToMultiByte(CP_UTF8, 0, wBuf.data(), wLen, &ret[0], uLen, NULL, NULL);
return ret;
}
static std::string Utf8ToLocal(const std::string& utf8, UINT cp) {
if (utf8.empty()) return "";
std::wstring w = UTF8ToW(utf8);
int len = WideCharToMultiByte(cp, 0, w.c_str(), (int)w.size(), NULL, 0, NULL, NULL);
if (len <= 0) return "";
std::string ret; ret.resize(len);
WideCharToMultiByte(cp, 0, w.c_str(), (int)w.size(), &ret[0], len, NULL, NULL);
return ret;
}
using MiuCore::Utf16ToUtf8;
static std::wstring Utf8ToUtf16(const std::string& utf8) {
if (utf8.empty()) return L"";
int wLen = MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.size(), NULL, 0);
if (wLen <= 0) return L"";
std::wstring ret; ret.resize(wLen);
MultiByteToWideChar(CP_UTF8, 0, utf8.data(), (int)utf8.size(), &ret[0], wLen);
return ret;
}
static std::wstring GetResString(UINT id) {
const wchar_t* pBuf = nullptr;
int len = LoadStringW(GetModuleHandle(NULL), id, (LPWSTR)&pBuf, 0);
if (len > 0 && pBuf) return std::wstring(pBuf, len);
return L"";
}
const int MAX_RECENT_FILES = 60;
const UINT IDM_RECENT_SEP = 0x7FF0;
const UINT IDM_RECENT_BASE = 0x8000;
const UINT IDM_CTX_UNDO = 3001;
const UINT IDM_CTX_REDO = 3002;
const UINT IDM_CTX_CUT = 3003;
const UINT IDM_CTX_COPY = 3004;
const UINT IDM_CTX_PASTE = 3005;
const UINT IDM_CTX_SELECT_ALL = 3006;
const size_t MAX_RECENT_MENU_ITEMS = 20;
static std::vector<std::wstring> s_sysMenuRecentFiles;
#pragma pack(push, 1)
struct SavedCursorEntry {
uint64_t head = 0;
uint64_t anchor = 0;
uint32_t headLine = 0;
uint32_t headCol = 0;
uint32_t anchorLine = 0;
uint32_t anchorCol = 0;
uint32_t selHash = 0;
uint32_t selLen = 0;
float desiredX = 0.0f;
uint8_t affinity = 0;
uint8_t reserved[3] = {};
};
struct FileViewState {
uint64_t docByteLen = 0;
uint64_t fileWriteTime = 0;
uint32_t contextHash = 0;
int32_t vScrollPos = 0;
int32_t vScrollSubLine = 0;
int32_t hScrollPos = 0;
uint8_t isRectSelecting = 0;
uint8_t cursorCount = 0;
uint16_t reserved = 0;
int32_t rectAnchorLine = 0;
int32_t rectHeadLine = 0;
float rectAnchorX = 0.0f;
float rectHeadX = 0.0f;
SavedCursorEntry cursors[16] = {};
};
#pragma pack(pop)
#pragma optimize("s", on)
struct StoredViewStateEntry {
std::wstring path;
FileViewState state;
};
static std::mutex s_recentMutex;
static bool s_recentCacheLoaded = false;
static std::vector<std::wstring> s_recentFilesCache;
static int s_lastSavedRecentCount = MAX_RECENT_FILES;
static bool s_viewStatesLoaded = false;
static std::vector<StoredViewStateEntry> s_viewStatesCache;
static const uint32_t VIEW_STATE_MAGIC = 0x3153564Du; // 'MVS1'
static const uint32_t VIEW_STATE_VERSION = 1u;
static std::wstring normalizePath(const std::wstring& p) {
std::wstring s = p;
while (!s.empty() && (s.front() == L' ' || s.front() == L'\"' || s.front() == L'\'')) s.erase(s.begin());
while (!s.empty() && (s.back() == L' ' || s.back() == L'\"' || s.back() == L'\'')) s.pop_back();
if (s.empty()) return L"";
wchar_t fullPath[MAX_PATH];
if (GetFullPathNameW(s.c_str(), MAX_PATH, fullPath, NULL)) {
wchar_t longPath[MAX_PATH];
if (GetLongPathNameW(fullPath, longPath, MAX_PATH)) {
return longPath;
}
return fullPath;
}
return s;
}
static void loadViewStatesLocked() {
if (s_viewStatesLoaded) return;
s_viewStatesLoaded = true;
s_viewStatesCache.clear();
HKEY hKey;
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\miu\\RecentFiles", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
DWORD type = 0;
DWORD size = 0;
if (RegQueryValueExW(hKey, L"ViewStates", NULL, &type, NULL, &size) == ERROR_SUCCESS && type == REG_BINARY && size >= sizeof(uint32_t) * 3 && size <= 1024 * 1024) {
std::vector<uint8_t> buf(size);
if (RegQueryValueExW(hKey, L"ViewStates", NULL, &type, buf.data(), &size) == ERROR_SUCCESS) {
size_t offset = 0;
uint32_t magic = 0, version = 0, count = 0;
std::memcpy(&magic, buf.data() + offset, sizeof(uint32_t)); offset += sizeof(uint32_t);
std::memcpy(&version, buf.data() + offset, sizeof(uint32_t)); offset += sizeof(uint32_t);
std::memcpy(&count, buf.data() + offset, sizeof(uint32_t)); offset += sizeof(uint32_t);
if (magic == VIEW_STATE_MAGIC && version == VIEW_STATE_VERSION && count <= (uint32_t)(MAX_RECENT_FILES * 2)) {
s_viewStatesCache.reserve(std::min((size_t)count, (size_t)MAX_RECENT_FILES));
for (uint32_t i = 0; i < count; ++i) {
if (offset + sizeof(uint16_t) > size) break;
uint16_t pathLen = 0;
std::memcpy(&pathLen, buf.data() + offset, sizeof(uint16_t)); offset += sizeof(uint16_t);
if (pathLen == 0 || pathLen > MAX_PATH) break;
size_t pathBytes = (size_t)pathLen * sizeof(wchar_t);
if (offset + pathBytes + sizeof(FileViewState) > size) break;
StoredViewStateEntry entry;
entry.path.resize(pathLen);
std::memcpy(&entry.path[0], buf.data() + offset, pathBytes); offset += pathBytes;
std::memcpy(&entry.state, buf.data() + offset, sizeof(FileViewState)); offset += sizeof(FileViewState);
if (entry.state.cursorCount > 16) entry.state.cursorCount = 16;
if (s_viewStatesCache.size() < (size_t)MAX_RECENT_FILES) {
s_viewStatesCache.push_back(std::move(entry));
}
}
}
}
}
RegCloseKey(hKey);
}
}
static void saveViewStatesLocked() {
HKEY hKey;
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\miu\\RecentFiles", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
uint32_t count = (uint32_t)std::min(s_viewStatesCache.size(), (size_t)MAX_RECENT_FILES);
size_t totalBytes = sizeof(uint32_t) * 3;
for (uint32_t i = 0; i < count; ++i) {
uint16_t pLen = (uint16_t)std::min(s_viewStatesCache[i].path.size(), (size_t)MAX_PATH);
totalBytes += sizeof(uint16_t) + (size_t)pLen * sizeof(wchar_t) + sizeof(FileViewState);
}
std::vector<uint8_t> buf(totalBytes);
size_t offset = 0;
std::memcpy(buf.data() + offset, &VIEW_STATE_MAGIC, sizeof(uint32_t)); offset += sizeof(uint32_t);
std::memcpy(buf.data() + offset, &VIEW_STATE_VERSION, sizeof(uint32_t)); offset += sizeof(uint32_t);
std::memcpy(buf.data() + offset, &count, sizeof(uint32_t)); offset += sizeof(uint32_t);
for (uint32_t i = 0; i < count; ++i) {
uint16_t pLen = (uint16_t)std::min(s_viewStatesCache[i].path.size(), (size_t)MAX_PATH);
size_t pathBytes = (size_t)pLen * sizeof(wchar_t);
std::memcpy(buf.data() + offset, &pLen, sizeof(uint16_t)); offset += sizeof(uint16_t);
if (pathBytes > 0) {
std::memcpy(buf.data() + offset, s_viewStatesCache[i].path.data(), pathBytes);
offset += pathBytes;
}
std::memcpy(buf.data() + offset, &s_viewStatesCache[i].state, sizeof(FileViewState)); offset += sizeof(FileViewState);
}
RegSetValueExW(hKey, L"ViewStates", 0, REG_BINARY, buf.data(), (DWORD)buf.size());
RegCloseKey(hKey);
}
}
static void saveFileViewState(const std::wstring& path, const FileViewState& state) {
if (path.empty()) return;
std::wstring norm = normalizePath(path);
if (norm.empty()) return;
std::lock_guard<std::mutex> lock(s_recentMutex);
loadViewStatesLocked();
for (auto it = s_viewStatesCache.begin(); it != s_viewStatesCache.end(); ) {
if (_wcsicmp(it->path.c_str(), norm.c_str()) == 0) it = s_viewStatesCache.erase(it);
else ++it;
}
s_viewStatesCache.insert(s_viewStatesCache.begin(), { norm, state });
if (s_viewStatesCache.size() > (size_t)MAX_RECENT_FILES) {
s_viewStatesCache.resize(MAX_RECENT_FILES);
}
saveViewStatesLocked();
}
static bool getFileViewState(const std::wstring& path, FileViewState& outState) {
if (path.empty()) return false;
std::wstring norm = normalizePath(path);
if (norm.empty()) return false;
std::lock_guard<std::mutex> lock(s_recentMutex);
loadViewStatesLocked();
for (const auto& entry : s_viewStatesCache) {
if (_wcsicmp(entry.path.c_str(), norm.c_str()) == 0) {
outState = entry.state;
return true;
}
}
return false;
}
static std::vector<std::wstring> loadRecentFiles() {
std::lock_guard<std::mutex> lock(s_recentMutex);
if (s_recentCacheLoaded) return s_recentFilesCache;
std::vector<std::wstring> list;
HKEY hKey;
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\miu\\RecentFiles", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
for (int i = 0; i < MAX_RECENT_FILES; ++i) {
std::wstring valName = std::to_wstring(i);
wchar_t path[MAX_PATH] = {};
DWORD size = sizeof(path);
if (RegGetValueW(hKey, NULL, valName.c_str(), RRF_RT_REG_SZ, NULL, path, &size) == ERROR_SUCCESS && path[0] != L'\0') {
list.push_back(path);
}
}
RegCloseKey(hKey);
}
s_recentFilesCache = list;
s_lastSavedRecentCount = (int)list.size();
s_recentCacheLoaded = true;
return list;
}
static void saveRecentFiles(const std::vector<std::wstring>& list) {
std::lock_guard<std::mutex> lock(s_recentMutex);
int count = std::min((int)list.size(), MAX_RECENT_FILES);
s_recentFilesCache.assign(list.begin(), list.begin() + count);
s_recentCacheLoaded = true;
HKEY hKey;
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\miu\\RecentFiles", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
for (int i = 0; i < count; ++i) {
std::wstring valName = std::to_wstring(i);
const std::wstring& path = s_recentFilesCache[i];
RegSetValueExW(hKey, valName.c_str(), 0, REG_SZ, (const BYTE*)path.c_str(), (DWORD)((path.size() + 1) * sizeof(wchar_t)));
}
int delEnd = std::max(s_lastSavedRecentCount, count);
for (int i = count; i < delEnd; ++i) {
std::wstring valName = std::to_wstring(i);
RegDeleteValueW(hKey, valName.c_str());
}
s_lastSavedRecentCount = count;
RegCloseKey(hKey);
}
}
static bool isRunningAsPackagedApp() {
static int s_state = -1;
if (s_state != -1) return s_state == 1;
typedef LONG(WINAPI* PFN_GetCurrentPackageFullName)(UINT32*, PWSTR);
HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
if (hKernel32) {
auto pfn = (PFN_GetCurrentPackageFullName)GetProcAddress(hKernel32, "GetCurrentPackageFullName");
if (pfn) {
UINT32 len = 0;
LONG rc = pfn(&len, nullptr);
if (rc == ERROR_INSUFFICIENT_BUFFER && len > 0) {
s_state = 1;
return true;
}
}
}
s_state = 0;
return false;
}
static std::wstring getJumpListLaunchExePath() {
wchar_t exePath[MAX_PATH] = {};
GetModuleFileNameW(NULL, exePath, MAX_PATH);
if (isRunningAsPackagedApp()) {
wchar_t localAppData[MAX_PATH] = {};
if (GetEnvironmentVariableW(L"LOCALAPPDATA", localAppData, MAX_PATH) > 0) {
std::wstring aliasPath = std::wstring(localAppData) + L"\\Microsoft\\WindowsApps\\miu.exe";
DWORD attrs = GetFileAttributesW(aliasPath.c_str());
if (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY)) {
return aliasPath;
}
}
}
return exePath;
}
static std::vector<std::wstring> extractRemovedPaths(IObjectArray* pRemoved) {
std::vector<std::wstring> toRemove;
if (!pRemoved) return toRemove;
UINT count = 0;
if (FAILED(pRemoved->GetCount(&count)) || count == 0) return toRemove;
wchar_t exePath[MAX_PATH] = {};
GetModuleFileNameW(NULL, exePath, MAX_PATH);
std::wstring normExe = normalizePath(exePath);
std::wstring normLaunchExe = normalizePath(getJumpListLaunchExePath());
for (UINT i = 0; i < count; ++i) {
IUnknown* pUnk = nullptr;
if (SUCCEEDED(pRemoved->GetAt(i, IID_PPV_ARGS(&pUnk)))) {
IShellItem* pItem = nullptr;
if (SUCCEEDED(pUnk->QueryInterface(IID_PPV_ARGS(&pItem)))) {
LPWSTR pszPath = nullptr;
if (SUCCEEDED(pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath)) && pszPath) {
std::wstring norm = normalizePath(pszPath);
if (!norm.empty()) toRemove.push_back(norm);
CoTaskMemFree(pszPath);
} else if (SUCCEEDED(pItem->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)) && pszPath) {
std::wstring norm = normalizePath(pszPath);
if (!norm.empty()) toRemove.push_back(norm);
CoTaskMemFree(pszPath);
}
pItem->Release();
}
IShellLinkW* pLink = nullptr;
if (SUCCEEDED(pUnk->QueryInterface(IID_PPV_ARGS(&pLink)))) {
wchar_t args[MAX_PATH] = {};
if (SUCCEEDED(pLink->GetArguments(args, MAX_PATH)) && args[0] != L'\0') {
std::wstring norm = normalizePath(args);
if (!norm.empty()) toRemove.push_back(norm);
}
wchar_t path[MAX_PATH] = {};
if (SUCCEEDED(pLink->GetPath(path, MAX_PATH, NULL, 0)) && path[0] != L'\0') {
std::wstring norm = normalizePath(path);
if (!norm.empty() && _wcsicmp(norm.c_str(), normExe.c_str()) != 0 && _wcsicmp(norm.c_str(), normLaunchExe.c_str()) != 0) {
toRemove.push_back(norm);
}
}
pLink->Release();
}
pUnk->Release();
}
}
return toRemove;
}
static void removeFromRecentFiles(const std::vector<std::wstring>& toRemove) {
if (toRemove.empty()) return;
std::vector<std::wstring> normRemove;
for (const auto& r : toRemove) {
std::wstring n = normalizePath(r);
if (!n.empty()) normRemove.push_back(n);
}
if (normRemove.empty()) return;
std::vector<std::wstring> current = loadRecentFiles();
std::vector<std::wstring> updated;
for (const auto& item : current) {
std::wstring normItem = normalizePath(item);
bool match = false;
for (const auto& rem : normRemove) {
if (_wcsicmp(normItem.c_str(), rem.c_str()) == 0) {
match = true;
break;
}
}
if (!match) updated.push_back(item);
}
if (updated.size() != current.size()) {
saveRecentFiles(updated);
std::lock_guard<std::mutex> lock(s_recentMutex);
loadViewStatesLocked();
bool stateRemoved = false;
for (auto it = s_viewStatesCache.begin(); it != s_viewStatesCache.end(); ) {
bool match = false;
for (const auto& rem : normRemove) {
if (_wcsicmp(it->path.c_str(), rem.c_str()) == 0) { match = true; break; }
}
if (match) { it = s_viewStatesCache.erase(it); stateRemoved = true; }
else ++it;
}
if (stateRemoved) saveViewStatesLocked();
}
}
static void updateJumpList() {
CoInitialize(NULL);
ICustomDestinationList* pDestList = nullptr;
if (FAILED(CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDestList)))) {
return;
}
if (!isRunningAsPackagedApp()) {
pDestList->SetAppID(L"miu");
}
UINT cMinSlots = 0;
IObjectArray* pRemoved = nullptr;
if (FAILED(pDestList->BeginList(&cMinSlots, IID_PPV_ARGS(&pRemoved)))) {
pDestList->Release();
return;
}
if (pRemoved) {
std::vector<std::wstring> toRemove = extractRemovedPaths(pRemoved);
if (!toRemove.empty()) {
removeFromRecentFiles(toRemove);
}
pRemoved->Release();
}
std::vector<std::wstring> recentList = loadRecentFiles();
std::vector<std::wstring> validList;
for (const auto& p : recentList) {
DWORD attrs = GetFileAttributesW(p.c_str());
if (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY)) {
validList.push_back(p);
}
}
if (validList.size() != recentList.size()) {
saveRecentFiles(validList);
}
UINT maxSlots = (cMinSlots > 0) ? std::min((UINT)validList.size(), cMinSlots) : (UINT)validList.size();
if (maxSlots > 0) {
IObjectCollection* pCollection = nullptr;
if (SUCCEEDED(CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pCollection)))) {
wchar_t exePath[MAX_PATH];
GetModuleFileNameW(NULL, exePath, MAX_PATH);
std::wstring launchPath = getJumpListLaunchExePath();
for (UINT i = 0; i < maxSlots; ++i) {
const std::wstring& filePath = validList[i];
IShellLinkW* pLink = nullptr;
if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pLink)))) {
pLink->SetPath(launchPath.c_str());
std::wstring arg = L"\"" + filePath + L"\"";
pLink->SetArguments(arg.c_str());
std::wstring title = filePath;
size_t lastSlash = filePath.find_last_of(L"\\/");
if (lastSlash != std::wstring::npos) title = filePath.substr(lastSlash + 1);
IPropertyStore* pPropStore = nullptr;
if (SUCCEEDED(pLink->QueryInterface(IID_PPV_ARGS(&pPropStore)))) {
PROPVARIANT pv;
InitPropVariantFromString(title.c_str(), &pv);
pPropStore->SetValue(PKEY_Title, pv);
PropVariantClear(&pv);
pPropStore->Commit();
pPropStore->Release();
}
pLink->SetDescription(filePath.c_str());
pLink->SetIconLocation(exePath, 0);
pCollection->AddObject(pLink);
pLink->Release();
}
}
std::wstring catName = GetResString(IDS_RECENT_FILES);
if (catName.empty()) catName = L"Recent Files";
pDestList->AppendCategory(catName.c_str(), pCollection);
pCollection->Release();
}
}
pDestList->CommitList();
pDestList->Release();
}
static void syncRemovedJumpListItems() {
CoInitialize(NULL);
ICustomDestinationList* pDestList = nullptr;
if (FAILED(CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDestList)))) {
return;
}
if (!isRunningAsPackagedApp()) {
pDestList->SetAppID(L"miu");
}
IObjectArray* pRemoved = nullptr;
if (SUCCEEDED(pDestList->GetRemovedDestinations(IID_PPV_ARGS(&pRemoved)))) {
if (pRemoved) {
UINT count = 0;
if (SUCCEEDED(pRemoved->GetCount(&count)) && count > 0) {
std::vector<std::wstring> toRemove = extractRemovedPaths(pRemoved);
pRemoved->Release();
pDestList->Release();
if (!toRemove.empty()) {
removeFromRecentFiles(toRemove);
}
updateJumpList();
return;
}
pRemoved->Release();
}
}
pDestList->Release();
}
static bool s_jumpListWorkerRunning = false;
static bool s_hasPendingShellUpdate = false;
static std::wstring s_pendingShellPath;
static void scheduleShellRecentUpdate(const std::wstring& normalizedPath) {
{
std::lock_guard<std::mutex> lock(s_recentMutex);
s_hasPendingShellUpdate = true;
if (!normalizedPath.empty()) {
s_pendingShellPath = normalizedPath;
}
if (s_jumpListWorkerRunning) return;
s_jumpListWorkerRunning = true;
}
std::thread([]() {
try {
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
for (;;) {
std::wstring pathToNotify;
{
std::lock_guard<std::mutex> lock(s_recentMutex);
if (!s_hasPendingShellUpdate) {
s_jumpListWorkerRunning = false;
break;
}
s_hasPendingShellUpdate = false;
pathToNotify = std::move(s_pendingShellPath);
s_pendingShellPath.clear();
}
updateJumpList();
if (!pathToNotify.empty()) {
SHAddToRecentDocs(SHARD_PATHW, pathToNotify.c_str());
}
}
CoUninitialize();
} catch (...) {
std::lock_guard<std::mutex> lock(s_recentMutex);
s_jumpListWorkerRunning = false;
}
}).detach();
}
static void addToRecentFiles(const std::wstring& path, bool fileAlreadyVerified = false) {
if (path.empty()) return;
std::wstring normalizedPath = normalizePath(path);
if (normalizedPath.empty()) return;
if (!fileAlreadyVerified) {
DWORD attrs = GetFileAttributesW(normalizedPath.c_str());
if (attrs == INVALID_FILE_ATTRIBUTES || (attrs & FILE_ATTRIBUTE_DIRECTORY)) return;
}
std::vector<std::wstring> list = loadRecentFiles();
if (list.empty() || _wcsicmp(list.front().c_str(), normalizedPath.c_str()) != 0) {
std::vector<std::wstring> updated;
updated.reserve(std::min((int)list.size() + 1, MAX_RECENT_FILES));
updated.push_back(normalizedPath);
for (const auto& item : list) {
if (_wcsicmp(item.c_str(), normalizedPath.c_str()) != 0) {
updated.push_back(item);
}
if (updated.size() >= MAX_RECENT_FILES) break;
}
saveRecentFiles(updated);
}
scheduleShellRecentUpdate(normalizedPath);
}
enum PreferredAppMode {
PAM_DEFAULT = 0,
PAM_ALLOW_DARK = 1,
PAM_FORCE_DARK = 2,
PAM_FORCE_LIGHT = 3,
PAM_MAX = 4
};
using fnSetPreferredAppMode = PreferredAppMode (WINAPI *)(PreferredAppMode appMode);
using fnAllowDarkModeForWindow = BOOL (WINAPI *)(HWND hWnd, BOOL allow);
using fnFlushMenuThemes = void (WINAPI *)();
static void InitDarkMode() {
HMODULE hUxtheme = GetModuleHandleW(L"uxtheme.dll");
if (!hUxtheme) hUxtheme = LoadLibraryExW(L"uxtheme.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hUxtheme) {
auto pSetPreferredAppMode = (fnSetPreferredAppMode)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135));
if (pSetPreferredAppMode) {
pSetPreferredAppMode(PAM_ALLOW_DARK);
}
auto pFlushMenuThemes = (fnFlushMenuThemes)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136));
if (pFlushMenuThemes) {
pFlushMenuThemes();
}
}
}
static void EnableDarkModeForWindow(HWND hwnd, BOOL enable) {
if (!hwnd) return;
HMODULE hUxtheme = GetModuleHandleW(L"uxtheme.dll");
if (hUxtheme) {
auto pAllowDarkModeForWindow = (fnAllowDarkModeForWindow)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133));
if (pAllowDarkModeForWindow) {
pAllowDarkModeForWindow(hwnd, enable);
}
}
}
static void ApplyMenuTheme(bool isDarkMode) {
HMODULE hUxtheme = GetModuleHandleW(L"uxtheme.dll");
if (!hUxtheme) hUxtheme = LoadLibraryExW(L"uxtheme.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hUxtheme) {
auto pSetPreferredAppMode = (fnSetPreferredAppMode)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135));
if (pSetPreferredAppMode) {
pSetPreferredAppMode(isDarkMode ? PAM_FORCE_DARK : PAM_FORCE_LIGHT);
}
auto pFlushMenuThemes = (fnFlushMenuThemes)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136));
if (pFlushMenuThemes) {
pFlushMenuThemes();
}
}
}
static void FlushMenuThemesInternal() {
HMODULE hUxtheme = GetModuleHandleW(L"uxtheme.dll");
if (hUxtheme) {
auto pFlushMenuThemes = (fnFlushMenuThemes)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136));
if (pFlushMenuThemes) {
pFlushMenuThemes();
}
}
}
static void updateSystemMenu(HWND hwnd) {
if (!hwnd) return;
syncRemovedJumpListItems();
HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);
if (!hSysMenu) return;
DeleteMenu(hSysMenu, IDM_RECENT_SEP, MF_BYCOMMAND);
for (UINT id = IDM_RECENT_BASE; id < IDM_RECENT_BASE + (UINT)(MAX_RECENT_MENU_ITEMS * 16); id += 16) {
DeleteMenu(hSysMenu, id, MF_BYCOMMAND);
}
s_sysMenuRecentFiles.clear();
std::vector<std::wstring> recentList = loadRecentFiles();
size_t count = std::min(recentList.size(), MAX_RECENT_MENU_ITEMS);
if (count > 0) {
AppendMenuW(hSysMenu, MF_SEPARATOR, IDM_RECENT_SEP, NULL);
for (size_t i = 0; i < count; ++i) {
const std::wstring& path = recentList[i];
s_sysMenuRecentFiles.push_back(path);
wchar_t dispPath[MAX_PATH] = {};
if (path.length() > 60) {
PathCompactPathExW(dispPath, path.c_str(), 60, 0);
} else {
wcsncpy_s(dispPath, MAX_PATH, path.c_str(), _TRUNCATE);
}
std::wstring escaped;
for (const wchar_t* p = dispPath; *p; ++p) {
if (*p == L'&') escaped += L"&&";
else escaped += *p;
}
std::wstring itemText;
if (i < 9) {
itemText = L"&" + std::to_wstring(i + 1) + L" " + escaped;
} else if (i == 9) {
itemText = L"1&0 " + escaped;
} else {
itemText = std::to_wstring(i + 1) + L" " + escaped;
}
UINT itemID = IDM_RECENT_BASE + (UINT)(i * 16);
AppendMenuW(hSysMenu, MF_STRING, itemID, itemText.c_str());
}
}
}
static std::string WToUTF8(const std::wstring& w) {
if (w.empty()) return {};
int n = WideCharToMultiByte(CP_UTF8, 0, w.data(), (int)w.size(), NULL, 0, NULL, NULL);
if (n <= 0) return {};
std::string s; s.resize(n);
WideCharToMultiByte(CP_UTF8, 0, w.data(), (int)w.size(), &s[0], n, NULL, NULL);
return s;
}
static std::string UnescapeString(const std::string& s, const std::string& newline) {
return MiuCore::unescapeReplaceString(s, newline);
}
#pragma optimize("", on)
using MiuCore::Piece;
using MiuCore::PieceTable;
using MiuCore::Cursor;
using MiuCore::EditOp;
using MiuCore::EditBatch;
using MiuCore::UndoManager;
struct MappedFile {
HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hMap = NULL; const char* ptr = nullptr; size_t size = 0;
std::vector<char> heapBuffer; bool isMapped = false;
FILETIME ftWrite = { 0, 0 };
static const size_t THRESHOLD = 50 * 1024 * 1024; // 50MB
bool open(const wchar_t* path) {
hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hFile == INVALID_HANDLE_VALUE) return false;
GetFileTime(hFile, NULL, NULL, &ftWrite);
LARGE_INTEGER li; if (!GetFileSizeEx(hFile, &li)) { CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return false; }
size = (size_t)li.QuadPart;
if (size == 0) { ptr = nullptr; CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return true; }
if (size >= THRESHOLD) {
hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (!hMap) { CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return false; }
ptr = (const char*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); isMapped = true; return !!ptr;
}
else {
heapBuffer.resize(size); DWORD bytesRead = 0;
if (ReadFile(hFile, heapBuffer.data(), (DWORD)size, &bytesRead, NULL) && bytesRead == size) {
ptr = heapBuffer.data(); isMapped = false; CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return true;
}
CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; return false;
}
}
void close() {
if (isMapped && ptr) { UnmapViewOfFile(ptr); ptr = nullptr; }
if (hMap) { CloseHandle(hMap); hMap = NULL; }
if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; }
heapBuffer.clear(); ptr = nullptr; size = 0; isMapped = false;
}
~MappedFile() { close(); }
};
#include <unordered_set>
#include <string_view>
#include <deque>
#include <cwctype>
class CustomTextRenderer : public IDWriteTextRenderer {
public:
ID2D1DeviceContext* rend;
ID2D1SolidColorBrush* defaultBrush;
CustomTextRenderer(ID2D1DeviceContext* r, ID2D1SolidColorBrush* b) : rend(r), defaultBrush(b) {}
IFACEMETHOD(DrawGlyphRun)(void*, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, DWRITE_GLYPH_RUN const* glyphRun, DWRITE_GLYPH_RUN_DESCRIPTION const*, IUnknown* clientDrawingEffect) override {
ID2D1SolidColorBrush* brush = defaultBrush;
if (clientDrawingEffect) clientDrawingEffect->QueryInterface(__uuidof(ID2D1SolidColorBrush), (void**)&brush);
rend->DrawGlyphRun(D2D1::Point2F(baselineOriginX, baselineOriginY), glyphRun, brush, measuringMode);
if (clientDrawingEffect && brush != defaultBrush) brush->Release();
return S_OK;
}
IFACEMETHOD(DrawUnderline)(void*, FLOAT, FLOAT, DWRITE_UNDERLINE const*, IUnknown*) override { return E_NOTIMPL; }
IFACEMETHOD(DrawStrikethrough)(void*, FLOAT, FLOAT, DWRITE_STRIKETHROUGH const*, IUnknown*) override { return E_NOTIMPL; }
IFACEMETHOD(DrawInlineObject)(void*, FLOAT, FLOAT, IDWriteInlineObject*, BOOL, BOOL, IUnknown*) override { return E_NOTIMPL; }
IFACEMETHOD(IsPixelSnappingDisabled)(void*, BOOL* disabled) override { *disabled = FALSE; return S_OK; }
IFACEMETHOD(GetCurrentTransform)(void*, DWRITE_MATRIX* m) override { rend->GetTransform((D2D1_MATRIX_3X2_F*)m); return S_OK; }
IFACEMETHOD(GetPixelsPerDip)(void*, FLOAT* pixelsPerDip) override { *pixelsPerDip = 1.0f; return S_OK; }
IFACEMETHODIMP_(ULONG) AddRef() { return 1; }
IFACEMETHODIMP_(ULONG) Release() { return 1; }
IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv) {
if (riid == __uuidof(IDWriteTextRenderer) || riid == __uuidof(IDWritePixelSnapping) || riid == __uuidof(IUnknown)) { *ppv = this; return S_OK; }
*ppv = NULL; return E_NOINTERFACE;
}
};
#pragma optimize("s", on)
struct CustomDialogButton {
int id = 0;
std::wstring text;
int width = 0;
int height = 0;
int x = 0;
int y = 0;
HWND hwnd = NULL;
bool isDefault = false;
bool isCancel = false;
};
struct CustomTaskDialogData {
HWND hDlg = NULL;
HWND hwndParent = NULL;
bool isDarkMode = false;
UINT dpi = 96;
std::wstring title;
std::wstring instruction;
std::wstring content;
bool hasContent = false;
HICON hIcon = NULL;
int iconSize = 32;
HFONT hFontInstruction = NULL;
HFONT hFontContent = NULL;
HFONT hFontButton = NULL;
int padX = 0;
int padY = 0;
int textLeft = 0;
int iconTextGap = 0;
int textGap = 0;
int instW = 0;
int instH = 0;
int contentW = 0;
int contentH = 0;
int upperHeight = 0;
int lowerHeight = 0;
int clientWidth = 0;
int clientHeight = 0;
std::vector<CustomDialogButton> buttons;
int resultId = 0;
int cancelId = IDCANCEL;
HWND hDefaultBtn = NULL;
};
static std::wstring GetStandardButtonText(int id) {
UINT resId = 0;
switch (id) {
case IDOK: resId = IDS_BTN_OK; break;
case IDYES: resId = IDS_BTN_YES; break;
case IDNO: resId = IDS_BTN_NO; break;
case IDCANCEL: resId = IDS_BTN_CANCEL; break;
}
if (resId != 0) {
std::wstring s = GetResString(resId);
if (!s.empty()) return s;
}
switch (id) {
case IDOK: return L"OK";
case IDYES: return L"縺ッ縺・&Y)";
case IDNO: return L"縺・>縺・&N)";
case IDCANCEL: return L"繧ュ繝」繝ウ繧サ繝ォ";
case IDRETRY: return L"蜀崎ゥヲ陦・&R)";
case IDCLOSE: return L"髢峨§繧・&C)";
default: return L"";
}
}
static LRESULT CALLBACK DarkButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
CustomTaskDialogData* pData = (CustomTaskDialogData*)dwRefData;
switch (uMsg) {
case WM_MOUSEMOVE: {
BOOL isHovered = (BOOL)(INT_PTR)GetPropW(hWnd, L"MiuHover");