Browse Source

Update AvalonEdit to 4.1.0.7920.

pull/205/merge
Daniel Grunwald 15 years ago
parent
commit
d50766287f
  1. 162
      AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj
  2. 13
      AvalonEdit/Documentation/Text Rendering.aml
  3. 5
      AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HtmlClipboardTests.cs
  4. 21
      AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.cs
  5. 14
      AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.xaml
  6. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs
  7. 1
      AvalonEdit/ICSharpCode.AvalonEdit/Document/ISegment.cs
  8. 21
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
  9. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs
  10. 67
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
  11. 6
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs
  12. 14
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs
  13. 14
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
  14. 10
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlClipboard.cs
  15. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd
  16. 57
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSS-Mode.xshd
  17. 31
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd
  18. 40
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/HTML-Mode.xshd
  19. 3
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs
  20. 3
      AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  21. 8
      AvalonEdit/ICSharpCode.AvalonEdit/Properties/GlobalAssemblyInfo.cs
  22. 1
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs
  23. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/NewLineElementGenerator.cs
  24. 18
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
  25. 34
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextLayer.cs
  26. 15
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  27. 30
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
  28. 29
      AvalonEdit/ICSharpCode.AvalonEdit/Utils/CompressingTreeList.cs

162
AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj

@ -1,4 +1,5 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<!-- The configuration and platform will be used to determine which <!-- The configuration and platform will be used to determine which
assemblies to include from solution and project documentation assemblies to include from solution and project documentation
@ -7,7 +8,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{850b6602-0a7f-413a-864a-e816b98d7407}</ProjectGuid> <ProjectGuid>{850b6602-0a7f-413a-864a-e816b98d7407}</ProjectGuid>
<SHFBSchemaVersion>1.8.0.0</SHFBSchemaVersion> <SHFBSchemaVersion>1.9.3.0</SHFBSchemaVersion>
<!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual <!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual
Studio adds them anyway --> Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName> <AssemblyName>Documentation</AssemblyName>
@ -30,63 +31,28 @@
</WorkingPath> </WorkingPath>
<BuildLogFile> <BuildLogFile>
</BuildLogFile> </BuildLogFile>
<FrameworkVersion>3.5</FrameworkVersion> <FrameworkVersion>.NET 4.0.30319</FrameworkVersion>
<HelpTitle>AvalonEdit</HelpTitle> <HelpTitle>AvalonEdit</HelpTitle>
<CopyrightText>Copyright 2008-2010, Daniel Grunwald</CopyrightText> <CopyrightText>Copyright 2008-2011, Daniel Grunwald</CopyrightText>
<PresentationStyle>Prototype</PresentationStyle> <PresentationStyle>Prototype</PresentationStyle>
<HelpFileVersion>4.0.0.0</HelpFileVersion> <HelpFileVersion>4.1.0.0</HelpFileVersion>
<ComponentConfigurations> <ComponentConfigurations>
<ComponentConfig id="Cached Reflection Index Data" enabled="True">
<component id="Cached Reflection Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<index name="reflection" value="/reflection/apis/api" key="@id" cache="10">
<cache base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" cacheFile="{@AppDataFolder}Cache\Reflection.cache" />
<data files="reflection.xml" />
</index>
<copy name="reflection" source="*" target="/document/reference" />
</component>
</ComponentConfig>
<ComponentConfig id="Cached MSDN URL References" enabled="True">
<component id="Cached MSDN URL References" type="SandcastleBuilder.Components.CachedResolveReferenceLinksComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<cache filename="{@AppDataFolder}Cache\MsdnUrl.cache" />
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@SDKLinks}" />
<targets files="reflection.xml" type="{@ProjectLinks}" />
</component>
</ComponentConfig>
<ComponentConfig id="IntelliSense Component" enabled="True">
<component id="IntelliSense Component" type="SandcastleBuilder.Components.IntelliSenseComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Output options (optional)
Attributes:
Include Namespaces (false by default)
Namespaces filename ("Namespaces" if not specified or empty)
Directory (current folder if not specified or empty) -->
<output includeNamespaces="false" namespacesFile="Namespaces" folder="{@OutputFolder}" />
</component>
</ComponentConfig>
<ComponentConfig id="Cached Framework Comments Index Data" enabled="True">
<component id="Cached Framework Comments Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<index name="comments" value="/doc/members/member" key="@name" cache="100">
{@CachedFrameworkCommentList}
{@CommentFileList}
</index>
<copy name="comments" source="*" target="/document/comments" />
</component>
</ComponentConfig>
<ComponentConfig id="Code Block Component" enabled="True"> <ComponentConfig id="Code Block Component" enabled="True">
<component id="Code Block Component" type="SandcastleBuilder.Components.CodeBlockComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"> <component id="Code Block Component" type="SandcastleBuilder.Components.CodeBlockComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Base path for relative filenames in source attributes <!-- Base path for relative filenames in source attributes
(optional) --> (optional) -->
<basePath value="{@HtmlEncProjectFolder}" /> <basePath value="{@HtmlEncProjectFolder}" />
<!-- Connect to language filter (optional). If omitted, <!-- Connect to language filter (optional). If omitted,
language filtering is enabled by default. --> language filtering is enabled by default. -->
<languageFilter value="true" /> <languageFilter value="true" />
<!-- Allow missing source files (Optional). If omitted, <!-- Allow missing source files (Optional). If omitted,
it will generate errors if referenced source files it will generate errors if referenced source files
are missing. --> are missing. -->
<allowMissingSource value="false" /> <allowMissingSource value="false" />
<!-- Remove region markers from imported code blocks. If omitted, <!-- Remove region markers from imported code blocks. If omitted,
region markers in imported code blocks are left alone. --> region markers in imported code blocks are left alone. -->
<removeRegionMarkers value="false" /> <removeRegionMarkers value="false" />
<!-- Code colorizer options (required). <!-- Code colorizer options (required).
Attributes: Attributes:
Language syntax configuration file (required) Language syntax configuration file (required)
XSLT style file (required) XSLT style file (required)
@ -97,48 +63,92 @@
Keep XML comment "see" tags within the code (optional) Keep XML comment "see" tags within the code (optional)
Tab size override (optional, 0 = Use syntax file setting) Tab size override (optional, 0 = Use syntax file setting)
Use language name as default title (optional) --> Use language name as default title (optional) -->
<colorizer syntaxFile="{@SHFBFolder}Colorizer\highlight.xml" styleFile="{@SHFBFolder}Colorizer\highlight.xsl" copyImageUrl="../icons/CopyCode.gif" language="cs" numberLines="false" outlining="false" keepSeeTags="false" tabSize="0" defaultTitle="true" /> <colorizer syntaxFile="{@SHFBFolder}Colorizer\highlight.xml" styleFile="{@SHFBFolder}Colorizer\highlight.xsl" copyImageUrl="../icons/CopyCode.gif" language="cs" numberLines="false" outlining="false" keepSeeTags="false" tabSize="0" defaultTitle="true" />
</component> </component>
</ComponentConfig> </ComponentConfig>
<ComponentConfig id="Post-transform Component" enabled="True"> <ComponentConfig id="IntelliSense Component" enabled="True"><component id="IntelliSense Component" type="SandcastleBuilder.Components.IntelliSenseComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<component id="Post-transform Component" type="SandcastleBuilder.Components.PostTransformComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll"> <!-- Output options (optional)
<!-- Code colorizer files (required). Attributes:
Include Namespaces (false by default)
Namespaces filename ("Namespaces" if not specified or empty)
Directory (current folder if not specified or empty) -->
<output includeNamespaces="false" namespacesFile="Namespaces" folder="{@OutputFolder}" />
</component></ComponentConfig>
<ComponentConfig id="Cached MSDN URL References" enabled="True"><component id="Cached MSDN URL References" type="SandcastleBuilder.Components.CachedResolveReferenceLinksComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll" locale="{@Locale}" linkTarget="{@SdkLinkTarget}">
<helpOutput format="HtmlHelp1">
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@HtmlSdkLinkType}" />
<targets files="reflection.xml" type="Local" />
</helpOutput>
<helpOutput format="MSHelp2">
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@MSHelp2SdkLinkType}" />
<targets files="reflection.xml" type="Index" />
</helpOutput>
<helpOutput format="MSHelpViewer">
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@MSHelpViewerSdkLinkType}" />
<targets files="reflection.xml" type="Id" />
</helpOutput>
<helpOutput format="Website">
<cache filename="{@LocalDataFolder}Cache\MsdnUrl.cache" />
<targets base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" type="{@WebsiteSdkLinkType}" />
<targets files="reflection.xml" type="Local" />
</helpOutput>
</component></ComponentConfig>
<ComponentConfig id="Post-transform Component" enabled="True"><component id="Post-transform Component" type="SandcastleBuilder.Components.PostTransformComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<!-- Code colorizer files (required).
Attributes: Attributes:
Stylesheet file (required) Stylesheet file (required)
Script file (required) Script file (required)
"Copy" image file (required) --> "Copy" image file (required) -->
<colorizer stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" copyImage="{@SHFBFolder}Colorizer\CopyCode.gif" /> <colorizer stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" copyImage="{@SHFBFolder}Colorizer\CopyCode.gif" />
<!-- Base output path for the files (required). This should match <!-- Base output paths for the files (required). These should match
the parent folder of the output path of the HTML files (see the parent folder of the output path of the HTML files (see
SaveComponent). --> each of the SaveComponent instances below). -->
<outputPath value="Output\" /> <outputPaths>
<!-- Logo image file (optional). Filename is required. The height, {@HelpFormatOutputPaths}
</outputPaths>
<!-- Logo image file (optional). Filename is required. The height,
width, altText, placement, and alignment attributes are width, altText, placement, and alignment attributes are
optional. --> optional. -->
<logoFile filename="" height="0" width="0" altText="" placement="left" alignment="left" /> <logoFile filename="" height="0" width="0" altText="" placement="left" alignment="left" />
</component> </component></ComponentConfig>
</ComponentConfig> <ComponentConfig id="Cached Reflection Index Data" enabled="True"><component id="Cached Reflection Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
</ComponentConfigurations> <index name="reflection" value="/reflection/apis/api" key="@id" cache="10">
<cache base="{@SandcastlePath}Data\Reflection" recurse="true" files="*.xml" cacheFile="{@LocalDataFolder}Cache\Reflection.cache" />
<data files="reflection.xml" />
</index>
<copy name="reflection" source="*" target="/document/reference" />
</component></ComponentConfig>
<ComponentConfig id="Cached Framework Comments Index Data" enabled="True"><component id="Cached Framework Comments Index Data" type="SandcastleBuilder.Components.CachedCopyFromIndexComponent" assembly="{@SHFBFolder}SandcastleBuilder.Components.dll">
<index name="comments" value="/doc/members/member" key="@name" cache="100">
{@CachedFrameworkCommentList}
{@CommentFileList}
</index>
<copy name="comments" source="*" target="/document/comments" />
</component></ComponentConfig></ComponentConfigurations>
<DocumentationSources> <DocumentationSources>
<DocumentationSource sourceFile="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" /> <DocumentationSource sourceFile="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" />
</DocumentationSources> </DocumentationSources>
<NamespaceSummaries> <NamespaceSummaries>
<NamespaceSummaryItem name="(global)" isDocumented="False" /> <NamespaceSummaryItem name="(global)" isDocumented="False" />
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit" isDocumented="True">This is the main AvalonEdit namespace.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit" isDocumented="True">This is the main AvalonEdit namespace.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.CodeCompletion" isDocumented="True">This namespace contains classes to show the code completion window.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.CodeCompletion" isDocumented="True">This namespace contains classes to show the code completion window.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Document" isDocumented="True">This namespace contains the document model. <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Document" isDocumented="True">This namespace contains the document model.
The most important class here is TextDocument, which represents document that can be displayed and edited in the text editor.</NamespaceSummaryItem> The most important class here is TextDocument, which represents document that can be displayed and edited in the text editor.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Editing" isDocumented="True">This namespace is the home of the TextArea class. It manages user input and handles the caret and the selection.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Editing" isDocumented="True">This namespace is the home of the TextArea class. It manages user input and handles the caret and the selection.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Folding" isDocumented="True">This namespace contains the folding (code collapsing) implementation.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Folding" isDocumented="True">This namespace contains the folding (code collapsing) implementation.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting" isDocumented="True">This namespace contains the engine for highlighting text documents (DocumentHighlighter). <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting" isDocumented="True">This namespace contains the engine for highlighting text documents (DocumentHighlighter).
Additionally, the class HighlightingColorizer provides integration of the highlighting engine into the text editor GUI.</NamespaceSummaryItem> Additionally, the class HighlightingColorizer provides integration of the highlighting engine into the text editor GUI.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting.Xshd" isDocumented="True">This namespace contains a document model for syntax highlighting definitions (.xshd files).</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Highlighting.Xshd" isDocumented="True">This namespace contains a document model for syntax highlighting definitions (.xshd files).</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Indentation" isDocumented="True">This namespace contains the logic for automatic indentation.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Indentation" isDocumented="True">This namespace contains the logic for automatic indentation.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Rendering" isDocumented="True">This namespace contains the text rendering infrastructure.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Rendering" isDocumented="True">This namespace contains the text rendering infrastructure.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Utils" isDocumented="True">This namespace contains various utility classes.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Utils" isDocumented="True">This namespace contains various utility classes.</NamespaceSummaryItem>
<NamespaceSummaryItem name="XamlGeneratedNamespace" isDocumented="False" /> <NamespaceSummaryItem name="XamlGeneratedNamespace" isDocumented="False" />
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Xml" isDocumented="True">This namespace contains an error-tolerant XML parser with support for incremental parsing, only reparsing the changed regions of a TextDocument.</NamespaceSummaryItem> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Xml" isDocumented="True">This namespace contains an error-tolerant XML parser with support for incremental parsing, only reparsing the changed regions of a TextDocument.</NamespaceSummaryItem>
<NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Snippets" isDocumented="True">Snippets perform automatic text insertion. Snippets can be interactive after they were expanded, for example to allow the user to easily replace fields in the expanded snippet.</NamespaceSummaryItem></NamespaceSummaries> <NamespaceSummaryItem name="ICSharpCode.AvalonEdit.Snippets" isDocumented="True">Snippets perform automatic text insertion. Snippets can be interactive after they were expanded, for example to allow the user to easily replace fields in the expanded snippet.</NamespaceSummaryItem>
</NamespaceSummaries>
<CleanIntermediates>True</CleanIntermediates> <CleanIntermediates>True</CleanIntermediates>
<SyntaxFilters>Standard</SyntaxFilters> <SyntaxFilters>Standard</SyntaxFilters>
</PropertyGroup> </PropertyGroup>

