forked from PavelTorgashov/FastColoredTextBox
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFastColoredTextBox.cs
More file actions
8742 lines (7678 loc) · 300 KB
/
FastColoredTextBox.cs
File metadata and controls
8742 lines (7678 loc) · 300 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
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
// License: GNU Lesser General Public License (LGPLv3)
//
// Email: pavel_torgashov@ukr.net
//
// Copyright (C) Pavel Torgashov, 2011-2016.
// #define debug
// -------------------------------------------------------------------------------
// By default the FastColoredTextbox supports no more 16 styles at the same time.
// This restriction saves memory.
// However, you can to compile FCTB with 32 styles supporting.
// Uncomment following definition if you need 32 styles instead of 16:
//
// #define Styles32
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using Microsoft.Win32;
using Timer = System.Windows.Forms.Timer;
namespace FastColoredTextBoxNS
{
/// <summary>
/// Fast colored textbox
/// </summary>
public partial class FastColoredTextBox : UserControl, ISupportInitialize
{
internal const int minLeftIndent = 8;
private const int maxBracketSearchIterations = 1000;
private const int maxLinesForFolding = 3000;
private const int minLinesForAccuracy = 100000;
private const int WM_IME_SETCONTEXT = 0x0281;
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;
private const int SB_ENDSCROLL = 0x8;
public readonly List<LineInfo> LineInfos = new List<LineInfo>();
private readonly Range selection;
private readonly Timer timer = new Timer();
private readonly Timer timer2 = new Timer();
private readonly Timer timer3 = new Timer();
private readonly List<VisualMarker> visibleMarkers = new List<VisualMarker>();
public int TextHeight;
public bool AllowInsertRemoveLines = true;
private Brush backBrush;
private BaseBookmarks bookmarks;
private bool caretVisible;
private Color changedLineColor;
private int charHeight;
private Color currentLineColor;
private Cursor defaultCursor;
private Range delayedTextChangedRange;
private string descriptionFile;
private int endFoldingLine = -1;
private Color foldingIndicatorColor;
protected Dictionary<int, int> foldingPairs = new Dictionary<int, int>();
private bool handledChar;
private bool highlightFoldingIndicator;
private Hints hints;
private Color indentBackColor;
private bool isChanged;
private bool isLineSelect;
private bool isReplaceMode;
private Language language;
private Keys lastModifiers;
private Point lastMouseCoord;
private DateTime lastNavigatedDateTime;
private Range leftBracketPosition;
private Range leftBracketPosition2;
private int leftPadding;
private int lineInterval;
private Color lineNumberColor;
private uint lineNumberStartValue;
private int lineSelectFrom;
private TextSource lines;
private IntPtr m_hImc;
private int maxLineLength;
private bool mouseIsDrag;
private bool mouseIsDragDrop;
private bool multiline;
protected bool needRecalc;
protected bool needRecalcWordWrap;
private Point needRecalcWordWrapInterval;
private bool needRecalcFoldingLines;
private bool needRiseSelectionChangedDelayed;
private bool needRiseTextChangedDelayed;
private bool needRiseVisibleRangeChangedDelayed;
private Color paddingBackColor;
private int preferredLineWidth;
private Range rightBracketPosition;
private Range rightBracketPosition2;
private bool scrollBars;
private Color selectionColor;
private Color serviceLinesColor;
private bool showFoldingLines;
private bool showLineNumbers;
private FastColoredTextBox sourceTextBox;
private int startFoldingLine = -1;
private int updating;
private Range updatingRange;
private Range visibleRange;
private bool wordWrap;
private WordWrapMode wordWrapMode = WordWrapMode.WordWrapControlWidth;
private int reservedCountOfLineNumberChars = 1;
private int zoom = 100;
private Size localAutoScrollMinSize;
/// <summary>
/// Constructor
/// </summary>
public FastColoredTextBox()
{
//register type provider
TypeDescriptionProvider prov = TypeDescriptor.GetProvider(GetType());
object theProvider =
prov.GetType().GetField("Provider", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(prov);
if (theProvider.GetType() != typeof(FCTBDescriptionProvider))
TypeDescriptor.AddProvider(new FCTBDescriptionProvider(GetType()), GetType());
//drawing optimization
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
//append monospace font
Font = new Font(FontFamily.GenericMonospace, 9.75f);
//create one line
InitTextSource(CreateTextSource());
if (lines.Count == 0)
lines.InsertLine(0, lines.CreateLine());
selection = new Range(this) { Start = new Place(0, 0) };
//default settings
Cursor = Cursors.IBeam;
BackColor = Color.White;
LineNumberColor = Color.Teal;
IndentBackColor = Color.WhiteSmoke;
ServiceLinesColor = Color.Silver;
FoldingIndicatorColor = Color.Green;
CurrentLineColor = Color.Transparent;
ChangedLineColor = Color.Transparent;
HighlightFoldingIndicator = true;
ShowLineNumbers = true;
TabLength = 4;
FoldedBlockStyle = new FoldedBlockStyle(Brushes.Gray, null, FontStyle.Regular);
SelectionColor = Color.Blue;
BracketsStyle = new MarkerStyle(new SolidBrush(Color.FromArgb(80, Color.Lime)));
BracketsStyle2 = new MarkerStyle(new SolidBrush(Color.FromArgb(60, Color.Red)));
DelayedEventsInterval = 100;
DelayedTextChangedInterval = 100;
AllowSeveralTextStyleDrawing = false;
LeftBracket = '\x0';
RightBracket = '\x0';
LeftBracket2 = '\x0';
RightBracket2 = '\x0';
SyntaxHighlighter = new SyntaxHighlighter(this);
language = Language.Custom;
PreferredLineWidth = 0;
needRecalc = true;
lastNavigatedDateTime = DateTime.Now;
AutoIndent = true;
AutoIndentExistingLines = true;
CommentPrefix = "//";
lineNumberStartValue = 1;
multiline = true;
scrollBars = true;
AcceptsTab = true;
AcceptsReturn = true;
caretVisible = true;
CaretColor = Color.Black;
WideCaret = false;
Paddings = new Padding(0, 0, 0, 0);
PaddingBackColor = Color.Transparent;
DisabledColor = Color.FromArgb(100, 180, 180, 180);
needRecalcFoldingLines = true;
AllowDrop = true;
FindEndOfFoldingBlockStrategy = FindEndOfFoldingBlockStrategy.Strategy1;
VirtualSpace = false;
bookmarks = new Bookmarks(this);
BookmarkColor = Color.PowderBlue;
ToolTip = new ToolTip();
timer3.Interval = 500;
hints = new Hints(this);
SelectionHighlightingForLineBreaksEnabled = true;
textAreaBorder = TextAreaBorderType.None;
textAreaBorderColor = Color.Black;
macrosManager = new MacrosManager(this);
HotkeysMapping = new HotkeysMapping();
HotkeysMapping.InitDefault();
WordWrapAutoIndent = true;
FoldedBlocks = new Dictionary<int, int>();
AutoCompleteBrackets = false;
AutoIndentCharsPatterns = @"^\s*[\w\.]+\s*(?<range>=)\s*(?<range>[^;]+);";
AutoIndentChars = true;
CaretBlinking = true;
ServiceColors = new ServiceColors();
//
base.AutoScroll = true;
timer.Tick += timer_Tick;
timer2.Tick += timer2_Tick;
timer3.Tick += timer3_Tick;
middleClickScrollingTimer.Tick += middleClickScrollingTimer_Tick;
}
internal static bool IsChinese(char c)
{
bool BoolValue = false;
if (Convert.ToInt32(c) < Convert.ToInt32(Convert.ToChar(128)))
{
BoolValue = false;
}
else
{
return BoolValue = true;
}
return BoolValue;
}
private char[] autoCompleteBracketsList = { '(', ')', '{', '}', '[', ']', '"', '"', '\'', '\'' };
public char[] AutoCompleteBracketsList
{
get { return autoCompleteBracketsList; }
set { autoCompleteBracketsList = value; }
}
/// <summary>
/// AutoComplete brackets
/// </summary>
[DefaultValue(false)]
[Description("AutoComplete brackets.")]
public bool AutoCompleteBrackets { get; set; }
/// <summary>
/// Colors of some service visual markers
/// </summary>
[Browsable(true)]
[Description("Colors of some service visual markers.")]
[TypeConverter(typeof(ExpandableObjectConverter))]
public ServiceColors ServiceColors { get; set; }
/// <summary>
/// Contains UniqueId of start lines of folded blocks
/// </summary>
/// <remarks>This dictionary remembers folding state of blocks.
/// It is needed to restore child folding after user collapsed/expanded top-level folding block.</remarks>
[Browsable(false)]
public Dictionary<int, int> FoldedBlocks { get; private set; }
/// <summary>
/// Strategy of search of brackets to highlighting
/// </summary>
[DefaultValue(typeof(BracketsHighlightStrategy), "Strategy1")]
[Description("Strategy of search of brackets to highlighting.")]
public BracketsHighlightStrategy BracketsHighlightStrategy { get; set; }
/// <summary>
/// Automatically shifts secondary wordwrap lines on the shift amount of the first line
/// </summary>
[DefaultValue(true)]
[Description("Automatically shifts secondary wordwrap lines on the shift amount of the first line.")]
public bool WordWrapAutoIndent { get; set; }
/// <summary>
/// Indent of secondary wordwrap lines (in chars)
/// </summary>
[DefaultValue(0)]
[Description("Indent of secondary wordwrap lines (in chars).")]
public int WordWrapIndent { get; set; }
MacrosManager macrosManager;
/// <summary>
/// MacrosManager records, stores and executes the macroses
/// </summary>
[Browsable(false)]
public MacrosManager MacrosManager { get { return macrosManager; } }
/// <summary>
/// Allows drag and drop
/// </summary>
[DefaultValue(true)]
[Description("Allows drag and drop")]
public override bool AllowDrop
{
get { return base.AllowDrop; }
set { base.AllowDrop = value; }
}
/// <summary>
/// Collection of Hints.
/// This is temporary buffer for currently displayed hints.
/// </summary>
/// <remarks>You can asynchronously add, remove and clear hints. Appropriate hints will be shown or hidden from the screen.</remarks>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never)]
public Hints Hints
{
get { return hints; }
set { hints = value; }
}
/// <summary>
/// Delay (ms) of ToolTip
/// </summary>
[Browsable(true)]
[DefaultValue(500)]
[Description("Delay(ms) of ToolTip.")]
public int ToolTipDelay
{
get { return timer3.Interval; }
set { timer3.Interval = value; }
}
/// <summary>
/// ToolTip component
/// </summary>
[Browsable(true)]
[Description("ToolTip component.")]
public ToolTip ToolTip { get; set; }
/// <summary>
/// Color of bookmarks
/// </summary>
[Browsable(true)]
[DefaultValue(typeof(Color), "PowderBlue")]
[Description("Color of bookmarks.")]
public Color BookmarkColor { get; set; }
/// <summary>
/// Bookmarks
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never)]
public BaseBookmarks Bookmarks
{
get { return bookmarks; }
set { bookmarks = value; }
}
/// <summary>
/// Enables virtual spaces
/// </summary>
[DefaultValue(false)]
[Description("Enables virtual spaces.")]
public bool VirtualSpace { get; set; }
/// <summary>
/// Strategy of search of end of folding block
/// </summary>
[DefaultValue(FindEndOfFoldingBlockStrategy.Strategy1)]
[Description("Strategy of search of end of folding block.")]
public FindEndOfFoldingBlockStrategy FindEndOfFoldingBlockStrategy { get; set; }
/// <summary>
/// Indicates if tab characters are accepted as input
/// </summary>
[DefaultValue(true)]
[Description("Indicates if tab characters are accepted as input.")]
public bool AcceptsTab { get; set; }
/// <summary>
/// Indicates if return characters are accepted as input
/// </summary>
[DefaultValue(true)]
[Description("Indicates if return characters are accepted as input.")]
public bool AcceptsReturn { get; set; }
/// <summary>
/// Shows or hides the caret
/// </summary>
[DefaultValue(true)]
[Description("Shows or hides the caret")]
public bool CaretVisible
{
get { return caretVisible; }
set
{
caretVisible = value;
Invalidate();
}
}
/// <summary>
/// Enables caret blinking
/// </summary>
[DefaultValue(true)]
[Description("Enables caret blinking")]
public bool CaretBlinking { get; set; }
/// <summary>
/// Draw caret when the control is not focused
/// </summary>
[DefaultValue(false)]
public bool ShowCaretWhenInactive { get; set; }
Color textAreaBorderColor;
/// <summary>
/// Color of border of text area
/// </summary>
[DefaultValue(typeof(Color), "Black")]
[Description("Color of border of text area")]
public Color TextAreaBorderColor
{
get { return textAreaBorderColor; }
set
{
textAreaBorderColor = value;
Invalidate();
}
}
TextAreaBorderType textAreaBorder;
/// <summary>
/// Type of border of text area
/// </summary>
[DefaultValue(typeof(TextAreaBorderType), "None")]
[Description("Type of border of text area")]
public TextAreaBorderType TextAreaBorder
{
get { return textAreaBorder; }
set
{
textAreaBorder = value;
Invalidate();
}
}
/// <summary>
/// Background color for current line
/// </summary>
[DefaultValue(typeof(Color), "Transparent")]
[Description("Background color for current line. Set to Color.Transparent to hide current line highlighting")]
public Color CurrentLineColor
{
get { return currentLineColor; }
set
{
currentLineColor = value;
Invalidate();
}
}
/// <summary>
/// Background color for highlighting of changed lines
/// </summary>
[DefaultValue(typeof(Color), "Transparent")]
[Description("Background color for highlighting of changed lines. Set to Color.Transparent to hide changed line highlighting")]
public Color ChangedLineColor
{
get { return changedLineColor; }
set
{
changedLineColor = value;
Invalidate();
}
}
/// <summary>
/// Fore color (default style color)
/// </summary>
public override Color ForeColor
{
get { return base.ForeColor; }
set
{
base.ForeColor = value;
lines.InitDefaultStyle();
Invalidate();
}
}
/// <summary>
/// Height of char in pixels (includes LineInterval)
/// </summary>
[Browsable(false)]
public int CharHeight
{
get { return charHeight; }
set
{
charHeight = value;
NeedRecalc();
OnCharSizeChanged();
}
}
/// <summary>
/// Interval between lines (in pixels)
/// </summary>
[Description("Interval between lines in pixels")]
[DefaultValue(0)]
public int LineInterval
{
get { return lineInterval; }
set
{
lineInterval = value;
SetFont(Font);
Invalidate();
}
}
/// <summary>
/// Width of char in pixels
/// </summary>
[Browsable(false)]
public int CharWidth { get; set; }
[Browsable(false)]
public int CharCnWidth { get; set; }
/// <summary>
/// Spaces count for tab
/// </summary>
[DefaultValue(4)]
[Description("Spaces count for tab")]
public int TabLength { get; set; }
/// <summary>
/// Text was changed
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsChanged
{
get { return isChanged; }
set
{
if (!value)
//clear line's IsChanged property
lines.ClearIsChanged();
isChanged = value;
}
}
/// <summary>
/// Text version
/// </summary>
/// <remarks>This counter is incremented each time changes the text</remarks>
[Browsable(false)]
public int TextVersion { get; private set; }
/// <summary>
/// Read only
/// </summary>
[DefaultValue(false)]
public bool ReadOnly { get; set; }
/// <summary>
/// Shows line numbers.
/// </summary>
[DefaultValue(true)]
[Description("Shows line numbers.")]
public bool ShowLineNumbers
{
get { return showLineNumbers; }
set
{
showLineNumbers = value;
NeedRecalc();
Invalidate();
}
}
/// <summary>
/// Shows vertical lines between folding start line and folding end line.
/// </summary>
[DefaultValue(false)]
[Description("Shows vertical lines between folding start line and folding end line.")]
public bool ShowFoldingLines
{
get { return showFoldingLines; }
set
{
showFoldingLines = value;
Invalidate();
}
}
/// <summary>
/// Rectangle where located text
/// </summary>
[Browsable(false)]
public Rectangle TextAreaRect
{
get
{
int rightPaddingStartX = LeftIndent + maxLineLength * CharWidth + Paddings.Left + 1;
rightPaddingStartX = Math.Max(ClientSize.Width - Paddings.Right, rightPaddingStartX);
int bottomPaddingStartY = TextHeight + Paddings.Top;
bottomPaddingStartY = Math.Max(ClientSize.Height - Paddings.Bottom, bottomPaddingStartY);
var top = Math.Max(0, Paddings.Top - 1) - VerticalScroll.Value;
var left = LeftIndent - HorizontalScroll.Value - 2 + Math.Max(0, Paddings.Left - 1);
var rect = Rectangle.FromLTRB(left, top, rightPaddingStartX - HorizontalScroll.Value, bottomPaddingStartY - VerticalScroll.Value);
return rect;
}
}
/// <summary>
/// Color of line numbers.
/// </summary>
[DefaultValue(typeof(Color), "Teal")]
[Description("Color of line numbers.")]
public Color LineNumberColor
{
get { return lineNumberColor; }
set
{
lineNumberColor = value;
Invalidate();
}
}
/// <summary>
/// Start value of first line number.
/// </summary>
[DefaultValue(typeof(uint), "1")]
[Description("Start value of first line number.")]
public uint LineNumberStartValue
{
get { return lineNumberStartValue; }
set
{
lineNumberStartValue = value;
needRecalc = true;
Invalidate();
}
}
/// <summary>
/// Background color of indent area
/// </summary>
[DefaultValue(typeof(Color), "WhiteSmoke")]
[Description("Background color of indent area")]
public Color IndentBackColor
{
get { return indentBackColor; }
set
{
indentBackColor = value;
Invalidate();
}
}
/// <summary>
/// Background color of padding area
/// </summary>
[DefaultValue(typeof(Color), "Transparent")]
[Description("Background color of padding area")]
public Color PaddingBackColor
{
get { return paddingBackColor; }
set
{
paddingBackColor = value;
Invalidate();
}
}
/// <summary>
/// Color of disabled component
/// </summary>
[DefaultValue(typeof(Color), "100;180;180;180")]
[Description("Color of disabled component")]
public Color DisabledColor { get; set; }
/// <summary>
/// Color of caret
/// </summary>
[DefaultValue(typeof(Color), "Black")]
[Description("Color of caret.")]
public Color CaretColor { get; set; }
/// <summary>
/// Wide caret
/// </summary>
[DefaultValue(false)]
[Description("Wide caret.")]
public bool WideCaret { get; set; }
/// <summary>
/// Color of service lines (folding lines, borders of blocks etc.)
/// </summary>
[DefaultValue(typeof(Color), "Silver")]
[Description("Color of service lines (folding lines, borders of blocks etc.)")]
public Color ServiceLinesColor
{
get { return serviceLinesColor; }
set
{
serviceLinesColor = value;
Invalidate();
}
}
/// <summary>
/// Padings of text area
/// </summary>
[Browsable(true)]
[Description("Paddings of text area.")]
public Padding Paddings { get; set; }
/// <summary>
/// --Do not use this property--
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never)]
public new Padding Padding
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
//hide RTL
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
EditorBrowsable(EditorBrowsableState.Never)]
public new bool RightToLeft
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
/// <summary>
/// Color of folding area indicator
/// </summary>
[DefaultValue(typeof(Color), "Green")]
[Description("Color of folding area indicator.")]
public Color FoldingIndicatorColor
{
get { return foldingIndicatorColor; }
set
{
foldingIndicatorColor = value;
Invalidate();
}
}
/// <summary>
/// Enables folding indicator (left vertical line between folding bounds)
/// </summary>
[DefaultValue(true)]
[Description("Enables folding indicator (left vertical line between folding bounds)")]
public bool HighlightFoldingIndicator
{
get { return highlightFoldingIndicator; }
set
{
highlightFoldingIndicator = value;
Invalidate();
}
}
/// <summary>
/// Left distance to text beginning
/// </summary>
[Browsable(false)]
[Description("Left distance to text beginning.")]
public int LeftIndent { get; private set; }
/// <summary>
/// Left padding in pixels
/// </summary>
[DefaultValue(0)]
[Description("Width of left service area (in pixels)")]
public int LeftPadding
{
get { return leftPadding; }
set
{
leftPadding = value;
Invalidate();
}
}
/// <summary>
/// This property draws vertical line after defined char position.
/// Set to 0 for disable drawing of vertical line.
/// </summary>
[DefaultValue(0)]
[Description("This property draws vertical line after defined char position. Set to 0 for disable drawing of vertical line.")]
public int PreferredLineWidth
{
get { return preferredLineWidth; }
set
{
preferredLineWidth = value;
Invalidate();
}
}
/// <summary>
/// Styles
/// </summary>
[Browsable(false)]
public Style[] Styles
{
get { return lines.Styles; }
}
/// <summary>
/// Hotkeys. Do not use this property in your code, use HotkeysMapping property.
/// </summary>
[Description("Here you can change hotkeys for FastColoredTextBox.")]
[Editor(typeof(HotkeysEditor), typeof(UITypeEditor))]
[DefaultValue("Tab=IndentIncrease, Escape=ClearHints, PgUp=GoPageUp, PgDn=GoPageDown, End=GoEnd, Home=GoHome, Left=GoLeft, Up=GoUp, Right=GoRight, Down=GoDown, Ins=ReplaceMode, Del=DeleteCharRight, F3=FindNext, Shift+Tab=IndentDecrease, Shift+PgUp=GoPageUpWithSelection, Shift+PgDn=GoPageDownWithSelection, Shift+End=GoEndWithSelection, Shift+Home=GoHomeWithSelection, Shift+Left=GoLeftWithSelection, Shift+Up=GoUpWithSelection, Shift+Right=GoRightWithSelection, Shift+Down=GoDownWithSelection, Shift+Ins=Paste, Shift+Del=Cut, Ctrl+Back=ClearWordLeft, Ctrl+Space=AutocompleteMenu, Ctrl+End=GoLastLine, Ctrl+Home=GoFirstLine, Ctrl+Left=GoWordLeft, Ctrl+Up=ScrollUp, Ctrl+Right=GoWordRight, Ctrl+Down=ScrollDown, Ctrl+Ins=Copy, Ctrl+Del=ClearWordRight, Ctrl+0=ZoomNormal, Ctrl+A=SelectAll, Ctrl+B=BookmarkLine, Ctrl+C=Copy, Ctrl+E=MacroExecute, Ctrl+F=FindDialog, Ctrl+G=GoToDialog, Ctrl+H=ReplaceDialog, Ctrl+I=AutoIndentChars, Ctrl+M=MacroRecord, Ctrl+N=GoNextBookmark, Ctrl+R=Redo, Ctrl+U=UpperCase, Ctrl+V=Paste, Ctrl+X=Cut, Ctrl+Z=Undo, Ctrl+Add=ZoomIn, Ctrl+Subtract=ZoomOut, Ctrl+OemMinus=NavigateBackward, Ctrl+Shift+End=GoLastLineWithSelection, Ctrl+Shift+Home=GoFirstLineWithSelection, Ctrl+Shift+Left=GoWordLeftWithSelection, Ctrl+Shift+Right=GoWordRightWithSelection, Ctrl+Shift+B=UnbookmarkLine, Ctrl+Shift+C=CommentSelected, Ctrl+Shift+N=GoPrevBookmark, Ctrl+Shift+U=LowerCase, Ctrl+Shift+OemMinus=NavigateForward, Alt+Back=Undo, Alt+Up=MoveSelectedLinesUp, Alt+Down=MoveSelectedLinesDown, Alt+F=FindChar, Alt+Shift+Left=GoLeft_ColumnSelectionMode, Alt+Shift+Up=GoUp_ColumnSelectionMode, Alt+Shift+Right=GoRight_ColumnSelectionMode, Alt+Shift+Down=GoDown_ColumnSelectionMode")]
public string Hotkeys
{
get { return HotkeysMapping.ToString(); }
set { HotkeysMapping = HotkeysMapping.Parse(value); }
}
/// <summary>
/// Hotkeys mapping
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public HotkeysMapping HotkeysMapping { get; set; }
/// <summary>
/// Default text style
/// This style is using when no one other TextStyle is not defined in Char.style
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TextStyle DefaultStyle
{
get { return lines.DefaultStyle; }
set { lines.DefaultStyle = value; }
}
/// <summary>
/// Style for rendering Selection area
/// </summary>
[Browsable(false)]
public SelectionStyle SelectionStyle { get; set; }
/// <summary>
/// Style for folded block rendering
/// </summary>
[Browsable(false)]
public TextStyle FoldedBlockStyle { get; set; }
/// <summary>
/// Style for brackets highlighting
/// </summary>
[Browsable(false)]
public MarkerStyle BracketsStyle { get; set; }
/// <summary>
/// Style for alternative brackets highlighting
/// </summary>
[Browsable(false)]
public MarkerStyle BracketsStyle2 { get; set; }
/// <summary>
/// Opening bracket for brackets highlighting.
/// Set to '\x0' for disable brackets highlighting.
/// </summary>
[DefaultValue('\x0')]
[Description("Opening bracket for brackets highlighting. Set to '\\x0' for disable brackets highlighting.")]
public char LeftBracket { get; set; }
/// <summary>
/// Closing bracket for brackets highlighting.
/// Set to '\x0' for disable brackets highlighting.
/// </summary>
[DefaultValue('\x0')]
[Description("Closing bracket for brackets highlighting. Set to '\\x0' for disable brackets highlighting.")]
public char RightBracket { get; set; }
/// <summary>
/// Alternative opening bracket for brackets highlighting.
/// Set to '\x0' for disable brackets highlighting.
/// </summary>
[DefaultValue('\x0')]
[Description("Alternative opening bracket for brackets highlighting. Set to '\\x0' for disable brackets highlighting.")]
public char LeftBracket2 { get; set; }
/// <summary>
/// Alternative closing bracket for brackets highlighting.
/// Set to '\x0' for disable brackets highlighting.
/// </summary>
[DefaultValue('\x0')]
[Description("Alternative closing bracket for brackets highlighting. Set to '\\x0' for disable brackets highlighting.")]
public char RightBracket2 { get; set; }
/// <summary>
/// Comment line prefix.
/// </summary>
[DefaultValue("//")]
[Description("Comment line prefix.")]
public string CommentPrefix { get; set; }
/// <summary>
/// This property specifies which part of the text will be highlighted as you type (by built-in highlighter).
/// </summary>
/// <remarks>When a user enters text, a component refreshes highlighting (because the text was changed).
/// This property specifies exactly which section of the text will be re-highlighted.
/// This can be useful to highlight multi-line comments, for example.</remarks>
[DefaultValue(typeof(HighlightingRangeType), "ChangedRange")]
[Description("This property specifies which part of the text will be highlighted as you type.")]
public HighlightingRangeType HighlightingRangeType { get; set; }
/// <summary>
/// Is keyboard in replace mode (wide caret) ?
/// </summary>
[Browsable(false)]
public bool IsReplaceMode
{
get
{
return isReplaceMode &&
Selection.IsEmpty &&
(!Selection.ColumnSelectionMode) &&
Selection.Start.iChar < lines[Selection.Start.iLine].Count;
}
set { isReplaceMode = value; }
}
/// <summary>
/// Allows text rendering several styles same time.
/// </summary>
[Browsable(true)]
[DefaultValue(false)]
[Description("Allows text rendering several styles same time.")]
public bool AllowSeveralTextStyleDrawing { get; set; }
/// <summary>
/// Allows to record macros.
/// </summary>
[Browsable(true)]
[DefaultValue(true)]
[Description("Allows to record macros.")]
public bool AllowMacroRecording
{
get { return macrosManager.AllowMacroRecordingByUser; }
set { macrosManager.AllowMacroRecordingByUser = value; }
}
/// <summary>
/// Allows AutoIndent. Inserts spaces before new line.
/// </summary>
[DefaultValue(true)]
[Description("Allows auto indent. Inserts spaces before line chars.")]
public bool AutoIndent { get; set; }
/// <summary>
/// Does autoindenting in existing lines. It works only if AutoIndent is True.
/// </summary>
[DefaultValue(true)]
[Description("Does autoindenting in existing lines. It works only if AutoIndent is True.")]
public bool AutoIndentExistingLines { get; set; }
/// <summary>
/// Minimal delay(ms) for delayed events (except TextChangedDelayed).
/// </summary>
[Browsable(true)]
[DefaultValue(100)]
[Description("Minimal delay(ms) for delayed events (except TextChangedDelayed).")]
public int DelayedEventsInterval
{
get { return timer.Interval; }
set { timer.Interval = value; }
}
/// <summary>
/// Minimal delay(ms) for TextChangedDelayed event.
/// </summary>
[Browsable(true)]
[DefaultValue(100)]
[Description("Minimal delay(ms) for TextChangedDelayed event.")]
public int DelayedTextChangedInterval
{
get { return timer2.Interval; }
set { timer2.Interval = value; }
}
/// <summary>
/// Language for highlighting by built-in highlighter.
/// </summary>
[Browsable(true)]