Browse Source

Update AvalonEdit to 4.1.0.7411

pull/150/head
Daniel Grunwald 14 years ago
parent
commit
d6c08392c6
  1. 3
      AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs
  2. 25
      AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  3. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocumentWeakEventManager.cs
  4. 5
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
  5. 7
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/LineNumberMargin.cs
  6. 70
      AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs
  7. 6
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs
  8. 24
      AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs
  9. 5
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs
  10. 2
      AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd
  11. 2
      AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  12. 6
      AvalonEdit/ICSharpCode.AvalonEdit/Properties/GlobalAssemblyInfo.cs
  13. 3
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/IBackgroundRenderer.cs
  14. 12
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/ITextRunConstructionContext.cs
  15. 28
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs
  16. 21
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/MouseHoverLogic.cs
  17. 6
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs
  18. 15
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  19. 12
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs
  20. 8
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineText.cs
  21. 15
      AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineTextSource.cs
  22. 4
      AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  23. 58
      AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
  24. 107
      AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs

3
AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs

@ -314,6 +314,9 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion @@ -314,6 +314,9 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
int GetMatchQuality(string itemText, string query)
{
if (itemText == null)
throw new ArgumentNullException("itemText", "ICompletionData.Text returned null");
// Qualities:
// 8 = full match case sensitive
// 7 = full match

25
AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Globalization;
@ -21,7 +22,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -21,7 +22,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <inheritdoc cref="VerifyAccess"/>
/// <para>However, there is a single method that is thread-safe: <see cref="CreateSnapshot()"/> (and its overloads).</para>
/// </remarks>
public sealed class TextDocument : ITextSource
public sealed class TextDocument : ITextSource, INotifyPropertyChanged
{
#region Thread ownership
readonly object lockObject = new object();
@ -207,8 +208,16 @@ namespace ICSharpCode.AvalonEdit.Document @@ -207,8 +208,16 @@ namespace ICSharpCode.AvalonEdit.Document
/// Is raised when the TextLength property changes.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
[Obsolete("This event will be removed in a future version; use the PropertyChanged event instead")]
public event EventHandler TextLengthChanged;
/// <summary>
/// Is raised when one of the properties <see cref="Text"/>, <see cref="TextLength"/>, <see cref="LineCount"/>,
/// <see cref="UndoStack"/> changes.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Is raised before the document changes.
/// </summary>
@ -231,8 +240,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -231,8 +240,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <item><description><b><see cref="EndUpdate">EndUpdate()</see></b></description>
/// <list type="bullet">
/// <item><description><see cref="TextChanged"/> event is raised</description></item>
/// <item><description><see cref="TextLengthChanged"/> event is raised</description></item>
/// <item><description><see cref="LineCountChanged"/> event is raised</description></item>
/// <item><description><see cref="PropertyChanged"/> event is raised (for the Text, TextLength, LineCount properties, in that order)</description></item>
/// <item><description>End of change group (on undo stack)</description></item>
/// <item><description><see cref="UpdateFinished"/> event is raised</description></item>
/// </list></item>
@ -418,21 +426,30 @@ namespace ICSharpCode.AvalonEdit.Document @@ -418,21 +426,30 @@ namespace ICSharpCode.AvalonEdit.Document
fireTextChanged = false;
if (TextChanged != null)
TextChanged(this, EventArgs.Empty);
OnPropertyChanged("Text");
int textLength = rope.Length;
if (textLength != oldTextLength) {
oldTextLength = textLength;
if (TextLengthChanged != null)
TextLengthChanged(this, EventArgs.Empty);
OnPropertyChanged("TextLength");
}
int lineCount = lineTree.LineCount;
if (lineCount != oldLineCount) {
oldLineCount = lineCount;
if (LineCountChanged != null)
LineCountChanged(this, EventArgs.Empty);
OnPropertyChanged("LineCount");
}
}
}
void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
#region Insert / Remove / Replace
@ -743,6 +760,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -743,6 +760,7 @@ namespace ICSharpCode.AvalonEdit.Document
undoStack.ClearAll(); // first clear old undo stack, so that it can't be used to perform unexpected changes on this document
// ClearAll() will also throw an exception when it's not safe to replace the undo stack (e.g. update is currently in progress)
undoStack = value;
OnPropertyChanged("UndoStack");
}
}
}
@ -775,6 +793,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -775,6 +793,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// <summary>
/// Is raised when the LineCount property changes.
/// </summary>
[Obsolete("This event will be removed in a future version; use the PropertyChanged event instead")]
public event EventHandler LineCountChanged;
#endregion