13
AvalonEdit/Documentation/Text Rendering.aml

@ -153,9 +153,16 @@
</para> </para>
<para> <para>
These are the predefined layers: These are the predefined layers:
<list class="bullet"><listItem>Background layer: renders the background colors associated with the visual elements</listItem><listItem>Selection layer: renders the background of the selection</listItem><listItem>Text layer: renders the TextLines that were constructed during the Measure step. <list class="bullet">
The text layer also serves as container for any inline UI elements. <listItem>Background layer: renders the background colors associated with the visual elements</listItem>
</listItem><listItem>Caret layer: renders a blinking caret</listItem></list> <listItem>Selection layer: renders the background of the selection</listItem>
<listItem>Text layer: renders the TextLines that were constructed during the Measure step.
Starting with AvalonEdit 4.1, the TextLayer uses child elements to draw the text: one DrawingVisual for each VisualLine.
</listItem>
<listItem>
Immediately after the text layer, any inline UI elements are placed as if they were separate layers.
</listItem>
<listItem>Caret layer: renders a blinking caret</listItem></list>
It's also possible to insert new layers into the TextView using the It's also possible to insert new layers into the TextView using the
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.TextView.InsertLayer(System.Windows.UIElement,ICSharpCode.AvalonEdit.Rendering.KnownLayer,ICSharpCode.AvalonEdit.Rendering.LayerInsertionPosition)</codeEntityReference> <codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.TextView.InsertLayer(System.Windows.UIElement,ICSharpCode.AvalonEdit.Rendering.KnownLayer,ICSharpCode.AvalonEdit.Rendering.LayerInsertionPosition)</codeEntityReference>
method. method.

