Skip to content

Commit

Permalink
Added FastColoredTextBox sources instead of the compiled binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Mar 11, 2018
1 parent 12b2f9c commit ed9627b
Show file tree
Hide file tree
Showing 35 changed files with 11,328 additions and 1,959 deletions.
3 changes: 0 additions & 3 deletions Irony.GrammarExplorer/030.Irony.GrammarExplorer.2010.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="FastColoredTextBox">
<HintPath>..\Libraries\FastColoredTextBox\FastColoredTextBox.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
Expand Down
57 changes: 54 additions & 3 deletions Irony.WinForms/035.Irony.WinForms.2010.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="FastColoredTextBox">
<HintPath>..\Libraries\FastColoredTextBox\FastColoredTextBox.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
Expand All @@ -52,6 +49,48 @@
<Compile Include="Exceptions\fmShowException.Designer.cs">
<DependentUpon>fmShowException.cs</DependentUpon>
</Compile>
<Compile Include="FastColoredTextBox\AutocompleteItem.cs" />
<Compile Include="FastColoredTextBox\AutocompleteMenu.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FastColoredTextBox\Char.cs" />
<Compile Include="FastColoredTextBox\CommandManager.cs" />
<Compile Include="FastColoredTextBox\Commands.cs" />
<Compile Include="FastColoredTextBox\Export.cs" />
<Compile Include="FastColoredTextBox\FastColoredTextBox.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="FastColoredTextBox\FileTextSource.cs" />
<Compile Include="FastColoredTextBox\FindForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FastColoredTextBox\FindForm.Designer.cs">
<DependentUpon>FindForm.cs</DependentUpon>
</Compile>
<Compile Include="FastColoredTextBox\GoToForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FastColoredTextBox\GoToForm.Designer.cs">
<DependentUpon>GoToForm.cs</DependentUpon>
</Compile>
<Compile Include="FastColoredTextBox\LimitedStack.cs" />
<Compile Include="FastColoredTextBox\Line.cs" />
<Compile Include="FastColoredTextBox\LinesAccessor.cs" />
<Compile Include="FastColoredTextBox\Place.cs" />
<Compile Include="FastColoredTextBox\PlatformType.cs" />
<Compile Include="FastColoredTextBox\Range.cs" />
<Compile Include="FastColoredTextBox\ReplaceForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FastColoredTextBox\ReplaceForm.Designer.cs">
<DependentUpon>ReplaceForm.cs</DependentUpon>
</Compile>
<Compile Include="FastColoredTextBox\Style.cs" />
<Compile Include="FastColoredTextBox\SyntaxDescriptor.cs" />
<Compile Include="FastColoredTextBox\SyntaxHighlighter.cs" />
<Compile Include="FastColoredTextBox\TextSource.cs" />
<Compile Include="FastColoredTextBox\TypeDescriptor.cs" />
<Compile Include="FastColoredTextBox\VisualMarker.cs" />
<Compile Include="Highlighter\EditorAdapter.cs" />
<Compile Include="Highlighter\EditorViewAdapter.cs" />
<Compile Include="Highlighter\FastColoredTextBoxHighlighter.cs" />
Expand All @@ -72,6 +111,18 @@
<EmbeddedResource Include="Exceptions\fmShowException.resx">
<DependentUpon>fmShowException.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FastColoredTextBox\FastColoredTextBox.resx">
<DependentUpon>FastColoredTextBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FastColoredTextBox\FindForm.resx">
<DependentUpon>FindForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FastColoredTextBox\GoToForm.resx">
<DependentUpon>GoToForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FastColoredTextBox\ReplaceForm.resx">
<DependentUpon>ReplaceForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
File renamed without changes.
230 changes: 230 additions & 0 deletions Irony.WinForms/FastColoredTextBox/AutocompleteItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
using System;

namespace FastColoredTextBoxNS
{
/// <summary>
/// Item of autocomplete menu
/// </summary>
public class AutocompleteItem
{
public string Text;
public int ImageIndex = -1;
public object Tag;
string toolTipTitle;
string toolTipText;
string menuText;
public AutocompleteMenu Parent { get; internal set; }


public AutocompleteItem()
{
}

public AutocompleteItem(string text)
{
Text = text;
}

public AutocompleteItem(string text, int imageIndex)
: this(text)
{
this.ImageIndex = imageIndex;
}

public AutocompleteItem(string text, int imageIndex, string menuText)
: this(text, imageIndex)
{
this.menuText = menuText;
}

public AutocompleteItem(string text, int imageIndex, string menuText, string toolTipTitle, string toolTipText)
: this(text, imageIndex, menuText)
{
this.toolTipTitle = toolTipTitle;
this.toolTipText = toolTipText;
}

/// <summary>
/// Returns text for inserting into Textbox
/// </summary>
public virtual string GetTextForReplace()
{
return Text;
}

/// <summary>
/// Compares fragment text with this item
/// </summary>
public virtual CompareResult Compare(string fragmentText)
{
if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase) &&
Text != fragmentText)
return CompareResult.VisibleAndSelected;

return CompareResult.Hidden;
}

