-
Notifications
You must be signed in to change notification settings - Fork 4
/
Settings.cpp
2216 lines (1937 loc) · 112 KB
/
Settings.cpp
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
#include "stdafx.h"
enum KEY_TYPE
{
KEY_INT,
KEY_UINT,
KEY_ULONG,
KEY_BOOL,
KEY_STRUCT
};
CString GetStringedProperty(void* member, KEY_TYPE type)
{
switch(type)
{
case KEY_INT:
{
CString temp;
temp.Format(L"%d", *(int*)member);
return temp;
}
case KEY_UINT:
case KEY_ULONG:
{
CString temp;
temp.Format(L"%u", *(unsigned long*)member);
return temp;
}
case KEY_BOOL:
{
CString temp;
temp.Format(L"%s", *(bool*)member ? L"true" : L"false");
return temp;
}
default:
return CString();
}
}
bool StrToBool(CString sValue)
{
return sValue == L"true";
}
// Settings XML nodes
const wchar_t KEEP_ENCODING_KEY[] = L"KeepEncoding";
const wchar_t DEFAULT_ENCODING_KEY[] = L"DefaultSaveEncoding";
const wchar_t SEARCH_OPTIONS_KEY[] = L"SearchOptions";
const wchar_t COLOR_BG_KEY[] = L"ColorBG";
const wchar_t COLOR_FG_KEY[] = L"ColorFG";
const wchar_t FONT_SIZE_KEY[] = L"FontSize";
const wchar_t XML_SRC_WRAP_KEY[] = L"XMLSrcWrap";
const wchar_t XML_SRC_SYNTAX_HL_KEY[] = L"XMLSrcSyntaxHL";
const wchar_t XML_SRC_TAG_HL_KEY[] = L"XMLSrcTagHL";
const wchar_t XML_SRC_SHOW_EOL_KEY[] = L"XMLSrcShowEOL";
const wchar_t XML_SRC_SHOW_SPACE_KEY[] = L"XMLSrcShowSpace";
const wchar_t FAST_MODE_KEY[] = L"FastMode";
const wchar_t FONT_KEY[] = L"Font";
const wchar_t SRC_FONT_KEY[] = L"SrcFont";
const wchar_t VIEW_STATUS_BAR_KEY[] = L"ViewStatusBar";
const wchar_t VIEW_DOCUMENT_TREE_KEY[] = L"ViewDocumentTree";
const wchar_t SPLITTER_POS_KEY[] = L"SplitterPos";
const wchar_t TOOLBARS_SETTINGS_KEY[] = L"Toolbars";
const wchar_t RESTORE_FILE_POS_KEY[] = L"RestoreFilePosition";
const wchar_t INTERFACE_LANG_KEY[] = L"IntefaceLangID";
const wchar_t SCRIPTS_FOLDER_KEY[] = L"ScriptsFolder";
// Added by SeNS
const wchar_t USESPELLER_CHECK_KEY[] = L"UseSpellChecker";
const wchar_t HIGHLIGHT_CHECK_KEY[] = L"HighlightMisspells";
const wchar_t CUSTOM_DICT_KEY[] = L"CustomDict";
const wchar_t CUSTOM_DICT_CODEPAGE_KEY[]= L"CustomDictCodePage";
const wchar_t NBSPCHAR_KEY[] = L"NBSPChar";
const wchar_t CHANGE_KEYBD_CHECK_KEY[] = L"ChangeKeybLayout";
const wchar_t KEYB_LAYOUT_KEY[] = L"KeyboardLayout";
const wchar_t SHOW_LINE_NUMBERS_KEY[] = L"XMLSrcShowLineNumbers";
const wchar_t IMAGE_TYPE_KEY[] = L"PasteImageType";
const wchar_t JPEG_QUALITY_KEY[] = L"JpegQuality";
//
const wchar_t INSIMAGE_ASKING[] = L"InsImageDialog";
const wchar_t SCRIPTS_HKEY_ERR_NTF[] = L"ScrHkErrDialog";
const wchar_t INS_CLEAR_IMAGE[] = L"InsClearImage";
const wchar_t WINDOW_POSITION[] = L"WindowPosition";
const wchar_t WORDS_DLG_POSITION[] = L"WordsDlgPosition";
const wchar_t SHOW_WORDS_EXCLUSIONS[] = L"ShowWordsExclusions";
// Default values for string settings
const wchar_t DEFAULT_ENCODING[] = L"utf-8";
const wchar_t DEFAULT_FONT[] = L"Trebuchet MS";
const wchar_t DEFAULT_SRCFONT[] = L"Lucida Console";
const wchar_t DEFAULT_SCRIPTS_FOLDER[] = L"Scripts";
// XML serialization filenames
const wchar_t SETTINGS_XML_FILE[] = L"Settings.xml";
const wchar_t HOTKEYS_XML_FILE[] = L"Hotkeys.xml";
const wchar_t WORDS_XML_FILE[] = L"Words.xml";
#include "Settings.h"
#include "ElementDescMnr.h"
extern CElementDescMnr _EDMnr;
CSettings::CSettings():m_need_restart(false), keycodes(0)
{
}
CSettings::~CSettings()
{
}
void CSettings::Init()
{
TCHAR filepath[MAX_PATH];
DWORD pathlen = ::GetModuleFileName(_Module.GetModuleInstance(),filepath,MAX_PATH);
TCHAR *appname;
if (pathlen == 0)
appname = L"FictionBook Editor";
else
{
CString tmp = U::GetFullPathName(filepath);
int pos = tmp.ReverseFind(_T('\\'));
if (pos >= 0)
tmp.Delete(0, pos+1);
pos = tmp.ReverseFind(_T('.'));
if (pos >= 0)
{
const TCHAR *cp = tmp;
cp += pos;
if(_tcsicmp(cp,_T(".exe")) == 0 || _tcsicmp(cp, _T(".dll")) == 0)
tmp.Delete(pos, tmp.GetLength() - pos);
}
if (tmp.IsEmpty())
appname=L"FictionBook Editor";
else
{
lstrcpyn(filepath, tmp, MAX_PATH);
appname = L"FictionBook Editor"/*filepath*/;
}
}
m_key_path = L"Software\\FBETeam\\";
m_key_path += appname;
m_key.Create(HKEY_CURRENT_USER, m_key_path);
}
void CSettings::InitHotkeyGroups()
{
// File group hotkeys
CHotkeysGroup file_hotkeys_group(L"File", IDS_HOTKEY_GROUP_FILE);
// Open
CHotkey FileOpen(L"Open", IDS_HOTKEY_FILE_OPEN, FCONTROL, ID_FILE_OPEN, U::StringToKeycode(L"O"));
file_hotkeys_group.m_hotkeys.push_back(FileOpen);
// Save
CHotkey FileSave(L"Save", IDS_HOTKEY_FILE_SAVE, NULL, ID_FILE_SAVE, VK_F2);
file_hotkeys_group.m_hotkeys.push_back(FileSave);
// Save as...
CHotkey FileSaveAs(L"SaveAs", IDS_HOTKEY_FILE_SAVEAS, FSHIFT, ID_FILE_SAVE_AS, VK_F2);
file_hotkeys_group.m_hotkeys.push_back(FileSaveAs);
// Validate
CHotkey FileValidate(L"Validate", IDS_HOTKEY_FILE_VALIDATE, NULL, ID_FILE_VALIDATE, VK_F8);
file_hotkeys_group.m_hotkeys.push_back(FileValidate);
//Edit group hotkeys
CHotkeysGroup edit_hotkeys_group(L"Edit", IDS_HOTKEY_GROUP_EDIT);
// Add annotation
CHotkey EditAddAnnotation(L"AddAnnotation",
IDS_HOTKEY_EDIT_ADD_ANNOTATION,
FCONTROL,
ID_EDIT_ADD_ANN,
U::StringToKeycode(L"J"));
edit_hotkeys_group.m_hotkeys.push_back(EditAddAnnotation);
// Add body
CHotkey EditAddBody(L"AddBody", IDS_HOTKEY_EDIT_ADD_BODY, FALT+FSHIFT, ID_EDIT_ADD_BODY, U::StringToKeycode(L"B"));
edit_hotkeys_group.m_hotkeys.push_back(EditAddBody);
// Add epigraph
CHotkey EditAddEpigraph(L"AddEpigraph",
IDS_HOTKEY_EDIT_ADD_EPIGRAPH,
FCONTROL,
ID_EDIT_ADD_EPIGRAPH,
U::StringToKeycode(L"N"));
edit_hotkeys_group.m_hotkeys.push_back(EditAddEpigraph);
// Add section image
CHotkey EditAddSectionImage(L"AddSectionImage", IDS_HOTKEY_EDIT_ADD_IMAGE, FCONTROL, ID_EDIT_ADD_IMAGE,
U::StringToKeycode(L"G"));
edit_hotkeys_group.m_hotkeys.push_back(EditAddSectionImage);
// Add text author
CHotkey EditAddTextAuthor(L"AddTextAuthor", IDS_HOTKEY_EDIT_ADD_TA, FCONTROL, ID_EDIT_ADD_TA, U::StringToKeycode(L"D"));
edit_hotkeys_group.m_hotkeys.push_back(EditAddTextAuthor);
// Add title
CHotkey EditAddTitle(L"AddTitle", IDS_HOTKEY_EDIT_ADD_TITLE, FCONTROL, ID_EDIT_ADD_TITLE,U::StringToKeycode(L"T"));
edit_hotkeys_group.m_hotkeys.push_back(EditAddTitle);
// Bold
CHotkey EditBold(L"Bold", IDS_HOTKEY_EDIT_BOLD, FCONTROL, ID_EDIT_BOLD, U::StringToKeycode(L"B"));
edit_hotkeys_group.m_hotkeys.push_back(EditBold);
// Clone
CHotkey EditClone(L"Clone", IDS_HOTKEY_EDIT_CLONE, FCONTROL, ID_EDIT_CLONE, VK_RETURN);
edit_hotkeys_group.m_hotkeys.push_back(EditClone);
// Copy
CHotkey EditCopy(L"Copy", IDS_HOTKEY_EDIT_COPY, FCONTROL, ID_EDIT_COPY, U::StringToKeycode(L"C"));
edit_hotkeys_group.m_hotkeys.push_back(EditCopy);
// Cut
CHotkey EditCut(L"Cut", IDS_HOTKEY_EDIT_CUT, FCONTROL, ID_EDIT_CUT, U::StringToKeycode(L"X"));
edit_hotkeys_group.m_hotkeys.push_back(EditCut);
// Find
CHotkey EditFind(L"Find", IDS_HOTKEY_EDIT_FIND, FCONTROL, ID_EDIT_FIND, U::StringToKeycode(L"F"));
edit_hotkeys_group.m_hotkeys.push_back(EditFind);
// Find next
CHotkey EditFindNext(L"FindNext", IDS_HOTKEY_EDIT_FIND_NEXT, NULL, ID_EDIT_FINDNEXT, VK_F3);
edit_hotkeys_group.m_hotkeys.push_back(EditFindNext);
// Incremental search
CHotkey EditIncrementalSearch(L"IncrementalSearch",
IDS_HOTKEY_EDIT_INCREMENTAL_SEARCH,
FALT,
ID_EDIT_INCSEARCH,
U::StringToKeycode(L"I"));
edit_hotkeys_group.m_hotkeys.push_back(EditIncrementalSearch);
// Insert cite
CHotkey EditInsertCite(L"InsertCite",
IDS_HOTKEY_EDIT_INSERT_CITE,
FALT,
ID_EDIT_INS_CITE,
U::StringToKeycode(L"C"));
edit_hotkeys_group.m_hotkeys.push_back(EditInsertCite);
// Insert image
CHotkey EditInsertImage(L"InsertImage",
IDS_HOTKEY_EDIT_INSERT_IMAGE,
FCONTROL,
ID_EDIT_INS_IMAGE,
U::StringToKeycode(L"M"));
edit_hotkeys_group.m_hotkeys.push_back(EditInsertImage);
// Insert inline image - added by SeNS
CHotkey EditInsertInlineImage(L"InsertInlineImage",
IDS_HOTKEY_EDIT_INSERT_INLINEIMAGE,
FALT,
ID_EDIT_INS_INLINEIMAGE,
U::StringToKeycode(L"M"));
edit_hotkeys_group.m_hotkeys.push_back(EditInsertInlineImage);
// Insert poem
CHotkey EditInsertPoem(L"InsertPoem",
IDS_HOTKEY_EDIT_INSERT_POEM,
FCONTROL,
ID_EDIT_INS_POEM,
U::StringToKeycode(L"P"));
edit_hotkeys_group.m_hotkeys.push_back(EditInsertPoem);
// Italic
CHotkey EditItalic(L"Italic", IDS_HOTKEY_EDIT_ITALIC, FCONTROL, ID_EDIT_ITALIC, U::StringToKeycode(L"I"));
edit_hotkeys_group.m_hotkeys.push_back(EditItalic);
// Merge
CHotkey EditMerge(L"Merge", IDS_HOTKEY_EDIT_MERGE, FALT, ID_EDIT_MERGE, VK_DELETE);
edit_hotkeys_group.m_hotkeys.push_back(EditMerge);
// Added by SeNS
CHotkey EditSub(L"Subscript", IDS_HOTKEY_EDIT_SUB, NULL, ID_EDIT_SUB, NULL);
edit_hotkeys_group.m_hotkeys.push_back(EditSub);
CHotkey EditSup(L"Superscript", IDS_HOTKEY_EDIT_SUP, NULL, ID_EDIT_SUP, NULL);
edit_hotkeys_group.m_hotkeys.push_back(EditSup);
// Paste : changed by SeNS
CHotkey EditPaste(L"Paste", IDS_HOTKEY_EDIT_PASTE, FSHIFT, ID_EDIT_PASTE, VK_INSERT);
edit_hotkeys_group.m_hotkeys.push_back(EditPaste);
// Redo
CHotkey EditRedo(L"Redo", IDS_HOTKEY_EDIT_REDO, FCONTROL, ID_EDIT_REDO, U::StringToKeycode(L"Y"));
edit_hotkeys_group.m_hotkeys.push_back(EditRedo);
// Replace
CHotkey EditReplace(L"Replace", IDS_HOTKEY_EDIT_REPLACE, FCONTROL, ID_EDIT_REPLACE, U::StringToKeycode(L"H"));
edit_hotkeys_group.m_hotkeys.push_back(EditReplace);
// Split
CHotkey EditSplit(L"Split", IDS_HOTKEY_EDIT_SPLIT, FSHIFT, ID_EDIT_SPLIT, VK_RETURN);
edit_hotkeys_group.m_hotkeys.push_back(EditSplit);
// Undo
CHotkey EditUndo(L"Undo", IDS_HOTKEY_EDIT_UNDO, FCONTROL, ID_EDIT_UNDO, U::StringToKeycode(L"Z"));
edit_hotkeys_group.m_hotkeys.push_back(EditUndo);
// Insert table
CHotkey EditInsertTable(L"InsertTable",
IDS_HOTKEY_EDIT_INSERT_TABLE,
FALT,
ID_INSERT_TABLE,
U::StringToKeycode(L"T"));
edit_hotkeys_group.m_hotkeys.push_back(EditInsertTable);
// Remove outer section
CHotkey RemoveOuterSection(L"RemoveOuterSection",
IDS_HOTKEY_EDIT_REMOVE_OUTER_SECTION,
FALT | FCONTROL,
ID_EDIT_REMOVE_OUTER_SECTION,
VK_SPACE);
edit_hotkeys_group.m_hotkeys.push_back(RemoveOuterSection);
//Navigation group hotkeys
CHotkeysGroup navigation_hotkeys_group(L"Navigation", IDS_HOTKEY_GROUP_NAVIGATION);
// Goto reference
CHotkey NavigationGotoFootnote (L"GotoFootnote",
IDS_HOTKEY_NAVIGATION_GOTO_FOOTNOTE,
FCONTROL,
ID_GOTO_FOOTNOTE,
VK_BACK);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationGotoFootnote);
// Goto matched tag
CHotkey NavigationGotoMatchingTag (L"GotoMatchingTag",
IDS_HOTKEY_NAVIGATION_GOTO_MATCHTAG,
FALT,
ID_GOTO_MATCHTAG,
U::StringToKeycode(L":"));
navigation_hotkeys_group.m_hotkeys.push_back(NavigationGotoMatchingTag);
// Goto wrong tag
CHotkey NavigationGotoWrongTag (L"GotoWrongTag",
IDS_HOTKEY_NAVIGATION_GOTO_WRONGTAG,
FCONTROL,
ID_GOTO_WRONGTAG,
U::StringToKeycode(L":"));
navigation_hotkeys_group.m_hotkeys.push_back(NavigationGotoWrongTag);
// Next item
CHotkey NavigationNextItem(L"NextItem",
IDS_HOTKEY_NAVIGATION_NEXT_ITEM,
FCONTROL,
ID_NEXT_ITEM,
VK_TAB);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationNextItem);
// Collapse tree 1 level
CHotkey NavigationCollapse1(L"Collapse1",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE1,
NULL,
ID_SCI_COLLAPSE1,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse1);
// Collapse tree 2 levels
CHotkey NavigationCollapse2(L"Collapse2",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE2,
NULL,
ID_SCI_COLLAPSE2,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse2);
// Collapse tree 3 levels
CHotkey NavigationCollapse3(L"Collapse3",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE3,
NULL,
ID_SCI_COLLAPSE3,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse3);
// Collapse tree 4 levels
CHotkey NavigationCollapse4(L"Collapse4",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE4,
NULL,
ID_SCI_COLLAPSE4,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse4);
// Collapse tree 5 levels
CHotkey NavigationCollapse5(L"Collapse5",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE5,
NULL,
ID_SCI_COLLAPSE5,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse5);
// Collapse tree 6 levels
CHotkey NavigationCollapse6(L"Collapse6",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE6,
NULL,
ID_SCI_COLLAPSE6,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse6);
// Collapse tree 7 levels
CHotkey NavigationCollapse7(L"Collapse7",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE7,
NULL,
ID_SCI_COLLAPSE7,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse7);
// Collapse tree 8 levels
CHotkey NavigationCollapse8(L"Collapse8",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE8,
NULL,
ID_SCI_COLLAPSE8,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse8);
// Collapse tree 9 levels
CHotkey NavigationCollapse9(L"Collapse9",
IDS_HOTKEY_NAVIGATION_SCI_COLLAPSE9,
NULL,
ID_SCI_COLLAPSE9,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationCollapse9);
// Expand tree 1 level
CHotkey NavigationExpand1(L"Expand1",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND1,
NULL,
ID_SCI_EXPAND1,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand1);
// Expand tree 2 levels
CHotkey NavigationExpand2(L"Expand2",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND2,
NULL,
ID_SCI_EXPAND2,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand2);
// Expand tree 3 levels
CHotkey NavigationExpand3(L"Expand3",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND3,
NULL,
ID_SCI_EXPAND3,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand3);
// Expand tree 4 levels
CHotkey NavigationExpand4(L"Expand4",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND4,
NULL,
ID_SCI_EXPAND4,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand4);
// Expand tree 5 levels
CHotkey NavigationExpand5(L"Expand5",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND5,
NULL,
ID_SCI_EXPAND5,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand5);
// Expand tree 6 levels
CHotkey NavigationExpand6(L"Expand6",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND6,
NULL,
ID_SCI_EXPAND6,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand6);
// Expand tree 7 levels
CHotkey NavigationExpand7(L"Expand7",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND7,
NULL,
ID_SCI_EXPAND7,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand7);
// Expand tree 8 levels
CHotkey NavigationExpand8(L"Expand8",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND8,
NULL,
ID_SCI_EXPAND8,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand8);
// Expand tree 9 levels
CHotkey NavigationExpand9(L"Expand9",
IDS_HOTKEY_NAVIGATION_SCI_EXPAND9,
NULL,
ID_SCI_EXPAND9,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationExpand9);
// Select href
CHotkey NavigationSelectHref(L"SelectHref",
IDS_HOTKEY_NAVIGATION_SELECT_HREF,
FALT,
ID_SELECT_HREF,
U::StringToKeycode(L"H"));
navigation_hotkeys_group.m_hotkeys.push_back(NavigationSelectHref);
// Select ID
CHotkey NavigationSelectID(L"SelectID",
IDS_HOTKEY_NAVIGATION_SELECT_ID,
NULL,
ID_SELECT_ID,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationSelectID);
// Select table ID
CHotkey NavigationSelectTableID(L"SelectTableID",
IDS_HOTKEY_NAVIGATION_SELECT_ID_TABLE,
NULL,
ID_SELECT_IDT,
NULL);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationSelectTableID);
// Select text
CHotkey NavigationSelectText(L"SelectText",
IDS_HOTKEY_NAVIGATION_SELECT_TEXT,
NULL,
ID_SELECT_TEXT,
VK_ESCAPE);
navigation_hotkeys_group.m_hotkeys.push_back(NavigationSelectText);
// Select tree
CHotkey NavigationSelectTree(L"SelectTree",
IDS_HOTKEY_NAVIGATION_SELECT_TREE,
FALT,
ID_SELECT_TREE,
U::StringToKeycode(L"Q"));
navigation_hotkeys_group.m_hotkeys.push_back(NavigationSelectTree);
//Style group hotkeys
CHotkeysGroup style_hotkeys_group(L"Style", IDS_HOTKEY_GROUP_STYLE);
// Link
CHotkey StyleLink(L"Link", IDS_HOTKEY_STYLE_LINK, FCONTROL, ID_STYLE_LINK, U::StringToKeycode(L"L"));
style_hotkeys_group.m_hotkeys.push_back(StyleLink);
// No link
CHotkey StyleNoLink(L"NoLink", IDS_HOTKEY_STYLE_NO_LINK, FCONTROL, ID_STYLE_NOLINK, U::StringToKeycode(L"U"));
style_hotkeys_group.m_hotkeys.push_back(StyleNoLink);
// Normal
CHotkey StyleNormal(L"Normal", IDS_HOTKEY_STYLE_NORMAL, FALT, ID_STYLE_NORMAL, U::StringToKeycode(L"N"));
style_hotkeys_group.m_hotkeys.push_back(StyleNormal);
// Note
CHotkey StyleNote(L"Note", IDS_HOTKEY_STYLE_NOTE, FCONTROL, ID_STYLE_NOTE, U::StringToKeycode(L"W"));
style_hotkeys_group.m_hotkeys.push_back(StyleNote);
// Subtitle
CHotkey StyleSubtitle(L"Subtitle", IDS_HOTKEY_STYLE_SUBTITLE, FALT, ID_STYLE_SUBTITLE, U::StringToKeycode(L"S"));
style_hotkeys_group.m_hotkeys.push_back(StyleSubtitle);
// Text author
CHotkey StyleTextAuthor(L"TextAuthor",
IDS_HOTKEY_STYLE_TEXT_AUTHOR,
FALT,
ID_STYLE_TEXTAUTHOR,
U::StringToKeycode(L"A"));
style_hotkeys_group.m_hotkeys.push_back(StyleTextAuthor);
// View group hotkeys
CHotkeysGroup view_hotkeys_group(L"View", IDS_HOTKEY_GROUP_VIEW);
// View body
CHotkey ViewBody(L"Body", IDS_HOTKEY_VIEW_BODY, FALT, ID_VIEW_BODY, VK_F2);
view_hotkeys_group.m_hotkeys.push_back(ViewBody);
// View description
CHotkey ViewDescription(L"Description", IDS_HOTKEY_VIEW_DESCRIPTION, FALT, ID_VIEW_DESC, VK_F1);
view_hotkeys_group.m_hotkeys.push_back(ViewDescription);
// View source
CHotkey ViewSource(L"Source", IDS_HOTKEY_VIEW_SOURCE, FALT, ID_VIEW_SOURCE, VK_F3);
view_hotkeys_group.m_hotkeys.push_back(ViewSource);
// Added by SeNS
// Fast mode
CHotkey FastMode(L"Fast mode", IDS_HOTKEY_FASTMODE, NULL, ID_VIEW_FASTMODE, VK_F5);
view_hotkeys_group.m_hotkeys.push_back(FastMode);
CHotkey ViewTree(L"Toggle Tree View", IDS_HOTKEY_TREEVIEW, FCONTROL, ID_VIEW_TREE, VK_F5);
view_hotkeys_group.m_hotkeys.push_back(ViewTree);
// Scripts group hotkeys
CHotkeysGroup scripts_hotkeys_group(L"Scripts", IDS_HOTKEY_GROUP_SCRIPTS);
// Last script
CHotkey ScriptsLastScript(L"LastScript",
IDS_HOTKEY_SCRIPTS_LAST_SCRIPT,
FCONTROL,
ID_LAST_SCRIPT,
VK_OEM_3);
scripts_hotkeys_group.m_hotkeys.push_back(ScriptsLastScript);
// Plugins group hotkeys
CHotkeysGroup plugins_hotkeys_group(L"Plugins", IDS_HOTKEY_GROUP_PLUGINS);
// Last plugin
CHotkey PluginsLastPlugin(L"LastPlugin",
IDS_HOTKEY_PLUGINS_LAST_PLUGIN,
FALT,
ID_LAST_PLUGIN,
VK_OEM_3);
plugins_hotkeys_group.m_hotkeys.push_back(PluginsLastPlugin);
// Tools group hotkeys
CHotkeysGroup tools_hotkeys_group(L"Tools", IDS_HOTKEY_GROUP_TOOLS);
// Words
CHotkey ToolsWords(L"Words", IDS_HOTKEY_TOOLS_WORDS, FALT, ID_TOOLS_WORDS, U::StringToKeycode(L"W"));
tools_hotkeys_group.m_hotkeys.push_back(ToolsWords);
// Added by SeNS
CHotkey ToolsSpell(L"Spell check", IDS_HOTKEY_TOOLS_SPELL, NULL, ID_TOOLS_SPELLCHECK, VK_F7);
tools_hotkeys_group.m_hotkeys.push_back(ToolsSpell);
CHotkey ToolsSpellHighlight(L"Toggle highlight", IDS_HOTKEY_TOOLS_SPELLHIGHLIGHT, FSHIFT, ID_TOOLS_SPELLCHECK_HIGHLIGHT, VK_F7);
tools_hotkeys_group.m_hotkeys.push_back(ToolsSpellHighlight);
CHotkey ToolsSpellAddToDict(L"Add to dictionary", IDC_SPELL_ADD2DICT, NULL, IDC_SPELL_ADD2DICT, NULL);
tools_hotkeys_group.m_hotkeys.push_back(ToolsSpellAddToDict);
CHotkey ToolsSpellIgnore(L"Ignore", IDC_SPELL_IGNOREALL, NULL, IDC_SPELL_IGNOREALL, NULL);
tools_hotkeys_group.m_hotkeys.push_back(ToolsSpellIgnore);
// Symbols group hotkeys
CHotkeysGroup symbols_hotkeys_group(L"Symbols", IDS_HOTKEY_GROUP_SYMBOLS);
wchar_t vals[32767 + 1];
ZeroMemory(vals, sizeof(vals));
int valcount = ::GetPrivateProfileSection(L"symbols", vals, 32767, U::GetProgDir() + L"symbols.ini");
CSimpleMap<CString, CString> mapSymbs;
int k = 0;
while(vals[k] != 0 && k < valcount)
{
CString str = &vals[k];
CString resKey, resVal;
int curPos = 0;
resKey = str.Tokenize(L"=", curPos);
resVal = str.Tokenize(L"=", curPos);
if(!resKey.IsEmpty() && !resVal.IsEmpty())
mapSymbs.Add(resKey + L"=", resVal);
k += (wcslen(&vals[k]) + 1);
}
for(int i = 1; i < 100; ++i)
{
CString pattern, langPatt;
pattern.Format(L"%s%d=", L"sym", i);
langPatt.Format(L"%s%d_%d=", L"sym", i, m_interface_lang_id);
if(mapSymbs.Lookup(pattern) != L"")
{
int val = _wtoi(mapSymbs.Lookup(pattern).GetBuffer());
CString desc;
if(mapSymbs.Lookup(langPatt) != L"")
desc = mapSymbs.Lookup(langPatt) + L" ";
// special case for combining chars
if ((val>=0x0300 && val<=0x036F) || (val>=0x1DC0 && val<=0x1DFF) ||
(val>=0x20D0 && val<=0x20FF) || (val>=0xFE20 && val<=0xFE2F)) desc += CString(L"( ");
else desc += CString(L"(");
if (val==160) desc += GetNBSPChar() + CString(L")"); else desc += (wchar_t)val + CString(L")");
// special fix for nbsp
if (val==160) val = m_nbsp_char[0];
CHotkey Symbol(mapSymbs.Lookup(pattern).GetBuffer(),
desc,
wchar_t(val),
NULL,
ID_EDIT_INS_SYMBOL + i,
NULL);
symbols_hotkeys_group.m_hotkeys.push_back(Symbol);
}
}
// Collect all hotkey groups and sort
m_hotkey_groups.push_back(file_hotkeys_group);
m_hotkey_groups.push_back(edit_hotkeys_group);
m_hotkey_groups.push_back(navigation_hotkeys_group);
m_hotkey_groups.push_back(style_hotkeys_group);
m_hotkey_groups.push_back(tools_hotkeys_group);
m_hotkey_groups.push_back(view_hotkeys_group);
m_hotkey_groups.push_back(plugins_hotkeys_group);
m_hotkey_groups.push_back(scripts_hotkeys_group);
m_hotkey_groups.push_back(symbols_hotkeys_group);
std::sort(m_hotkey_groups.begin(), m_hotkey_groups.end());
}
void CSettings::Close()
{
m_key.Close();
}
// ISerializable interface
int CSettings::GetProperties(std::vector<CString>& properties)
{
properties.push_back(KEEP_ENCODING_KEY);
properties.push_back(DEFAULT_ENCODING_KEY);
properties.push_back(SEARCH_OPTIONS_KEY);
properties.push_back(COLOR_BG_KEY);
properties.push_back(COLOR_FG_KEY);
properties.push_back(FONT_SIZE_KEY);
properties.push_back(XML_SRC_WRAP_KEY);
properties.push_back(XML_SRC_SYNTAX_HL_KEY);
properties.push_back(XML_SRC_TAG_HL_KEY);
properties.push_back(XML_SRC_SHOW_EOL_KEY);
properties.push_back(XML_SRC_SHOW_SPACE_KEY);
properties.push_back(FAST_MODE_KEY);
properties.push_back(FONT_KEY);
properties.push_back(SRC_FONT_KEY);
properties.push_back(VIEW_STATUS_BAR_KEY);
properties.push_back(VIEW_DOCUMENT_TREE_KEY);
properties.push_back(SPLITTER_POS_KEY);
properties.push_back(TOOLBARS_SETTINGS_KEY);
properties.push_back(RESTORE_FILE_POS_KEY);
properties.push_back(INTERFACE_LANG_KEY);
properties.push_back(SCRIPTS_FOLDER_KEY);
// SeNS
properties.push_back(USESPELLER_CHECK_KEY);
properties.push_back(HIGHLIGHT_CHECK_KEY);
properties.push_back(CUSTOM_DICT_KEY);
properties.push_back(CUSTOM_DICT_CODEPAGE_KEY);
properties.push_back(NBSPCHAR_KEY);
properties.push_back(CHANGE_KEYBD_CHECK_KEY);
properties.push_back(KEYB_LAYOUT_KEY);
properties.push_back(SHOW_LINE_NUMBERS_KEY);
properties.push_back(IMAGE_TYPE_KEY);
properties.push_back(JPEG_QUALITY_KEY);
properties.push_back(INSIMAGE_ASKING);
properties.push_back(INS_CLEAR_IMAGE);
properties.push_back(WINDOW_POSITION);
properties.push_back(WORDS_DLG_POSITION);
properties.push_back(SHOW_WORDS_EXCLUSIONS);
properties.push_back(m_desc.GetClassName());
properties.push_back(m_tree_items.GetClassName());
return properties.size();
}
bool CSettings::GetPropertyValue(const CString& sProperty, CProperty& property)
{
if(sProperty == KEEP_ENCODING_KEY)
{
property = GetStringedProperty(&m_keep_encoding, KEY_BOOL);
return true;
}
else if(sProperty == DEFAULT_ENCODING_KEY)
{
property = m_default_encoding;
return true;
}
else if(sProperty == SEARCH_OPTIONS_KEY)
{
property = GetStringedProperty(&m_search_options, KEY_INT);
return true;
}
else if(sProperty == COLOR_BG_KEY)
{
property = GetStringedProperty(&m_collorBG, KEY_ULONG);
return true;
}
else if(sProperty == COLOR_FG_KEY)
{
property = GetStringedProperty(&m_collorFG, KEY_ULONG);
return true;
}
else if(sProperty == FONT_SIZE_KEY)
{
property = GetStringedProperty(&m_font_size, KEY_INT);
return true;
}
else if(sProperty == XML_SRC_WRAP_KEY)
{
property = GetStringedProperty(&m_xml_src_wrap, KEY_BOOL);
return true;
}
else if(sProperty == XML_SRC_SYNTAX_HL_KEY)
{
property = GetStringedProperty(&m_xml_src_syntaxHL, KEY_BOOL);
return true;
}
else if(sProperty == XML_SRC_TAG_HL_KEY)
{
property = GetStringedProperty(&m_xml_src_tagHL, KEY_BOOL);
return true;
}
else if(sProperty == XML_SRC_SHOW_EOL_KEY)
{
property = GetStringedProperty(&m_xml_src_showEOL, KEY_BOOL);
return true;
}
else if(sProperty == XML_SRC_SHOW_SPACE_KEY)
{
property = GetStringedProperty(&m_xml_src_showSpace, KEY_BOOL);
return true;
}
else if(sProperty == FAST_MODE_KEY)
{
property = GetStringedProperty(&m_fast_mode, KEY_BOOL);
return true;
}
else if(sProperty == FONT_KEY)
{
property = m_font;
return true;
}
else if(sProperty == SRC_FONT_KEY)
{
property = m_srcfont;
return true;
}
else if(sProperty == VIEW_STATUS_BAR_KEY)
{
property = GetStringedProperty(&m_view_status_bar, KEY_BOOL);
return true;
}
else if(sProperty == VIEW_DOCUMENT_TREE_KEY)
{
property = GetStringedProperty(&m_view_doc_tree, KEY_BOOL);
return true;
}
else if(sProperty == SPLITTER_POS_KEY)
{
property = GetStringedProperty(&m_splitter_pos, KEY_INT);
return true;
}
else if(sProperty == TOOLBARS_SETTINGS_KEY)
{
property = m_toolbars_settings;
return true;
}
else if(sProperty == RESTORE_FILE_POS_KEY)
{
property = GetStringedProperty(&m_restore_file_position, KEY_BOOL);
return true;
}
else if(sProperty == INTERFACE_LANG_KEY)
{
property = GetStringedProperty(&m_interface_lang_id, KEY_INT);
return true;
}
else if(sProperty == SCRIPTS_FOLDER_KEY)
{
property = m_scripts_folder;
return true;
}
// added SeNS
else if(sProperty == USESPELLER_CHECK_KEY)
{
property = GetStringedProperty(&m_usespell_check, KEY_BOOL);
return true;
}
else if(sProperty == HIGHLIGHT_CHECK_KEY)
{
property = GetStringedProperty(&m_highlght_check, KEY_BOOL);
return true;
}
else if(sProperty == CUSTOM_DICT_KEY)
{
property = m_custom_dict;
return true;
}
else if(sProperty == CUSTOM_DICT_CODEPAGE_KEY)
{
property = GetStringedProperty(&m_custom_dict_codepage, KEY_INT);
return true;
}
else if(sProperty == NBSPCHAR_KEY)
{
property = m_nbsp_char;
return true;
}
else if(sProperty == CHANGE_KEYBD_CHECK_KEY)
{
property = GetStringedProperty(&m_change_kbd_layout_check, KEY_BOOL);
return true;
}
else if(sProperty == KEYB_LAYOUT_KEY)
{
property = GetStringedProperty(&m_keyb_layout, KEY_INT);
return true;
}
else if(sProperty == SHOW_LINE_NUMBERS_KEY)
{
property = GetStringedProperty(&m_show_line_numbers, KEY_BOOL);
return true;
}
else if(sProperty == IMAGE_TYPE_KEY)
{
property = GetStringedProperty(&m_image_type, KEY_INT);
return true;
}
else if(sProperty == JPEG_QUALITY_KEY)
{
property = GetStringedProperty(&m_jpeg_quality, KEY_INT);
return true;
}
///
else if(sProperty == INSIMAGE_ASKING)
{
property = GetStringedProperty(&m_insimage_ask, KEY_BOOL);
return true;
}
else if(sProperty == INS_CLEAR_IMAGE)
{
property = GetStringedProperty(&m_ins_clear_image, KEY_BOOL);
return true;
}
else if(sProperty == WORDS_DLG_POSITION)
{
CString temp;
temp.Format(L"%u;%u;%u;%ld;%ld;%ld;%ld;%ld;%ld;%ld;%ld",
m_words_dlg_placement.length,
m_words_dlg_placement.flags,
m_words_dlg_placement.showCmd,
m_words_dlg_placement.ptMinPosition.x,
m_words_dlg_placement.ptMinPosition.y,
m_words_dlg_placement.ptMaxPosition.x,
m_words_dlg_placement.ptMaxPosition.y,
m_words_dlg_placement.rcNormalPosition.bottom,
m_words_dlg_placement.rcNormalPosition.left,
m_words_dlg_placement.rcNormalPosition.top,
m_words_dlg_placement.rcNormalPosition.right);
property = temp;
return true;
}
else if(sProperty == SHOW_WORDS_EXCLUSIONS)
{
property = GetStringedProperty(&m_show_words_excls, KEY_BOOL);
return true;
}
else if(sProperty == WINDOW_POSITION)
{
CString temp;
temp.Format(L"%u;%u;%u;%ld;%ld;%ld;%ld;%ld;%ld;%ld;%ld",
m_wnd_placement.length,
m_wnd_placement.flags,
m_wnd_placement.showCmd,
m_wnd_placement.ptMinPosition.x,
m_wnd_placement.ptMinPosition.y,
m_wnd_placement.ptMaxPosition.x,
m_wnd_placement.ptMaxPosition.y,
m_wnd_placement.rcNormalPosition.bottom,
m_wnd_placement.rcNormalPosition.left,
m_wnd_placement.rcNormalPosition.top,
m_wnd_placement.rcNormalPosition.right);
property = temp;
return true;
}
else if(sProperty == m_desc.GetClassName())
{
property = (ISerializable*)&m_desc;
property.SetFactory(&m_desc);
return true;
}
else if(sProperty == m_tree_items.GetClassName())
{
property = (ISerializable*)&m_tree_items;
property.SetFactory(&m_tree_items);
return true;
}
return false;
}
bool CSettings::SetPropertyValue(const CString& sProperty, CProperty& sValue)
{
if(sProperty == KEEP_ENCODING_KEY)
{
m_keep_encoding = StrToBool(sValue.GetStringValue());
return true;
}
else if(sProperty == DEFAULT_ENCODING_KEY)
{
m_default_encoding = sValue.GetStringValue();
return true;
}
else if(sProperty == SEARCH_OPTIONS_KEY)
{
m_search_options = StrToInt(sValue.GetStringValue());
return true;
}