5
AvalonEdit/ICSharpCode.AvalonEdit.Tests/Highlighting/HtmlClipboardTests.cs

@ -25,10 +25,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{ {
var segment = new TextSegment { StartOffset = 0, Length = document.TextLength }; var segment = new TextSegment { StartOffset = 0, Length = document.TextLength };
string html = HtmlClipboard.CreateHtmlFragment(document, highlighter, segment, new HtmlOptions()); string html = HtmlClipboard.CreateHtmlFragment(document, highlighter, segment, new HtmlOptions());
Assert.AreEqual("<span style=\"color: #008000; font-weight: bold; \">using</span>&nbsp;" + Assert.AreEqual("<span style=\"color: #008000; font-weight: bold; \">using</span>&nbsp;System.Text;<br>" + Environment.NewLine +
"System<span style=\"color: #006400; \">.</span>Text<span style=\"color: #006400; \">;</span><br>" + Environment.NewLine +
"&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #ff0000; \">string</span>&nbsp;" + "&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #ff0000; \">string</span>&nbsp;" +
"text =&nbsp;<span style=\"color: #191970; font-weight: bold; \">SomeMethod</span><span style=\"color: #006400; \">();</span>", html); "text =&nbsp;<span style=\"color: #191970; font-weight: bold; \">SomeMethod</span>();", html);
} }
[Test] [Test]

21
AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.cs

@ -3,6 +3,7 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
@ -28,6 +29,12 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
{ {
this.CloseAutomatically = true; this.CloseAutomatically = true;
AttachEvents(); AttachEvents();
Rect caret = this.TextArea.Caret.CalculateCaretRectangle();
Rect workingArea = System.Windows.Forms.Screen.FromPoint(caret.Location.ToSystemDrawing()).WorkingArea.ToWpf();
MaxHeight = workingArea.Height;
MaxWidth = Math.Min(workingArea.Width, Math.Max(1000, workingArea.Width * 0.6));
} }
/// <summary> /// <summary>
@ -63,4 +70,18 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
} }
} }
} }
/// <summary>
/// TemplateSelector for InsightWindow to replace plain string content by a TextBlock with TextWrapping.
/// </summary>
internal sealed class InsightWindowTemplateSelector : DataTemplateSelector
{
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is string)
return (DataTemplate)((FrameworkElement)container).FindResource("TextBlockTemplate");
return null;
}
}
} }

14
AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.xaml

@ -2,6 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:ICSharpCode.AvalonEdit.CodeCompletion" xmlns:cc="clr-namespace:ICSharpCode.AvalonEdit.CodeCompletion"
> >
<cc:InsightWindowTemplateSelector x:Key="templateSelector" />
<!-- Template for InsightWindow. Based on the template for ToolTip. --> <!-- Template for InsightWindow. Based on the template for ToolTip. -->
<Style TargetType="{x:Type cc:InsightWindow}"> <Style TargetType="{x:Type cc:InsightWindow}">
<Setter Property="SizeToContent" Value="WidthAndHeight" /> <Setter Property="SizeToContent" Value="WidthAndHeight" />
@ -76,6 +78,10 @@
</Setter> </Setter>
</Style.Setters> </Style.Setters>
</Style> </Style>
<DataTemplate x:Key="TextBlockTemplate">
<TextBlock TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />
</DataTemplate>
</Grid.Resources> </Grid.Resources>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -100,10 +106,10 @@
<Path Stroke="Black" Fill="Black" Data="M 0,0 L 1,0 L 0.5,0.866 Z" Stretch="UniformToFill" /> <Path Stroke="Black" Fill="Black" Data="M 0,0 L 1,0 L 0.5,0.866 Z" Stretch="UniformToFill" />
</Button> </Button>
</StackPanel> </StackPanel>
<ContentControl Grid.Row="0" Grid.Column="1" <ContentPresenter Grid.Row="0" Grid.Column="1" ContentTemplateSelector="{StaticResource templateSelector}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentHeader}"/> Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentHeader}" />
<ContentControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" <ContentPresenter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ContentTemplateSelector="{StaticResource templateSelector}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentContent}"/> Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentContent}" />
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>

