-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Parameters.h
2036 lines (1614 loc) · 62.3 KB
/
Parameters.h
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
// This file is part of Notepad++ project
// Copyright (C)2021 Don HO <don.h@free.fr>
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include "tinyxmlA.h"
#include "tinyxml.h"
#include "Scintilla.h"
#include "ScintillaRef.h"
#include "ToolBar.h"
#include "UserDefineLangReference.h"
#include "colors.h"
#include "shortcut.h"
#include "ContextMenu.h"
#include "dpiManager.h"
#include "NppDarkMode.h"
#include <assert.h>
#include <tchar.h>
#include <map>
#include "ILexer.h"
#include "Lexilla.h"
#ifdef _WIN64
#ifdef _M_ARM64
#define ARCH_TYPE IMAGE_FILE_MACHINE_ARM64
#else
#define ARCH_TYPE IMAGE_FILE_MACHINE_AMD64
#endif
#else
#define ARCH_TYPE IMAGE_FILE_MACHINE_I386
#endif
#define CMD_INTERPRETER TEXT("%COMSPEC%")
class NativeLangSpeaker;
const bool POS_VERTICAL = true;
const bool POS_HORIZOTAL = false;
const int UDD_SHOW = 1; // 0000 0001
const int UDD_DOCKED = 2; // 0000 0010
// 0 : 0000 0000 hide & undocked
// 1 : 0000 0001 show & undocked
// 2 : 0000 0010 hide & docked
// 3 : 0000 0011 show & docked
const int TAB_DRAWTOPBAR = 1; //0000 0000 0001
const int TAB_DRAWINACTIVETAB = 2; //0000 0000 0010
const int TAB_DRAGNDROP = 4; //0000 0000 0100
const int TAB_REDUCE = 8; //0000 0000 1000
const int TAB_CLOSEBUTTON = 16; //0000 0001 0000
const int TAB_DBCLK2CLOSE = 32; //0000 0010 0000
const int TAB_VERTICAL = 64; //0000 0100 0000
const int TAB_MULTILINE = 128; //0000 1000 0000
const int TAB_HIDE = 256; //0001 0000 0000
const int TAB_QUITONEMPTY = 512; //0010 0000 0000
const int TAB_ALTICONS = 1024; //0100 0000 0000
const bool activeText = true;
const bool activeNumeric = false;
enum class EolType: std::uint8_t
{
windows,
macos,
unix,
// special values
unknown, // can not be the first value for legacy code
osdefault = windows,
};
/*!
** \brief Convert an int into a FormatType
** \param value An arbitrary int
** \param defvalue The default value to use if an invalid value is provided
*/
EolType convertIntToFormatType(int value, EolType defvalue = EolType::osdefault);
enum UniMode {uni8Bit=0, uniUTF8=1, uni16BE=2, uni16LE=3, uniCookie=4, uni7Bit=5, uni16BE_NoBOM=6, uni16LE_NoBOM=7, uniEnd};
enum ChangeDetect { cdDisabled = 0x0, cdEnabledOld = 0x01, cdEnabledNew = 0x02, cdAutoUpdate = 0x04, cdGo2end = 0x08 };
enum BackupFeature {bak_none = 0, bak_simple = 1, bak_verbose = 2};
enum OpenSaveDirSetting {dir_followCurrent = 0, dir_last = 1, dir_userDef = 2};
enum MultiInstSetting {monoInst = 0, multiInstOnSession = 1, multiInst = 2};
enum writeTechnologyEngine {defaultTechnology = 0, directWriteTechnology = 1};
enum urlMode {urlDisable = 0, urlNoUnderLineFg, urlUnderLineFg, urlNoUnderLineBg, urlUnderLineBg,
urlMin = urlDisable,
urlMax = urlUnderLineBg};
const int LANG_INDEX_INSTR = 0;
const int LANG_INDEX_INSTR2 = 1;
const int LANG_INDEX_TYPE = 2;
const int LANG_INDEX_TYPE2 = 3;
const int LANG_INDEX_TYPE3 = 4;
const int LANG_INDEX_TYPE4 = 5;
const int LANG_INDEX_TYPE5 = 6;
const int LANG_INDEX_TYPE6 = 7;
const int LANG_INDEX_TYPE7 = 8;
const int COPYDATA_PARAMS = 0;
//const int COPYDATA_FILENAMESA = 1; // obsolete, no more useful
const int COPYDATA_FILENAMESW = 2;
const int COPYDATA_FULL_CMDLINE = 3;
#define PURE_LC_NONE 0
#define PURE_LC_BOL 1
#define PURE_LC_WSP 2
#define DECSEP_DOT 0
#define DECSEP_COMMA 1
#define DECSEP_BOTH 2
#define DROPBOX_AVAILABLE 1
#define ONEDRIVE_AVAILABLE 2
#define GOOGLEDRIVE_AVAILABLE 4
#define NPP_STYLING_FILESIZE_LIMIT_DEFAULT (200 * 1024 * 1024) // 200MB+ file won't be styled
const int FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT = 1024;
const TCHAR fontSizeStrs[][3] = {TEXT(""), TEXT("5"), TEXT("6"), TEXT("7"), TEXT("8"), TEXT("9"), TEXT("10"), TEXT("11"), TEXT("12"), TEXT("14"), TEXT("16"), TEXT("18"), TEXT("20"), TEXT("22"), TEXT("24"), TEXT("26"), TEXT("28")};
const TCHAR localConfFile[] = TEXT("doLocalConf.xml");
const TCHAR notepadStyleFile[] = TEXT("asNotepad.xml");
// issue xml/log file name
const TCHAR nppLogNetworkDriveIssue[] = TEXT("nppLogNetworkDriveIssue");
const TCHAR nppLogNulContentCorruptionIssue[] = TEXT("nppLogNulContentCorruptionIssue");
void cutString(const TCHAR *str2cut, std::vector<std::wstring> & patternVect);
void cutStringBy(const TCHAR *str2cut, std::vector<std::wstring> & patternVect, char byChar, bool allowEmptyStr);
// style names
const wchar_t g_npcStyleName[] = L"Non-printing characters custom color";
struct Position
{
intptr_t _firstVisibleLine = 0;
intptr_t _startPos = 0;
intptr_t _endPos = 0;
intptr_t _xOffset = 0;
intptr_t _selMode = 0;
intptr_t _scrollWidth = 1;
intptr_t _offset = 0;
intptr_t _wrapCount = 0;
};
struct MapPosition
{
private:
intptr_t _maxPeekLenInKB = 512; // 512 KB
public:
intptr_t _firstVisibleDisplayLine = -1;
intptr_t _firstVisibleDocLine = -1; // map
intptr_t _lastVisibleDocLine = -1; // map
intptr_t _nbLine = -1; // map
intptr_t _higherPos = -1; // map
intptr_t _width = -1;
intptr_t _height = -1;
intptr_t _wrapIndentMode = -1;
intptr_t _KByteInDoc = _maxPeekLenInKB;
bool _isWrap = false;
bool isValid() const { return (_firstVisibleDisplayLine != -1); };
bool canScroll() const { return (_KByteInDoc < _maxPeekLenInKB); }; // _nbCharInDoc < _maxPeekLen : Don't scroll the document for the performance issue
};
struct sessionFileInfo : public Position
{
sessionFileInfo(const wchar_t* fn, const TCHAR *ln, int encoding, bool userReadOnly, const Position& pos, const TCHAR *backupFilePath, FILETIME originalFileLastModifTimestamp, const MapPosition & mapPos) :
Position(pos), _encoding(encoding), _isUserReadOnly(userReadOnly), _originalFileLastModifTimestamp(originalFileLastModifTimestamp), _mapPos(mapPos)
{
if (fn) _fileName = fn;
if (ln) _langName = ln;
if (backupFilePath) _backupFilePath = backupFilePath;
}
sessionFileInfo(std::wstring fn) : _fileName(fn) {}
std::wstring _fileName;
std::wstring _langName;
std::vector<size_t> _marks;
std::vector<size_t> _foldStates;
int _encoding = -1;
bool _isUserReadOnly = false;
bool _isMonitoring = false;
int _individualTabColour = -1;
bool _isRTL = false;
std::wstring _backupFilePath;
FILETIME _originalFileLastModifTimestamp {};
MapPosition _mapPos;
};
struct Session
{
size_t nbMainFiles() const {return _mainViewFiles.size();};
size_t nbSubFiles() const {return _subViewFiles.size();};
size_t _activeView = 0;
size_t _activeMainIndex = 0;
size_t _activeSubIndex = 0;
bool _includeFileBrowser = false;
std::wstring _fileBrowserSelectedItem;
std::vector<sessionFileInfo> _mainViewFiles;
std::vector<sessionFileInfo> _subViewFiles;
std::vector<std::wstring> _fileBrowserRoots;
};
struct CmdLineParams
{
bool _isNoPlugin = false;
bool _isReadOnly = false;
bool _isNoSession = false;
bool _isNoTab = false;
bool _isPreLaunch = false;
bool _showLoadingTime = false;
bool _alwaysOnTop = false;
intptr_t _line2go = -1;
intptr_t _column2go = -1;
intptr_t _pos2go = -1;
POINT _point = {};
bool _isPointXValid = false;
bool _isPointYValid = false;
bool _isSessionFile = false;
bool _isRecursive = false;
bool _openFoldersAsWorkspace = false;
bool _monitorFiles = false;
LangType _langType = L_EXTERNAL;
std::wstring _localizationPath;
std::wstring _udlName;
std::wstring _pluginMessage;
std::wstring _easterEggName;
unsigned char _quoteType = 0;
int _ghostTypingSpeed = -1; // -1: initial value 1: slow 2: fast 3: speed of light
CmdLineParams()
{
_point.x = 0;
_point.y = 0;
}
bool isPointValid() const
{
return _isPointXValid && _isPointYValid;
}
};
// A POD class to send CmdLineParams through WM_COPYDATA and to Notepad_plus::loadCommandlineParams
struct CmdLineParamsDTO
{
bool _isReadOnly = false;
bool _isNoSession = false;
bool _isSessionFile = false;
bool _isRecursive = false;
bool _openFoldersAsWorkspace = false;
bool _monitorFiles = false;
intptr_t _line2go = 0;
intptr_t _column2go = 0;
intptr_t _pos2go = 0;
LangType _langType = L_EXTERNAL;
wchar_t _udlName[MAX_PATH] = {'\0'};
wchar_t _pluginMessage[MAX_PATH] = {'\0'};
static CmdLineParamsDTO FromCmdLineParams(const CmdLineParams& params)
{
CmdLineParamsDTO dto;
dto._isReadOnly = params._isReadOnly;
dto._isNoSession = params._isNoSession;
dto._isSessionFile = params._isSessionFile;
dto._isRecursive = params._isRecursive;
dto._openFoldersAsWorkspace = params._openFoldersAsWorkspace;
dto._monitorFiles = params._monitorFiles;
dto._line2go = params._line2go;
dto._column2go = params._column2go;
dto._pos2go = params._pos2go;
dto._langType = params._langType;
wcsncpy(dto._udlName, params._udlName.c_str(), MAX_PATH);
wcsncpy(dto._pluginMessage, params._pluginMessage.c_str(), MAX_PATH);
return dto;
}
};
struct FloatingWindowInfo
{
int _cont = 0;
RECT _pos = {};
FloatingWindowInfo(int cont, int x, int y, int w, int h)
: _cont(cont)
{
_pos.left = x;
_pos.top = y;
_pos.right = w;
_pos.bottom = h;
}
};
struct PluginDlgDockingInfo final
{
std::wstring _name;
int _internalID = -1;
int _currContainer = -1;
int _prevContainer = -1;
bool _isVisible = false;
PluginDlgDockingInfo(const TCHAR* pluginName, int id, int curr, int prev, bool isVis)
: _name(pluginName), _internalID(id), _currContainer(curr), _prevContainer(prev), _isVisible(isVis)
{}
bool operator == (const PluginDlgDockingInfo& rhs) const
{
return _internalID == rhs._internalID and _name == rhs._name;
}
};
struct ContainerTabInfo final
{
int _cont = 0;
int _activeTab = 0;
ContainerTabInfo(int cont, int activeTab) : _cont(cont), _activeTab(activeTab) {};
};
struct DockingManagerData final
{
int _leftWidth = 200;
int _rightWidth = 200;
int _topHeight = 200;
int _bottomHight = 200;
std::vector<FloatingWindowInfo> _flaotingWindowInfo;
std::vector<PluginDlgDockingInfo> _pluginDockInfo;
std::vector<ContainerTabInfo> _containerTabInfo;
bool getFloatingRCFrom(int floatCont, RECT& rc) const
{
for (size_t i = 0, fwiLen = _flaotingWindowInfo.size(); i < fwiLen; ++i)
{
if (_flaotingWindowInfo[i]._cont == floatCont)
{
rc.left = _flaotingWindowInfo[i]._pos.left;
rc.top = _flaotingWindowInfo[i]._pos.top;
rc.right = _flaotingWindowInfo[i]._pos.right;
rc.bottom = _flaotingWindowInfo[i]._pos.bottom;
return true;
}
}
return false;
}
};
const int FONTSTYLE_NONE = 0;
const int FONTSTYLE_BOLD = 1;
const int FONTSTYLE_ITALIC = 2;
const int FONTSTYLE_UNDERLINE = 4;
const int STYLE_NOT_USED = -1;
const int COLORSTYLE_FOREGROUND = 0x01;
const int COLORSTYLE_BACKGROUND = 0x02;
const int COLORSTYLE_ALL = COLORSTYLE_FOREGROUND|COLORSTYLE_BACKGROUND;
struct Style final
{
int _styleID = STYLE_NOT_USED;
std::wstring _styleDesc;
COLORREF _fgColor = COLORREF(STYLE_NOT_USED);
COLORREF _bgColor = COLORREF(STYLE_NOT_USED);
int _colorStyle = COLORSTYLE_ALL;
bool _isFontEnabled = false;
std::wstring _fontName;
int _fontStyle = STYLE_NOT_USED;
int _fontSize = STYLE_NOT_USED;
int _nesting = FONTSTYLE_NONE;
int _keywordClass = STYLE_NOT_USED;
std::wstring _keywords;
};
struct GlobalOverride final
{
bool isEnable() const {return (enableFg || enableBg || enableFont || enableFontSize || enableBold || enableItalic || enableUnderLine);}
bool enableFg = false;
bool enableBg = false;
bool enableFont = false;
bool enableFontSize = false;
bool enableBold = false;
bool enableItalic = false;
bool enableUnderLine = false;
};
struct StyleArray
{
auto begin() { return _styleVect.begin(); };
auto end() { return _styleVect.end(); };
void clear() { _styleVect.clear(); };
Style& getStyler(size_t index) {
if (index >= _styleVect.size())
throw std::out_of_range("Styler index out of range");
return _styleVect[index];
};
void addStyler(int styleID, TiXmlNode *styleNode);
void addStyler(int styleID, const std::wstring& styleName) {
_styleVect.emplace_back();
Style& s = _styleVect.back();
s._styleID = styleID;
s._styleDesc = styleName;
s._fgColor = black;
s._bgColor = white;
};
Style* findByID(int id) {
for (size_t i = 0; i < _styleVect.size(); ++i)
{
if (_styleVect[i]._styleID == id)
return &(_styleVect[i]);
}
return nullptr;
};
Style* findByName(const std::wstring& name) {
for (size_t i = 0; i < _styleVect.size(); ++i)
{
if (_styleVect[i]._styleDesc == name)
return &(_styleVect[i]);
}
return nullptr;
};
protected:
std::vector<Style> _styleVect;
};
struct LexerStyler : public StyleArray
{
public:
LexerStyler & operator=(const LexerStyler & ls)
{
if (this != &ls)
{
*(static_cast<StyleArray *>(this)) = ls;
this->_lexerName = ls._lexerName;
this->_lexerDesc = ls._lexerDesc;
this->_lexerUserExt = ls._lexerUserExt;
}
return *this;
}
void setLexerName(const TCHAR *lexerName)
{
_lexerName = lexerName;
}
void setLexerDesc(const TCHAR *lexerDesc)
{
_lexerDesc = lexerDesc;
}
void setLexerUserExt(const TCHAR *lexerUserExt) {
_lexerUserExt = lexerUserExt;
};
const TCHAR * getLexerName() const {return _lexerName.c_str();};
const TCHAR * getLexerDesc() const {return _lexerDesc.c_str();};
const TCHAR * getLexerUserExt() const {return _lexerUserExt.c_str();};
private :
std::wstring _lexerName;
std::wstring _lexerDesc;
std::wstring _lexerUserExt;
};
struct SortLexersInAlphabeticalOrder {
bool operator() (LexerStyler& l, LexerStyler& r) {
if (!lstrcmp(l.getLexerDesc(), TEXT("Search result")))
return false;
if (!lstrcmp(r.getLexerDesc(), TEXT("Search result")))
return true;
return lstrcmp(l.getLexerDesc(), r.getLexerDesc()) < 0;
}
};
struct LexerStylerArray
{
size_t getNbLexer() const { return _lexerStylerVect.size(); }
void clear() { _lexerStylerVect.clear(); }
LexerStyler & getLexerFromIndex(size_t index)
{
assert(index < _lexerStylerVect.size());
return _lexerStylerVect[index];
};
const TCHAR * getLexerNameFromIndex(size_t index) const { return _lexerStylerVect[index].getLexerName(); }
const TCHAR * getLexerDescFromIndex(size_t index) const { return _lexerStylerVect[index].getLexerDesc(); }
LexerStyler * getLexerStylerByName(const TCHAR *lexerName) {
if (!lexerName) return nullptr;
for (size_t i = 0 ; i < _lexerStylerVect.size() ; ++i)
{
if (!lstrcmp(_lexerStylerVect[i].getLexerName(), lexerName))
return &(_lexerStylerVect[i]);
}
return nullptr;
};
void addLexerStyler(const TCHAR *lexerName, const TCHAR *lexerDesc, const TCHAR *lexerUserExt, TiXmlNode *lexerNode);
void sort() {
std::sort(_lexerStylerVect.begin(), _lexerStylerVect.end(), SortLexersInAlphabeticalOrder());
};
private :
std::vector<LexerStyler> _lexerStylerVect;
};
struct NewDocDefaultSettings final
{
EolType _format = EolType::osdefault;
UniMode _unicodeMode = uniCookie;
bool _openAnsiAsUtf8 = true;
LangType _lang = L_TEXT;
int _codepage = -1; // -1 when not using
bool _addNewDocumentOnStartup = false;
};
struct LangMenuItem final
{
LangType _langType = L_TEXT;
int _cmdID = -1;
std::wstring _langName;
LangMenuItem(LangType lt, int cmdID = 0, const std::wstring& langName = TEXT("")):
_langType(lt), _cmdID(cmdID), _langName(langName){};
bool operator<(const LangMenuItem& rhs)
{
std::wstring lhs_lang(this->_langName.length(), ' '), rhs_lang(rhs._langName.length(), ' ');
std::transform(this->_langName.begin(), this->_langName.end(), lhs_lang.begin(), towlower);
std::transform(rhs._langName.begin(), rhs._langName.end(), rhs_lang.begin(), towlower);
return lhs_lang < rhs_lang;
}
};
struct PrintSettings final {
bool _printLineNumber = true;
int _printOption = SC_PRINT_COLOURONWHITE;
std::wstring _headerLeft;
std::wstring _headerMiddle;
std::wstring _headerRight;
std::wstring _headerFontName;
int _headerFontStyle = 0;
int _headerFontSize = 0;
std::wstring _footerLeft;
std::wstring _footerMiddle;
std::wstring _footerRight;
std::wstring _footerFontName;
int _footerFontStyle = 0;
int _footerFontSize = 0;
RECT _marge = {};
PrintSettings() {
_marge.left = 0; _marge.top = 0; _marge.right = 0; _marge.bottom = 0;
};
bool isHeaderPresent() const {
return ((_headerLeft != TEXT("")) || (_headerMiddle != TEXT("")) || (_headerRight != TEXT("")));
};
bool isFooterPresent() const {
return ((_footerLeft != TEXT("")) || (_footerMiddle != TEXT("")) || (_footerRight != TEXT("")));
};
bool isUserMargePresent() const {
return ((_marge.left != 0) || (_marge.top != 0) || (_marge.right != 0) || (_marge.bottom != 0));
};
};
class Date final
{
public:
Date() = default;
Date(unsigned long year, unsigned long month, unsigned long day)
: _year(year)
, _month(month)
, _day(day)
{
assert(year > 0 && year <= 9999); // I don't think Notepad++ will last till AD 10000 :)
assert(month > 0 && month <= 12);
assert(day > 0 && day <= 31);
assert(!(month == 2 && day > 29) &&
!(month == 4 && day > 30) &&
!(month == 6 && day > 30) &&
!(month == 9 && day > 30) &&
!(month == 11 && day > 30));
}
explicit Date(const TCHAR *dateStr);
// The constructor which makes the date of number of days from now
// nbDaysFromNow could be negative if user want to make a date in the past
// if the value of nbDaysFromNow is 0 then the date will be now
Date(int nbDaysFromNow);
void now();
std::wstring toString() const // Return Notepad++ date format : YYYYMMDD
{
TCHAR dateStr[16];
wsprintf(dateStr, TEXT("%04u%02u%02u"), _year, _month, _day);
return dateStr;
}
bool operator < (const Date & compare) const
{
if (this->_year != compare._year)
return (this->_year < compare._year);
if (this->_month != compare._month)
return (this->_month < compare._month);
return (this->_day < compare._day);
}
bool operator > (const Date & compare) const
{
if (this->_year != compare._year)
return (this->_year > compare._year);
if (this->_month != compare._month)
return (this->_month > compare._month);
return (this->_day > compare._day);
}
bool operator == (const Date & compare) const
{
if (this->_year != compare._year)
return false;
if (this->_month != compare._month)
return false;
return (this->_day == compare._day);
}
bool operator != (const Date & compare) const
{
if (this->_year != compare._year)
return true;
if (this->_month != compare._month)
return true;
return (this->_day != compare._day);
}
private:
unsigned long _year = 2008;
unsigned long _month = 4;
unsigned long _day = 26;
};
class MatchedPairConf final
{
public:
bool hasUserDefinedPairs() const { return _matchedPairs.size() != 0; }
bool hasDefaultPairs() const { return _doParentheses||_doBrackets||_doCurlyBrackets||_doQuotes||_doDoubleQuotes||_doHtmlXmlTag; }
bool hasAnyPairsPair() const { return hasUserDefinedPairs() || hasDefaultPairs(); }
public:
std::vector<std::pair<char, char>> _matchedPairs;
std::vector<std::pair<char, char>> _matchedPairsInit; // used only on init
bool _doHtmlXmlTag = false;
bool _doParentheses = false;
bool _doBrackets = false;
bool _doCurlyBrackets = false;
bool _doQuotes = false;
bool _doDoubleQuotes = false;
};
struct DarkModeConf final
{
bool _isEnabled = false;
bool _isEnabledPlugin = true;
NppDarkMode::ColorTone _colorTone = NppDarkMode::blackTone;
NppDarkMode::Colors _customColors = NppDarkMode::getDarkModeDefaultColors();
NppDarkMode::AdvancedOptions _advOptions{};
};
struct LargeFileRestriction final
{
int64_t _largeFileSizeDefInByte = NPP_STYLING_FILESIZE_LIMIT_DEFAULT;
bool _isEnabled = true;
bool _deactivateWordWrap = true;
bool _allowBraceMatch = false;
bool _allowAutoCompletion = false;
bool _allowSmartHilite = false;
bool _allowClickableLink = false;
bool _suppress2GBWarning = false;
};
struct NppGUI final
{
toolBarStatusType _toolBarStatus = TB_STANDARD;
bool _toolbarShow = true;
bool _statusBarShow = true;
bool _menuBarShow = true;
// 1st bit : draw top bar;
// 2nd bit : draw inactive tabs
// 3rd bit : enable drag & drop
// 4th bit : reduce the height
// 5th bit : enable vertical
// 6th bit : enable multiline
// 0:don't draw; 1:draw top bar 2:draw inactive tabs 3:draw both 7:draw both+drag&drop
int _tabStatus = (TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP | TAB_REDUCE | TAB_CLOSEBUTTON);
bool _splitterPos = POS_VERTICAL;
int _userDefineDlgStatus = UDD_DOCKED;
int _tabSize = 4;
bool _tabReplacedBySpace = false;
bool _finderLinesAreCurrentlyWrapped = false;
bool _finderPurgeBeforeEverySearch = false;
bool _finderShowOnlyOneEntryPerFoundLine = true;
int _fileAutoDetection = cdEnabledNew;
bool _checkHistoryFiles = false;
RECT _appPos {0, 0, 1024, 700};
RECT _findWindowPos {};
bool _findWindowLessMode = false;
bool _isMaximized = false;
bool _isMinimizedToTray = false;
bool _rememberLastSession = true; // remember next session boolean will be written in the settings
bool _keepSessionAbsentFileEntries = false;
bool _isCmdlineNosessionActivated = false; // used for if -nosession is indicated on the launch time
bool _detectEncoding = true;
bool _saveAllConfirm = true;
bool _setSaveDlgExtFiltToAllTypes = false;
bool _doTaskList = true;
bool _maitainIndent = true;
bool _enableSmartHilite = true;
bool _smartHiliteCaseSensitive = false;
bool _smartHiliteWordOnly = true;
bool _smartHiliteUseFindSettings = false;
bool _smartHiliteOnAnotherView = false;
bool _markAllCaseSensitive = false;
bool _markAllWordOnly = true;
bool _disableSmartHiliteTmp = false;
bool _enableTagsMatchHilite = true;
bool _enableTagAttrsHilite = true;
bool _enableHiliteNonHTMLZone = false;
bool _styleMRU = true;
char _leftmostDelimiter = '(';
char _rightmostDelimiter = ')';
bool _delimiterSelectionOnEntireDocument = false;
bool _backSlashIsEscapeCharacterForSql = true;
bool _fillFindFieldWithSelected = true;
bool _fillFindFieldSelectCaret = true;
bool _monospacedFontFindDlg = false;
bool _findDlgAlwaysVisible = false;
bool _confirmReplaceInAllOpenDocs = true;
bool _replaceStopsWithoutFindingNext = false;
int _inSelectionAutocheckThreshold = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
bool _muteSounds = false;
bool _enableFoldCmdToggable = false;
bool _hideMenuRightShortcuts = false;
writeTechnologyEngine _writeTechnologyEngine = directWriteTechnology;
bool _isWordCharDefault = true;
std::string _customWordChars;
urlMode _styleURL = urlUnderLineFg;
std::wstring _uriSchemes = TEXT("svn:// cvs:// git:// imap:// irc:// irc6:// ircs:// ldap:// ldaps:// news: telnet:// gopher:// ssh:// sftp:// smb:// skype: snmp:// spotify: steam:// sms: slack:// chrome:// bitcoin:");
NewDocDefaultSettings _newDocDefaultSettings;
std::wstring _dateTimeFormat = TEXT("yyyy-MM-dd HH:mm:ss");
bool _dateTimeReverseDefaultOrder = false;
void setTabReplacedBySpace(bool b) {_tabReplacedBySpace = b;};
const NewDocDefaultSettings & getNewDocDefaultSettings() const {return _newDocDefaultSettings;};
std::vector<LangMenuItem> _excludedLangList;
bool _isLangMenuCompact = true;
PrintSettings _printSettings;
BackupFeature _backup = bak_none;
bool _useDir = false;
std::wstring _backupDir;
DockingManagerData _dockingData;
GlobalOverride _globalOverride;
enum AutocStatus{autoc_none, autoc_func, autoc_word, autoc_both};
AutocStatus _autocStatus = autoc_both;
UINT _autocFromLen = 1;
bool _autocIgnoreNumbers = true;
bool _autocInsertSelectedUseENTER = true;
bool _autocInsertSelectedUseTAB = true;
bool _autocBrief = false;
bool _funcParams = true;
MatchedPairConf _matchedPairConf;
std::wstring _definedSessionExt;
std::wstring _definedWorkspaceExt;
// items with no Notepad++ GUI to set
std::wstring _commandLineInterpreter = CMD_INTERPRETER;
struct AutoUpdateOptions
{
bool _doAutoUpdate = true;
int _intervalDays = 15;
Date _nextUpdateDate;
AutoUpdateOptions(): _nextUpdateDate(Date()) {};
}
_autoUpdateOpt;
bool _doesExistUpdater = false;
int _caretBlinkRate = 600;
int _caretWidth = 1;
bool _shortTitlebar = false;
OpenSaveDirSetting _openSaveDir = dir_followCurrent;
TCHAR _defaultDir[MAX_PATH]{};
TCHAR _defaultDirExp[MAX_PATH]{}; //expanded environment variables
TCHAR _lastUsedDir[MAX_PATH]{};
std::wstring _themeName;
MultiInstSetting _multiInstSetting = monoInst;
bool _clipboardHistoryPanelKeepState = false;
bool _docListKeepState = false;
bool _charPanelKeepState = false;
bool _fileBrowserKeepState = false;
bool _projectPanelKeepState = false;
bool _docMapKeepState = false;
bool _funcListKeepState = false;
bool _pluginPanelKeepState = false;
bool _fileSwitcherWithoutExtColumn = false;
int _fileSwitcherExtWidth = 50;
bool _fileSwitcherWithoutPathColumn = true;
int _fileSwitcherPathWidth = 50;
bool _fileSwitcherDisableListViewGroups = false;
bool isSnapshotMode() const {return _isSnapshotMode && _rememberLastSession && !_isCmdlineNosessionActivated;};
bool _isSnapshotMode = true;
size_t _snapshotBackupTiming = 7000;
std::wstring _cloudPath; // this option will never be read/written from/to config.xml
unsigned char _availableClouds = '\0'; // this option will never be read/written from/to config.xml
enum SearchEngineChoice{ se_custom = 0, se_duckDuckGo = 1, se_google = 2, se_bing = 3, se_yahoo = 4, se_stackoverflow = 5 };
SearchEngineChoice _searchEngineChoice = se_google;
std::wstring _searchEngineCustom;
bool _isFolderDroppedOpenFiles = false;
bool _isDocPeekOnTab = false;
bool _isDocPeekOnMap = false;
// function list should be sorted by default on new file open
bool _shouldSortFunctionList = false;
DarkModeConf _darkmode;
LargeFileRestriction _largeFileRestriction;
};
struct ScintillaViewParams
{
bool _lineNumberMarginShow = true;
bool _lineNumberMarginDynamicWidth = true;
bool _bookMarkMarginShow = true;
bool _isChangeHistoryEnabled = true;
bool _isChangeHistoryEnabled4NextSession = true;
folderStyle _folderStyle = FOLDER_STYLE_BOX; //"simple", "arrow", "circle", "box" and "none"
lineWrapMethod _lineWrapMethod = LINEWRAP_ALIGNED;
bool _foldMarginShow = true;
bool _indentGuideLineShow = true;
lineHiliteMode _currentLineHiliteMode = LINEHILITE_HILITE;
unsigned char _currentLineFrameWidth = 1; // 1-6 pixel
bool _wrapSymbolShow = false;
bool _doWrap = false;
bool _isEdgeBgMode = false;
std::vector<size_t> _edgeMultiColumnPos;
intptr_t _zoom = 0;
intptr_t _zoom2 = 0;
bool _whiteSpaceShow = false;
bool _eolShow = false;
enum crlfMode {plainText = 0, roundedRectangleText = 1, plainTextCustomColor = 2, roundedRectangleTextCustomColor = 3};
crlfMode _eolMode = roundedRectangleText;
bool _npcShow = false;
enum npcMode { identity = 0, abbreviation = 1, codepoint = 2 };
npcMode _npcMode = abbreviation;
bool _npcCustomColor = false;
bool _npcIncludeCcUniEol = false;
bool _ccUniEolShow = true;
int _borderWidth = 2;
bool _virtualSpace = false;
bool _scrollBeyondLastLine = true;
bool _rightClickKeepsSelection = false;
bool _disableAdvancedScrolling = false;
bool _doSmoothFont = false;
bool _showBorderEdge = true;
unsigned char _paddingLeft = 0; // 0-9 pixel
unsigned char _paddingRight = 0; // 0-9 pixel
// distractionFreeDivPart is used for divising the fullscreen pixel width.
// the result of division will be the left & right padding in Distraction Free mode
unsigned char _distractionFreeDivPart = 4; // 3-9 parts
int getDistractionFreePadding(int editViewWidth) const {
const int defaultDiviser = 4;
int diviser = _distractionFreeDivPart > 2 ? _distractionFreeDivPart : defaultDiviser;
int paddingLen = editViewWidth / diviser;
if (paddingLen <= 0)
paddingLen = editViewWidth / defaultDiviser;
return paddingLen;
};
};
const int NB_LIST = 20;
const int NB_MAX_LRF_FILE = 30;
const int NB_MAX_USER_LANG = 30;
const int NB_MAX_EXTERNAL_LANG = 30;
const int NB_MAX_IMPORTED_UDL = 50;
constexpr int NB_DEFAULT_LRF_CUSTOMLENGTH = 100;
constexpr int NB_MAX_LRF_CUSTOMLENGTH = MAX_PATH - 1;
const int NB_MAX_FINDHISTORY_FIND = 30;
const int NB_MAX_FINDHISTORY_REPLACE = 30;
const int NB_MAX_FINDHISTORY_PATH = 30;
const int NB_MAX_FINDHISTORY_FILTER = 20;