/// <summary>
/// Returns text for display into popup menu
/// </summary>
public override string ToString()
{
return menuText ?? Text;
}

/// <summary>
/// This method is called after item inserted into text
/// </summary>
public virtual void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
{
;
}

/// <summary>
/// Title for tooltip.
/// </summary>
/// <remarks>Return null for disable tooltip for this item</remarks>
public virtual string ToolTipTitle
{
get { return toolTipTitle; }
set { toolTipTitle = value; }
}

/// <summary>
/// Tooltip text.
/// </summary>
/// <remarks>For display tooltip text, ToolTipTitle must be not null</remarks>
public virtual string ToolTipText
{
get{ return toolTipText; }
set { toolTipText = value; }
}

/// <summary>
/// Menu text. This text is displayed in the drop-down menu.
/// </summary>
public virtual string MenuText
{
get { return menuText; }
set { menuText = value; }
}
}

public enum CompareResult
{
/// <summary>
/// Item do not appears
/// </summary>
Hidden,
/// <summary>
/// Item appears
/// </summary>
Visible,
/// <summary>
/// Item appears and will selected
/// </summary>
VisibleAndSelected
}

/// <summary>
/// Autocomplete item for code snippets
/// </summary>
/// <remarks>Snippet can contain special char ^ for caret position.</remarks>
public class SnippetAutocompleteItem : AutocompleteItem
{
public SnippetAutocompleteItem(string snippet)
{
Text = snippet.Replace("\r", "");
ToolTipTitle = "Code snippet:";
ToolTipText = Text;
}

public override string ToString()
{
return MenuText ?? Text.Replace("\n", " ").Replace("^", "");
}

public override string GetTextForReplace()
{
return Text;
}

public override void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
{
e.Tb.BeginUpdate();
e.Tb.Selection.BeginUpdate();
//remember places
var p1 = popupMenu.Fragment.Start;
var p2 = e.Tb.Selection.Start;
//do auto indent
if (e.Tb.AutoIndent)
{
for (int iLine = p1.iLine + 1; iLine <= p2.iLine; iLine++)
{
e.Tb.Selection.Start = new Place(0, iLine);
e.Tb.DoAutoIndent(iLine);
}
}
e.Tb.Selection.Start = p1;
//move caret position right and find char ^
while (e.Tb.Selection.CharBeforeStart != '^')
if (!e.Tb.Selection.GoRightThroughFolded())
break;
//remove char ^
e.Tb.Selection.GoLeft(true);
e.Tb.InsertText("");
//
e.Tb.Selection.EndUpdate();
e.Tb.EndUpdate();
}

/// <summary>
/// Compares fragment text with this item
/// </summary>
public override CompareResult Compare(string fragmentText)
{
if (Text.StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase) &&
Text != fragmentText)
return CompareResult.Visible;

return CompareResult.Hidden;
}
}

/// <summary>
/// This autocomplete item appears after dot
/// </summary>
public class MethodAutocompleteItem : AutocompleteItem
{
string firstPart;
string lowercaseText;

public MethodAutocompleteItem(string text)
: base(text)
{
lowercaseText = Text.ToLower();
}

public override CompareResult Compare(string fragmentText)
{
int i = fragmentText.LastIndexOf('.');
if (i < 0)
return CompareResult.Hidden;
string lastPart = fragmentText.Substring(i + 1);
firstPart = fragmentText.Substring(0, i);

if(lastPart=="") return CompareResult.Visible;
if(Text.StartsWith(lastPart, StringComparison.InvariantCultureIgnoreCase))
return CompareResult.VisibleAndSelected;
if(lowercaseText.Contains(lastPart.ToLower()))
return CompareResult.Visible;

return CompareResult.Hidden;
}

public override string GetTextForReplace()
{
return firstPart + "." + Text;
}
}
}
Loading

0 comments on commit ed9627b

Please sign in to comment.