2
AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.AvalonEdit.Document
public int Offset { get; private set; } public int Offset { get; private set; }
/// <summary> /// <summary>
/// The text that was inserted. /// The text that was removed.
/// </summary> /// </summary>
public string RemovedText { get; private set; } public string RemovedText { get; private set; }

1
AvalonEdit/ICSharpCode.AvalonEdit/Document/ISegment.cs

@ -127,7 +127,6 @@ namespace ICSharpCode.AvalonEdit.Document
return !left.Equals(right); return !left.Equals(right);
} }
/// <inheritdoc/>
public override string ToString() public override string ToString()
{ {
return "[Offset=" + Offset.ToString(CultureInfo.InvariantCulture) + ", Length=" + Length.ToString(CultureInfo.InvariantCulture) + "]"; return "[Offset=" + Offset.ToString(CultureInfo.InvariantCulture) + ", Length=" + Length.ToString(CultureInfo.InvariantCulture) + "]";

21
AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -51,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.Editing
AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(EditingCommands.SelectRightByCharacter)); AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(EditingCommands.SelectRightByCharacter));
AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(EditingCommands.SelectRightByWord)); AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(EditingCommands.SelectRightByWord));
AddBinding(EditingCommands.Backspace, ModifierKeys.None, Key.Back, OnDelete(EditingCommands.SelectLeftByCharacter)); AddBinding(EditingCommands.Backspace, ModifierKeys.None, Key.Back, OnDelete(EditingCommands.SelectLeftByCharacter));
InputBindings.Add(new KeyBinding(EditingCommands.Backspace, Key.Back, ModifierKeys.Shift)); // make Shift-Backspace do the same as plain backspace InputBindings.Add(TextAreaDefaultInputHandler.CreateFrozenKeyBinding(EditingCommands.Backspace, ModifierKeys.Shift, Key.Back)); // make Shift-Backspace do the same as plain backspace
AddBinding(EditingCommands.DeletePreviousWord, ModifierKeys.Control, Key.Back, OnDelete(EditingCommands.SelectLeftByWord)); AddBinding(EditingCommands.DeletePreviousWord, ModifierKeys.Control, Key.Back, OnDelete(EditingCommands.SelectLeftByWord));
AddBinding(EditingCommands.EnterParagraphBreak, ModifierKeys.None, Key.Enter, OnEnter); AddBinding(EditingCommands.EnterParagraphBreak, ModifierKeys.None, Key.Enter, OnEnter);
AddBinding(EditingCommands.EnterLineBreak, ModifierKeys.Shift, Key.Enter, OnEnter); AddBinding(EditingCommands.EnterLineBreak, ModifierKeys.Shift, Key.Enter, OnEnter);
@ -365,6 +365,8 @@ namespace ICSharpCode.AvalonEdit.Editing
if (textArea != null && textArea.Document != null) { if (textArea != null && textArea.Document != null) {
args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset) args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)
&& Clipboard.ContainsText(); && Clipboard.ContainsText();
// WPF Clipboard.ContainsText() is safe to call without catching ExternalExceptions
// because it doesn't try to lock the clipboard - it just peeks inside with IsClipboardFormatAvailable().
args.Handled = true; args.Handled = true;
} }
} }
@ -373,15 +375,24 @@ namespace ICSharpCode.AvalonEdit.Editing
{ {
TextArea textArea = GetTextArea(target); TextArea textArea = GetTextArea(target);
if (textArea != null && textArea.Document != null) { if (textArea != null && textArea.Document != null) {
Debug.WriteLine( Clipboard.GetText(TextDataFormat.Html) ); IDataObject dataObject;
try {
dataObject = Clipboard.GetDataObject();
} catch (ExternalException) {
return;
}
if (dataObject == null)
return;
Debug.WriteLine( dataObject.GetData(DataFormats.Html) as string );
// convert text back to correct newlines for this document // convert text back to correct newlines for this document
string newLine = TextUtilities.GetNewLineFromDocument(textArea.Document, textArea.Caret.Line); string newLine = TextUtilities.GetNewLineFromDocument(textArea.Document, textArea.Caret.Line);
string text = TextUtilities.NormalizeNewLines(Clipboard.GetText(), newLine); string text = (string)dataObject.GetData(DataFormats.UnicodeText);
text = TextUtilities.NormalizeNewLines(text, newLine);
if (!string.IsNullOrEmpty(text)) { if (!string.IsNullOrEmpty(text)) {
bool fullLine = textArea.Options.CutCopyWholeLine && Clipboard.ContainsData(LineSelectedType); bool fullLine = textArea.Options.CutCopyWholeLine && dataObject.GetDataPresent(LineSelectedType);
bool rectangular = Clipboard.ContainsData(RectangleSelection.RectangularSelectionDataType); bool rectangular = dataObject.GetDataPresent(RectangleSelection.RectangularSelectionDataType);
if (fullLine) { if (fullLine) {
DocumentLine currentLine = textArea.Document.GetLineByNumber(textArea.Caret.Line); DocumentLine currentLine = textArea.Document.GetLineByNumber(textArea.Caret.Line);
if (textArea.ReadOnlySectionProvider.CanInsert(currentLine.Offset)) { if (textArea.ReadOnlySectionProvider.CanInsert(currentLine.Offset)) {

2
AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs

@ -327,6 +327,7 @@ namespace ICSharpCode.AvalonEdit.Folding
margin = new FoldingMargin() { FoldingManager = this }; margin = new FoldingMargin() { FoldingManager = this };
generator = new FoldingElementGenerator() { FoldingManager = this }; generator = new FoldingElementGenerator() { FoldingManager = this };
textArea.LeftMargins.Add(margin); textArea.LeftMargins.Add(margin);
textArea.TextView.Services.AddService(typeof(FoldingManager), this);
// HACK: folding only works correctly when it has highest priority // HACK: folding only works correctly when it has highest priority
textArea.TextView.ElementGenerators.Insert(0, generator); textArea.TextView.ElementGenerators.Insert(0, generator);
textArea.Caret.PositionChanged += textArea_Caret_PositionChanged; textArea.Caret.PositionChanged += textArea_Caret_PositionChanged;
@ -363,6 +364,7 @@ namespace ICSharpCode.AvalonEdit.Folding
textArea.Caret.PositionChanged -= textArea_Caret_PositionChanged; textArea.Caret.PositionChanged -= textArea_Caret_PositionChanged;
textArea.LeftMargins.Remove(margin); textArea.LeftMargins.Remove(margin);
textArea.TextView.ElementGenerators.Remove(generator); textArea.TextView.ElementGenerators.Remove(generator);
textArea.TextView.Services.RemoveService(typeof(FoldingManager));
margin = null; margin = null;
generator = null; generator = null;
textArea = null; textArea = null;

67
AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Text;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
@ -71,6 +72,72 @@ namespace ICSharpCode.AvalonEdit.Folding
} }
} }
/// <summary>
/// Gets the content of the collapsed lines as text.
/// </summary>
public string TextContent {
get {
return manager.document.GetText(StartOffset, EndOffset - StartOffset);
}
}
/// <summary>
/// Gets the content of the collapsed lines as tooltip text.
/// </summary>
public string TooltipText {
get {
// This fixes SD-1394:
// Each line is checked for leading indentation whitespaces. If
// a line has the same or more indentation than the first line,
// it is reduced. If a line is less indented than the first line
// the indentation is removed completely.
//
// See the following example:
// line 1
// line 2
// line 3
// line 4
//
// is reduced to:
// line 1
// line 2
// line 3
// line 4
var startLine = manager.document.GetLineByOffset(StartOffset);
var endLine = manager.document.GetLineByOffset(EndOffset);
var builder = new StringBuilder();
var current = startLine;
ISegment startIndent = TextUtilities.GetLeadingWhitespace(manager.document, startLine);
while (current != endLine.NextLine) {
ISegment currentIndent = TextUtilities.GetLeadingWhitespace(manager.document, current);
if (current == startLine && current == endLine)
builder.Append(manager.document.GetText(StartOffset, EndOffset - StartOffset));
else if (current == startLine) {
if (current.EndOffset - StartOffset > 0)
builder.AppendLine(manager.document.GetText(StartOffset, current.EndOffset - StartOffset).TrimStart());
} else if (current == endLine) {
if (startIndent.Length <= currentIndent.Length)
builder.Append(manager.document.GetText(current.Offset + startIndent.Length, EndOffset - current.Offset - startIndent.Length));
else
builder.Append(manager.document.GetText(current.Offset + currentIndent.Length, EndOffset - current.Offset - currentIndent.Length));
} else {
if (startIndent.Length <= currentIndent.Length)
builder.AppendLine(manager.document.GetText(current.Offset + startIndent.Length, current.Length - startIndent.Length));
else
builder.AppendLine(manager.document.GetText(current.Offset + currentIndent.Length, current.Length - currentIndent.Length));
}
current = current.NextLine;
}
return builder.ToString();
}
}
/// <summary> /// <summary>
/// Gets/Sets an additional object associated with this folding section. /// Gets/Sets an additional object associated with this folding section.
/// </summary> /// </summary>

6
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedInlineBuilder.cs

@ -84,6 +84,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{ {
if (color == null) if (color == null)
throw new ArgumentNullException("color"); throw new ArgumentNullException("color");
if (color.Foreground == null && color.FontStyle == null && color.FontWeight == null) {
// Optimization: don't split the HighlightingState when we're not changing
// any property. For example, the "Punctuation" color in C# is
// empty by default.
return;
}
int startIndex = GetIndexForOffset(offset); int startIndex = GetIndexForOffset(offset);
int endIndex = GetIndexForOffset(offset + length); int endIndex = GetIndexForOffset(offset + length);
for (int i = startIndex; i < endIndex; i++) { for (int i = startIndex; i < endIndex; i++) {

14
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs

@ -127,12 +127,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
HtmlClipboard.EscapeHtml(w, document.GetText(textOffset, newOffset - textOffset), options); HtmlClipboard.EscapeHtml(w, document.GetText(textOffset, newOffset - textOffset), options);
} }
textOffset = Math.Max(textOffset, newOffset); textOffset = Math.Max(textOffset, newOffset);
if (e.IsEnd) { if (options.ColorNeedsSpanForStyling(e.Color)) {
w.Write("</span>"); if (e.IsEnd) {
} else { w.Write("</span>");
w.Write("<span"); } else {
options.WriteStyleAttributeForColor(w, e.Color); w.Write("<span");
w.Write('>'); options.WriteStyleAttributeForColor(w, e.Color);
w.Write('>');
}
} }
} }
HtmlClipboard.EscapeHtml(w, document.GetText(textOffset, endOffset - textOffset), options); HtmlClipboard.EscapeHtml(w, document.GetText(textOffset, endOffset - textOffset), options);

14
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs

@ -137,6 +137,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
HighlightedLine hl = highlighter.HighlightLine(lineNumberBeingColorized); HighlightedLine hl = highlighter.HighlightLine(lineNumberBeingColorized);
lineNumberBeingColorized = 0; lineNumberBeingColorized = 0;
foreach (HighlightedSection section in hl.Sections) { foreach (HighlightedSection section in hl.Sections) {
if (IsEmptyColor(section.Color))
continue;
ChangeLinePart(section.Offset, section.Offset + section.Length, ChangeLinePart(section.Offset, section.Offset + section.Length,
visualLineElement => ApplyColorToElement(visualLineElement, section.Color)); visualLineElement => ApplyColorToElement(visualLineElement, section.Color));
} }
@ -144,6 +146,18 @@ namespace ICSharpCode.AvalonEdit.Highlighting
this.lastColorizedLine = line; this.lastColorizedLine = line;
} }
/// <summary>
/// Gets whether the color is empty (has no effect on a VisualLineTextElement).
/// For example, the C# "Punctuation" is an empty color.
/// </summary>
bool IsEmptyColor(HighlightingColor color)
{
if (color == null)
return true;
return color.Background == null && color.Foreground == null
&& color.FontStyle == null && color.FontWeight == null;
}
/// <summary> /// <summary>
/// Applies a highlighting color to a visual line element. /// Applies a highlighting color to a visual line element.
/// </summary> /// </summary>

10
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlClipboard.cs

@ -187,5 +187,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting
writer.Write(color.ToCss()); writer.Write(color.ToCss());
writer.Write("\""); writer.Write("\"");
} }
/// <summary>
/// Gets whether the color needs to be written out to HTML.
/// </summary>
public virtual bool ColorNeedsSpanForStyling(HighlightingColor color)
{
if (color == null)
throw new ArgumentNullException("color");
return !string.IsNullOrEmpty(color.ToCss());
}
} }
} }

