AvalonEdit
TextSegment Class
NamespacesICSharpCode.AvalonEdit.DocumentTextSegment
A segment that can be put into a TextSegmentCollection<(Of <(<'T>)>)>.
Declaration Syntax
C#Visual BasicVisual C++
public class TextSegment : ISegment
Public Class TextSegment _
	Implements ISegment
public ref class TextSegment : ISegment
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
TextSegment()()()()
Initializes a new instance of the TextSegment class

Contains(ISegment, Int32, Int32)
Gets whether segment fully contains the specified segment.
(Inherited from ISegmentExtensions.)
Contains(ISegment, ISegment)
Gets whether thisSegment fully contains the specified segment.
(Inherited from ISegmentExtensions.)
EndOffset
Gets/Sets the end offset of the segment.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Finalize()()()()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()()
Gets the Type of the current instance.
(Inherited from Object.)
IsConnectedToCollection
Gets whether this segment is connected to a TextSegmentCollection and will automatically update its offsets.

Length
Gets/Sets the length of the segment.

MemberwiseClone()()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
OnSegmentChanged()()()()
This method gets called when the StartOffset/Length/EndOffset properties are set. It is not called when StartOffset/Length/EndOffset change due to document changes

StartOffset
Gets/Sets the start offset of the segment.

ToString()()()()
Returns a String that represents the current Object.
(Overrides Object.ToString()()()().)
Remarks

A TextSegment can be stand-alone or part of a TextSegmentCollection<(Of <(<'T>)>)>. If the segment is stored inside a TextSegmentCollection, its Offset and Length will be updated by that collection.

When the document changes, the offsets of all text segments in the TextSegmentCollection will be adjusted accordingly. Start offsets move like AnchorMovementType.AfterInsertion, end offsets move like AnchorMovementType.BeforeInsertion (i.e. the segment will always stay as small as possible).

If a document change causes a segment to be deleted completely, it will be reduced to length 0, but segments are never automatically removed from the collection. Segments with length 0 will never expand due to document changes, and they move as AfterInsertion.

Thread-safety: a TextSegmentCollection that is connected to a TextDocument may only be used on that document's owner thread. A disconnected TextSegmentCollection is safe for concurrent reads, but concurrent access is not safe when there are writes. Keep in mind that reading the Offset properties of a text segment inside the collection is a read access on the collection; and setting an Offset property of a text segment is a write access on the collection.

Inheritance Hierarchy
See Also

Assembly: ICSharpCode.AvalonEdit (Module: ICSharpCode.AvalonEdit.dll) Version: 5.0.0.4238