2
AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocumentWeakEventManager.cs

@ -91,6 +91,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -91,6 +91,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// Weak event manager for the <see cref="TextDocument.LineCountChanged"/> event.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
[Obsolete("The TextDocument.LineCountChanged event will be removed in a future version. Use PropertyChangedEventManager instead.")]
public sealed class LineCountChanged : WeakEventManagerBase<LineCountChanged, TextDocument>
{
/// <inheritdoc/>
@ -110,6 +111,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -110,6 +111,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// Weak event manager for the <see cref="TextDocument.TextLengthChanged"/> event.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
[Obsolete("The TextDocument.TextLengthChanged event will be removed in a future version. Use PropertyChangedEventManager instead.")]
public sealed class TextLengthChanged : WeakEventManagerBase<TextLengthChanged, TextDocument>
{
/// <inheritdoc/>

5
AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -300,7 +300,10 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -300,7 +300,10 @@ namespace ICSharpCode.AvalonEdit.Editing
if (textArea.Selection.IsEmpty && textArea.Options.CutCopyWholeLine) {
DocumentLine currentLine = textArea.Document.GetLineByNumber(textArea.Caret.Line);
CopyWholeLine(textArea, currentLine);
textArea.Document.Remove(currentLine.Offset, currentLine.TotalLength);
ISegment[] segmentsToDelete = textArea.GetDeletableSegments(new SimpleSegment(currentLine.Offset, currentLine.TotalLength));
for (int i = segmentsToDelete.Length - 1; i >= 0; i--) {
textArea.Document.Remove(segmentsToDelete[i]);
}
} else {
CopySelectedText(textArea);
textArea.RemoveSelectedText();

7
AvalonEdit/ICSharpCode.AvalonEdit/Editing/LineNumberMargin.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.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
@ -89,11 +90,11 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -89,11 +90,11 @@ namespace ICSharpCode.AvalonEdit.Editing
protected override void OnDocumentChanged(TextDocument oldDocument, TextDocument newDocument)
{
if (oldDocument != null) {
TextDocumentWeakEventManager.LineCountChanged.RemoveListener(oldDocument, this);
PropertyChangedEventManager.RemoveListener(oldDocument, this, "LineCount");
}
base.OnDocumentChanged(oldDocument, newDocument);
if (newDocument != null) {
TextDocumentWeakEventManager.LineCountChanged.AddListener(newDocument, this);
PropertyChangedEventManager.AddListener(newDocument, this, "LineCount");
}
OnDocumentLineCountChanged();
}
@ -101,7 +102,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -101,7 +102,7 @@ namespace ICSharpCode.AvalonEdit.Editing
/// <inheritdoc cref="IWeakEventListener.ReceiveWeakEvent"/>
protected virtual bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
{
if (managerType == typeof(TextDocumentWeakEventManager.LineCountChanged)) {
if (managerType == typeof(PropertyChangedEventManager)) {
OnDocumentLineCountChanged();
return true;
}

70
AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.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.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
@ -56,9 +57,6 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -56,9 +57,6 @@ namespace ICSharpCode.AvalonEdit.Editing
}
#endregion
// TODO: allow disabling text drag'n'drop
const bool AllowTextDragDrop = true;
readonly TextArea textArea;
SelectionMode mode;
@ -83,14 +81,11 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -83,14 +81,11 @@ namespace ICSharpCode.AvalonEdit.Editing
textArea.MouseMove += textArea_MouseMove;
textArea.MouseLeftButtonUp += textArea_MouseLeftButtonUp;
textArea.QueryCursor += textArea_QueryCursor;
if (AllowTextDragDrop) {
textArea.AllowDrop = true;
textArea.GiveFeedback += textArea_GiveFeedback;
textArea.QueryContinueDrag += textArea_QueryContinueDrag;
textArea.DragEnter += textArea_DragEnter;
textArea.DragOver += textArea_DragOver;
textArea.DragLeave += textArea_DragLeave;
textArea.Drop += textArea_Drop;
textArea.OptionChanged += textArea_OptionChanged;
enableTextDragDrop = textArea.Options.EnableTextDragDrop;
if (enableTextDragDrop) {
AttachDragDrop();
}
}
@ -101,14 +96,45 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -101,14 +96,45 @@ namespace ICSharpCode.AvalonEdit.Editing
textArea.MouseMove -= textArea_MouseMove;
textArea.MouseLeftButtonUp -= textArea_MouseLeftButtonUp;
textArea.QueryCursor -= textArea_QueryCursor;
if (AllowTextDragDrop) {
textArea.AllowDrop = false;
textArea.GiveFeedback -= textArea_GiveFeedback;
textArea.QueryContinueDrag -= textArea_QueryContinueDrag;
textArea.DragEnter -= textArea_DragEnter;
textArea.DragOver -= textArea_DragOver;
textArea.DragLeave -= textArea_DragLeave;
textArea.Drop -= textArea_Drop;
textArea.OptionChanged -= textArea_OptionChanged;
if (enableTextDragDrop) {
DetachDragDrop();
}
}
void AttachDragDrop()
{
textArea.AllowDrop = true;
textArea.GiveFeedback += textArea_GiveFeedback;
textArea.QueryContinueDrag += textArea_QueryContinueDrag;
textArea.DragEnter += textArea_DragEnter;
textArea.DragOver += textArea_DragOver;
textArea.DragLeave += textArea_DragLeave;
textArea.Drop += textArea_Drop;
}
void DetachDragDrop()
{
textArea.AllowDrop = false;
textArea.GiveFeedback -= textArea_GiveFeedback;
textArea.QueryContinueDrag -= textArea_QueryContinueDrag;
textArea.DragEnter -= textArea_DragEnter;
textArea.DragOver -= textArea_DragOver;
textArea.DragLeave -= textArea_DragLeave;
textArea.Drop -= textArea_Drop;
}
bool enableTextDragDrop;
void textArea_OptionChanged(object sender, PropertyChangedEventArgs e)
{
bool newEnableTextDragDrop = textArea.Options.EnableTextDragDrop;
if (newEnableTextDragDrop != enableTextDragDrop) {
enableTextDragDrop = newEnableTextDragDrop;
if (newEnableTextDragDrop)
AttachDragDrop();
else
DetachDragDrop();
}
}
#endregion
@ -323,7 +349,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -323,7 +349,7 @@ namespace ICSharpCode.AvalonEdit.Editing
void textArea_QueryCursor(object sender, QueryCursorEventArgs e)
{
if (!e.Handled) {
if (mode != SelectionMode.None || !AllowTextDragDrop) {
if (mode != SelectionMode.None || !enableTextDragDrop) {
e.Cursor = Cursors.IBeam;
e.Handled = true;
} else if (textArea.TextView.VisualLinesValid) {
@ -352,7 +378,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -352,7 +378,7 @@ namespace ICSharpCode.AvalonEdit.Editing
if (!e.Handled && e.ChangedButton == MouseButton.Left) {
ModifierKeys modifiers = Keyboard.Modifiers;
bool shift = (modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
if (AllowTextDragDrop && e.ClickCount == 1 && !shift) {
if (enableTextDragDrop && e.ClickCount == 1 && !shift) {
int visualColumn;
int offset = GetOffsetFromMousePosition(e, out visualColumn);
if (textArea.Selection.Contains(offset)) {
@ -373,7 +399,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -373,7 +399,7 @@ namespace ICSharpCode.AvalonEdit.Editing
textArea.Selection = Selection.Empty;
}
if (textArea.CaptureMouse()) {
if ((modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) {
if ((modifiers & ModifierKeys.Alt) == ModifierKeys.Alt && textArea.Options.EnableRectangularSelection) {
mode = SelectionMode.Rectangular;
if (shift && textArea.Selection is RectangleSelection) {
textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldOffset, textArea.Caret.Offset);

6
AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs

@ -167,10 +167,16 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -167,10 +167,16 @@ namespace ICSharpCode.AvalonEdit.Folding
}
}
/// <summary>
/// Default brush for folding element text. Value: Brushes.Gray
/// </summary>
public static readonly Brush DefaultTextBrush = Brushes.Gray;
static Brush textBrush = DefaultTextBrush;
/// <summary>
/// Gets/sets the brush used for folding element text.
/// </summary>
public static Brush TextBrush {
get { return textBrush; }
set { textBrush = value; }

24
AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingMargin.cs

@ -28,39 +28,63 @@ namespace ICSharpCode.AvalonEdit.Folding @@ -28,39 +28,63 @@ namespace ICSharpCode.AvalonEdit.Folding
internal const double SizeFactor = Constants.PixelPerPoint;
#region Brushes
/// <summary>
/// FoldingMarkerBrush dependency property.
/// </summary>
public static readonly DependencyProperty FoldingMarkerBrushProperty =
DependencyProperty.RegisterAttached("FoldingMarkerBrush", typeof(Brush), typeof(FoldingMargin),
new FrameworkPropertyMetadata(Brushes.Gray, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
/// <summary>
/// Gets/sets the Brush used for displaying the lines of folding markers.
/// </summary>
public Brush FoldingMarkerBrush {
get { return (Brush)GetValue(FoldingMarkerBrushProperty); }
set { SetValue(FoldingMarkerBrushProperty, value); }
}
/// <summary>
/// FoldingMarkerBackgroundBrush dependency property.
/// </summary>
public static readonly DependencyProperty FoldingMarkerBackgroundBrushProperty =
DependencyProperty.RegisterAttached("FoldingMarkerBackgroundBrush", typeof(Brush), typeof(FoldingMargin),
new FrameworkPropertyMetadata(Brushes.White, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
/// <summary>
/// Gets/sets the Brush used for displaying the background of folding markers.
/// </summary>
public Brush FoldingMarkerBackgroundBrush {
get { return (Brush)GetValue(FoldingMarkerBackgroundBrushProperty); }
set { SetValue(FoldingMarkerBackgroundBrushProperty, value); }
}
/// <summary>
/// SelectedFoldingMarkerBrush dependency property.
/// </summary>
public static readonly DependencyProperty SelectedFoldingMarkerBrushProperty =
DependencyProperty.RegisterAttached("SelectedFoldingMarkerBrush",
typeof(Brush), typeof(FoldingMargin),
new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
/// <summary>
/// Gets/sets the Brush used for displaying the lines of selected folding markers.
/// </summary>
public Brush SelectedFoldingMarkerBrush {
get { return (Brush)GetValue(SelectedFoldingMarkerBrushProperty); }
set { SetValue(SelectedFoldingMarkerBrushProperty, value); }
}
/// <summary>
/// SelectedFoldingMarkerBackgroundBrush dependency property.
/// </summary>
public static readonly DependencyProperty SelectedFoldingMarkerBackgroundBrushProperty =
DependencyProperty.RegisterAttached("SelectedFoldingMarkerBackgroundBrush",
typeof(Brush), typeof(FoldingMargin),
new FrameworkPropertyMetadata(Brushes.White, FrameworkPropertyMetadataOptions.Inherits, OnUpdateBrushes));
/// <summary>
/// Gets/sets the Brush used for displaying the background of selected folding markers.
/// </summary>
public Brush SelectedFoldingMarkerBackgroundBrush {
get { return (Brush)GetValue(SelectedFoldingMarkerBackgroundBrushProperty); }
set { SetValue(SelectedFoldingMarkerBackgroundBrushProperty, value); }

5
AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs

@ -154,6 +154,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -154,6 +154,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (b != null)
element.TextRunProperties.SetForegroundBrush(b);
}
if (color.Background != null) {
Brush b = color.Background.GetBrush(CurrentContext);
if (b != null)
element.TextRunProperties.SetBackgroundBrush(b);
}
if (color.FontStyle != null || color.FontWeight != null) {
Typeface tf = element.TextRunProperties.Typeface;
element.TextRunProperties.SetTypeface(new Typeface(

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

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<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">
<Span color="ASPSection" ruleSet="ASP" multiline="true">
<Span ruleSet="ASP" multiline="true">
<Begin color="ASPSectionStartEndTags">&lt;%</Begin>
<End color="ASPSectionStartEndTags">%&gt;</End>
</Span>

2
AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -215,7 +215,6 @@ @@ -215,7 +215,6 @@
<Compile Include="Indentation\CSharp\DocumentAccessor.cs" />
<Compile Include="Indentation\DefaultIndentationStrategy.cs" />
<Compile Include="Indentation\IIndentationStrategy.cs" />
<Compile Include="Properties\GlobalAssemblyInfo.cs" />
<Compile Include="Rendering\BackgroundGeometryBuilder.cs">
<DependentUpon>IBackgroundRenderer.cs</DependentUpon>
</Compile>
@ -341,6 +340,7 @@ @@ -341,6 +340,7 @@
<Compile Include="Utils\Rope.cs" />
<Compile Include="Utils\RopeNode.cs" />
<Compile Include="Utils\RopeTextReader.cs" />
<Compile Include="Utils\StringSegment.cs" />
<Compile Include="Utils\TextFormatterFactory.cs" />
<Compile Include="Utils\WeakEventManagerBase.cs" />
<Compile Include="Utils\PixelSnapHelpers.cs" />

6
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 + "-d9a90d79")]
[assembly: AssemblyInformationalVersion(RevisionClass.FullVersion + "-3301c6c4")]
[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 = "7275";
public const string Revision = "7411";
public const string VersionName = "alpha";
public const string FullVersion = Major + "." + Minor + "." + Build + ".7275-alpha";
public const string FullVersion = Major + "." + Minor + "." + Build + ".7411-alpha";
}

3
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/IBackgroundRenderer.cs

@ -11,9 +11,6 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -11,9 +11,6 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// You can use background renderers to draw non-interactive elements on the TextView
/// without introducing new UIElements.
/// </summary>
/// <remarks>Background renderer will draw only if their associated known
/// layer chooses to draw them. For example, background renderers in the caret
/// layer will be invisible when the caret is hidden.</remarks>
public interface IBackgroundRenderer
{
/// <summary>

12
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/ITextRunConstructionContext.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.Windows.Media.TextFormatting;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Rendering
{
@ -31,5 +32,16 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -31,5 +32,16 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// Gets the global text run properties.
/// </summary>
TextRunProperties GlobalTextRunProperties { get; }
/// <summary>
/// Gets a piece of text from the document.
/// </summary>
/// <remarks>
/// This method is allowed to return a larger string than requested.
/// It does this by returning a <see cref="StringSegment"/> that describes the requested segment within the returned string.
/// This method should be the preferred text access method in the text transformation pipeline, as it can avoid repeatedly allocating string instances
/// for text within the same line.
/// </remarks>
StringSegment GetText(int offset, int length);
}
}

28
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/LinkElementGenerator.cs

@ -2,16 +2,8 @@ @@ -2,16 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using ICSharpCode.AvalonEdit.Document;
using System.Windows.Navigation;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Rendering
{
@ -65,25 +57,29 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -65,25 +57,29 @@ namespace ICSharpCode.AvalonEdit.Rendering
this.RequireControlModifierForClick = options.RequireControlModifierForHyperlinkClick;
}
Match GetMatch(int startOffset)
Match GetMatch(int startOffset, out int matchOffset)
{
int endOffset = CurrentContext.VisualLine.LastDocumentLine.EndOffset;
string relevantText = CurrentContext.Document.GetText(startOffset, endOffset - startOffset);
return linkRegex.Match(relevantText);
StringSegment relevantText = CurrentContext.GetText(startOffset, endOffset - startOffset);
Match m = linkRegex.Match(relevantText.Text, relevantText.Offset, relevantText.Count);
matchOffset = m.Success ? m.Index - relevantText.Offset + startOffset : -1;
return m;
}
/// <inheritdoc/>
public override int GetFirstInterestedOffset(int startOffset)
{
Match m = GetMatch(startOffset);
return m.Success ? startOffset + m.Index : -1;
int matchOffset;
GetMatch(startOffset, out matchOffset);
return matchOffset;
}
/// <inheritdoc/>
public override VisualLineElement ConstructElement(int offset)
{
Match m = GetMatch(offset);
if (m.Success && m.Index == 0) {
int matchOffset;
Match m = GetMatch(offset, out matchOffset);
if (m.Success && matchOffset == offset) {
Uri uri = GetUriFromMatch(m);
if (uri == null)
return null;

21
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/MouseHoverLogic.cs

@ -8,6 +8,9 @@ using System.Windows.Threading; @@ -8,6 +8,9 @@ using System.Windows.Threading;
namespace ICSharpCode.AvalonEdit.Rendering
{
/// <summary>
/// Encapsulates and adds MouseHover support to UIElements.
/// </summary>
public class MouseHoverLogic : IDisposable
{
UIElement target;
@ -17,6 +20,9 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -17,6 +20,9 @@ namespace ICSharpCode.AvalonEdit.Rendering
MouseEventArgs mouseHoverLastEventArgs;
bool mouseHovering;
/// <summary>
/// Creates a new instance and attaches itself to the <paramref name="target" /> UIElement.
/// </summary>
public MouseHoverLogic(UIElement target)
{
if (target == null)
@ -70,8 +76,14 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -70,8 +76,14 @@ namespace ICSharpCode.AvalonEdit.Rendering
OnMouseHover(mouseHoverLastEventArgs);
}
/// <summary>
/// Occurs when the mouse starts hovering over a certain location.
/// </summary>
public event EventHandler<MouseEventArgs> MouseHover;
/// <summary>
/// Raises the <see cref="MouseHover"/> event.
/// </summary>
protected virtual void OnMouseHover(MouseEventArgs e)
{
if (MouseHover != null) {
@ -79,8 +91,14 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -79,8 +91,14 @@ namespace ICSharpCode.AvalonEdit.Rendering
}
}
/// <summary>
/// Occurs when the mouse stops hovering over a certain location.
/// </summary>
public event EventHandler<MouseEventArgs> MouseHoverStopped;
/// <summary>
/// Raises the <see cref="MouseHoverStopped"/> event.
/// </summary>
protected virtual void OnMouseHoverStopped(MouseEventArgs e)
{
if (MouseHoverStopped != null) {
@ -90,6 +108,9 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -90,6 +108,9 @@ namespace ICSharpCode.AvalonEdit.Rendering
bool disposed;
/// <summary>
/// Removes the MouseHover support from the target UIElement.
/// </summary>
public void Dispose()
{
if (!disposed) {

6
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs

@ -60,10 +60,10 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -60,10 +60,10 @@ namespace ICSharpCode.AvalonEdit.Rendering
public override int GetFirstInterestedOffset(int startOffset)
{
DocumentLine endLine = CurrentContext.VisualLine.LastDocumentLine;
string relevantText = CurrentContext.Document.GetText(startOffset, endLine.EndOffset - startOffset);
StringSegment relevantText = CurrentContext.GetText(startOffset, endLine.EndOffset - startOffset);
for (int i = 0; i < relevantText.Length; i++) {
char c = relevantText[i];
for (int i = 0; i < relevantText.Count; i++) {
char c = relevantText.Text[relevantText.Offset + i];
switch (c) {
case ' ':
if (ShowSpaces)

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

@ -1739,12 +1739,21 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -1739,12 +1739,21 @@ namespace ICSharpCode.AvalonEdit.Rendering
#endregion
/// <summary>
/// Collapses lines for the purpose of scrolling. This method is meant for
/// <see cref="VisualLineElementGenerator"/>s that cause <see cref="VisualLine"/>s to span
/// Collapses lines for the purpose of scrolling. <see cref="DocumentLine"/>s marked as collapsed will be hidden
/// and not used to start the generation of a <see cref="VisualLine"/>.
/// </summary>
/// <remarks>
/// This method is meant for <see cref="VisualLineElementGenerator"/>s that cause <see cref="VisualLine"/>s to span
/// multiple <see cref="DocumentLine"/>s. Do not call it without providing a corresponding
/// <see cref="VisualLineElementGenerator"/>.
/// If you want to create collapsible text sections, see <see cref="Folding.FoldingManager"/>.
/// </summary>
///
/// Note that if you want a VisualLineElement to span from line N to line M, then you need to collapse only the lines
/// N+1 to M. Do not collapse line N itself.
///
/// When you no longer need the section to be collapsed, call <see cref="CollapsedLineSection.Uncollapse()"/> on the
/// <see cref="CollapsedLineSection"/> returned from this method.
/// </remarks>
public CollapsedLineSection CollapseLines(DocumentLine start, DocumentLine end)
{
VerifyAccess();

12
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -53,7 +53,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// Gets the start offset of the VisualLine inside the document.
/// This is equivalent to <c>FirstDocumentLine.Offset</c>.
/// </summary>
public int StartOffset {
public int StartOffset {
get {
return FirstDocumentLine.Offset;
}
@ -137,8 +137,14 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -137,8 +137,14 @@ namespace ICSharpCode.AvalonEdit.Rendering
askInterestOffset = 0;
offset += element.DocumentLength;
if (offset > currentLineEnd) {
LastDocumentLine = document.GetLineByOffset(offset);
currentLineEnd = LastDocumentLine.Offset + LastDocumentLine.Length;
DocumentLine newEndLine = document.GetLineByOffset(offset);
if (newEndLine == this.LastDocumentLine) {
throw new InvalidOperationException(
"The VisualLineElementGenerator " + g.GetType().Name +
" produced an element which ends within the line delimiter");
}
currentLineEnd = newEndLine.Offset + newEndLine.Length;
this.LastDocumentLine = newEndLine;
}
break;
}

8
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineText.cs

@ -53,8 +53,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -53,8 +53,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
throw new ArgumentNullException("context");
int relativeOffset = startVisualColumn - VisualColumn;
string text = context.Document.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
return new TextCharacters(text, 0, text.Length, this.TextRunProperties);
StringSegment text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
return new TextCharacters(text.Text, text.Offset, text.Count, this.TextRunProperties);
}
/// <inheritdoc/>
@ -71,8 +71,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -71,8 +71,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
throw new ArgumentNullException("context");
int relativeOffset = visualColumnLimit - VisualColumn;
string text = context.Document.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset, relativeOffset);
CharacterBufferRange range = new CharacterBufferRange(text, 0, text.Length);
StringSegment text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset, relativeOffset);
CharacterBufferRange range = new CharacterBufferRange(text.Text, text.Offset, text.Count);
return new TextSpan<CultureSpecificCharacterBufferRange>(range.Length, new CultureSpecificCharacterBufferRange(this.TextRunProperties.CultureInfo, range));
}

15
AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineTextSource.cs

@ -6,6 +6,7 @@ using System.Diagnostics; @@ -6,6 +6,7 @@ using System.Diagnostics;
using System.Windows.Media.TextFormatting;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Rendering
{
@ -83,5 +84,19 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -83,5 +84,19 @@ namespace ICSharpCode.AvalonEdit.Rendering
{
throw new NotSupportedException();
}
string cachedString;
int cachedStringOffset;
public StringSegment GetText(int offset, int length)
{
if (cachedString != null) {
if (offset >= cachedStringOffset && offset + length <= cachedStringOffset + cachedString.Length) {
return new StringSegment(cachedString, offset - cachedStringOffset, length);
}
}
cachedStringOffset = offset;
return new StringSegment(cachedString = this.Document.GetText(offset, length));
}
}
}

4
AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -669,6 +669,7 @@ namespace ICSharpCode.AvalonEdit @@ -669,6 +669,7 @@ namespace ICSharpCode.AvalonEdit
/// </summary>
public void ScrollToEnd()
{
ApplyTemplate(); // ensure scrollViewer is created
if (scrollViewer != null)
scrollViewer.ScrollToEnd();
}
@ -678,6 +679,7 @@ namespace ICSharpCode.AvalonEdit @@ -678,6 +679,7 @@ namespace ICSharpCode.AvalonEdit
/// </summary>
public void ScrollToHome()
{
ApplyTemplate(); // ensure scrollViewer is created
if (scrollViewer != null)
scrollViewer.ScrollToHome();
}
@ -687,6 +689,7 @@ namespace ICSharpCode.AvalonEdit @@ -687,6 +689,7 @@ namespace ICSharpCode.AvalonEdit
/// </summary>
public void ScrollToHorizontalOffset(double offset)
{
ApplyTemplate(); // ensure scrollViewer is created
if (scrollViewer != null)
scrollViewer.ScrollToHorizontalOffset(offset);
}
@ -696,6 +699,7 @@ namespace ICSharpCode.AvalonEdit @@ -696,6 +699,7 @@ namespace ICSharpCode.AvalonEdit
/// </summary>
public void ScrollToVerticalOffset(double offset)
{
ApplyTemplate(); // ensure scrollViewer is created
if (scrollViewer != null)
scrollViewer.ScrollToVerticalOffset(offset);
}

58
AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.ComponentModel;
using System.Reflection;
using System.Text;
namespace ICSharpCode.AvalonEdit
@ -13,6 +14,31 @@ namespace ICSharpCode.AvalonEdit @@ -13,6 +14,31 @@ namespace ICSharpCode.AvalonEdit
[Serializable]
public class TextEditorOptions : INotifyPropertyChanged
{
#region ctor
/// <summary>
/// Initializes an empty instance of TextEditorOptions.
/// </summary>
public TextEditorOptions()
{
}
/// <summary>
/// Initializes a new instance of TextEditorOptions by copying all values
/// from <paramref name="options"/> to the new instance.
/// </summary>
public TextEditorOptions(TextEditorOptions options)
{
// get all the fields in the class
FieldInfo[] fields = typeof(TextEditorOptions).GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
// copy each value over to 'this'
foreach(FieldInfo fi in fields) {
if (!fi.IsNotSerialized)
fi.SetValue(this, fi.GetValue(options));
}
}
#endregion
#region PropertyChanged handling
/// <inheritdoc/>
[field: NonSerialized]
@ -304,5 +330,37 @@ namespace ICSharpCode.AvalonEdit @@ -304,5 +330,37 @@ namespace ICSharpCode.AvalonEdit
}
}
}
bool enableRectangularSelection = true;
/// <summary>
/// Enables rectangular selection (press ALT and select a rectangle)
/// </summary>
[DefaultValue(true)]
public bool EnableRectangularSelection {
get { return enableRectangularSelection; }
set {
if (enableRectangularSelection != value) {
enableRectangularSelection = value;
OnPropertyChanged("AllowRectangularSelection");
}
}
}
bool enableTextDragDrop = true;
/// <summary>
/// Enable dragging text within the text area.
/// </summary>
[DefaultValue(true)]
public bool EnableTextDragDrop {
get { return enableTextDragDrop; }
set {
if (enableTextDragDrop != value) {
enableTextDragDrop = value;
OnPropertyChanged("EnableTextDrag");
}
}
}
}
}

107
AvalonEdit/ICSharpCode.AvalonEdit/Utils/StringSegment.cs

@ -0,0 +1,107 @@ @@ -0,0 +1,107 @@
// 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;
namespace ICSharpCode.AvalonEdit.Utils
{
/// <summary>
/// Represents a string with a segment.
/// Similar to System.ArraySegment&lt;T&gt;, but for strings instead of arrays.
/// </summary>
public struct StringSegment : IEquatable<StringSegment>
{
readonly string text;
readonly int offset;
readonly int count;
/// <summary>
/// Creates a new StringSegment.
/// </summary>
public StringSegment(string text, int offset, int count)
{
if (text == null)
throw new ArgumentNullException("text");
if (offset < 0 || offset > text.Length)
throw new ArgumentOutOfRangeException("offset");
if (offset + count > text.Length)
throw new ArgumentOutOfRangeException("count");
this.text = text;
this.offset = offset;
this.count = count;
}
/// <summary>
/// Creates a new StringSegment.
/// </summary>
public StringSegment(string text)
{
if (text == null)
throw new ArgumentNullException("text");
this.text = text;
this.offset = 0;
this.count = text.Length;
}
/// <summary>
/// Gets the string used for this segment.
/// </summary>
public string Text {
get { return text; }
}
/// <summary>
/// Gets the start offset of the segment with the text.
/// </summary>
public int Offset {
get { return offset; }
}
/// <summary>
/// Gets the length of the segment.
/// </summary>
public int Count {
get { return count; }
}
#region Equals and GetHashCode implementation
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is StringSegment)
return Equals((StringSegment)obj); // use Equals method below
else
return false;
}
/// <inheritdoc/>
public bool Equals(StringSegment other)
{
// add comparisions for all members here
return object.ReferenceEquals(this.text, other.text) && offset == other.offset && count == other.count;
}
/// <inheritdoc/>
public override int GetHashCode()
{
return text.GetHashCode() ^ offset ^ count;
}
/// <summary>
/// Equality operator.
/// </summary>
public static bool operator ==(StringSegment left, StringSegment right)
{
return left.Equals(right);
}
/// <summary>
/// Inequality operator.
/// </summary>
public static bool operator !=(StringSegment left, StringSegment right)
{
return !left.Equals(right);
}
#endregion
}
}
Loading…
Cancel
Save