2
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- converted to AvalonEdit format by Siegfried Pammer in 2010 --> <!-- converted to AvalonEdit format by Siegfried Pammer in 2010 -->
<SyntaxDefinition name="ASP/XHTML" extensions=".asp;.aspx;.asax;.asmx" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> <SyntaxDefinition name="ASP/XHTML" extensions=".asp;.aspx;.asax;.asmx;.ascx;.master" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="ASPSectionStartEndTags" foreground="Black" background="Yellow" exampleText="&lt;% System.Console.WriteLine(&quot;Hello World!&quot;); %&gt;" /> <Color name="ASPSectionStartEndTags" foreground="Black" background="Yellow" exampleText="&lt;% System.Console.WriteLine(&quot;Hello World!&quot;); %&gt;" />
<Color name="ASPSection" foreground="Black" background="#FFF7F2E3" exampleText="&lt;% System.Console.WriteLine(&quot;Hello World!&quot;); %&gt;" /> <Color name="ASPSection" foreground="Black" background="#FFF7F2E3" exampleText="&lt;% System.Console.WriteLine(&quot;Hello World!&quot;); %&gt;" />
<RuleSet ignoreCase="true"> <RuleSet ignoreCase="true">

57
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSS-Mode.xshd

@ -0,0 +1,57 @@
<SyntaxDefinition name="CSS" extensions=".css" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="Gray" />
<Color name="String" foreground="Green" />
<Color name="Selector" foreground="DarkBlue" fontWeight="bold" />
<Color name="Class" foreground="DarkMagenta" />
<Color name="Property" foreground="Red"/>
<Color name="Value" foreground="Blue" />
<Color name="Default" foreground="Pink" />
<Color name="CurlyBraces" foreground="Black" />
<Color name="Colon" foreground="Black" />
<RuleSet ignoreCase="true">
<Span color="Comment" multiline="true">
<Begin>/\*</Begin>
<End>\*/</End>
</Span>
<Span
color="Property"
multiline="true"
ruleSet="CSSBlock">
<Begin color="CurlyBraces">\{</Begin>
<End color="CurlyBraces">\}</End>
</Span>
<Span color="Class">
<Begin>\#</Begin>
<End>\s</End>
</Span>
<Rule color="Selector">[\d\w]</Rule>
</RuleSet>
<RuleSet name="CSSBlock">
<Span color="Comment" multiline="true">
<Begin>/\*</Begin>
<End>\*/</End>
</Span>
<Span color="Value" multiline="true">
<Begin color="Colon">\:</Begin>
<End color="CurlyBraces">\;|(?=\})</End>
<RuleSet>
<Span color="String" multiline="true">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<Span begin="\\" end="." />
</RuleSet>
</Span>
<Span color="String" multiline="true">
<Begin>'</Begin>
<End>'</End>
<RuleSet>
<Span begin="\\" end="." />
</RuleSet>
</Span>
</RuleSet>
</Span>
</RuleSet>
</SyntaxDefinition>

