Browse Source

Update AvalonEdit to 4.1.0.7920.

pull/205/merge
Daniel Grunwald 14 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 @@ @@ -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>
<!-- The configuration and platform will be used to determine which
assemblies to include from solution and project documentation
@ -7,7 +8,7 @@ @@ -7,7 +8,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<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
Studio adds them anyway -->
<AssemblyName>Documentation</AssemblyName>
@ -30,63 +31,28 @@ @@ -30,63 +31,28 @@
</WorkingPath>
<BuildLogFile>
</BuildLogFile>
<FrameworkVersion>3.5</FrameworkVersion>
<FrameworkVersion>.NET 4.0.30319</FrameworkVersion>
<HelpTitle>AvalonEdit</HelpTitle>
<CopyrightText>Copyright 2008-2010, Daniel Grunwald</CopyrightText>
<CopyrightText>Copyright 2008-2011, Daniel Grunwald</CopyrightText>
<PresentationStyle>Prototype</PresentationStyle>
<HelpFileVersion>4.0.0.0</HelpFileVersion>
<HelpFileVersion>4.1.0.0</HelpFileVersion>
<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">
<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) -->
<basePath value="{@HtmlEncProjectFolder}" />
<!-- Connect to language filter (optional). If omitted,
<basePath value="{@HtmlEncProjectFolder}" />
<!-- Connect to language filter (optional). If omitted,
language filtering is enabled by default. -->
<languageFilter value="true" />
<!-- Allow missing source files (Optional). If omitted,
<languageFilter value="true" />
<!-- Allow missing source files (Optional). If omitted,
it will generate errors if referenced source files
are missing. -->
<allowMissingSource value="false" />
<!-- Remove region markers from imported code blocks. If omitted,
<allowMissingSource value="false" />
<!-- Remove region markers from imported code blocks. If omitted,
region markers in imported code blocks are left alone. -->
<removeRegionMarkers value="false" />
<!-- Code colorizer options (required).
<removeRegionMarkers value="false" />
<!-- Code colorizer options (required).
Attributes:
Language syntax configuration file (required)
XSLT style file (required)
@ -97,48 +63,92 @@ @@ -97,48 +63,92 @@
Keep XML comment "see" tags within the code (optional)
Tab size override (optional, 0 = Use syntax file setting)
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" />
</component>
<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>
</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).
<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 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:
Stylesheet file (required)
Script file (required)
"Copy" image file (required) -->
<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
<colorizer stylesheet="{@SHFBFolder}Colorizer\highlight.css" scriptFile="{@SHFBFolder}Colorizer\highlight.js" copyImage="{@SHFBFolder}Colorizer\CopyCode.gif" />
<!-- Base output paths for the files (required). These should match
the parent folder of the output path of the HTML files (see
SaveComponent). -->
<outputPath value="Output\" />
<!-- Logo image file (optional). Filename is required. The height,
each of the SaveComponent instances below). -->
<outputPaths>
{@HelpFormatOutputPaths}
</outputPaths>
<!-- Logo image file (optional). Filename is required. The height,
width, altText, placement, and alignment attributes are
optional. -->
<logoFile filename="" height="0" width="0" altText="" placement="left" alignment="left" />
</component>
</ComponentConfig>
</ComponentConfigurations>
<logoFile filename="" height="0" width="0" altText="" placement="left" alignment="left" />
</component></ComponentConfig>
<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="{@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>
<DocumentationSource sourceFile="..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj" />
</DocumentationSources>
<NamespaceSummaries>
<NamespaceSummaryItem name="(global)" isDocumented="False" />
<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.Document" isDocumented="True">This namespace contains the document model.
<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.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>
<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.Highlighting" isDocumented="True">This namespace contains the engine for highlighting text documents (DocumentHighlighter).
<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.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>
<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.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="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.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.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.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="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.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>
<SyntaxFilters>Standard</SyntaxFilters>
</PropertyGroup>

13
AvalonEdit/Documentation/Text Rendering.aml

@ -153,9 +153,16 @@ @@ -153,9 +153,16 @@
</para>
<para>
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.
The text layer also serves as container for any inline UI elements.
</listItem><listItem>Caret layer: renders a blinking caret</listItem></list>
<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.
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
<codeEntityReference qualifyHint="true">M:ICSharpCode.AvalonEdit.Rendering.TextView.InsertLayer(System.Windows.UIElement,ICSharpCode.AvalonEdit.Rendering.KnownLayer,ICSharpCode.AvalonEdit.Rendering.LayerInsertionPosition)</codeEntityReference>
method.

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

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

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

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

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

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

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

