Skip to content

Commit 8f001af

Browse files
author
PavelTorgashov
committed
First release (Version 2.9.3)
1 parent 9ad08bf commit 8f001af

File tree

230 files changed

+37326
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+37326
-0
lines changed

Diff for: FastColoredTextBox.sln

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastColoredTextBox", "FastColoredTextBox\FastColoredTextBox.csproj", "{6DD14A85-CCFC-4774-BD26-0F5772512319}"
7+
EndProject
8+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TesterVB", "TesterVB\TesterVB.vbproj", "{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|Mixed Platforms = Debug|Mixed Platforms
14+
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
16+
Release|Mixed Platforms = Release|Mixed Platforms
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Debug|Any CPU.ActiveCfg = Debug|x86
21+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
22+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Debug|Mixed Platforms.Build.0 = Debug|x86
23+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Debug|x86.ActiveCfg = Debug|x86
24+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Debug|x86.Build.0 = Debug|x86
25+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Release|Any CPU.ActiveCfg = Release|x86
26+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Release|Mixed Platforms.ActiveCfg = Release|x86
27+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Release|Mixed Platforms.Build.0 = Release|x86
28+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Release|x86.ActiveCfg = Release|x86
29+
{EBE443EE-F4C7-49E6-AC22-959CA62FAA05}.Release|x86.Build.0 = Release|x86
30+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
33+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
34+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Debug|x86.ActiveCfg = Debug|Any CPU
35+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
38+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Release|Mixed Platforms.Build.0 = Release|Any CPU
39+
{6DD14A85-CCFC-4774-BD26-0F5772512319}.Release|x86.ActiveCfg = Release|Any CPU
40+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Debug|Any CPU.ActiveCfg = Debug|x86
41+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
42+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Debug|Mixed Platforms.Build.0 = Debug|x86
43+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Debug|x86.ActiveCfg = Debug|x86
44+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Debug|x86.Build.0 = Debug|x86
45+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Release|Any CPU.ActiveCfg = Release|x86
46+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Release|Mixed Platforms.ActiveCfg = Release|x86
47+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Release|Mixed Platforms.Build.0 = Release|x86
48+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Release|x86.ActiveCfg = Release|x86
49+
{3EF3A5A0-2365-41FD-97A0-254A2CFC6577}.Release|x86.Build.0 = Release|x86
50+
EndGlobalSection
51+
GlobalSection(SolutionProperties) = preSolution
52+
HideSolutionNode = FALSE
53+
EndGlobalSection
54+
EndGlobal

Diff for: FastColoredTextBox/AutocompleteItem.cs

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
using System;
2+
using System.Drawing.Printing;
3+
4+
namespace FastColoredTextBoxNS
5+
{
6+
/// <summary>
7+
/// Item of autocomplete menu
8+
/// </summary>
9+
public class AutocompleteItem
10+
{
11+
public string Text;
12+
public int ImageIndex = -1;
13+
public object Tag;
14+
string toolTipTitle;
15+
string toolTipText;
16+
string menuText;
17+
public AutocompleteMenu Parent { get; internal set; }
18+
19+
20+
public AutocompleteItem()
21+
{
22+
}
23+
24+
public AutocompleteItem(string text)
25+
{
26+
Text = text;
27+
}
28+
29+
public AutocompleteItem(string text, int imageIndex)
30+
: this(text)
31+
{
32+
this.ImageIndex = imageIndex;
33+
}
34+
35+
public AutocompleteItem(string text, int imageIndex, string menuText)
36+
: this(text, imageIndex)
37+
{
38+
this.menuText = menuText;
39+
}
40+
41+
public AutocompleteItem(string text, int imageIndex, string menuText, string toolTipTitle, string toolTipText)
42+
: this(text, imageIndex, menuText)
43+
{
44+
this.toolTipTitle = toolTipTitle;
45+
this.toolTipText = toolTipText;
46+
}
47+
48+
/// <summary>
49+
/// Returns text for inserting into Textbox
50+
/// </summary>
51+
public virtual string GetTextForReplace()
52+
{
53+
return Text;
54+
}
55+
56+
/// <summary>
57+
/// Compares fragment text with this item
58+
/// </summary>
59+
public virtual CompareResult Compare(string fragmentText)
60+
{
61+
if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase) &&
62+
Text != fragmentText)
63+
return CompareResult.VisibleAndSelected;
64+
65+
return CompareResult.Hidden;
66+
}
67+
68+
/// <summary>
69+
/// Returns text for display into popup menu
70+
/// </summary>
71+
public override string ToString()
72+
{
73+
return menuText ?? Text;
74+
}
75+
76+
/// <summary>
77+
/// This method is called after item inserted into text
78+
/// </summary>
79+
public virtual void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
80+
{
81+
;
82+
}
83+
84+
/// <summary>
85+
/// Title for tooltip.
86+
/// </summary>
87+
/// <remarks>Return null for disable tooltip for this item</remarks>
88+
public virtual string ToolTipTitle
89+
{
90+
get { return toolTipTitle; }
91+
set { toolTipTitle = value; }
92+
}
93+
94+
/// <summary>
95+
/// Tooltip text.
96+
/// </summary>
97+
/// <remarks>For display tooltip text, ToolTipTitle must be not null</remarks>
98+
public virtual string ToolTipText
99+
{
100+
get{ return toolTipText; }
101+
set { toolTipText = value; }
102+
}
103+
104+
/// <summary>
105+
/// Menu text. This text is displayed in the drop-down menu.
106+
/// </summary>
107+
public virtual string MenuText
108+
{
109+
get { return menuText; }
110+
set { menuText = value; }
111+
}
112+
}
113+
114+
public enum CompareResult
115+
{
116+
/// <summary>
117+
/// Item do not appears
118+
/// </summary>
119+
Hidden,
120+
/// <summary>
121+
/// Item appears
122+
/// </summary>
123+
Visible,
124+
/// <summary>
125+
/// Item appears and will selected
126+
/// </summary>
127+
VisibleAndSelected
128+
}
129+
130+
/// <summary>
131+
/// Autocomplete item for code snippets
132+
/// </summary>
133+
/// <remarks>Snippet can contain special char ^ for caret position.</remarks>
134+
public class SnippetAutocompleteItem : AutocompleteItem
135+
{
136+
public SnippetAutocompleteItem(string snippet)
137+
{
138+
Text = snippet.Replace("\r", "");
139+
ToolTipTitle = "Code snippet:";
140+
ToolTipText = Text;
141+
}
142+
143+
public override string ToString()
144+
{
145+
return MenuText ?? Text.Replace("\n", " ").Replace("^", "");
146+
}
147+
148+
public override string GetTextForReplace()
149+
{
150+
return Text;
151+
}
152+
153+
public override void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
154+
{
155+
e.Tb.BeginUpdate();
156+
e.Tb.Selection.BeginUpdate();
157+
//remember places
158+
var p1 = popupMenu.Fragment.Start;
159+
var p2 = e.Tb.Selection.Start;
160+
//do auto indent
161+
if (e.Tb.AutoIndent)
162+
{
163+
for (int iLine = p1.iLine + 1; iLine <= p2.iLine; iLine++)
164+
{
165+
e.Tb.Selection.Start = new Place(0, iLine);
166+
e.Tb.DoAutoIndent(iLine);
167+
}
168+
}
169+
e.Tb.Selection.Start = p1;
170+
//move caret position right and find char ^
171+
while (e.Tb.Selection.CharBeforeStart != '^')
172+
if (!e.Tb.Selection.GoRightThroughFolded())
173+
break;
174+
//remove char ^
175+
e.Tb.Selection.GoLeft(true);
176+
e.Tb.InsertText("");
177+
//
178+
e.Tb.Selection.EndUpdate();
179+
e.Tb.EndUpdate();
180+
}
181+
182+
/// <summary>
183+
/// Compares fragment text with this item
184+
/// </summary>
185+
public override CompareResult Compare(string fragmentText)
186+
{
187+
if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase) &&
188+
Text != fragmentText)
189+
return CompareResult.Visible;
190+
191+
return CompareResult.Hidden;
192+
}
193+
}
194+
195+
/// <summary>
196+
/// This autocomplete item appears after dot
197+
/// </summary>
198+
public class MethodAutocompleteItem : AutocompleteItem
199+
{
200+
string firstPart;
201+
string lowercaseText;
202+
203+
public MethodAutocompleteItem(string text)
204+
: base(text)
205+
{
206+
lowercaseText = Text.ToLower();
207+
}
208+
209+
public override CompareResult Compare(string fragmentText)
210+
{
211+
int i = fragmentText.LastIndexOf('.');
212+
if (i < 0)
213+
return CompareResult.Hidden;
214+
string lastPart = fragmentText.Substring(i + 1);
215+
firstPart = fragmentText.Substring(0, i);
216+
217+
if(lastPart=="") return CompareResult.Visible;
218+
if(Text.StartsWith(lastPart, StringComparison.InvariantCultureIgnoreCase))
219+
return CompareResult.VisibleAndSelected;
220+
if(lowercaseText.Contains(lastPart.ToLower()))
221+
return CompareResult.Visible;
222+
223+
return CompareResult.Hidden;
224+
}
225+
226+
public override string GetTextForReplace()
227+
{
228+
return firstPart + "." + Text;
229+
}
230+
}
231+
}

0 commit comments

Comments
 (0)