31
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CSharp-Mode.xshd

@ -5,7 +5,7 @@
<Color name="String" foreground="Blue" exampleText="string text = &quot;Hello, World!&quot;"/> <Color name="String" foreground="Blue" exampleText="string text = &quot;Hello, World!&quot;"/>
<Color name="Char" foreground="Magenta" exampleText="char linefeed = '\n';"/> <Color name="Char" foreground="Magenta" exampleText="char linefeed = '\n';"/>
<Color name="Preprocessor" foreground="Green" exampleText="#region Title" /> <Color name="Preprocessor" foreground="Green" exampleText="#region Title" />
<Color name="Punctuation" foreground="DarkGreen" exampleText="a(b.c);" /> <Color name="Punctuation" exampleText="a(b.c);" />
<Color name="ValueTypes" fontWeight="bold" foreground="Red" exampleText="bool b = true;" /> <Color name="ValueTypes" fontWeight="bold" foreground="Red" exampleText="bool b = true;" />
<Color name="ReferenceTypes" foreground="Red" exampleText="object o;" /> <Color name="ReferenceTypes" foreground="Red" exampleText="object o;" />
<Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.ToString();"/> <Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.ToString();"/>
@ -43,20 +43,21 @@
<Span color="Preprocessor"> <Span color="Preprocessor">
<Begin>\#</Begin> <Begin>\#</Begin>
<RuleSet name="PreprocessorSet"> <RuleSet name="PreprocessorSet">
<Keywords fontWeight="bold"> <Span> <!-- preprocessor directives that allow comments -->
<Word>if</Word> <Begin fontWeight="bold">
<Word>else</Word> (define|undef|if|elif|else|endif|line)\b
<Word>elif</Word> </Begin>
<Word>endif</Word> <RuleSet>
<Word>define</Word> <Span color="Comment" ruleSet="CommentMarkerSet">
<Word>undef</Word> <Begin>//</Begin>
<Word>warning</Word> </Span>
<Word>error</Word> </RuleSet>
<Word>line</Word> </Span>
<Word>region</Word> <Span> <!-- preprocessor directives that don't allow comments -->
<Word>endregion</Word> <Begin fontWeight="bold">
<Word>pragma</Word> (region|endregion|error|warning|pragma)\b
</Keywords> </Begin>
</Span>
</RuleSet> </RuleSet>
</Span> </Span>

40
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/HTML-Mode.xshd

@ -4,11 +4,11 @@
<SyntaxDefinition name="HTML" extensions=".htm;.html" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> <SyntaxDefinition name="HTML" extensions=".htm;.html" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="DarkSlateGray" /> <Color name="Comment" foreground="DarkSlateGray" />
<Color name="Digits" foreground="DarkBlue" /> <Color name="Digits" foreground="DarkBlue" />
<Color name="ScriptTag" foreground="#FF00FF7F" /> <Color name="ScriptTag" foreground="#FF8B008B" />
<Color name="JavaScriptTag" foreground="#FF00FF7F" /> <Color name="JavaScriptTag" foreground="#FF8B008B" />
<Color name="JScriptTag" foreground="#FF00FF7F" /> <Color name="JScriptTag" foreground="#FF8B008B" />
<Color name="VBScriptTag" foreground="#FF00FF7F" /> <Color name="VBScriptTag" foreground="#FF8B008B" />
<Color name="UnknownScriptTag" foreground="#FF00FF7F" /> <Color name="UnknownScriptTag" foreground="#FF8B008B" />
<Color name="HtmlTag" foreground="#FF8B008B" /> <Color name="HtmlTag" foreground="#FF8B008B" />
<Color name="Tags" foreground="#FF8B008B" /> <Color name="Tags" foreground="#FF8B008B" />
<Color name="Attributes" foreground="Red" /> <Color name="Attributes" foreground="Red" />
@ -23,25 +23,25 @@
<Begin>&lt;!--</Begin> <Begin>&lt;!--</Begin>
<End>--&gt;</End> <End>--&gt;</End>
</Span> </Span>
<Span color="ScriptTag" ruleSet="JavaScriptSet" multiline="true"> <Span ruleSet="JavaScriptSet" multiline="true">
<Begin>&lt;script&gt;</Begin> <Begin color="ScriptTag">&lt;script&gt;</Begin>
<End>&lt;/script&gt;</End> <End color="ScriptTag">&lt;/script&gt;</End>
</Span> </Span>
<Span color="JavaScriptTag" ruleSet="JavaScriptSet" multiline="true"> <Span ruleSet="JavaScriptSet" multiline="true">
<Begin>&lt;script\ lang="JavaScript"&gt;</Begin> <Begin color="JavaScriptTag">&lt;script\ lang="JavaScript"&gt;</Begin>
<End>&lt;/script&gt;</End> <End color="JavaScriptTag">&lt;/script&gt;</End>
</Span> </Span>
<Span color="JScriptTag" multiline="true"> <Span multiline="true">
<Begin>&lt;script\ lang="JScript"&gt;</Begin> <Begin color="JScriptTag">&lt;script\ lang="JScript"&gt;</Begin>
<End>&lt;/script&gt;</End> <End color="JScriptTag">&lt;/script&gt;</End>
</Span> </Span>
<Span color="VBScriptTag" multiline="true"> <Span multiline="true">
<Begin>&lt;script\ lang="VBScript"&gt;</Begin> <Begin color="VBScriptTag">&lt;script\ lang="VBScript"&gt;</Begin>
<End>&lt;/script&gt;</End> <End color="VBScriptTag">&lt;/script&gt;</End>
</Span> </Span>
<Span color="UnknownScriptTag" multiline="true"> <Span multiline="true">
<Begin>&lt;script[^\w\d_]</Begin> <Begin color="UnknownScriptTag">&lt;script[^\w\d_]</Begin>
<End>&lt;/script&gt;</End> <End color="UnknownScriptTag">&lt;/script&gt;</End>
</Span> </Span>
<Span color="HtmlTag" ruleSet="HtmlTagSet" multiline="true"> <Span color="HtmlTag" ruleSet="HtmlTagSet" multiline="true">
<Begin>&lt;</Begin> <Begin>&lt;</Begin>