@ -127,7 +127,6 @@ namespace ICSharpCode.AvalonEdit.Document @@ -127,7 +127,6 @@ namespace ICSharpCode.AvalonEdit.Document
return !left.Equals(right);
}
/// <inheritdoc/>
public override string ToString()
{
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 @@ -51,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.Editing
AddBinding(EditingCommands.Delete, ModifierKeys.None, Key.Delete, OnDelete(EditingCommands.SelectRightByCharacter));
AddBinding(EditingCommands.DeleteNextWord, ModifierKeys.Control, Key.Delete, OnDelete(EditingCommands.SelectRightByWord));
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.EnterParagraphBreak, ModifierKeys.None, Key.Enter, OnEnter);
AddBinding(EditingCommands.EnterLineBreak, ModifierKeys.Shift, Key.Enter, OnEnter);
@ -365,6 +365,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -365,6 +365,8 @@ namespace ICSharpCode.AvalonEdit.Editing
if (textArea != null && textArea.Document != null) {
args.CanExecute = textArea.ReadOnlySectionProvider.CanInsert(textArea.Caret.Offset)
&& 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;
}
}
@ -373,15 +375,24 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -373,15 +375,24 @@ namespace ICSharpCode.AvalonEdit.Editing
{
TextArea textArea = GetTextArea(target);
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
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)) {
bool fullLine = textArea.Options.CutCopyWholeLine && Clipboard.ContainsData(LineSelectedType);
bool rectangular = Clipboard.ContainsData(RectangleSelection.RectangularSelectionDataType);
bool fullLine = textArea.Options.CutCopyWholeLine && dataObject.GetDataPresent(LineSelectedType);
bool rectangular = dataObject.GetDataPresent(RectangleSelection.RectangularSelectionDataType);
if (fullLine) {
DocumentLine currentLine = textArea.Document.GetLineByNumber(textArea.Caret.Line);
if (textArea.ReadOnlySectionProvider.CanInsert(currentLine.Offset)) {

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

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

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

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Text;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
@ -71,6 +72,72 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -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>
/// Gets/Sets an additional object associated with this folding section.
/// </summary>

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

@ -84,6 +84,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -84,6 +84,12 @@ namespace ICSharpCode.AvalonEdit.Highlighting
{
if (color == null)
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 endIndex = GetIndexForOffset(offset + length);
for (int i = startIndex; i < endIndex; i++) {

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

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

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

@ -137,6 +137,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -137,6 +137,8 @@ namespace ICSharpCode.AvalonEdit.Highlighting
HighlightedLine hl = highlighter.HighlightLine(lineNumberBeingColorized);
lineNumberBeingColorized = 0;
foreach (HighlightedSection section in hl.Sections) {
if (IsEmptyColor(section.Color))
continue;
ChangeLinePart(section.Offset, section.Offset + section.Length,
visualLineElement => ApplyColorToElement(visualLineElement, section.Color));
}
@ -144,6 +146,18 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -144,6 +146,18 @@ namespace ICSharpCode.AvalonEdit.Highlighting
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>
/// Applies a highlighting color to a visual line element.
/// </summary>

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

@ -187,5 +187,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -187,5 +187,15 @@ namespace ICSharpCode.AvalonEdit.Highlighting
writer.Write(color.ToCss());
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 @@ @@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!-- 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="ASPSection" foreground="Black" background="#FFF7F2E3" exampleText="&lt;% System.Console.WriteLine(&quot;Hello World!&quot;); %&gt;" />
<RuleSet ignoreCase="true">

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

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

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

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

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

@ -25,10 +25,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -25,10 +25,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
hlm.RegisterHighlighting("JavaScript", new[] { ".js" }, "JavaScript-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("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("Java", new[] { ".java" }, "Java-Mode.xshd");
hlm.RegisterHighlighting("Patch", new[] { ".patch", ".diff" }, "Patch-Mode.xshd");

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

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

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

@ -18,7 +18,7 @@ using System.Reflection; @@ -18,7 +18,7 @@ using System.Reflection;
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2011 AlphaSierraPapa for the SharpDevelop Team")]
[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: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
@ -29,8 +29,8 @@ internal static class RevisionClass @@ -29,8 +29,8 @@ internal static class RevisionClass
public const string Major = "4";
public const string Minor = "1";
public const string Build = "0";
public const string Revision = "7411";
public const string VersionName = "alpha";
public const string Revision = "7920";
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 @@ -126,7 +126,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
{
}
/// <inheritdoc/>
protected override Uri GetUriFromMatch(Match match)
{
return new Uri("mailto:" + match.Value);

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

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

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

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

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

@ -33,10 +33,38 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -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.RenderTextLayer(drawingContext);
textView.ArrangeTextLayer(visuals);
}
}
}

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

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

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

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
// 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)
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Utils;
using System;
using System.Collections.Generic;
@ -424,5 +425,34 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -424,5 +425,34 @@ namespace ICSharpCode.AvalonEdit.Rendering
{
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 @@ -343,9 +343,38 @@ namespace ICSharpCode.AvalonEdit.Utils
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>
/// Gets the number of elements after <paramref name="index"/> that have the same value as each other.
/// </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)
{
if (index < 0 || index >= this.Count)

Loading…
Cancel
Save