Browse Source

Make AvalonEdit implement the ICSharpCode.Editor interfaces.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
839a5cbc8d
  1. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs
  2. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/ICompletionData.cs
  3. 36
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ChangeTrackingCheckpoint.cs
  4. 39
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs
  5. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentLine.cs
  6. 320
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs
  7. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs
  8. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs
  9. 103
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/RopeTextSource.cs
  10. 59
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/SimpleSegment.cs
  11. 26
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchor.cs
  12. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchorTree.cs
  13. 101
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs
  14. 166
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextLocation.cs
  15. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegment.cs
  16. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs
  17. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs
  18. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  19. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs
  20. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/IReadOnlySectionProvider.cs
  21. 5
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/NoReadOnlySections.cs
  22. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
  23. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs
  24. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionColorizer.cs
  25. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs
  26. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
  27. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs
  28. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextSegmentReadOnlySectionProvider.cs
  29. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/AbstractFoldingStrategy.cs
  30. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs
  31. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs
  32. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs
  33. 10
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/NewFolding.cs
  34. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs
  35. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedSection.cs
  36. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlClipboard.cs
  37. 11
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
  38. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/DefaultIndentationStrategy.cs
  39. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs
  40. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  41. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/IActiveElement.cs
  42. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/InsertionContext.cs
  43. 5
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/Snippet.cs
  44. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetAnchorElement.cs
  45. 3
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetBoundElement.cs
  46. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetCaretElement.cs
  47. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetContainerElement.cs
  48. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetElement.cs
  49. 4
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetInputHandler.cs
  50. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetReplaceableTextElement.cs
  51. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetSelectionElement.cs
  52. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetTextElement.cs
  53. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextViewPosition.cs

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs

@ -2,16 +2,18 @@ @@ -2,16 +2,18 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.CodeCompletion
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/ICompletionData.cs

@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
using System;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.CodeCompletion
{

36
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ChangeTrackingCheckpoint.cs

@ -1,12 +1,14 @@ @@ -1,12 +1,14 @@
// 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 ICSharpCode.AvalonEdit.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
@ -20,8 +22,10 @@ namespace ICSharpCode.AvalonEdit.Document @@ -20,8 +22,10 @@ namespace ICSharpCode.AvalonEdit.Document
/// <para>Once you have two checkpoints, you can call <see cref="ChangeTrackingCheckpoint.GetChangesTo"/> to retrieve the complete list
/// of document changes that happened between those versions of the document.</para>
/// </remarks>
public sealed class ChangeTrackingCheckpoint
public sealed class ChangeTrackingCheckpoint : ITextSourceVersion
{
static readonly ChangeTrackingCheckpoint checkpointBelongsToNoDocument = new ChangeTrackingCheckpoint(null);
// Object that is unique per document.
// Used to determine if two checkpoints belong to the same document.
// We don't use a reference to the document itself to allow the GC to reclaim the document memory
@ -136,5 +140,33 @@ namespace ICSharpCode.AvalonEdit.Document @@ -136,5 +140,33 @@ namespace ICSharpCode.AvalonEdit.Document
}
return offset;
}
static ChangeTrackingCheckpoint GetCheckPoint(ITextSourceVersion version)
{
if (version == null)
return null;
else
return version as ChangeTrackingCheckpoint ?? checkpointBelongsToNoDocument;
}
bool ITextSourceVersion.BelongsToSameDocumentAs(ITextSourceVersion other)
{
return BelongsToSameDocumentAs(GetCheckPoint(other));
}
int ITextSourceVersion.CompareAge(ITextSourceVersion other)
{
return CompareAge(GetCheckPoint(other));
}
IEnumerable<TextChangeEventArgs> ITextSourceVersion.GetChangesTo(ITextSourceVersion other)
{
return GetChangesTo(GetCheckPoint(other));
}
int ITextSourceVersion.MoveOffsetTo(ITextSourceVersion other, int oldOffset, AnchorMovementType movement)
{
return MoveOffsetTo(GetCheckPoint(other), oldOffset, movement);
}
}
}