3
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs

@ -25,10 +25,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
hlm.RegisterHighlighting("JavaScript", new[] { ".js" }, "JavaScript-Mode.xshd"); hlm.RegisterHighlighting("JavaScript", new[] { ".js" }, "JavaScript-Mode.xshd");
hlm.RegisterHighlighting("HTML", new[] { ".htm", ".html" }, "HTML-Mode.xshd"); hlm.RegisterHighlighting("HTML", new[] { ".htm", ".html" }, "HTML-Mode.xshd");
hlm.RegisterHighlighting("ASP/XHTML", new[] { ".asp", ".aspx", ".asax", ".asmx" }, "ASPX.xshd"); hlm.RegisterHighlighting("ASP/XHTML", new[] { ".asp", ".aspx", ".asax", ".asmx", ".ascx", ".master" }, "ASPX.xshd");
hlm.RegisterHighlighting("Boo", new[] { ".boo" }, "Boo.xshd"); hlm.RegisterHighlighting("Boo", new[] { ".boo" }, "Boo.xshd");
hlm.RegisterHighlighting("Coco", new[] { ".atg" }, "Coco-Mode.xshd"); hlm.RegisterHighlighting("Coco", new[] { ".atg" }, "Coco-Mode.xshd");
hlm.RegisterHighlighting("CSS", new[] { ".css" }, "CSS-Mode.xshd");
hlm.RegisterHighlighting("C++", new[] { ".c", ".h", ".cc", ".cpp" , ".hpp" }, "CPP-Mode.xshd"); hlm.RegisterHighlighting("C++", new[] { ".c", ".h", ".cc", ".cpp" , ".hpp" }, "CPP-Mode.xshd");
hlm.RegisterHighlighting("Java", new[] { ".java" }, "Java-Mode.xshd"); hlm.RegisterHighlighting("Java", new[] { ".java" }, "Java-Mode.xshd");
hlm.RegisterHighlighting("Patch", new[] { ".patch", ".diff" }, "Patch-Mode.xshd"); hlm.RegisterHighlighting("Patch", new[] { ".patch", ".diff" }, "Patch-Mode.xshd");

3
AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -407,4 +407,7 @@
<Page Include="TextEditor.xaml" /> <Page Include="TextEditor.xaml" />
<Page Include="themes\generic.xaml" /> <Page Include="themes\generic.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Highlighting\Resources\CSS-Mode.xshd" />
</ItemGroup>
</Project> </Project>

8
AvalonEdit/ICSharpCode.AvalonEdit/Properties/GlobalAssemblyInfo.cs

@ -18,7 +18,7 @@ using System.Reflection;
[assembly: AssemblyProduct("SharpDevelop")] [assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2011 AlphaSierraPapa for the SharpDevelop Team")] [assembly: AssemblyCopyright("2000-2011 AlphaSierraPapa for the SharpDevelop Team")]
[assembly: AssemblyVersion(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision)] [assembly: AssemblyVersion(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision)]
[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-3301c6c4")] [assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-ae3458d9")]
[assembly: NeutralResourcesLanguage("en-US")] [assembly: NeutralResourcesLanguage("en-US")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly", [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
@ -29,8 +29,8 @@ internal static class RevisionClass
public const string Major = "4"; public const string Major = "4";
public const string Minor = "1"; public const string Minor = "1";
public const string Build = "0"; public const string Build = "0";
public const string Revision = "7411"; public const string Revision = "7920";
public const string VersionName = "alpha"; public const string VersionName = null;
public const string FullVersion = Major + "." + Minor + "." + Build + ".7411-alpha"; public const string FullVersion = Major + "." + Minor + "." + Build + ".7920";
} }

1
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs

