Skip to content

Commit

Permalink
Replated RichTextBox with FastColoredTextBox. Added FastColoredTextBo…
Browse files Browse the repository at this point in the history
…xHighlighter.
  • Loading branch information
yallie committed Mar 9, 2012
0 parents commit f9daa78
Show file tree
Hide file tree
Showing 356 changed files with 38,879 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax: glob
*.suo
*.user
*.cache
*.Cache
*.FileListAbsolute.txt
*.gpState
bin
obj
*.lnk
TestResults/*
174 changes: 174 additions & 0 deletions Irony.GrammarExplorer/030.Irony.GrammarExplorer.2010.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE1C04A8-B03D-4144-98E9-BF66C50265E7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Irony.GrammarExplorer</RootNamespace>
<AssemblyName>Irony.GrammarExplorer</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<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>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="fmGrammarExplorer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="fmGrammarExplorer.Designer.cs">
<DependentUpon>fmGrammarExplorer.cs</DependentUpon>
</Compile>
<Compile Include="fmSelectGrammars.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="fmSelectGrammars.Designer.cs">
<DependentUpon>fmSelectGrammars.cs</DependentUpon>
</Compile>
<Compile Include="GrammarItemList.cs" />
<Compile Include="GrammarLoader.cs" />
<Compile Include="Highlighter\EditorAdapter.cs" />
<Compile Include="Highlighter\EditorViewAdapter.cs" />
<Compile Include="Highlighter\FastColoredTextBoxHighlighter.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="fmGrammarExplorer.resx">
<DependentUpon>fmGrammarExplorer.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="fmSelectGrammars.resx">
<DependentUpon>fmSelectGrammars.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="fmShowException.resx">
<SubType>Designer</SubType>
<DependentUpon>fmShowException.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="fmShowException.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="fmShowException.Designer.cs">
<DependentUpon>fmShowException.cs</DependentUpon>
</Compile>
<Compile Include="Highlighter\RichTextBoxHighlighter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Highlighter\AboutCodeHighlighter.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Irony.Interpreter\015.Irony.Interpreter.2010.csproj">
<Project>{321A7F5D-00C2-4095-9970-075CDEE8C139}</Project>
<Name>015.Irony.Interpreter.2010</Name>
</ProjectReference>
<ProjectReference Include="..\Irony\010.Irony.2010.csproj">
<Project>{D81F5C91-D7DB-46E5-BC99-49488FB6814C}</Project>
<Name>010.Irony.2010</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
10 changes: 10 additions & 0 deletions Irony.GrammarExplorer/030.Irony.GrammarExplorer.2010.csproj.vspscc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}
109 changes: 109 additions & 0 deletions Irony.GrammarExplorer/GrammarItemList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#region License
/* **********************************************************************************
* Copyright (c) Roman Ivantsov
* This source code is subject to terms and conditions of the MIT License
* for Irony. A copy of the license can be found in the License.txt file
* at the root of this distribution.
* By using this source code in any fashion, you are agreeing to be bound by the terms of the
* MIT License.
* You must not remove this notice from this software.
* **********************************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Windows.Forms;
using System.Reflection;
using Irony.Parsing;
using System.IO;
using System.Threading;

namespace Irony.GrammarExplorer {

//Helper classes for supporting showing grammar list in top combo, saving list on exit and loading on start
public class GrammarItem {
public readonly string Caption;
public readonly string LongCaption;
public readonly string Location; //location of assembly containing the grammar
public readonly string TypeName; //full type name
internal bool _loading;
public GrammarItem(string caption, string location, string typeName) {
Caption = caption;
Location = location;
TypeName = typeName;
}
public GrammarItem(Type grammarClass, string assemblyLocation) {
_loading = true;
Location = assemblyLocation;
TypeName = grammarClass.FullName;
//Get language name from Language attribute
Caption = grammarClass.Name; //default caption
LongCaption = Caption;
var langAttr = LanguageAttribute.GetValue(grammarClass);
if (langAttr != null) {
Caption = langAttr.LanguageName;
if (!string.IsNullOrEmpty(langAttr.Version))
Caption += ", version " + langAttr.Version;
LongCaption = Caption;
if (!string.IsNullOrEmpty(langAttr.Description))
LongCaption += ": " + langAttr.Description;
}
}
public GrammarItem(XmlElement element) {
Caption = element.GetAttribute("Caption");
Location = element.GetAttribute("Location");
TypeName = element.GetAttribute("TypeName");
}
public void Save(XmlElement toElement) {
toElement.SetAttribute("Caption", Caption);
toElement.SetAttribute("Location", Location);
toElement.SetAttribute("TypeName", TypeName);
}
public override string ToString() {
return _loading ? LongCaption : Caption;
}

}//class

public class GrammarItemList : List<GrammarItem> {
public static GrammarItemList FromXml(string xml) {
GrammarItemList list = new GrammarItemList();
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xml);
XmlNodeList xlist = xdoc.SelectNodes("//Grammar");
foreach (XmlElement xitem in xlist) {
GrammarItem item = new GrammarItem(xitem);
list.Add(item);
}
return list;
}
public static GrammarItemList FromCombo(ComboBox combo) {
GrammarItemList list = new GrammarItemList();
foreach (GrammarItem item in combo.Items)
list.Add(item);
return list;
}

public string ToXml() {
XmlDocument xdoc = new XmlDocument();
XmlElement xlist = xdoc.CreateElement("Grammars");
xdoc.AppendChild(xlist);
foreach (GrammarItem item in this) {
XmlElement xitem = xdoc.CreateElement("Grammar");
xlist.AppendChild(xitem);
item.Save(xitem);
} //foreach
return xdoc.OuterXml;
}//method

public void ShowIn(ComboBox combo) {
combo.Items.Clear();
foreach (GrammarItem item in this)
combo.Items.Add(item);
}

}//class
}
Loading

0 comments on commit f9daa78

Please sign in to comment.