39
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentChangeEventArgs.cs

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
// 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 ICSharpCode.AvalonEdit.Utils;
using System;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
@ -11,37 +12,8 @@ namespace ICSharpCode.AvalonEdit.Document @@ -11,37 +12,8 @@ namespace ICSharpCode.AvalonEdit.Document
/// This class is thread-safe.
/// </summary>
[Serializable]
public class DocumentChangeEventArgs : EventArgs
public class DocumentChangeEventArgs : TextChangeEventArgs
{
/// <summary>
/// The offset at which the change occurs.
/// </summary>
public int Offset { get; private set; }
/// <summary>
/// The text that was inserted.
/// </summary>
public string RemovedText { get; private set; }
/// <summary>
/// The number of characters removed.
/// </summary>
public int RemovalLength {
get { return RemovedText.Length; }
}
/// <summary>
/// The text that was inserted.
/// </summary>
public string InsertedText { get; private set; }
/// <summary>
/// The number of characters inserted.
/// </summary>
public int InsertionLength {
get { return InsertedText.Length; }
}
volatile OffsetChangeMap offsetChangeMap;
/// <summary>
@ -97,15 +69,12 @@ namespace ICSharpCode.AvalonEdit.Document @@ -97,15 +69,12 @@ namespace ICSharpCode.AvalonEdit.Document
/// Creates a new DocumentChangeEventArgs object.
/// </summary>
public DocumentChangeEventArgs(int offset, string removedText, string insertedText, OffsetChangeMap offsetChangeMap)
: base(offset, removedText, insertedText)
{
ThrowUtil.CheckNotNegative(offset, "offset");
ThrowUtil.CheckNotNull(removedText, "removedText");
ThrowUtil.CheckNotNull(insertedText, "insertedText");
this.Offset = offset;
this.RemovedText = removedText;
this.InsertedText = insertedText;
if (offsetChangeMap != null) {
if (!offsetChangeMap.IsFrozen)
throw new ArgumentException("The OffsetChangeMap must be frozen before it can be used in DocumentChangeEventArgs");

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/DocumentLine.cs

@ -5,6 +5,8 @@ using System; @@ -5,6 +5,8 @@ using System;
using System.Diagnostics;
using System.Globalization;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
@ -22,7 +24,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -22,7 +24,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// and the data structure also updates all offsets in O(lg N) whenever a line is inserted or removed.
/// </para>
/// </remarks>
public sealed partial class DocumentLine : ISegment
public sealed partial class DocumentLine : IDocumentLine
{
#region Constructor
#if DEBUG

320
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs

@ -1,320 +0,0 @@ @@ -1,320 +0,0 @@
// 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 ICSharpCode.AvalonEdit.Utils;
using System;
using System.IO;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// Interface for read-only access to a text source.
/// </summary>
/// <seealso cref="TextDocument"/>
/// <seealso cref="StringTextSource"/>
public interface ITextSource
{
/// <summary>
/// Gets the whole text as string.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
string Text { get; }
/// <summary>
/// Is raised when the Text property changes.
/// </summary>
event EventHandler TextChanged;
/// <summary>
/// Gets the total text length.
/// </summary>
/// <returns>The length of the text, in characters.</returns>
/// <remarks>This is the same as Text.Length, but is more efficient because
/// it doesn't require creating a String object.</remarks>
int TextLength { get; }
/// <summary>
/// Gets a character at the specified position in the document.
/// </summary>
/// <paramref name="offset">The index of the character to get.</paramref>
/// <exception cref="ArgumentOutOfRangeException">Offset is outside the valid range (0 to TextLength-1).</exception>
/// <returns>The character at the specified position.</returns>
/// <remarks>This is the same as Text[offset], but is more efficient because
/// it doesn't require creating a String object.</remarks>
char GetCharAt(int offset);
/// <summary>
/// Gets the index of the first occurrence of any character in the specified array.
/// </summary>
/// <param name="anyOf"></param>
/// <param name="startIndex">Start index of the search.</param>
/// <param name="count">Length of the area to search.</param>
/// <returns>The first index where any character was found; or -1 if no occurrence was found.</returns>
int IndexOfAny(char[] anyOf, int startIndex, int count);
/// <summary>
/// Retrieves the text for a portion of the document.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">offset or length is outside the valid range.</exception>
/// <remarks>This is the same as Text.Substring, but is more efficient because
/// it doesn't require creating a String object for the whole document.</remarks>
string GetText(int offset, int length);
/// <summary>
/// Creates a snapshot of the current text.
/// </summary>
/// <remarks>
/// This method is generally not thread-safe when called on a mutable text buffer, but the resulting text buffer is immutable and thread-safe.
/// However, some implementing classes may provide additional thread-safety guarantees, see <see cref="TextDocument.CreateSnapshot()">TextDocument.CreateSnapshot</see>.
/// </remarks>
ITextSource CreateSnapshot();
/// <summary>
/// Creates a snapshot of a part of the current text.
/// </summary>
/// <remarks>
/// This method is generally not thread-safe when called on a mutable text buffer, but the resulting text buffer is immutable and thread-safe.
/// However, some implementing classes may provide additional thread-safety guarantees, see <see cref="TextDocument.CreateSnapshot()">TextDocument.CreateSnapshot</see>.
/// </remarks>
ITextSource CreateSnapshot(int offset, int length);
/// <summary>
/// Creates a text reader.
/// If the text is changed while a reader is active, the reader will continue to read from the old text version.
/// </summary>
TextReader CreateReader();
}
/// <summary>
/// Implements the ITextSource interface by wrapping another TextSource
/// and viewing only a part of the text.
/// </summary>
[Obsolete("This class will be removed in a future version of AvalonEdit")]
public sealed class TextSourceView : ITextSource
{
readonly ITextSource baseTextSource;
readonly ISegment viewedSegment;
/// <summary>
/// Creates a new TextSourceView object.
/// </summary>
/// <param name="baseTextSource">The base text source.</param>
/// <param name="viewedSegment">A text segment from the base text source</param>
public TextSourceView(ITextSource baseTextSource, ISegment viewedSegment)
{
if (baseTextSource == null)
throw new ArgumentNullException("baseTextSource");
if (viewedSegment == null)
throw new ArgumentNullException("viewedSegment");
this.baseTextSource = baseTextSource;
this.viewedSegment = viewedSegment;
}
/// <inheritdoc/>
public event EventHandler TextChanged {
add { baseTextSource.TextChanged += value; }
remove { baseTextSource.TextChanged -= value; }
}
/// <inheritdoc/>
public string Text {
get {
return baseTextSource.GetText(viewedSegment.Offset, viewedSegment.Length);
}
}
/// <inheritdoc/>
public int TextLength {
get { return viewedSegment.Length; }
}
/// <inheritdoc/>
public char GetCharAt(int offset)
{
return baseTextSource.GetCharAt(viewedSegment.Offset + offset);
}
/// <inheritdoc/>
public string GetText(int offset, int length)
{
return baseTextSource.GetText(viewedSegment.Offset + offset, length);
}
/// <inheritdoc/>
public ITextSource CreateSnapshot()
{
return baseTextSource.CreateSnapshot(viewedSegment.Offset, viewedSegment.Length);
}
/// <inheritdoc/>
public ITextSource CreateSnapshot(int offset, int length)
{
return baseTextSource.CreateSnapshot(viewedSegment.Offset + offset, length);
}
/// <inheritdoc/>
public TextReader CreateReader()
{
return CreateSnapshot().CreateReader();
}
/// <inheritdoc/>
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
int offset = viewedSegment.Offset;
int result = baseTextSource.IndexOfAny(anyOf, startIndex + offset, count);
return result >= 0 ? result - offset : result;
}
}
/// <summary>
/// Implements the ITextSource interface using a string.
/// </summary>
public sealed class StringTextSource : ITextSource
{
readonly string text;
/// <summary>
/// Creates a new StringTextSource.
/// </summary>
public StringTextSource(string text)
{
if (text == null)
throw new ArgumentNullException("text");
this.text = text;
}
// Text can never change
event EventHandler ITextSource.TextChanged { add {} remove {} }
/// <inheritdoc/>
public string Text {
get { return text; }
}
/// <inheritdoc/>
public int TextLength {
get { return text.Length; }
}
/// <inheritdoc/>
public char GetCharAt(int offset)
{
// GetCharAt must throw ArgumentOutOfRangeException, not IndexOutOfRangeException
if (offset < 0 || offset >= text.Length)
throw new ArgumentOutOfRangeException("offset", offset, "offset must be between 0 and " + (text.Length - 1));
return text[offset];
}
/// <inheritdoc/>
public string GetText(int offset, int length)
{
return text.Substring(offset, length);
}
/// <inheritdoc/>
public TextReader CreateReader()
{
return new StringReader(text);
}
/// <inheritdoc/>
public ITextSource CreateSnapshot()
{
return this; // StringTextSource already is immutable
}
/// <inheritdoc/>
public ITextSource CreateSnapshot(int offset, int length)
{
return new StringTextSource(text.Substring(offset, length));
}
/// <inheritdoc/>
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
return text.IndexOfAny(anyOf, startIndex, count);
}
}
/// <summary>
/// Implements the ITextSource interface using a rope.
/// </summary>
public sealed class RopeTextSource : ITextSource
{
readonly Rope<char> rope;
/// <summary>
/// Creates a new RopeTextSource.
/// </summary>
public RopeTextSource(Rope<char> rope)
{
if (rope == null)
throw new ArgumentNullException("rope");
this.rope = rope;
}
/// <summary>
/// Returns a clone of the rope used for this text source.
/// </summary>
/// <remarks>
/// RopeTextSource only publishes a copy of the contained rope to ensure that the underlying rope cannot be modified.
/// Unless the creator of the RopeTextSource still has a reference on the rope, RopeTextSource is immutable.
/// </remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification="Not a property because it creates a clone")]
public Rope<char> GetRope()
{
return rope.Clone();
}
// Change event is not supported
event EventHandler ITextSource.TextChanged { add {} remove {} }
/// <inheritdoc/>
public string Text {
get { return rope.ToString(); }
}
/// <inheritdoc/>
public int TextLength {
get { return rope.Length; }
}
/// <inheritdoc/>
public char GetCharAt(int offset)
{
return rope[offset];
}
/// <inheritdoc/>
public string GetText(int offset, int length)
{
return rope.ToString(offset, length);
}
/// <inheritdoc/>
public TextReader CreateReader()
{
return new RopeTextReader(rope);
}
/// <inheritdoc/>
public ITextSource CreateSnapshot()
{
// we clone the underlying rope because the creator of the RopeTextSource might be modifying it
return new RopeTextSource(rope.Clone());
}
/// <inheritdoc/>
public ITextSource CreateSnapshot(int offset, int length)
{
return new RopeTextSource(rope.GetRange(offset, length));
}
/// <inheritdoc/>
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
return rope.IndexOfAny(anyOf, startIndex, count);
}
}
}

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs

@ -2,9 +2,8 @@ @@ -2,9 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/OffsetChangeMap.cs

@ -7,6 +7,7 @@ using System.Collections.ObjectModel; @@ -7,6 +7,7 @@ using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{

103
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/RopeTextSource.cs

@ -0,0 +1,103 @@ @@ -0,0 +1,103 @@
// 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;
using System.IO;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// Implements the ITextSource interface using a rope.
/// </summary>
public sealed class RopeTextSource : ITextSource
{
readonly Rope<char> rope;
/// <summary>
/// Creates a new RopeTextSource.
/// </summary>
public RopeTextSource(Rope<char> rope)
{
if (rope == null)
throw new ArgumentNullException("rope");
this.rope = rope;
}
/// <summary>
/// Returns a clone of the rope used for this text source.
/// </summary>
/// <remarks>
/// RopeTextSource only publishes a copy of the contained rope to ensure that the underlying rope cannot be modified.
/// Unless the creator of the RopeTextSource still has a reference on the rope, RopeTextSource is immutable.
/// </remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification="Not a property because it creates a clone")]
public Rope<char> GetRope()
{
return rope.Clone();
}
/// <inheritdoc/>
public string Text {
get { return rope.ToString(); }
}
/// <inheritdoc/>
public int TextLength {
get { return rope.Length; }
}
/// <inheritdoc/>
public char GetCharAt(int offset)
{
return rope[offset];
}
/// <inheritdoc/>
public string GetText(int offset, int length)
{
return rope.ToString(offset, length);
}
/// <inheritdoc/>
public TextReader CreateReader()
{
return new RopeTextReader(rope);
}
/// <inheritdoc/>
public TextReader CreateReader(int offset, int length)
{
return new RopeTextReader(rope.GetRange(offset, length));
}
/// <inheritdoc/>
public ITextSource CreateSnapshot()
{
// we clone the underlying rope because the creator of the RopeTextSource might be modifying it
return new RopeTextSource(rope.Clone());
}
/// <inheritdoc/>
public ITextSource CreateSnapshot(int offset, int length)
{
return new RopeTextSource(rope.GetRange(offset, length));
}
/// <inheritdoc/>
public int IndexOfAny(char[] anyOf, int startIndex, int count)
{
return rope.IndexOfAny(anyOf, startIndex, count);
}
ITextSourceVersion ITextSource.Version {
get { return null; }
}
string ITextSource.GetText(ICSharpCode.Editor.ISegment segment)
{
throw new NotImplementedException();
}
}
}