@ -126,7 +126,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
{ {
} }
/// <inheritdoc/>
protected override Uri GetUriFromMatch(Match match) protected override Uri GetUriFromMatch(Match match)
{ {
return new Uri("mailto:" + match.Value); return new Uri("mailto:" + match.Value);

2
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/NewLineElementGenerator.cs

@ -26,7 +26,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
{ {
} }
/// <inheritdoc/>
public override int GetFirstInterestedOffset(int startOffset) public override int GetFirstInterestedOffset(int startOffset)
{ {
DocumentLine lastDocumentLine = CurrentContext.VisualLine.LastDocumentLine; DocumentLine lastDocumentLine = CurrentContext.VisualLine.LastDocumentLine;
@ -36,7 +35,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
return -1; return -1;
} }
/// <inheritdoc/>
public override VisualLineElement ConstructElement(int offset) public override VisualLineElement ConstructElement(int offset)
{ {
string newlineText; string newlineText;

18
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs

@ -56,7 +56,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
this.ShowBoxForControlCharacters = options.ShowBoxForControlCharacters; this.ShowBoxForControlCharacters = options.ShowBoxForControlCharacters;
} }
/// <inheritdoc/>
public override int GetFirstInterestedOffset(int startOffset) public override int GetFirstInterestedOffset(int startOffset)
{ {
DocumentLine endLine = CurrentContext.VisualLine.LastDocumentLine; DocumentLine endLine = CurrentContext.VisualLine.LastDocumentLine;
@ -83,7 +82,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
return -1; return -1;
} }
/// <inheritdoc/>
public override VisualLineElement ConstructElement(int offset) public override VisualLineElement ConstructElement(int offset)
{ {
char c = CurrentContext.Document.GetCharAt(offset); char c = CurrentContext.Document.GetCharAt(offset);
@ -230,6 +228,14 @@ namespace ICSharpCode.AvalonEdit.Rendering
sealed class SpecialCharacterTextRun : FormattedTextRun sealed class SpecialCharacterTextRun : FormattedTextRun
{ {
static readonly SolidColorBrush darkGrayBrush;
static SpecialCharacterTextRun()
{
darkGrayBrush = new SolidColorBrush(Color.FromArgb(200, 128, 128, 128));
darkGrayBrush.Freeze();
}
public SpecialCharacterTextRun(FormattedTextElement element, TextRunProperties properties) public SpecialCharacterTextRun(FormattedTextElement element, TextRunProperties properties)
: base(element, properties) : base(element, properties)
{ {
@ -237,10 +243,10 @@ namespace ICSharpCode.AvalonEdit.Rendering
public override void Draw(DrawingContext drawingContext, Point origin, bool rightToLeft, bool sideways) public override void Draw(DrawingContext drawingContext, Point origin, bool rightToLeft, bool sideways)
{ {
Point newOrigin = new Point(origin.X + 1, origin.Y); Point newOrigin = new Point(origin.X + 1.5, origin.Y);
var metrics = Format(double.PositiveInfinity); var metrics = base.Format(double.PositiveInfinity);
Rect r = new Rect(newOrigin.X + 1, newOrigin.Y - metrics.Baseline, metrics.Width + 1, metrics.Height); Rect r = new Rect(newOrigin.X - 0.5, newOrigin.Y - metrics.Baseline, metrics.Width + 2, metrics.Height);
drawingContext.DrawRoundedRectangle(Brushes.DarkGray, null, r, 2.5, 2.5); drawingContext.DrawRoundedRectangle(darkGrayBrush, null, r, 2.5, 2.5);
base.Draw(drawingContext, newOrigin, rightToLeft, sideways); base.Draw(drawingContext, newOrigin, rightToLeft, sideways);
} }

34
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextLayer.cs

@ -33,10 +33,38 @@ namespace ICSharpCode.AvalonEdit.Rendering
{ {
} }
protected override void OnRender(DrawingContext drawingContext) List<VisualLineDrawingVisual> visuals = new List<VisualLineDrawingVisual>();
internal void SetVisualLines(ICollection<VisualLine> visualLines)
{
foreach (VisualLineDrawingVisual v in visuals) {
if (v.VisualLine.IsDisposed)
RemoveVisualChild(v);
}
visuals.Clear();
foreach (VisualLine newLine in visualLines) {
VisualLineDrawingVisual v = newLine.Render();
if (!v.IsAdded) {
AddVisualChild(v);
v.IsAdded = true;
}
visuals.Add(v);
}
InvalidateArrange();
}
protected override int VisualChildrenCount {
get { return visuals.Count; }
}
protected override Visual GetVisualChild(int index)
{
return visuals[index];
}
protected override void ArrangeCore(Rect finalRect)
{ {
base.OnRender(drawingContext); textView.ArrangeTextLayer(visuals);
textView.RenderTextLayer(drawingContext);
} }
} }
} }

15
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -833,7 +833,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
MeasureInlineObjects(); MeasureInlineObjects();
InvalidateVisual(); // = InvalidateArrange+InvalidateRender InvalidateVisual(); // = InvalidateArrange+InvalidateRender
textLayer.InvalidateVisual();
double maxWidth; double maxWidth;
if (document == null) { if (document == null) {
@ -862,6 +861,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
} }
} }
textLayer.SetVisualLines(visibleVisualLines);
SetScrollData(availableSize, SetScrollData(availableSize,
new Size(maxWidth, heightTreeHeight), new Size(maxWidth, heightTreeHeight),
scrollOffset); scrollOffset);
@ -1153,14 +1154,16 @@ namespace ICSharpCode.AvalonEdit.Rendering
} }
} }
internal void RenderTextLayer(DrawingContext drawingContext) internal void ArrangeTextLayer(IList<VisualLineDrawingVisual> visuals)
{ {
Point pos = new Point(-scrollOffset.X, -clippedPixelsOnTop); Point pos = new Point(-scrollOffset.X, -clippedPixelsOnTop);
foreach (VisualLine visualLine in allVisualLines) { foreach (VisualLineDrawingVisual visual in visuals) {
foreach (TextLine textLine in visualLine.TextLines) { TranslateTransform t = visual.Transform as TranslateTransform;
textLine.Draw(drawingContext, pos, InvertAxes.None); if (t == null || t.X != pos.X || t.Y != pos.Y) {
pos.Y += textLine.Height; visual.Transform = new TranslateTransform(pos.X, pos.Y);
visual.Transform.Freeze();
} }
pos.Y += visual.Height;
} }
} }
#endregion #endregion

30
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -1,6 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -424,5 +425,34 @@ namespace ICSharpCode.AvalonEdit.Rendering
{ {
return true; return true;
} }
VisualLineDrawingVisual visual;
internal VisualLineDrawingVisual Render()
{
if (visual == null)
visual = new VisualLineDrawingVisual(this);
return visual;
}
}
sealed class VisualLineDrawingVisual : DrawingVisual
{
public readonly VisualLine VisualLine;
public readonly double Height;
internal bool IsAdded;
public VisualLineDrawingVisual(VisualLine visualLine)
{
this.VisualLine = visualLine;
var drawingContext = RenderOpen();
double pos = 0;
foreach (TextLine textLine in visualLine.TextLines) {
textLine.Draw(drawingContext, new Point(0, pos), InvertAxes.None);
pos += textLine.Height;
}
this.Height = pos;
drawingContext.Close();
}
} }
} }

29
AvalonEdit/ICSharpCode.AvalonEdit/Utils/CompressingTreeList.cs

@ -343,9 +343,38 @@ namespace ICSharpCode.AvalonEdit.Utils
return -1; return -1;
} }
/// <summary>
/// Gets the the first index so that all values from the result index to <paramref name="index"/>
/// are equal.
/// </summary>
public int GetStartOfRun(int index)
{
if (index < 0 || index >= this.Count)
throw new ArgumentOutOfRangeException("index", index, "Value must be between 0 and " + (this.Count - 1));
int indexInRun = index;
GetNode(ref indexInRun);
return index - indexInRun;
}
/// <summary>
/// Gets the first index after <paramref name="index"/> so that the value at the result index is not
/// equal to the value at <paramref name="index"/>.
/// That is, this method returns the exclusive end index of the run of equal values.
/// </summary>
public int GetEndOfRun(int index)
{
if (index < 0 || index >= this.Count)
throw new ArgumentOutOfRangeException("index", index, "Value must be between 0 and " + (this.Count - 1));
int indexInRun = index;
int runLength = GetNode(ref indexInRun).count;
return index - indexInRun + runLength;
}
/// <summary> /// <summary>
/// Gets the number of elements after <paramref name="index"/> that have the same value as each other. /// Gets the number of elements after <paramref name="index"/> that have the same value as each other.
/// </summary> /// </summary>
[Obsolete("This method may be confusing as it returns only the remaining run length after index. " +
"Use GetStartOfRun/GetEndOfRun instead.")]
public int GetRunLength(int index) public int GetRunLength(int index)
{ {
if (index < 0 || index >= this.Count) if (index < 0 || index >= this.Count)

Loading…
Cancel
Save