59
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ISegment.cs → src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/SimpleSegment.cs

@ -3,73 +3,34 @@ @@ -3,73 +3,34 @@
using System;
using System.Diagnostics;
using ICSharpCode.AvalonEdit.Utils;
using System.Globalization;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// An (Offset,Length)-pair.
/// Represents a simple segment (Offset,Length pair) that is not automatically updated
/// on document changes.
/// </summary>
/// <seealso cref="TextSegment"/>
/// <seealso cref="AnchorSegment"/>
public interface ISegment
{
/// <summary>
/// Gets the start offset of the segment.
/// </summary>
int Offset { get; }
/// <summary>
/// Gets the length of the segment.
/// </summary>
/// <remarks>Must not be negative.</remarks>
int Length { get; }
/// <summary>
/// Gets the end offset of the segment.
/// </summary>
/// <remarks>EndOffset = Offset + Length;</remarks>
int EndOffset { get; }
}
static class SegmentExtensions
struct SimpleSegment : IEquatable<SimpleSegment>, ISegment
{
/// <summary>
/// Gets whether the segment contains the offset.
/// </summary>
/// <returns>
/// True, if offset is between segment.Start and segment.End (inclusive); otherwise, false.
/// </returns>
public static bool Contains(this ISegment segment, int offset)
{
int start = segment.Offset;
int end = start + segment.Length;
return offset >= start && offset <= end;
}
public static readonly SimpleSegment Invalid = new SimpleSegment(-1, -1);
/// <summary>
/// Gets the overlapping portion of the segments.
/// Returns SimpleSegment.Invalid if the segments don't overlap.
/// </summary>
public static SimpleSegment GetOverlap(this ISegment segment, ISegment other)
public static SimpleSegment GetOverlap(ISegment segment1, ISegment segment2)
{
int start = Math.Max(segment.Offset, other.Offset);
int end = Math.Min(segment.EndOffset, other.EndOffset);
int start = Math.Max(segment1.Offset, segment2.Offset);
int end = Math.Min(segment1.EndOffset, segment2.EndOffset);
if (end < start)
return SimpleSegment.Invalid;
else
return new SimpleSegment(start, end - start);
}
}
/// <summary>
/// Represents a simple segment (Offset,Length pair) that is not automatically updated
/// on document changes.
/// </summary>
struct SimpleSegment : IEquatable<SimpleSegment>, ISegment
{
public static readonly SimpleSegment Invalid = new SimpleSegment(-1, -1);
public readonly int Offset, Length;

26
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchor.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
@ -33,7 +34,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -33,7 +34,7 @@ namespace ICSharpCode.AvalonEdit.Document
/// int newOffset = anchor.Offset;
/// </code>
/// </example>
public sealed class TextAnchor
public sealed class TextAnchor : ITextAnchor
{
readonly TextDocument document;
internal TextAnchorNode node;
@ -168,27 +169,4 @@ namespace ICSharpCode.AvalonEdit.Document @@ -168,27 +169,4 @@ namespace ICSharpCode.AvalonEdit.Document
return "[TextAnchor Offset=" + Offset + "]";
}
}
/// <summary>
/// Defines how a text anchor moves.
/// </summary>
public enum AnchorMovementType
{
/// <summary>
/// When text is inserted at the anchor position, the type of the insertion
/// determines where the caret moves to. For normal insertions, the anchor will stay
/// behind the inserted text.
/// </summary>
Default,
/// <summary>
/// When text is inserted at the anchor position, the anchor will stay
/// before the inserted text.
/// </summary>
BeforeInsertion,
/// <summary>
/// When text is insered at the anchor position, the anchor will move
/// after the inserted text.
/// </summary>
AfterInsertion
}
}

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextAnchorTree.cs

@ -7,6 +7,7 @@ using System.Diagnostics; @@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Text;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{

101
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs

@ -6,11 +6,11 @@ using System.Collections.Generic; @@ -6,11 +6,11 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Globalization;
using System.Linq.Expressions;
using System.Threading;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
@ -22,7 +22,7 @@ namespace ICSharpCode.AvalonEdit.Document @@ -22,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, INotifyPropertyChanged
public sealed class TextDocument : IDocument, INotifyPropertyChanged
{
#region Thread ownership
readonly object lockObject = new object();
@ -196,6 +196,11 @@ namespace ICSharpCode.AvalonEdit.Document @@ -196,6 +196,11 @@ namespace ICSharpCode.AvalonEdit.Document
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler TextChanged;
event EventHandler IDocument.ChangeCompleted {
add { this.TextChanged += value; }
remove { this.TextChanged -= value; }
}
/// <inheritdoc/>
public int TextLength {
get {
@ -257,12 +262,27 @@ namespace ICSharpCode.AvalonEdit.Document @@ -257,12 +262,27 @@ namespace ICSharpCode.AvalonEdit.Document
/// </remarks>
public event EventHandler<DocumentChangeEventArgs> Changing;
// Unfortunately EventHandler<T> is invariant, so we have to use two separate events
private event EventHandler<TextChangeEventArgs> textChanging;
event EventHandler<TextChangeEventArgs> IDocument.TextChanging {
add { textChanging += value; }
remove { textChanging -= value; }
}
/// <summary>
/// Is raised after the document has changed.
/// </summary>
/// <remarks><inheritdoc cref="Changing"/></remarks>
public event EventHandler<DocumentChangeEventArgs> Changed;
private event EventHandler<TextChangeEventArgs> textChanged;
event EventHandler<TextChangeEventArgs> IDocument.TextChanged {
add { textChanged += value; }
remove { textChanged -= value; }
}
/// <summary>
/// Creates a snapshot of the current text.
/// </summary>
@ -282,6 +302,17 @@ namespace ICSharpCode.AvalonEdit.Document @@ -282,6 +302,17 @@ namespace ICSharpCode.AvalonEdit.Document
}
}
/// <summary>
/// Creates a snapshot of a part of the current text.
/// </summary>
/// <remarks><inheritdoc cref="CreateSnapshot()"/></remarks>
public ITextSource CreateSnapshot(int offset, int length)
{
lock (lockObject) {
return new RopeTextSource(rope.GetRange(offset, length));
}
}
/// <summary>
/// Creates a snapshot of the current text.
/// Additionally, creates a checkpoint that allows tracking document changes.
@ -307,22 +338,23 @@ namespace ICSharpCode.AvalonEdit.Document @@ -307,22 +338,23 @@ namespace ICSharpCode.AvalonEdit.Document
}
}
/// <summary>
/// Creates a snapshot of a part of the current text.
/// </summary>
/// <remarks><inheritdoc cref="CreateSnapshot()"/></remarks>
public ITextSource CreateSnapshot(int offset, int length)
ITextSourceVersion ITextSource.Version {
get { return CreateChangeTrackingCheckpoint(); }
}
/// <inheritdoc/>
public System.IO.TextReader CreateReader()
{
lock (lockObject) {
return new RopeTextSource(rope.GetRange(offset, length));
return new RopeTextReader(rope);
}
}
/// <inheritdoc/>
public System.IO.TextReader CreateReader()
public System.IO.TextReader CreateReader(int offset, int length)
{
lock (lockObject) {
return new RopeTextReader(rope);
return new RopeTextReader(rope.GetRange(offset, length));
}
}
#endregion
@ -613,6 +645,8 @@ namespace ICSharpCode.AvalonEdit.Document @@ -613,6 +645,8 @@ namespace ICSharpCode.AvalonEdit.Document
// fire DocumentChanging event
if (Changing != null)
Changing(this, args);
if (textChanging != null)
textChanging(this, args);
undoStack.Push(this, args);
@ -661,6 +695,8 @@ namespace ICSharpCode.AvalonEdit.Document @@ -661,6 +695,8 @@ namespace ICSharpCode.AvalonEdit.Document
// fire DocumentChanged event
if (Changed != null)
Changed(this, args);
if (textChanged != null)
textChanged(this, args);
}
#endregion
@ -684,6 +720,11 @@ namespace ICSharpCode.AvalonEdit.Document @@ -684,6 +720,11 @@ namespace ICSharpCode.AvalonEdit.Document
return lineTree.GetByNumber(number);
}
IDocumentLine IDocument.GetLineByNumber(int lineNumber)
{
return GetLineByNumber(lineNumber);
}
/// <summary>
/// Gets a document lines by offset.
/// Runtime: O(log n)
@ -697,8 +738,14 @@ namespace ICSharpCode.AvalonEdit.Document @@ -697,8 +738,14 @@ namespace ICSharpCode.AvalonEdit.Document
}
return lineTree.GetByOffset(offset);
}
IDocumentLine IDocument.GetLineByOffset(int offset)
{
return GetLineByOffset(offset);
}
#endregion
#region GetOffset / GetLocation
/// <summary>
/// Gets the offset from a text location.
/// </summary>
@ -731,7 +778,9 @@ namespace ICSharpCode.AvalonEdit.Document @@ -731,7 +778,9 @@ namespace ICSharpCode.AvalonEdit.Document
DocumentLine line = GetLineByOffset(offset);
return new TextLocation(line.LineNumber, offset - line.Offset + 1);
}
#endregion
#region Line Trackers
readonly ObservableCollection<ILineTracker> lineTrackers = new ObservableCollection<ILineTracker>();
/// <summary>
@ -744,7 +793,9 @@ namespace ICSharpCode.AvalonEdit.Document @@ -744,7 +793,9 @@ namespace ICSharpCode.AvalonEdit.Document
return lineTrackers;
}
}
#endregion
#region UndoStack
UndoStack undoStack;
/// <summary>
@ -764,7 +815,9 @@ namespace ICSharpCode.AvalonEdit.Document @@ -764,7 +815,9 @@ namespace ICSharpCode.AvalonEdit.Document
}
}
}
#endregion
#region CreateAnchor
/// <summary>
/// Creates a new <see cref="TextAnchor"/> at the specified offset.
/// </summary>
@ -778,6 +831,12 @@ namespace ICSharpCode.AvalonEdit.Document @@ -778,6 +831,12 @@ namespace ICSharpCode.AvalonEdit.Document
return anchorTree.CreateAnchor(offset);
}
ITextAnchor IDocument.CreateAnchor(int offset)
{
return CreateAnchor(offset);
}
#endregion
#region LineCount
/// <summary>
/// Gets the total number of lines in the document.
@ -832,5 +891,25 @@ namespace ICSharpCode.AvalonEdit.Document @@ -832,5 +891,25 @@ namespace ICSharpCode.AvalonEdit.Document
#endif
}
#endregion
void IDocument.Insert(int offset, string text, AnchorMovementType defaultAnchorMovementType)
{
throw new NotImplementedException();
}
void IDocument.StartUndoableAction()
{
throw new NotImplementedException();
}
void IDocument.EndUndoableAction()
{
throw new NotImplementedException();
}
IDisposable IDocument.OpenUndoGroup()
{
throw new NotImplementedException();
}
}
}

166
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextLocation.cs

@ -1,166 +0,0 @@ @@ -1,166 +0,0 @@
// 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;
using System.Globalization;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>
/// A line/column position.
/// Text editor lines/columns are counted started from one.
/// </summary>
/// <remarks>
/// The document provides the methods <see cref="TextDocument.GetLocation"/> and
/// <see cref="TextDocument.GetOffset(TextLocation)"/> to convert between offsets and TextLocations.
/// </remarks>
public struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>
{
/// <summary>
/// Represents no text location (0, 0).
/// </summary>
public static readonly TextLocation Empty = new TextLocation(0, 0);
/// <summary>
/// Creates a TextLocation instance.
/// <para>
/// Warning: the parameters are (line, column).
/// Not (column, line) as in ICSharpCode.TextEditor!
/// </para>
/// </summary>
public TextLocation(int line, int column)
{
y = line;
x = column;
}
int x, y;
/// <summary>
/// Gets the line number.
/// </summary>
public int Line {
get { return y; }
}
/// <summary>
/// Gets the column number.
/// </summary>
public int Column {
get { return x; }
}
/// <summary>
/// Gets whether the TextLocation instance is empty.
/// </summary>
public bool IsEmpty {
get {
return x <= 0 && y <= 0;
}
}
/// <summary>
/// Gets a string representation for debugging purposes.
/// </summary>
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "(Line {1}, Col {0})", this.x, this.y);
}
/// <summary>
/// Gets a hash code.
/// </summary>
public override int GetHashCode()
{
return unchecked (87 * x.GetHashCode() ^ y.GetHashCode());
}
/// <summary>
/// Equality test.
/// </summary>
public override bool Equals(object obj)
{
if (!(obj is TextLocation)) return false;
return (TextLocation)obj == this;
}
/// <summary>
/// Equality test.
/// </summary>
public bool Equals(TextLocation other)
{
return this == other;
}
/// <summary>
/// Equality test.
/// </summary>
public static bool operator ==(TextLocation left, TextLocation right)
{
return left.x == right.x && left.y == right.y;
}
/// <summary>
/// Inequality test.
/// </summary>
public static bool operator !=(TextLocation left, TextLocation right)
{
return left.x != right.x || left.y != right.y;
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator <(TextLocation left, TextLocation right)
{
if (left.y < right.y)
return true;
else if (left.y == right.y)
return left.x < right.x;
else
return false;
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator >(TextLocation left, TextLocation right)
{
if (left.y > right.y)
return true;
else if (left.y == right.y)
return left.x > right.x;
else
return false;
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator <=(TextLocation left, TextLocation right)
{
return !(left > right);
}
/// <summary>
/// Compares two text locations.
/// </summary>
public static bool operator >=(TextLocation left, TextLocation right)
{
return !(left < right);
}
/// <summary>
/// Compares two text locations.
/// </summary>
public int CompareTo(TextLocation other)
{
if (this == other)
return 0;
if (this < other)
return -1;
else
return 1;
}
}
}

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegment.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Diagnostics;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
// 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 ICSharpCode.AvalonEdit.Utils;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -10,6 +9,9 @@ using System.Linq; @@ -10,6 +9,9 @@ using System.Linq;
using System.Text;
using System.Windows;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextUtilities.cs

@ -5,6 +5,8 @@ using System; @@ -5,6 +5,8 @@ using System;
using System.Globalization;
using System.Windows.Documents;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Document
{
/// <summary>

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -12,13 +12,14 @@ using System.Windows.Threading; @@ -12,13 +12,14 @@ using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{
/// <summary>
/// Helper class with caret-related methods.
/// </summary>
public sealed class Caret
public sealed class Caret : ITextEditorCaret
{
readonly TextArea textArea;
readonly TextView textView;
@ -226,6 +227,11 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -226,6 +227,11 @@ namespace ICSharpCode.AvalonEdit.Editing
/// </summary>
public event EventHandler PositionChanged;
event EventHandler ITextEditorCaret.LocationChanged {
add { this.PositionChanged += value; }
remove { this.PositionChanged -= value; }
}
bool raisePositionChangedOnUpdateFinished;
void RaisePositionChanged()

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EditingCommandHandler.cs

@ -8,7 +8,6 @@ using System.Globalization; @@ -8,7 +8,6 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
@ -16,6 +15,7 @@ using System.Windows.Input; @@ -16,6 +15,7 @@ using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/IReadOnlySectionProvider.cs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

5
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/NoReadOnlySections.cs

@ -2,10 +2,11 @@ @@ -2,10 +2,11 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document;
using System.Linq;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs

@ -8,7 +8,7 @@ using System.Linq; @@ -8,7 +8,7 @@ using System.Linq;
using System.Text;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs

@ -8,6 +8,7 @@ using System.Windows; @@ -8,6 +8,7 @@ using System.Windows;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionColorizer.cs

@ -2,9 +2,8 @@ @@ -2,9 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs

@ -14,6 +14,7 @@ using System.Windows.Threading; @@ -14,6 +14,7 @@ using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs

@ -3,10 +3,9 @@ @@ -3,10 +3,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextArea.cs

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
@ -11,16 +10,15 @@ using System.Linq; @@ -11,16 +10,15 @@ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Indentation;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextSegmentReadOnlySectionProvider.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Editing
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/AbstractFoldingStrategy.cs

@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.AvalonEdit.Document;
using System.Collections.Generic;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Folding
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs

@ -7,6 +7,7 @@ using System.Windows; @@ -7,6 +7,7 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;

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

@ -6,12 +6,10 @@ using System.Collections.Generic; @@ -6,12 +6,10 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Folding
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;

10
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/NewFolding.cs

@ -2,15 +2,7 @@ @@ -2,15 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Folding
{

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedLine.cs

@ -5,10 +5,10 @@ using System; @@ -5,10 +5,10 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Highlighting
{
@ -111,7 +111,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -111,7 +111,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
List<HtmlElement> elements = new List<HtmlElement>();
for (int i = 0; i < this.Sections.Count; i++) {
HighlightedSection s = this.Sections[i];
if (s.GetOverlap(requestedSegment).Length > 0) {
if (SimpleSegment.GetOverlap(s, requestedSegment).Length > 0) {
elements.Add(new HtmlElement(s.Offset, i, false, s.Color));
elements.Add(new HtmlElement(s.Offset + s.Length, i, true, s.Color));
}

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightedSection.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Highlighting
{

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HtmlClipboard.cs

@ -9,6 +9,7 @@ using System.Text; @@ -9,6 +9,7 @@ using System.Text;
using System.Windows;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Highlighting
{
@ -86,7 +87,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting @@ -86,7 +87,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
highlightedLine = highlighter.HighlightLine(line.LineNumber);
else
highlightedLine = new HighlightedLine(document, line);
SimpleSegment s = segment.GetOverlap(line);
SimpleSegment s = SimpleSegment.GetOverlap(segment, line);
if (html.Length > 0)
html.AppendLine("<br>");
html.Append(highlightedLine.ToHtml(s.Offset, s.EndOffset, options));

11
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj

@ -102,8 +102,8 @@ @@ -102,8 +102,8 @@
<DependentUpon>UndoStack.cs</DependentUpon>
</Compile>
<Compile Include="Document\ILineTracker.cs" />
<Compile Include="Document\ISegment.cs" />
<Compile Include="Document\ITextSource.cs" />
<Compile Include="Document\SimpleSegment.cs" />
<Compile Include="Document\RopeTextSource.cs" />
<Compile Include="Document\IUndoableOperation.cs">
<DependentUpon>UndoStack.cs</DependentUpon>
</Compile>
@ -123,7 +123,6 @@ @@ -123,7 +123,6 @@
<Compile Include="Document\TextAnchorTree.cs">
<DependentUpon>TextAnchor.cs</DependentUpon>
</Compile>
<Compile Include="Document\TextLocation.cs" />
<Compile Include="Document\TextSegment.cs" />
<Compile Include="Document\TextUtilities.cs" />
<Compile Include="Document\UndoOperationGroup.cs">
@ -412,4 +411,10 @@ @@ -412,4 +411,10 @@
<ItemGroup>
<EmbeddedResource Include="Highlighting\Resources\CSS-Mode.xshd" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\NRefactory\ICSharpCode.Editor\ICSharpCode.Editor.csproj">
<Project>{F054A788-B591-4561-A8BA-AE745BBEB817}</Project>
<Name>ICSharpCode.Editor</Name>
</ProjectReference>
</ItemGroup>
</Project>

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Indentation/DefaultIndentationStrategy.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
// 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 ICSharpCode.AvalonEdit.Utils;
using System;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Indentation
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs

@ -8,8 +8,8 @@ using System.Windows; @@ -8,8 +8,8 @@ using System.Windows;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Rendering
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -19,6 +19,7 @@ using System.Windows.Threading; @@ -19,6 +19,7 @@ using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Rendering
{

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/IActiveElement.cs

@ -2,8 +2,7 @@ @@ -2,8 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/InsertionContext.cs

@ -4,11 +4,10 @@ @@ -4,11 +4,10 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{

5
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/Snippet.cs

@ -2,12 +2,9 @@ @@ -2,12 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetAnchorElement.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{

3
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetBoundElement.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{
@ -91,7 +92,7 @@ namespace ICSharpCode.AvalonEdit.Snippets @@ -91,7 +92,7 @@ namespace ICSharpCode.AvalonEdit.Snippets
{
// Don't copy text if the segments overlap (we would get an endless loop).
// This can happen if the user deletes the text between the replaceable element and the bound element.
if (segment.GetOverlap(targetElement.Segment) == SimpleSegment.Invalid) {
if (SimpleSegment.GetOverlap(segment, targetElement.Segment) == SimpleSegment.Invalid) {
int offset = segment.Offset;
int length = segment.Length;
string text = boundElement.ConvertText(targetElement.Text);

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetCaretElement.cs

@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetContainerElement.cs

@ -3,10 +3,8 @@ @@ -3,10 +3,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Snippets

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetElement.cs

@ -2,12 +2,8 @@ @@ -2,12 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils;
namespace ICSharpCode.AvalonEdit.Snippets
{
/// <summary>

4
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetInputHandler.cs

@ -2,12 +2,10 @@ @@ -2,12 +2,10 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing;
namespace ICSharpCode.AvalonEdit.Snippets

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetReplaceableTextElement.cs

@ -6,10 +6,10 @@ using System.Linq; @@ -6,10 +6,10 @@ using System.Linq;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit.Snippets
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetSelectionElement.cs

@ -3,8 +3,6 @@ @@ -3,8 +3,6 @@
using System;
using System.Text;
using System.Windows.Input;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Snippets
{

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Snippets/SnippetTextElement.cs

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
using System;
using System.Windows.Documents;
using ICSharpCode.AvalonEdit.Document;
namespace ICSharpCode.AvalonEdit.Snippets
{

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextViewPosition.cs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
using System;
using System.Globalization;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Editor;
namespace ICSharpCode.AvalonEdit
{

Loading…
Cancel
Save