ICSharpCode.AvalonEdit
Custom commands for AvalonEdit.
Toggles Overstrike mode
The default shortcut is Ins.
Deletes the current line.
The default shortcut is Ctrl+D.
Removes leading whitespace from the selected lines (or the whole document if the selection is empty).
Removes trailing whitespace from the selected lines (or the whole document if the selection is empty).
Converts the selected text to upper case.
Converts the selected text to lower case.
Converts the selected text to title case.
Inverts the case of the selected text.
Converts tabs to spaces in the selected text.
Converts spaces to tabs in the selected text.
Converts leading tabs to spaces in the selected lines (or the whole document if the selection is empty).
Converts leading spaces to tabs in the selected lines (or the whole document if the selection is empty).
Runs the IIndentationStrategy on the selected lines (or the whole document if the selection is empty).
The listbox used inside the CompletionWindow, contains CompletionListBox.
If true, the CompletionList is filtered to show only matching items. Also enables search by substring.
If false, enables the old behavior: no filtering, search by string.StartsWith.
Dependency property for .
Content of EmptyTemplate will be shown when CompletionList contains no items.
If EmptyTemplate is null, nothing will be shown.
Is raised when the completion list indicates that the user has chosen
an entry to be completed.
Raises the InsertionRequested event.
Gets the list box.
Gets the scroll viewer used in this list box.
Gets the list to which completion data can be added.
Handles a key press. Used to let the completion list handle key presses while the
focus is still on the text editor.
Gets/Sets the selected item.
The setter of this property does not scroll to the selected item.
You might want to also call .
Scrolls the specified item into view.
Occurs when the SelectedItem property changes.
Selects the best match, and filter the items if turned on using .
Filters CompletionList items to show only those matching given query, and selects the best match.
Selects the item that starts with the specified query.
The list box used inside the CompletionList.
Gets the number of the first visible item.
Gets the number of visible items.
Removes the selection.
Selects the item with the specified index and scrolls it into view.
Centers the view on the item with the specified index.
The code completion window.
Gets the completion list used in this completion window.
Creates a new code completion window.
Gets/Sets whether the completion window should close automatically.
The default value is true.
When this flag is set, code completion closes if the caret moves to the
beginning of the allowed range. This is useful in Ctrl+Space and "complete when typing",
but not in dot-completion.
Has no effect if CloseAutomatically is false.
Base class for completion windows. Handles positioning the window at the caret.
Gets the parent TextArea.
Gets/Sets the start of the text range in which the completion window stays open.
This text portion is used to determine the text used to select an entry in the completion list by typing.
Gets/Sets the end of the text range in which the completion window stays open.
This text portion is used to determine the text used to select an entry in the completion list by typing.
Gets whether the window was opened above the current line.
Creates a new CompletionWindowBase.
Detaches events from the text area.
A dummy input handler (that justs invokes the default input handler).
This is used to ensure the completion window closes when any other input handler
becomes active.
Raises a tunnel/bubble event pair for a WPF control.
The WPF control for which the event should be raised.
The tunneling event.
The bubbling event.
The event args to use.
The value of the event args.
Activates the parent window.
Gets whether the completion window should automatically close when the text editor looses focus.
Positions the completion window at the specified position.
Updates the position of the CompletionWindow based on the parent TextView position and the screen working area.
It ensures that the CompletionWindow is completely visible on the screen.
Gets/sets whether the completion window should expect text insertion at the start offset,
which not go into the completion region, but before it.
This property allows only a single insertion, it is reset to false
when that insertion has occurred.
Describes an entry in the .
Note that the CompletionList uses WPF data binding against the properties in this interface.
Thus, your implementation of the interface must use public properties; not explicit interface implementation.
Gets the image.
Gets the text. This property is used to filter the list of visible elements.
The displayed content. This can be the same as 'Text', or a WPF UIElement if
you want to display rich content.
Gets the description.
Gets the priority. This property is used in the selection logic. You can use it to prefer selecting those items
which the user is accessing most frequently.
Perform the completion.
The text area on which completion is performed.
The text segment that was used by the completion window if
the user types (segment between CompletionWindow.StartOffset and CompletionWindow.EndOffset).
The EventArgs used for the insertion request.
These can be TextCompositionEventArgs, KeyEventArgs, MouseEventArgs, depending on how
the insertion was triggered.
A popup-like window that is attached to a text segment.
Creates a new InsightWindow.
Gets/Sets whether the insight window should close automatically.
The default value is true.
TemplateSelector for InsightWindow to replace plain string content by a TextBlock with TextWrapping.
Provides the items for the OverloadViewer.
Gets/Sets the selected index.
Gets the number of overloads.
Gets the text 'SelectedIndex of Count'.
Gets the current header.
Gets the current content.
Insight window that shows an OverloadViewer.
Creates a new OverloadInsightWindow.
Gets/Sets the item provider.
Represents a text between "Up" and "Down" buttons.
The text property.
Gets/Sets the text between the Up and Down buttons.
The ItemProvider property.
Gets/Sets the item provider.
Changes the selected index.
The relative index change - usual values are +1 or -1.
Describes a change of the document text.
This class is thread-safe.
Gets the OffsetChangeMap associated with this document change.
The OffsetChangeMap instance is guaranteed to be frozen and thus thread-safe.
Gets the OffsetChangeMap, or null if the default offset map (=single replacement) is being used.
Gets the new offset where the specified offset moves after this document change.
Creates a new DocumentChangeEventArgs object.
Creates a new DocumentChangeEventArgs object.
Creates a new DocumentChangeEventArgs object.
Describes a change to a TextDocument.
Represents a line inside a .
The collection contains one DocumentLine instance
for every line in the document. This collection is read-only to user code and is automatically
updated to reflect the current document content.
Internally, the DocumentLine instances are arranged in a binary tree that allows for both efficient updates and lookup.
Converting between offset and line number is possible in O(lg N) time,
and the data structure also updates all offsets in O(lg N) whenever a line is inserted or removed.
Gets if this line was deleted from the document.
Gets the number of this line.
Runtime: O(log n)
The line was deleted.
Gets the starting offset of the line in the document's text.
Runtime: O(log n)
The line was deleted.
Gets the end offset of the line in the document's text (the offset before the line delimiter).
Runtime: O(log n)
The line was deleted.
EndOffset = + .
Gets the length of this line. The length does not include the line delimiter. O(1)
This property is still available even if the line was deleted;
in that case, it contains the line's length before the deletion.
Gets the length of this line, including the line delimiter. O(1)
This property is still available even if the line was deleted;
in that case, it contains the line's length before the deletion.
Gets the length of the line delimiter.
The value is 1 for single "\r" or "\n", 2 for the "\r\n" sequence;
and 0 for the last line in the document.
This property is still available even if the line was deleted;
in that case, it contains the line delimiter's length before the deletion.
Gets the next line in the document.
The line following this line, or null if this is the last line.
Gets the previous line in the document.
The line before this line, or null if this is the first line.
Gets a string with debug output showing the line number and offset.
Does not include the line's text.
Resets the line to enable its reuse after a document rebuild.
The number of lines in this node and its child nodes.
Invariant:
nodeTotalCount = 1 + left.nodeTotalCount + right.nodeTotalCount
The total text length of this node and its child nodes.
Invariant:
nodeTotalLength = left.nodeTotalLength + documentLine.TotalLength + right.nodeTotalLength
Data structure for efficient management of the document lines (most operations are O(lg n)).
This implements an augmented red-black tree.
See for the augmented data.
NOTE: The tree is never empty, initially it contains an empty line.
Rebuild the tree, in O(n).
build a tree from a list of nodes
A TextWriter implementation that directly inserts into a document.
Creates a new DocumentTextWriter that inserts into document, starting at insertionOffset.
Gets/Sets the current insertion offset.
A document representing a source code file for refactoring.
Line and column counting starts at 1.
Offset counting starts at 0.
Gets/Sets the text of the whole document..
This event is called directly before a change is applied to the document.
It is invalid to modify the document within this event handler.
Aborting the change (by throwing an exception) is likely to cause corruption of data structures
that listen to the Changing and Changed events.
This event is called directly after a change is applied to the document.
It is invalid to modify the document within this event handler.
Aborting the event handler (by throwing an exception) is likely to cause corruption of data structures
that listen to the Changing and Changed events.
This event is called after a group of changes is completed.
Gets the number of lines in the document.
Gets the document line with the specified number.
The number of the line to retrieve. The first line has number 1.
Gets the document line that contains the specified offset.
Gets the offset from a text location.
Gets the offset from a text location.
Gets the location from an offset.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to their movement type.
For AnchorMovementType.Default, they will move behind the inserted text.
The caret will also move behind the inserted text.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to their movement type.
For AnchorMovementType.Default, they will move behind the inserted text.
The caret will also move behind the inserted text.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
The caret will also move according to the parameter.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
The caret will also move according to the parameter.
Removes text.
Starting offset of the text to be removed.
Length of the text to be removed.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
Make the document combine the following actions into a single
action for undo purposes.
Ends the undoable action started with .
Creates an undo group. Dispose the returned value to close the undo group.
An object that closes the undo group when Dispose() is called.
Creates a new at the specified offset.
Gets the name of the file the document is stored in.
Could also be a non-existent dummy file name or null if no name has been set.
Fired when the file name of the document changes.
A line inside a .
Gets the length of this line, including the line delimiter.
Gets the length of the line terminator.
Returns 1 or 2; or 0 at the end of the document.
Gets the number of this line.
The first line has the number 1.
Gets the previous line. Returns null if this is the first line in the document.
Gets the next line. Returns null if this is the last line in the document.
Gets whether the line was deleted.
Describes a change of the document text.
This class is thread-safe.
The offset at which the change occurs.
The text that was removed.
The number of characters removed.
The text that was inserted.
The number of characters inserted.
Creates a new TextChangeEventArgs object.
Creates a new TextChangeEventArgs object.
Gets the new offset where the specified offset moves after this document change.
Creates TextChangeEventArgs for the reverse change.
Allows for low-level line tracking.
The methods on this interface are called by the TextDocument's LineManager immediately after the document
has changed, *while* the DocumentLineTree is updating.
Thus, the DocumentLineTree may be in an invalid state when these methods are called.
This interface should only be used to update per-line data structures like the HeightTree.
Line trackers must not cause any events to be raised during an update to prevent other code from seeing
the invalid state.
Line trackers may be called while the TextDocument has taken a lock.
You must be careful not to dead-lock inside ILineTracker callbacks.
Is called immediately before a document line is removed.
Is called immediately before a document line changes length.
This method will be called whenever the line is changed, even when the length stays as it is.
The method might be called multiple times for a single line because
a replacement is internally handled as removal followed by insertion.
Is called immediately after a line was inserted.
The new line
The existing line before the new line
Indicates that there were changes to the document that the line tracker was not notified of.
The document is in a consistent state (but the line trackers aren't), and line trackers should
throw away their data and rebuild the document.
Notifies the line tracker that a document change (a single change, not a change group) has completed.
This method gets called after the change has been performed, but before the event
is raised.
The TextAnchor class references an offset (a position between two characters).
It automatically updates the offset when text is inserted/removed in front of the anchor.
Use the property to get the offset from a text anchor.
Use the method to create an anchor from an offset.
The document will automatically update all text anchors; and because it uses weak references to do so,
the garbage collector can simply collect the anchor object when you don't need it anymore.
Moreover, the document is able to efficiently update a large number of anchors without having to look
at each anchor object individually. Updating the offsets of all anchors usually only takes time logarithmic
to the number of anchors. Retrieving the property also runs in O(lg N).
Usage:
TextAnchor anchor = document.CreateAnchor(offset);
ChangeMyDocument();
int newOffset = anchor.Offset;
Gets the text location of this anchor.
Thrown when trying to get the Offset from a deleted anchor.
Gets the offset of the text anchor.
Thrown when trying to get the Offset from a deleted anchor.
Controls how the anchor moves.
Anchor movement is ambiguous if text is inserted exactly at the anchor's location.
Does the anchor stay before the inserted text, or does it move after it?
The property will be used to determine which of these two options the anchor will choose.
The default value is .
Specifies whether the anchor survives deletion of the text containing it.
false: The anchor is deleted when the a selection that includes the anchor is deleted.
true: The anchor is not deleted.
Gets whether the anchor was deleted.
When a piece of text containing an anchor is removed, then that anchor will be deleted.
First, the property is set to true on all deleted anchors,
then the events are raised.
You cannot retrieve the offset from an anchor that has been deleted.
This deletion behavior might be useful when using anchors for building a bookmark feature,
but in other cases you want to still be able to use the anchor. For those cases, set = true.
Occurs after the anchor was deleted.
Due to the 'weak reference' nature of text anchors, you will receive
the Deleted event only while your code holds a reference to the TextAnchor object.
Gets the line number of the anchor.
Thrown when trying to get the Offset from a deleted anchor.
Gets the column number of this anchor.
Thrown when trying to get the Offset from a deleted anchor.
Defines how a text anchor moves.
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 move
after the inserted text.
Behaves like a start marker - when text is inserted at the anchor position, the anchor will stay
before the inserted text.
Behave like an end marker - when text is inserted at the anchor position, the anchor will move
after the inserted text.
A read-only view on a (potentially mutable) text source.
The IDocument interface derives from this interface.
Gets a version identifier for this text source.
Returns null for unversioned text sources.
Creates an immutable snapshot of this text source.
Unlike all other methods in this interface, this method is thread-safe.
Creates an immutable snapshot of a part of this text source.
Unlike all other methods in this interface, this method is thread-safe.
Creates a new TextReader to read from this text source.
Creates a new TextReader to read from this text source.
Gets the total text length.
The length of the text, in characters.
This is the same as Text.Length, but is more efficient because
it doesn't require creating a String object.
Gets the whole text as string.
Gets a character at the specified position in the document.
The index of the character to get.
Offset is outside the valid range (0 to TextLength-1).
The character at the specified position.
This is the same as Text[offset], but is more efficient because
it doesn't require creating a String object.
Retrieves the text for a portion of the document.
offset or length is outside the valid range.
This is the same as Text.Substring, but is more efficient because
it doesn't require creating a String object for the whole document.
Retrieves the text for a portion of the document.
offset or length is outside the valid range.
Writes the text from this document into the TextWriter.
Writes the text from this document into the TextWriter.
Gets the index of the first occurrence of the character in the specified array.
Character to search for
Start index of the area to search.
Length of the area to search.
The first index where the character was found; or -1 if no occurrence was found.
Gets the index of the first occurrence of any character in the specified array.
Characters to search for
Start index of the area to search.
Length of the area to search.
The first index where any character was found; or -1 if no occurrence was found.
Gets the index of the first occurrence of the specified search text in this text source.
The search text
Start index of the area to search.
Length of the area to search.
String comparison to use.
The first index where the search term was found; or -1 if no occurrence was found.
Gets the index of the last occurrence of the specified character in this text source.
The search character
Start index of the area to search.
Length of the area to search.
The last index where the search term was found; or -1 if no occurrence was found.
The search proceeds backwards from (startIndex+count) to startIndex.
This is different than the meaning of the parameters on string.LastIndexOf!
Gets the index of the last occurrence of the specified search text in this text source.
The search text
Start index of the area to search.
Length of the area to search.
String comparison to use.
The last index where the search term was found; or -1 if no occurrence was found.
The search proceeds backwards from (startIndex+count) to startIndex.
This is different than the meaning of the parameters on string.LastIndexOf!
Represents a version identifier for a text source.
Versions can be used to efficiently detect whether a document has changed and needs reparsing;
or even to implement incremental parsers.
It is a separate class from ITextSource to allow the GC to collect the text source while
the version checkpoint is still in use.
Gets whether this checkpoint belongs to the same document as the other checkpoint.
Returns false when given null.
Compares the age of this checkpoint to the other checkpoint.
This method is thread-safe.
Raised if 'other' belongs to a different document than this version.
-1 if this version is older than .
0 if this version instance represents the same version as .
1 if this version is newer than .
Gets the changes from this checkpoint to the other checkpoint.
If 'other' is older than this checkpoint, reverse changes are calculated.
This method is thread-safe.
Raised if 'other' belongs to a different document than this checkpoint.
Calculates where the offset has moved in the other buffer version.
Raised if 'other' belongs to a different document than this checkpoint.
Implements the ITextSource interface using a string.
Gets a text source containing the empty string.
Creates a new StringTextSource with the given text.
Creates a new StringTextSource with the given text.
This Interface describes a the basic Undo/Redo operation
all Undo Operations must implement this interface.
Undo the last operation
Redo the last operation
Creates/Deletes lines when text is inserted/removed.
A copy of the line trackers. We need a copy so that line trackers may remove themselves
while being notified (used e.g. by WeakLineTracker)
Sets the total line length and checks the delimiter.
This method can cause line to be deleted when it contains a single '\n' character
and the previous line ends with '\r'.
Usually returns , but if line was deleted due to
the "\r\n" merge, returns the previous line.
Gets the location of the next new line character, or SimpleSegment.Invalid
if none is found.
Gets the location of the next new line character, or SimpleSegment.Invalid
if none is found.
Static helper methods for working with text.
Finds the next new line character starting at offset.
The text source to search in.
The starting offset for the search.
The string representing the new line that was found, or null if no new line was found.
The position of the first new line starting at or after ,
or -1 if no new line was found.
Gets whether the specified string is a newline sequence.
Normalizes all new lines in to be .
Gets the newline sequence used in the document at the specified line.
Gets the name of the control character.
For unknown characters, the unicode codepoint is returned as 4-digit hexadecimal value.
Gets all whitespace (' ' and '\t', but no newlines) after offset.
The text source.
The offset where the whitespace starts.
The segment containing the whitespace.
Gets all whitespace (' ' and '\t', but no newlines) before offset.
The text source.
The offset where the whitespace ends.
The segment containing the whitespace.
Gets the leading whitespace segment on the document line.
Gets the trailing whitespace segment on the document line.
Gets a single indentation segment starting at - at most one tab
or spaces.
The text source.
The offset where the indentation segment starts.
The size of an indentation unit. See .
The indentation segment.
If there is no indentation character at the specified ,
an empty segment is returned.
Gets whether the character is whitespace, part of an identifier, or line terminator.
Gets the next caret position.
The text source.
The start offset inside the text source.
The search direction (forwards or backwards).
The mode for caret positioning.
The offset of the next caret position, or -1 if there is no further caret position
in the text source.
This method is NOT equivalent to the actual caret movement when using VisualLine.GetNextCaretPosition.
In real caret movement, there are additional caret stops at line starts and ends. This method
treats linefeeds as simple whitespace.
Contains predefined offset change mapping types.
Normal replace.
Anchors in front of the replaced region will stay in front, anchors after the replaced region will stay after.
Anchors in the middle of the removed region will be deleted. If they survive deletion,
they move depending on their AnchorMovementType.
This is the default implementation of DocumentChangeEventArgs when OffsetChangeMap is null,
so using this option usually works without creating an OffsetChangeMap instance.
This is equivalent to an OffsetChangeMap with a single entry describing the replace operation.
First the old text is removed, then the new text is inserted.
Anchors immediately in front (or after) the replaced region may move to the other side of the insertion,
depending on the AnchorMovementType.
This is implemented as an OffsetChangeMap with two entries: the removal, and the insertion.
The text is replaced character-by-character.
Anchors keep their position inside the replaced text.
Anchors after the replaced region will move accordingly if the replacement text has a different length than the replaced text.
If the new text is shorter than the old text, anchors inside the old text that would end up behind the replacement text
will be moved so that they point to the end of the replacement text.
On the OffsetChangeMap level, growing text is implemented by replacing the last character in the replaced text
with itself and the additional text segment. A simple insertion of the additional text would have the undesired
effect of moving anchors immediately after the replaced text into the replacement text if they used
AnchorMovementStyle.BeforeInsertion.
Shrinking text is implemented by removing the text segment that's too long; but in a special mode that
causes anchors to always survive irrespective of their setting.
If the text keeps its old size, this is implemented as OffsetChangeMap.Empty.
Like 'Normal', but anchors with = Default will stay in front of the
insertion instead of being moved behind it.
Describes a series of offset changes.
Immutable OffsetChangeMap that is empty.
Creates a new OffsetChangeMap with a single element.
The entry.
Returns a frozen OffsetChangeMap with a single entry.
Creates a new OffsetChangeMap instance.
Gets the new offset where the specified offset moves after this document change.
Gets whether this OffsetChangeMap is a valid explanation for the specified document change.
Calculates the inverted OffsetChangeMap (used for the undo operation).
Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
Freezes this instance.
An entry in the OffsetChangeMap.
This represents the offset of a document change (either insertion or removal, not both at once).
The offset at which the change occurs.
The number of characters inserted.
Returns 0 if this entry represents a removal.
The number of characters removed.
Returns 0 if this entry represents an insertion.
Gets whether the removal should not cause any anchor deletions.
Gets whether default anchor movement causes the anchor to stay in front of the caret.
Gets the new offset where the specified offset moves after this document change.
Creates a new OffsetChangeMapEntry instance.
Creates a new OffsetChangeMapEntry instance.
Tests the two entries for equality.
Tests the two entries for inequality.
Implements the ITextSource interface using a rope.
Creates a new RopeTextSource.
Creates a new RopeTextSource.
Returns a clone of the rope used for this text source.
RopeTextSource only publishes a copy of the contained rope to ensure that the underlying rope cannot be modified.
Represents a simple segment (Offset,Length pair) that is not automatically updated
on document changes.
Gets the overlapping portion of the segments.
Returns SimpleSegment.Invalid if the segments don't overlap.
A segment using s as start and end positions.
For the constructors creating new anchors, the start position will be AfterInsertion and the end position will be BeforeInsertion.
Should the end position move before the start position, the segment will have length 0.
Creates a new AnchorSegment using the specified anchors.
The anchors must have set to true.
Creates a new AnchorSegment that creates new anchors.
Creates a new AnchorSegment that creates new anchors.
The TextAnchor class references an offset (a position between two characters).
It automatically updates the offset when text is inserted/removed in front of the anchor.
Use the property to get the offset from a text anchor.
Use the method to create an anchor from an offset.
The document will automatically update all text anchors; and because it uses weak references to do so,
the garbage collector can simply collect the anchor object when you don't need it anymore.
Moreover, the document is able to efficiently update a large number of anchors without having to look
at each anchor object individually. Updating the offsets of all anchors usually only takes time logarithmic
to the number of anchors. Retrieving the property also runs in O(lg N).
If you want to track a segment, you can use the class which
implements using two text anchors.
Usage:
TextAnchor anchor = document.CreateAnchor(offset);
ChangeMyDocument();
int newOffset = anchor.Offset;
Gets the document owning the anchor.
Gets the offset of the text anchor.
Thrown when trying to get the Offset from a deleted anchor.
Gets the line number of the anchor.
Thrown when trying to get the Offset from a deleted anchor.
Gets the column number of this anchor.
Thrown when trying to get the Offset from a deleted anchor.
Gets the text location of this anchor.
Thrown when trying to get the Offset from a deleted anchor.
A TextAnchorNode is placed in the TextAnchorTree.
It describes a section of text with a text anchor at the end of the section.
A weak reference is used to refer to the TextAnchor. (to save memory, we derive from WeakReference instead of referencing it)
Gets the inorder successor of the node.
Gets the inorder predecessor of the node.
A tree of TextAnchorNodes.
Swaps the anchors stored in the two nodes.
Finds the node at the specified offset.
After the method has run, offset is relative to the beginning of the returned node.
This class is the main class of the text model. Basically, it is a with events.
Thread safety:
However, there is a single method that is thread-safe: (and its overloads).
Verifies that the current thread is the documents owner thread.
Throws an if the wrong thread accesses the TextDocument.
The TextDocument class is not thread-safe. A document instance expects to have a single owner thread
and will throw an when accessed from another thread.
It is possible to change the owner thread using the method.
Transfers ownership of the document to another thread. This method can be used to load
a file into a TextDocument on a background thread and then transfer ownership to the UI thread
for displaying the document.
The owner can be set to null, which means that no thread can access the document. But, if the document
has no owner thread, any thread may take ownership by calling .
Create an empty text document.
Create a new text document with the specified initial text.
Create a new text document with the specified initial text.
Retrieves the text for a portion of the document.
Gets/Sets the text of the whole document.
This event is called after a group of changes is completed.
Is raised when one of the properties , , ,
changes.
Is raised before the document changes.
Here is the order in which events are raised during a document update:
- BeginUpdate()
- Start of change group (on undo stack)
- event is raised
- Insert() / Remove() / Replace()
- event is raised
- The document is changed
- TextAnchor.Deleted event is raised if anchors were
in the deleted text portion
- event is raised
- EndUpdate()
- event is raised
- event is raised (for the Text, TextLength, LineCount properties, in that order)
- End of change group (on undo stack)
- event is raised
If the insert/remove/replace methods are called without a call to BeginUpdate(),
they will call BeginUpdate() and EndUpdate() to ensure no change happens outside of UpdateStarted/UpdateFinished.
There can be multiple document changes between the BeginUpdate() and EndUpdate() calls.
In this case, the events associated with EndUpdate will be raised only once after the whole document update is done.
The listens to the UpdateStarted and UpdateFinished events to group all changes into a single undo step.
Is raised after the document has changed.
Creates a snapshot of the current text.
This method returns an immutable snapshot of the document, and may be safely called even when
the document's owner thread is concurrently modifying the document.
This special thread-safety guarantee is valid only for TextDocument.CreateSnapshot(), not necessarily for other
classes implementing ITextSource.CreateSnapshot().
Creates a snapshot of a part of the current text.
Gets if an update is running.
Immediately calls ,
and returns an IDisposable that calls .
Begins a group of document changes.
Some events are suspended until EndUpdate is called, and the will
group all changes into a single action.
Calling BeginUpdate several times increments a counter, only after the appropriate number
of EndUpdate calls the events resume their work.
Ends a group of document changes.
Occurs when a document change starts.
Occurs when a document change is finished.
Fires TextChanged, TextLengthChanged, LineCountChanged if required.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to their movement type.
For AnchorMovementType.Default, they will move behind the inserted text.
The caret will also move behind the inserted text.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to their movement type.
For AnchorMovementType.Default, they will move behind the inserted text.
The caret will also move behind the inserted text.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
The caret will also move according to the parameter.
Inserts text.
The offset at which the text is inserted.
The new text.
Anchors positioned exactly at the insertion offset will move according to the anchor's movement type.
For AnchorMovementType.Default, they will move according to the movement type specified by this parameter.
The caret will also move according to the parameter.
Removes text.
Removes text.
Starting offset of the text to be removed.
Length of the text to be removed.
Replaces text.
Replaces text.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
The offsetChangeMappingType determines how offsets inside the old text are mapped to the new text.
This affects how the anchors and segments inside the replaced region behave.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
The offsetChangeMappingType determines how offsets inside the old text are mapped to the new text.
This affects how the anchors and segments inside the replaced region behave.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
The offsetChangeMap determines how offsets inside the old text are mapped to the new text.
This affects how the anchors and segments inside the replaced region behave.
If you pass null (the default when using one of the other overloads), the offsets are changed as
in OffsetChangeMappingType.Normal mode.
If you pass OffsetChangeMap.Empty, then everything will stay in its old place (OffsetChangeMappingType.CharacterReplace mode).
The offsetChangeMap must be a valid 'explanation' for the document change. See .
Passing an OffsetChangeMap to the Replace method will automatically freeze it to ensure the thread safety of the resulting
DocumentChangeEventArgs instance.
Replaces text.
The starting offset of the text to be replaced.
The length of the text to be replaced.
The new text.
The offsetChangeMap determines how offsets inside the old text are mapped to the new text.
This affects how the anchors and segments inside the replaced region behave.
If you pass null (the default when using one of the other overloads), the offsets are changed as
in OffsetChangeMappingType.Normal mode.
If you pass OffsetChangeMap.Empty, then everything will stay in its old place (OffsetChangeMappingType.CharacterReplace mode).
The offsetChangeMap must be a valid 'explanation' for the document change. See .
Passing an OffsetChangeMap to the Replace method will automatically freeze it to ensure the thread safety of the resulting
DocumentChangeEventArgs instance.
Gets a read-only list of lines.
Gets a line by the line number: O(log n)
Gets a document lines by offset.
Runtime: O(log n)
Gets the offset from a text location.
Gets the offset from a text location.
Gets the location from an offset.
Gets the list of s attached to this document.
You can add custom line trackers to this list.
Gets the of the document.
This property can also be used to set the undo stack, e.g. for sharing a common undo stack between multiple documents.
Creates a new at the specified offset.
Gets the total number of lines in the document.
Runtime: O(1).
Gets the document lines tree in string form.
Gets the text anchor tree in string form.
Gets/Sets the service provider associated with this document.
By default, every TextDocument has its own ServiceContainer; and has the document itself
registered as and .
Contains weak event managers for the TextDocument events.
Weak event manager for the event.
Weak event manager for the event.
Weak event manager for the event.
Weak event manager for the event.
Weak event manager for the event.
A line/column position.
Text editor lines/columns are counted started from one.
The document provides the methods and
to convert between offsets and TextLocations.
Represents no text location (0, 0).
Creates a TextLocation instance.
Gets the line number.
Gets the column number.
Gets whether the TextLocation instance is empty.
Gets a string representation for debugging purposes.
Gets a hash code.
Equality test.
Equality test.
Equality test.
Inequality test.
Compares two text locations.
Compares two text locations.
Compares two text locations.
Compares two text locations.
Compares two text locations.
Converts strings of the form '0+[;,]0+' to a .
An (Offset,Length)-pair.
Gets the start offset of the segment.
Gets the length of the segment.
For line segments (IDocumentLine), the length does not include the line delimiter.
Gets the end offset of the segment.
EndOffset = Offset + Length;
Extension methods for .
Gets whether fully contains the specified segment.
Use segment.Contains(offset, 0) to detect whether a segment (end inclusive) contains offset;
use segment.Contains(offset, 1) to detect whether a segment (end exclusive) contains offset.
Gets whether fully contains the specified segment.
A segment that can be put into a .
A can be stand-alone or part of a .
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 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.
The color of the segment in the red/black tree.
The "length" of the node (distance to previous node)
The total "length" of this subtree.
The length of the segment (do not confuse with nodeLength).
distanceToMaxEnd = Max(segmentLength,
left.distanceToMaxEnd + left.Offset - Offset,
left.distanceToMaxEnd + right.Offset - Offset)
Gets whether this segment is connected to a TextSegmentCollection and will automatically
update its offsets.
Gets/Sets the start offset of the segment.
When setting the start offset, the end offset will change, too: the Length of the segment will stay constant.
Gets/Sets the end offset of the segment.
Setting the end offset will change the length, the start offset will stay constant.
Gets/Sets the length of the segment.
Setting the length will change the end offset, the start offset will stay constant.
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
Gets the inorder successor of the node.
Gets the inorder predecessor of the node.
Interface to allow TextSegments to access the TextSegmentCollection - we cannot use a direct reference
because TextSegmentCollection is generic.
A collection of text segments that supports efficient lookup of segments
intersecting with another segment.
Creates a new TextSegmentCollection that needs manual calls to .
Creates a new TextSegmentCollection that updates the offsets automatically.
The document to which the text segments
that will be added to the tree belong. When the document changes, the
position of the text segments will be updated accordingly.
Updates the start and end offsets of all segments stored in this collection.
DocumentChangeEventArgs instance describing the change to the document.
Updates the start and end offsets of all segments stored in this collection.
OffsetChangeMapEntry instance describing the change to the document.
Adds the specified segment to the tree. This will cause the segment to update when the
document changes.
Gets the next segment after the specified segment.
Segments are sorted by their start offset.
Returns null if segment is the last segment.
Gets the previous segment before the specified segment.
Segments are sorted by their start offset.
Returns null if segment is the first segment.
Returns the first segment in the collection or null, if the collection is empty.
Returns the last segment in the collection or null, if the collection is empty.
Gets the first segment with a start offset greater or equal to .
Returns null if no such segment is found.
Finds the node at the specified offset.
After the method has run, offset is relative to the beginning of the returned node.
Finds all segments that contain the given offset.
(StartOffset <= offset <= EndOffset)
Segments are returned in the order given by GetNextSegment/GetPreviousSegment.
Returns a new collection containing the results of the query.
This means it is safe to modify the TextSegmentCollection while iterating through the result collection.
Finds all segments that overlap with the given segment (including touching segments).
Returns a new collection containing the results of the query.
This means it is safe to modify the TextSegmentCollection while iterating through the result collection.
Finds all segments that overlap with the given segment (including touching segments).
Segments are returned in the order given by GetNextSegment/GetPreviousSegment.
Returns a new collection containing the results of the query.
This means it is safe to modify the TextSegmentCollection while iterating through the result collection.
Removes the specified segment from the tree. This will cause the segment to not update
anymore when the document changes.
Removes all segments from the tree.
Gets the number of segments in the tree.
Gets whether this tree contains the specified item.
Copies all segments in this SegmentTree to the specified array.
Gets an enumerator to enumerate the segments.
Provides ITextSourceVersion instances.
Creates a new TextSourceVersionProvider instance.
Gets the current version.
Replaces the current version with a new version.
Change from current version to new version
Specifies the mode for getting the next caret position.
Normal positioning (stop after every grapheme)
Stop only on word borders.
Stop only at the beginning of words. This is used for Ctrl+Left/Ctrl+Right.
Stop only at the beginning of words, and anywhere in the middle of symbols.
Stop only on word borders, and anywhere in the middle of symbols.
Stop between every Unicode codepoint, even within the same grapheme.
This is used to implement deleting the previous grapheme when Backspace is pressed.
Classifies a character as whitespace, line terminator, part of an identifier, or other.
The character is not whitespace, line terminator or part of an identifier.
The character is whitespace (but not line terminator).
The character can be part of an identifier (Letter, digit or underscore).
The character is line terminator (\r or \n).
The character is a unicode combining mark that modifies the previous character.
Corresponds to the Unicode designations "Mn", "Mc" and "Me".
This class stacks the last x operations from the undostack and makes
one undo/redo operation from it.
Undo stack implementation.
undo stack is listening for changes
undo stack is reverting/repeating a set of changes
state is used for checking that no one but the UndoStack performs changes
during Undo events
Number of times undo must be executed until the original state is reached.
Negative: number of times redo must be executed until the original state is reached.
Special case: int.MinValue == original state is unreachable
Gets whether the document is currently in its original state (no modifications).
Marks the current state as original. Discards any previous "original" markers.
Discards the current "original" marker.
Gets if the undo stack currently accepts changes.
Is false while an undo action is running.
Gets if there are actions on the undo stack.
Use the PropertyChanged event to listen to changes of this property.
Gets if there are actions on the redo stack.
Use the PropertyChanged event to listen to changes of this property.
Gets/Sets the limit on the number of items on the undo stack.
The size limit is enforced only on the number of stored top-level undo groups.
Elements within undo groups do not count towards the size limit.
If an undo group is open, gets the group descriptor of the current top-level
undo group.
If no undo group is open, gets the group descriptor from the previous undo group.
The group descriptor can be used to join adjacent undo groups:
use a group descriptor to mark your changes, and on the second action,
compare LastGroupDescriptor and use if you
want to join the undo groups.
Starts grouping changes.
Maintains a counter so that nested calls are possible.
Starts grouping changes.
Maintains a counter so that nested calls are possible.
An object that is stored with the undo group.
If this is not a top-level undo group, the parameter is ignored.
Starts grouping changes, continuing with the previously closed undo group if possible.
Maintains a counter so that nested calls are possible.
If the call to StartContinuedUndoGroup is a nested call, it behaves exactly
as , only top-level calls can continue existing undo groups.
An object that is stored with the undo group.
If this is not a top-level undo group, the parameter is ignored.
Stops grouping changes.
Throws an InvalidOperationException if an undo group is current open.
Call this method to undo the last operation on the stack
Call this method to redo the last undone operation
Call this method to push an UndoableOperation on the undostack.
The redostack will be cleared if you use this method.
Call this method to push an UndoableOperation on the undostack.
However, the operation will be only stored if the undo group contains a
non-optional operation.
Use this method to store the caret position/selection on the undo stack to
prevent having only actions that affect only the caret and not the document.
Call this method, if you want to clear the redo stack
Clears both the undo and redo stack.
Is raised when a property (CanUndo, CanRedo) changed.
Allows registering a line tracker on a TextDocument using a weak reference from the document to the line tracker.
Registers the as line tracker for the .
A weak reference to the target tracker will be used, and the WeakLineTracker will deregister itself
when the target tracker is garbage collected.
Deregisters the weak line tracker.
Base class for margins.
Margins don't have to derive from this class, it just helps maintaining a reference to the TextView
and the TextDocument.
AbstractMargin derives from FrameworkElement, so if you don't want to handle visual children and rendering
on your own, choose another base class for your margin!
TextView property.
Gets/sets the text view for which line numbers are displayed.
Adding a margin to will automatically set this property to the text area's TextView.
Gets the document associated with the margin.
Called when the is changing.
Called when the is changing.
Helper class with caret-related methods.
Gets/Sets the position of the caret.
Retrieving this property will validate the visual column (which can be expensive).
Use the property instead if you don't need the visual column.
Gets the caret position without validating it.
Gets/Sets the location of the caret.
The getter of this property is faster than because it doesn't have
to validate the visual column.
Gets/Sets the caret line.
Gets/Sets the caret column.
Gets/Sets the caret visual column.
Gets whether the caret is in virtual space.
Gets/Sets the caret offset.
Setting the caret offset has the side effect of setting the to NaN.
Gets/Sets the desired x-position of the caret, in device-independent pixels.
This property is NaN if the caret has no desired position.
Event raised when the caret position has changed.
If the caret position is changed inside a document update (between BeginUpdate/EndUpdate calls),
the PositionChanged event is raised only once at the end of the document update.
Validates the visual column of the caret using the specified visual line.
The visual line must contain the caret offset.
Returns the caret rectangle. The coordinate system is in device-independent pixels from the top of the document.
Minimum distance of the caret to the view border.
Scrolls the text view so that the caret is visible.
Makes the caret visible and updates its on-screen position.
Makes the caret invisible.
Gets/Sets the color of the caret.
Creates a new for the text area.
Contains classes for handling weak events on the Caret class.
Handles the Caret.PositionChanged event.
Margin for use with the text area.
A vertical dotted line to separate the line numbers from the text view.
Creates a vertical dotted line to separate the line numbers from the text view.
Gets whether the specified UIElement is the result of a DottedLineMargin.Create call.
Wraps exceptions that occur during drag'n'drop.
Exceptions during drag'n'drop might
get swallowed by WPF/COM, so AvalonEdit catches them and re-throws them later
wrapped in a DragDropException.
Creates a new DragDropException.
Creates a new DragDropException.
Creates a new DragDropException.
Deserializes a DragDropException.
We re-use the CommandBinding and InputBinding instances between multiple text areas,
so this class is static.
Creates a new for the text area.
Calls transformLine on all lines in the selected range.
transformLine needs to handle read-only segments!
Calls transformLine on all writable segment in the selected range.
Native API required for IME support.
Determines whether the document can be modified.
Gets whether insertion is possible at the specified offset.
Gets the deletable segments inside the given segment.
All segments in the result must be within the given segment, and they must be returned in order
(e.g. if two segments are returned, EndOffset of first segment must be less than StartOffset of second segment).
For replacements, the last segment being returned will be replaced with the new text. If an empty list is returned,
no replacement will be done.
Margin showing line numbers.
Creates a new instance of a LineNumberMargin
The typeface used for rendering the line number margin.
This field is calculated in MeasureOverride() based on the FontFamily etc. properties.
The font size used for rendering the line number margin.
This field is calculated in MeasureOverride() based on the FontFamily etc. properties.
Maximum length of a line number, in characters
Enumeration of possible states of mouse selection.
no selection (no mouse button down)
left mouse button down on selection, might be normal click
or might be drag'n'drop
dragging text
normal selection (click+drag)
whole-word selection (double click+drag or ctrl+click+drag)
whole-line selection (triple click+drag)
rectangular selection (alt+click+drag)
that has no read-only sections; all text is editable.
that completely disables editing.
Rectangular selection ("box selection").
Expands the selection left by one character, creating a rectangular selection.
Key gesture: Alt+Shift+Left
Expands the selection right by one character, creating a rectangular selection.
Key gesture: Alt+Shift+Right
Expands the selection left by one word, creating a rectangular selection.
Key gesture: Ctrl+Alt+Shift+Left
Expands the selection right by one word, creating a rectangular selection.
Key gesture: Ctrl+Alt+Shift+Right
Expands the selection up by one line, creating a rectangular selection.
Key gesture: Alt+Shift+Up
Expands the selection down by one line, creating a rectangular selection.
Key gesture: Alt+Shift+Down
Expands the selection to the start of the line, creating a rectangular selection.
Key gesture: Alt+Shift+Home
Expands the selection to the end of the line, creating a rectangular selection.
Key gesture: Alt+Shift+End
Creates a new rectangular selection.
Performs a rectangular paste operation.
Gets the name of the entry in the DataObject that signals rectangle selections.
Base class for selections.
Creates a new simple selection that selects the text from startOffset to endOffset.
Creates a new simple selection that selects the text in the specified segment.
Constructor for Selection.
Gets the start position of the selection.
Gets the end position of the selection.
Gets the selected text segments.
Gets the smallest segment that contains all segments in this selection.
May return null if the selection is empty.
Replaces the selection with the specified text.
Updates the selection when the document changes.
Gets whether the selection is empty.
Gets whether virtual space is enabled for this selection.
Gets the selection length.
Returns a new selection with the changed end point.
Cannot set endpoint for empty selection
If this selection is empty, starts a new selection from to
, otherwise, changes the endpoint of this selection.
Gets whether the selection is multi-line.
Gets the selected text.
Creates a HTML fragment for the selected text.
Gets whether the specified offset is included in the selection.
True, if the selection contains the offset (selection borders inclusive);
otherwise, false.
Creates a data object containing the selection's text.
Handles selection of text using the mouse.
Represents a selected segment.
Creates a SelectionSegment from two offsets.
Creates a SelectionSegment from two offsets and visual columns.
Gets the start offset.
Gets the end offset.
Gets the start visual column.
Gets the end visual column.
A simple selection.
Creates a new SimpleSelection instance.
Control that wraps a TextView and adds support for user input and the caret.
Creates a new TextArea instance.
Creates a new TextArea instance.
Gets the default input handler.
Gets/Sets the active input handler.
This property does not return currently active stacked input handlers. Setting this property detached all stacked input handlers.
Occurs when the ActiveInputHandler property changes.
Gets the list of currently active stacked input handlers.
Pushes an input handler onto the list of stacked input handlers.
Pops the stacked input handler (and all input handlers above it).
If is not found in the currently stacked input handlers, or is null, this method
does nothing.
Document property.
Gets/Sets the document displayed by the text editor.
Options property.
Gets/Sets the document displayed by the text editor.
Occurs when a text editor option has changed.
Raises the event.
Gets the text view used to display text in this text area.
Occurs when the selection has changed.
Gets/Sets the selection in this text area.
Clears the current selection.
The property.
Gets/Sets the background brush used for the selection.
The property.
Gets/Sets the foreground brush used for selected text.
The property.
Gets/Sets the pen used for the border of the selection.
The property.
Gets/Sets the corner radius of the selection.
Gets/Sets the active mouse selection mode.
Setting this property to MouseSelectionMode.None will cancel mouse selection
and release mouse capture.
Setting this property to another value will acquire mouse capture and
activate the mouse selection mode.
If mouse capture cannot be acquired, MouseSelectionMode will stay unchanged.
Currently, the setter only supports the values None, Normal
and Rectangular.
Code that updates only the caret but not the selection can cause confusion when
keys like 'Delete' delete the (possibly invisible) selected text and not the
text around the caret.
So we'll ensure that the caret is inside the selection.
(when the caret is not in the selection, we'll clear the selection)
This method is invoked using the Dispatcher so that code may temporarily violate this rule
(e.g. most 'extend selection' methods work by first setting the caret, then the selection),
it's sufficient to fix it after any event handlers have run.
Temporarily allows positioning the caret outside the selection.
Dispose the returned IDisposable to revert the allowance.
The text area only forces the caret to be inside the selection when other events
have finished running (using the dispatcher), so you don't have to use this method
for temporarily positioning the caret in event handlers.
This method is only necessary if you want to run the WPF dispatcher, e.g. if you
perform a drag'n'drop operation.
Gets the Caret used for this text area.
Gets the collection of margins displayed to the left of the text view.
Gets/Sets an object that provides read-only sections for the text area.
Occurs when the TextArea receives text input.
This is like the event,
but occurs immediately before the TextArea handles the TextInput event.
Occurs when the TextArea receives text input.
This is like the event,
but occurs immediately after the TextArea handles the TextInput event.
Raises the TextEntering event.
Raises the TextEntered event.
Performs text input.
This raises the event, replaces the selection with the text,
and then raises the event.
Performs text input.
This raises the event, replaces the selection with the text,
and then raises the event.
IndentationStrategy property.
Gets/Sets the indentation strategy used when inserting new lines.
The dependency property.
Gets/Sets whether overstrike mode is active.
Gets the requested service.
Returns the requested service instance, or null if the service cannot be found.
Occurs when text inside the TextArea was copied.
EventArgs with text.
Gets the text.
Creates a new TextEventArgs instance.
Contains the predefined input handlers.
Gets the caret navigation input handler.
Gets the editing input handler.
Gets the mouse selection input handler.
Creates a new TextAreaDefaultInputHandler instance.
A set of input bindings and event handlers for the text area.
There is one active input handler per text area (), plus
a number of active stacked input handlers.
The text area also stores a reference to a default input handler, but that is not necessarily active.
Stacked input handlers work in addition to the set of currently active handlers (without detaching them).
They are detached in the reverse order of being attached.
Gets the text area that the input handler belongs to.
Attaches an input handler to the text area.
Detaches the input handler from the text area.
Stacked input handler.
Uses OnEvent-methods instead of registering event handlers to ensure that the events are handled in the correct order.
Creates a new TextAreaInputHandler.
Called for the PreviewKeyDown event.
Called for the PreviewKeyUp event.
Default-implementation of .
Creates a new TextAreaInputHandler.
Gets whether the input handler is currently attached to the text area.
Gets the command bindings of this input handler.
Gets the input bindings of this input handler.
Adds a command and input binding.
The command ID.
The modifiers of the keyboard shortcut.
The key of the keyboard shortcut.
The event handler to run when the command is executed.
Gets the collection of nested input handlers. NestedInputHandlers are activated and deactivated
together with this input handler.
Implementation for that stores the segments
in a .
Gets the collection storing the read-only segments.
Creates a new TextSegmentReadOnlySectionProvider instance for the specified document.
Creates a new TextSegmentReadOnlySectionProvider instance using the specified TextSegmentCollection.
Gets whether insertion is possible at the specified offset.
Gets the deletable segments inside the given segment.
A that produces line elements for folded s.
Gets/Sets the folding manager from which the foldings should be shown.
Default brush for folding element text. Value: Brushes.Gray
Gets/sets the brush used for folding element text.
Stores a list of foldings for a specific TextView and TextDocument.
Creates a new FoldingManager instance.
Creates a folding for the specified text section.
Removes a folding section from this manager.
Removes all folding sections.
Gets all foldings in this manager.
The foldings are returned sorted by start offset;
for multiple foldings at the same offset the order is undefined.
Gets the first offset greater or equal to where a folded folding starts.
Returns -1 if there are no foldings after .
Gets the first folding with a greater or equal to
.
Returns null if there are no foldings after .
Gets all foldings that start exactly at .
Gets all foldings that contain .
Updates the foldings in this using the given new foldings.
This method will try to detect which new foldings correspond to which existing foldings; and will keep the state
() for existing foldings.
The new set of foldings. These must be sorted by starting offset.
The first position of a parse error. Existing foldings starting after
this offset will be kept even if they don't appear in .
Use -1 for this parameter if there were no parse errors.
Adds Folding support to the specified text area.
Warning: The folding manager is only valid for the text area's current document. The folding manager
must be uninstalled before the text area is bound to a different document.
The that manages the list of foldings inside the text area.
Uninstalls the folding manager.
The specified manager was not created using .
A margin that shows markers for foldings and allows to expand/collapse the foldings.
Gets/Sets the folding manager from which the foldings should be shown.
FoldingMarkerBrush dependency property.
Gets the value of the attached property for a specified .
Sets the value of the attached property for a specified .
Gets/sets the Brush used for displaying the lines of folding markers.
FoldingMarkerBackgroundBrush dependency property.
Gets the value of the attached property for a specified .
Sets the value of the attached property for a specified .
Gets/sets the Brush used for displaying the background of folding markers.
SelectedFoldingMarkerBrush dependency property.
Gets the value of the attached property for a specified .
Sets the value of the attached property for a specified .
Gets/sets the Brush used for displaying the lines of selected folding markers.
SelectedFoldingMarkerBackgroundBrush dependency property.
Gets the value of the attached property for a specified .
Sets the value of the attached property for a specified .
Gets/sets the Brush used for displaying the background of selected folding markers.
Calculates fold lines for all folding sections that start in front of the current view
and run into the current view.
Calculates fold lines for all folding sections that start inside the current view
Draws the lines for the folding sections (vertical line with 'color', horizontal lines with 'endMarker')
Each entry in the input arrays corresponds to one TextLine.
A section that can be folded.
Gets/sets if the section is folded.
Gets/Sets the text used to display the collapsed version of the folding section.
Gets the content of the collapsed lines as text.
Gets/Sets an additional object associated with this folding section.
Helper class used for .
Gets/Sets the start offset.
Gets/Sets the end offset.
Gets/Sets the name displayed for the folding.
Gets/Sets whether the folding is closed by default.
Gets/Sets whether the folding is considered to be a definition.
This has an effect on the 'Show Definitions only' command.
Creates a new NewFolding instance.
Creates a new NewFolding instance.
Holds information about the start of a fold in an xml string.
Determines folds for an xml string in the editor.
Flag indicating whether attributes should be displayed on folded
elements.
Create s for the specified document and updates the folding manager with them.
Create s for the specified document.
Create s for the specified document.
Creates a comment fold if the comment spans more than one line.
The text displayed when the comment is folded is the first
line of the comment.
Creates an XmlFoldStart for the start tag of an element.
Create an element fold if the start and end tag are on
different lines.
Gets the element's attributes as a string on one line that will
be displayed when the element is folded.
Currently this puts all attributes from an element on the same
line of the start tag. It does not cater for elements where attributes
are not on the same line as the start tag.
Xml encode the attribute string since the string returned from
the XmlTextReader is the plain unencoded string and .NET
does not provide us with an xml encode method.
This class can syntax-highlight a document.
It automatically manages invalidating the highlighting when the document changes.
Stores the span state at the end of each line.
storedSpanStacks[0] = state at beginning of document
storedSpanStacks[i] = state after line i
Gets the document that this DocumentHighlighter is highlighting.
Creates a new DocumentHighlighter instance.
Disposes the document highlighter.
Gets/sets the initial span stack of the document. Default value is .
Invalidates all stored highlighting info.
When the document changes, the highlighting is invalidated automatically, this method
needs to be called only when there are changes to the highlighting rule set.
Invalidates stored highlighting info, but does not raise the HighlightingStateChanged event.
Gets the span stack at the end of the specified line.
-> GetSpanStack(1) returns the spans at the start of the second line.
GetSpanStack(0) is valid and will return .
The elements are returned in inside-out order (first element of result enumerable is the color of the innermost span).
Sets the engine's CurrentSpanStack to the end of the target line.
Updates the span stack for all lines up to (and including) the target line, if necessary.
Is called when the highlighting state at the end of the specified line has changed.
This callback must not call HighlightLine or InvalidateHighlighting.
It may call GetSpanStack, but only for the changed line and lines above.
This method must not modify the document.
Takes a series of highlighting commands and stores them.
Later, it can build inline objects (for use with WPF TextBlock) from the commands.
This class is not used in AvalonEdit - but it is useful for someone who wants to put a HighlightedLine
into a TextBlock.
In SharpDevelop, we use it to provide syntax highlighting inside the search results pad.
Creates a new HighlightedInlineBuilder instance.
Creates a new HighlightedInlineBuilder instance.
Gets the text.
Applies the properties from the HighlightingColor to the specified text segment.
Sets the foreground brush on the specified text segment.
Sets the background brush on the specified text segment.
Sets the font weight on the specified text segment.
Sets the font style on the specified text segment.
Creates WPF Run instances that can be used for TextBlock.Inlines.
Creates a RichText instance.
Clones this HighlightedInlineBuilder.
Represents a highlighted document line.
Creates a new HighlightedLine instance.
Gets the document associated with this HighlightedLine.
Gets the document line associated with this HighlightedLine.
Gets the highlighted sections.
The sections are not overlapping, but they may be nested.
In that case, outer sections come in the list before inner sections.
The sections are sorted by start offset.
Validates that the sections are sorted correctly, and that they are not overlapping.
Merges the additional line into this line.
Writes the highlighted line to the RichTextWriter.
Writes a part of the highlighted line to the RichTextWriter.
Produces HTML code for the line, with <span class="colorName"> tags.
Produces HTML code for a section of the line, with <span class="colorName"> tags.
Creates a that stores the text and highlighting of this line.
Creates a that stores the highlighting of this line.
Creates a that stores the text and highlighting of this line.
A text section with syntax highlighting information.
Gets/sets the document offset of the section.
Gets/sets the length of the section.
Gets the highlighting color associated with the highlighted section.
A brush used for syntax highlighting. Can retrieve a real brush on-demand.
Gets the real brush.
The construction context. context can be null!
Gets the color of the brush.
The construction context. context can be null!
Highlighting brush implementation that takes a frozen brush.
Creates a new HighlightingBrush with the specified color.
HighlightingBrush implementation that finds a brush using a resource.
A highlighting color is a set of font properties and foreground and background color.
Gets/Sets the name of the color.
Gets/sets the font family. Null if the highlighting color does not change the font style.
Gets/sets the font size. Null if the highlighting color does not change the font style.
Gets/sets the font weight. Null if the highlighting color does not change the font weight.
Gets/sets the font style. Null if the highlighting color does not change the font style.
Gets/sets the underline flag. Null if the underline status does not change the font style.
Gets/sets the strikethrough flag. Null if the strikethrough status does not change the font style.
Gets/sets the foreground color applied by the highlighting.
Gets/sets the background color applied by the highlighting.
Creates a new HighlightingColor instance.
Deserializes a HighlightingColor.
Serializes this HighlightingColor instance.
Gets CSS code for the color.
Prevent further changes to this highlighting color.
Gets whether this HighlightingColor instance is frozen.
Clones this highlighting color.
If this color is frozen, the clone will be unfrozen.
Overwrites the properties in this HighlightingColor with those from the given color;
but maintains the current values where the properties of the given color return null.
A colorizes that interprets a highlighting rule set and colors the document accordingly.
Creates a new HighlightingColorizer instance.
The highlighting definition.
Creates a new HighlightingColorizer instance that uses a fixed highlighter instance.
The colorizer can only be used with text views that show the document for which
the highlighter was created.
The highlighter to be used.
Creates a new HighlightingColorizer instance.
Derived classes using this constructor must override the method.
This method is called when a text view is removed from this HighlightingColorizer,
and also when the TextDocument on any associated text view changes.
This method is called when a new text view is added to this HighlightingColorizer,
and also when the TextDocument on any associated text view changes.
Creates the IHighlighter instance for the specified text document.
Gets whether the color is empty (has no effect on a VisualLineTextElement).
For example, the C# "Punctuation" is an empty color.
Applies a highlighting color to a visual line element.
This method is responsible for telling the TextView to redraw lines when the highlighting state has changed.
Creation of a VisualLine triggers the syntax highlighter (which works on-demand), so it says:
Hey, the user typed "/*". Don't just recreate that line, but also the next one
because my highlighting state (at end of line) changed!
Indicates that the highlighting definition that was tried to load was invalid.
Creates a new HighlightingDefinitionInvalidException instance.
Creates a new HighlightingDefinitionInvalidException instance.
Creates a new HighlightingDefinitionInvalidException instance.
Creates a new HighlightingDefinitionInvalidException instance.
Converts between strings and by treating the string as the definition name
and calling HighlightingManager.Instance.GetDefinition(name).
Regex-based highlighting engine.
Creates a new HighlightingEngine instance.
Gets/sets the current span stack.
the HighlightedLine where highlighting output is being written to.
if this variable is null, nothing is highlighted and only the span state is updated
Highlights the specified line in the specified document.
Before calling this method, must be set to the proper
state for the beginning of this line. After highlighting has completed,
will be updated to represent the state after the line.
Updates for the specified line in the specified document.
Before calling this method, must be set to the proper
state for the beginning of this line. After highlighting has completed,
will be updated to represent the state after the line.
Returns the first match from the array or endSpanMatch.
Manages a list of syntax highlighting definitions.
All members on this class (including instance members) are thread-safe.
Gets a highlighting definition by name.
Returns null if the definition is not found.
Gets a copy of all highlightings.
Gets a highlighting definition by extension.
Returns null if the definition is not found.
Registers a highlighting definition.
The name to register the definition with.
The file extensions to register the definition for.
The highlighting definition.
Registers a highlighting definition.
The name to register the definition with.
The file extensions to register the definition for.
A function that loads the highlighting definition.
Gets the default HighlightingManager instance.
The default HighlightingManager comes with built-in highlightings.
A highlighting rule.
Gets/Sets the regular expression for the rule.
Gets/Sets the highlighting color.
A highlighting rule set describes a set of spans that are valid at a given code location.
Creates a new RuleSet instance.
Gets/Sets the name of the rule set.
Gets the list of spans.
Gets the list of rules.
A highlighting span is a region with start+end expression that has a different RuleSet inside
and colors the region.
Gets/Sets the start expression.
Gets/Sets the end expression.
Gets/Sets the rule set that applies inside this span.
Gets the color used for the text matching the start expression.
Gets the color used for the text between start and end.
Gets the color used for the text matching the end expression.
Gets/Sets whether the span color includes the start.
The default is false.
Gets/Sets whether the span color includes the end.
The default is false.
Allows copying HTML text to the clipboard.
Builds a header for the CF_HTML clipboard format.
Sets the TextDataFormat.Html on the data object to the specified html fragment.
This helper methods takes care of creating the necessary CF_HTML header.
Creates a HTML fragment from a part of a document.
The document to create HTML from.
The highlighter used to highlight the document. null is valid and will create HTML without any highlighting.
The part of the document to create HTML for. You can pass null to create HTML for the whole document.
The options for the HTML creation.
HTML code for the document part.
Holds options for converting text to HTML.
Creates a default HtmlOptions instance.
Creates a new HtmlOptions instance that copies applicable options from the .
The amount of spaces a tab gets converted to.
Writes the HTML attribute for the style to the text writer.
Gets whether the color needs to be written out to HTML.
RichTextWriter implementation that produces HTML.
Creates a new HtmlRichTextWriter instance.
The text writer where the raw HTML is written to.
The HtmlRichTextWriter does not take ownership of the htmlWriter;
disposing the HtmlRichTextWriter will not dispose the underlying htmlWriter!
Options that control the HTML output.
Represents a highlighted document.
This interface is used by the to register the highlighter as a TextView service.
Gets the underlying text document.
Gets the stack of active colors (the colors associated with the active spans) at the end of the specified line.
-> GetColorStack(1) returns the colors at the start of the second line.
GetColorStack(0) is valid and will return the empty stack.
The elements are returned in inside-out order (first element of result enumerable is the color of the innermost span).
Highlights the specified document line.
The line to highlight.
A line object that represents the highlighted sections.
Enforces a highlighting state update (triggering the HighlightingStateChanged event if necessary)
for all lines up to (and inclusive) the specified line number.
Notification when the highlighter detects that the highlighting state at the
beginning of the specified lines has changed.
fromLineNumber and toLineNumber are both inclusive;
the common case of a single-line change is represented by fromLineNumber == toLineNumber.
During highlighting, the highlighting of line X will cause this event to be raised
for line X+1 if the highlighting state at the end of line X has changed from its previous state.
This event may also be raised outside of the highlighting process to signalize that
changes to external data (not the document text; but e.g. semantic information)
require a re-highlighting of the specified lines.
For implementers: there is the requirement that, during highlighting,
if there was no state changed reported for the beginning of line X,
and there were no document changes between the start of line X and the start of line Y (with Y > X),
then this event must not be raised for any line between X and Y (inclusive).
Equal input state + unchanged line = Equal output state.
See the comment in the HighlightingColorizer.OnHighlightStateChanged implementation
for details about the requirements for a correct custom IHighlighter.
Outside of the highlighting process, this event can be raised without such restrictions.
Opens a group of calls.
It is not necessary to call this method before calling ,
however, doing so can make the highlighting much more performant in some cases
(e.g. the C# semantic highlighter in SharpDevelop will re-use the resolver within a highlighting group).
The group is closed by either a or a call.
Nested groups are not allowed.
Closes the currently opened group of calls.
.
Retrieves the HighlightingColor with the specified name. Returns null if no color matching the name is found.
Gets the default text color.
Event handler for
A highlighting definition.
Gets the name of the highlighting definition.
Gets the main rule set.
Gets a rule set by name.
The rule set, or null if it is not found.
Gets a named highlighting color.
The highlighting color, or null if it is not found.
Gets the list of named highlighting colors.
Gets the list of properties.
Interface for resolvers that can solve cross-definition references.
Gets the highlighting definition by name, or null if it is not found.
Represents a immutable piece text with highlighting information.
The empty string without any formatting information.
Creates a RichText instance with the given text and RichTextModel.
The text to use in this RichText instance.
The model that contains the formatting to use for this RichText instance.
model.DocumentLength should correspond to text.Length.
This parameter may be null, in which case the RichText instance just holds plain text.
Gets the text.
Gets the text length.
Gets the HighlightingColor for the specified offset.
Retrieves the highlighted sections in the specified range.
The highlighted sections will be sorted by offset, and there will not be any nested or overlapping sections.
Creates a new RichTextModel with the formatting from this RichText.
Gets the text.
Creates WPF Run instances that can be used for TextBlock.Inlines.
Produces HTML code for the line, with <span style="..."> tags.
Produces HTML code for a section of the line, with <span style="..."> tags.
Creates a substring of this rich text.
Concatenates the specified rich texts.
Concatenates the specified rich texts.
Implicit conversion from string to RichText.
A colorizer that applies the highlighting from a to the editor.
Creates a new RichTextColorizer instance.
Stores rich-text formatting.
Creates a new RichTextModel.
Creates a RichTextModel from a CONTIGUOUS list of HighlightedSections.
Updates the start and end offsets of all segments stored in this collection.
TextChangeEventArgs instance describing the change to the document.
Updates the start and end offsets of all segments stored in this collection.
OffsetChangeMap instance describing the change to the document.
Updates the start and end offsets of all segments stored in this collection.
OffsetChangeMapEntry instance describing the change to the document.
Appends another RichTextModel after this one.
Gets a copy of the HighlightingColor for the specified offset.
Applies the HighlightingColor to the specified range of text.
If the color specifies null for some properties, existing highlighting is preserved.
Sets the HighlightingColor for the specified range of text,
completely replacing the existing highlighting in that area.
Sets the foreground brush on the specified text segment.
Sets the background brush on the specified text segment.
Sets the font weight on the specified text segment.
Sets the font style on the specified text segment.
Retrieves the highlighted sections in the specified range.
The highlighted sections will be sorted by offset, and there will not be any nested or overlapping sections.
Creates WPF Run instances that can be used for TextBlock.Inlines.
The text source that holds the text for this RichTextModel.
A RichTextWriter that writes into a document and RichTextModel.
Creates a new RichTextModelWriter that inserts into document, starting at insertionOffset.
Gets/Sets the current insertion offset.
Static class with helper methods to load XSHD highlighting files.
Loads a syntax definition from the xml reader.
Creates a highlighting definition from the XSHD file.
Creates a highlighting definition from the XSHD file.
A visitor over the XSHD element tree.
Visit method for XshdRuleSet
Visit method for XshdColor
Visit method for XshdKeywords
Visit method for XshdSpan
Visit method for XshdImport
Visit method for XshdRule
Xshd visitor implementation that saves an .xshd file as XML.
XML namespace for XSHD.
Creates a new SaveXshdVisitor instance.
Writes the specified syntax definition.
Loads .xshd files, version 1.0.
Loads .xshd files, version 2.0.
Version 2.0 files are recognized by the namespace.
Sets the element's position to the XmlReader's position.
A color in an Xshd file.
Gets/sets the name.
Gets/sets the font family
Gets/sets the font size.
Gets/sets the foreground brush.
Gets/sets the background brush.
Gets/sets the font weight.
Gets/sets the underline flag
Gets/sets the strikethrough flag
Gets/sets the font style.
Gets/Sets the example text that demonstrates where the color is used.
Creates a new XshdColor instance.
Deserializes an XshdColor.
Serializes this XshdColor instance.
An element in a XSHD rule set.
Gets the line number in the .xshd file.
Gets the column number in the .xshd file.
Applies the visitor to this element.
<Import> element.
Gets/sets the referenced rule set.
A list of keywords.
The color.
Gets the list of key words.
A property in an Xshd file.
Gets/sets the name.
Gets/sets the value.
Creates a new XshdColor instance.
A reference to an xshd color, or an inline xshd color.
Gets the reference.
Gets the reference.
Gets the inline element.
Creates a new XshdReference instance.
Creates a new XshdReference instance.
Applies the visitor to the inline element, if there is any.
Equality operator.
Equality operator.
Inequality operator.
<Rule> element.
Gets/sets the rule regex.
Gets/sets the rule regex type.
Gets/sets the color reference.
A rule set in a XSHD file.
Gets/Sets the name of the rule set.
Gets/sets whether the case is ignored in expressions inside this rule set.
Gets the collection of elements.
Applies the visitor to all elements.
Specifies the type of the regex.
Normal regex. Used when the regex was specified as attribute.
Ignore pattern whitespace / allow regex comments. Used when the regex was specified as text element.
<Span> element.
Gets/sets the begin regex.
Gets/sets the begin regex type.
Gets/sets the end regex.
Gets/sets the end regex type.
Gets/sets whether the span is multiline.
Gets/sets the rule set reference.
Gets/sets the span color.
Gets/sets the span begin color.
Gets/sets the span end color.
A <SyntaxDefinition> element.
Creates a new XshdSyntaxDefinition object.
Gets/sets the definition name
Gets the associated extensions.
Gets the collection of elements.
Applies the visitor to all elements.
Smart indentation for C#.
Creates a new CSharpIndentationStrategy.
Creates a new CSharpIndentationStrategy and initializes the settings using the text editor options.
Gets/Sets the indentation string.
Performs indentation using the specified document accessor.
Object used for accessing the document line-by-line
Specifies whether empty lines should be kept
Interface used for the indentation class to access the document.
Gets if the current line is read only (because it is not in the
selected text region)
Gets the number of the current line.
Gets/Sets the text of the current line.
Advances to the next line.
Adapter IDocumentAccessor -> TextDocument
Creates a new TextDocumentAccessor.
Creates a new TextDocumentAccessor that indents only a part of the document.
Leave empty lines empty.
An indentation block. Tracks the state of the indentation.
The indentation outside of the block.
The indentation inside the block.
The last word that was seen inside this block.
Because parenthesis open a sub-block and thus don't change their parent's LastWord,
this property can be used to identify the type of block statement (if, while, switch)
at the position of the '{'.
The type of bracket that opened this block (, [ or {
Gets whether there's currently a line continuation going on inside this block.
Gets whether there's currently a 'one-line-block' going on. 'one-line-blocks' occur
with if statements that don't use '{}'. They are not represented by a Block instance on
the stack, but are instead handled similar to line continuations.
This property is an integer because there might be multiple nested one-line-blocks.
As soon as there is a finished statement, OneLineBlock is reset to 0.
The previous value of one-line-block before it was reset.
Used to restore the indentation of 'else' to the correct level.
Gets the line number where this block started.
Handles indentation by copying the indentation from the previous line.
Does not support indenting multiple lines.
Does nothing: indenting multiple lines is useless without a smart indentation strategy.
Strategy how the text editor handles indentation when new lines are inserted.
Sets the indentation for the specified line.
Usually this is constructed from the indentation of the previous line.
Reindents a set of lines.
Helper for creating a PathGeometry.
Gets/sets the radius of the rounded corners.
Gets/Sets whether to align to whole pixels.
If BorderThickness is set to 0, the geometry is aligned to whole pixels.
If BorderThickness is set to a non-zero value, the outer edge of the border is aligned
to whole pixels.
The default value is false.
Gets/sets the border thickness.
This property only has an effect if AlignToWholePixels is enabled.
When using the resulting geometry to paint a border, set this property to the border thickness.
Otherwise, leave the property set to the default value 0.
Gets/Sets whether to extend the rectangles to full width at line end.
Creates a new BackgroundGeometryBuilder instance.
Adds the specified segment to the geometry.
Adds a rectangle to the geometry.
This overload will align the coordinates according to
.
Use the -overload instead if the coordinates should not be aligned.
Calculates the list of rectangle where the segment in shown.
This method usually returns one rectangle for each line inside the segment
(but potentially more, e.g. when bidirectional text is involved).
Calculates the rectangles for the visual column segment.
This returns one rectangle for each line inside the segment.
Adds a rectangle to the geometry.
This overload assumes that the coordinates are aligned properly
(see ).
Use the -overload instead if the coordinates are not yet aligned.
Closes the current figure.
Creates the geometry.
Returns null when the geometry is empty!
Represents a collapsed line section.
Use the Uncollapse() method to uncollapse the section.
Gets if the document line is collapsed.
This property initially is true and turns to false when uncollapsing the section.
Gets the start line of the section.
When the section is uncollapsed or the text containing it is deleted,
this property returns null.
Gets the end line of the section.
When the section is uncollapsed or the text containing it is deleted,
this property returns null.
Uncollapses the section.
This causes the Start and End properties to be set to null!
Does nothing if the section is already uncollapsed.
Gets a string representation of the collapsed section.
Base class for that helps
splitting visual elements so that colors (and other text properties) can be easily assigned
to individual words/characters.
Gets the list of elements currently being transformed.
implementation.
Sets and calls .
Performs the colorization.
Changes visual element properties.
This method accesses , so it must be called only during
a call.
This method splits s as necessary to ensure that the region
can be colored by setting the of whole elements,
and then calls the on all elements in the region.
Start visual column of the region to change
End visual column of the region to change
Action that changes an individual .
Called when added to a text view.
Called when removed from a text view.
Renders a ruler at a certain column.
Default implementation for TextRunTypographyProperties.
Base class for that helps
colorizing the document. Derived classes can work with document lines
and text offsets and this class takes care of the visual lines and visual columns.
Gets the current ITextRunConstructionContext.
Override this method to colorize an individual document line.
Changes a part of the current document line.
Start offset of the region to change
End offset of the region to change
Action that changes an individual .
Formatted text (not normal document text).
This is used as base class for various VisualLineElements that are displayed using a
FormattedText, for example newline markers or collapsed folding sections.
Creates a new FormattedTextElement that displays the specified text
and occupies the specified length in the document.
Creates a new FormattedTextElement that displays the specified text
and occupies the specified length in the document.
Creates a new FormattedTextElement that displays the specified text
and occupies the specified length in the document.
Gets/sets the line break condition before the element.
The default is 'BreakPossible'.
Gets/sets the line break condition after the element.
The default is 'BreakPossible'.
Constructs a TextLine from a simple text.
This is the TextRun implementation used by the class.
Creates a new FormattedTextRun.
Gets the element for which the FormattedTextRun was created.
Red-black tree similar to DocumentLineTree, augmented with collapsing and height data.
Rebuild the tree, in O(n).
build a tree from a list of nodes
Collapses the specified text section.
Runtime: O(log n)
Returns 0 if the line is directly collapsed, otherwise, returns .
A node in the text view's height tree.
Gets the inorder successor of the node.
The number of lines in this node and its child nodes.
Invariant:
totalCount = 1 + left.totalCount + right.totalCount
The total height of this node and its child nodes, excluding directly collapsed nodes.
Invariant:
totalHeight = left.IsDirectlyCollapsed ? 0 : left.totalHeight
+ lineNode.IsDirectlyCollapsed ? 0 : lineNode.Height
+ right.IsDirectlyCollapsed ? 0 : right.totalHeight
List of the sections that hold this node collapsed.
Invariant 1:
For each document line in the range described by a CollapsedSection, exactly one ancestor
contains that CollapsedSection.
Invariant 2:
A CollapsedSection is contained either in left+middle or middle+right or just middle.
Invariant 3:
Start and end of a CollapsedSection always contain the collapsedSection in their
documentLine (middle node).
Background renderers draw in the background of a known layer.
You can use background renderers to draw non-interactive elements on the TextView
without introducing new UIElements.
Gets the layer on which this background renderer should draw.
Causes the background renderer to draw.
A inline UIElement in the document.
Gets the inline element that is displayed.
Creates a new InlineObjectElement.
The length of the element in the document. Must be non-negative.
The element to display.
A text run with an embedded UIElement.
Creates a new InlineObjectRun instance.
The length of the TextRun.
The to use.
The to display.
Gets the element displayed by the InlineObjectRun.
Gets the VisualLine that contains this object. This property is only available after the object
was added to the text view.
Contains information relevant for text run creation.
Gets the text document.
Gets the text view for which the construction runs.
Gets the visual line that is currently being constructed.
Gets the global text run properties.
Gets a piece of text from the document.
This method is allowed to return a larger string than requested.
It does this by returning a 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.
Allows s, s and
s to be notified when they are added or removed from a text view.
Called when added to a text view.
Called when removed from a text view.
Allows transforming visual line elements.
Applies the transformation to the specified list of visual line elements.
Base class for known layers.
An enumeration of well-known layers.
This layer is in the background.
There is no UIElement to represent this layer, it is directly drawn in the TextView.
It is not possible to replace the background layer or insert new layers below it.
This layer is below the Selection layer.
This layer contains the selection rectangle.
This layer is between the Background and the Text layers.
This layer contains the text and inline UI elements.
This layer is between the Selection and the Caret layers.
This layer contains the blinking caret.
This layer is above the Text layer.
Specifies where a new layer is inserted, in relation to an old layer.
The new layer is inserted below the specified layer.
The new layer replaces the specified layer. The old layer is removed
from the collection.
The new layer is inserted above the specified layer.
Detects hyperlinks and makes them clickable.
This element generator can be easily enabled and configured using the
.
Gets/Sets whether the user needs to press Control to click the link.
The default value is true.
Creates a new LinkElementGenerator.
Creates a new LinkElementGenerator using the specified regex.
Constructs a VisualLineElement that replaces the matched text.
The default implementation will create a
based on the URI provided by .
Fetches the URI from the regex match. Returns null if the URI format is invalid.
Detects e-mail addresses and makes them clickable.
This element generator can be easily enabled and configured using the
.
Creates a new MailLinkElementGenerator.
Encapsulates and adds MouseHover support to UIElements.
Creates a new instance and attaches itself to the UIElement.
Occurs when the mouse starts hovering over a certain location.
Raises the event.
Occurs when the mouse stops hovering over a certain location.
Raises the event.
Removes the MouseHover support from the target UIElement.
Element generator that displays · for spaces and » for tabs and a box for control characters.
This element generator is present in every TextView by default; the enabled features can be configured using the
.
Gets/Sets whether to show · for spaces.
Gets/Sets whether to show » for tabs.
Gets/Sets whether to show a box with the hex code for control characters.
Creates a new SingleCharacterElementGenerator instance.
The control that contains the text.
This control is used to allow other UIElements to be placed inside the TextView but
behind the text.
The text rendering process (VisualLine creation) is controlled by the TextView, this
class simply displays the created Visual Lines.
This class does not contain any input handling and is invisible to hit testing. Input
is handled by the TextView.
This allows UIElements that are displayed behind the text, but still can react to mouse input.
the index of the text layer in the layers collection
A virtualizing panel producing+showing s for a .
This is the heart of the text editor, this class controls the text rendering process.
Taken as a standalone control, it's a text viewer without any editing capability.
Creates a new TextView instance.
Document property.
Gets/Sets the document displayed by the text editor.
Occurs when the document property has changed.
Recreates the text formatter that is used internally
by calling .
Options property.
Gets/Sets the options used by the text editor.
Occurs when a text editor option has changed.
Raises the event.
Gets a collection where element generators can be registered.
Gets a collection where line transformers can be registered.
Gets the list of layers displayed in the text view.
Inserts a new layer at a position specified relative to an existing layer.
The new layer to insert.
The existing layer
Specifies whether the layer is inserted above,below, or replaces the referenced layer
Adds a new inline object.
Remove the inline objects that were marked for removal.
NonPrintableCharacterBrush dependency property.
Gets/sets the Brush used for displaying non-printable characters.
LinkTextForegroundBrush dependency property.
Gets/sets the Brush used for displaying link texts.
LinkTextBackgroundBrush dependency property.
Gets/sets the Brush used for the background of link texts.
LinkTextUnderlinedBrush dependency property.
Gets/sets whether to underline link texts.
Note that when setting this property to false, link text remains clickable and the LinkTextForegroundBrush (if any) is still applied.
Set TextEditorOptions.EnableHyperlinks and EnableEmailHyperlinks to false to disable links completely.
Causes the text editor to regenerate all visual lines.
Causes the text editor to regenerate all visual lines.
Causes the text editor to regenerate the specified visual line.
Causes the text editor to redraw all lines overlapping with the specified segment.
Causes a known layer to redraw.
This method does not invalidate visual lines;
use the method to do that.
Causes a known layer to redraw.
This method does not invalidate visual lines;
use the method to do that.
Causes the text editor to redraw all lines overlapping with the specified segment.
Does nothing if segment is null.
Invalidates all visual lines.
The caller of ClearVisualLines() must also call InvalidateMeasure() to ensure
that the visual lines will be recreated.
Gets the visual line that contains the document line with the specified number.
Returns null if the document line is outside the visible range.
Gets the visual line that contains the document line with the specified number.
If that line is outside the visible range, a new VisualLine for that document line is constructed.
Gets the currently visible visual lines.
Gets thrown if there are invalid visual lines when this property is accessed.
You can use the property to check for this case,
or use the method to force creating the visual lines
when they are invalid.
Gets whether the visual lines are valid.
Will return false after a call to Redraw().
Accessing the visual lines property will cause a
if this property is false.
Occurs when the TextView is about to be measured and will regenerate its visual lines.
This event may be used to mark visual lines as invalid that would otherwise be reused.
Occurs when the TextView was measured and changed its visual lines.
If the visual lines are invalid, creates new visual lines for the visible part
of the document.
If all visual lines are valid, this method does nothing.
The visual line build process is already running.
It is not allowed to call this method during the construction of a visual line.
Additonal amount that allows horizontal scrolling past the end of the longest line.
This is necessary to ensure the caret always is visible, even when it is at the end of the longest line.
Build all VisualLines in the visible range.
Width the longest line
Arrange implementation.
Gets the list of background renderers.
Size of the document, in pixels.
Offset of the scroll position.
Size of the viewport.
Gets the horizontal scroll offset.
Gets the vertical scroll offset.
Gets the scroll offset;
Occurs when the scroll offset has changed.
Gets the width of a 'wide space' (the space width used for calculating the tab size).
This is the width of an 'x' in the current font.
We do not measure the width of an actual space as that would lead to tiny tabs in
some proportional fonts.
For monospaced fonts, this property will return the expected value, as 'x' and ' ' have the same width.
Gets the default line height. This is the height of an empty line or a line containing regular text.
Lines that include formatted text or custom UI elements may have a different line height.
Gets the default baseline position. This is the difference between
and for a line containing regular text.
Lines that include formatted text or custom UI elements may have a different baseline.
Scrolls the text view so that the specified rectangle gets visible.
Updates the mouse cursor by calling , but with background priority.
Gets the visual line at the specified document position (relative to start of document).
Returns null if there is no visual line for the position (e.g. the position is outside the visible
text area).
Gets the visual top position (relative to start of document) from a document line number.
Gets the visual position from a text view position.
The text view position.
The mode how to retrieve the Y position.
The position in WPF device-independent pixels relative
to the top left corner of the document.
Gets the text view position from the specified visual position.
If the position is within a character, it is rounded to the next character boundary.
The position in WPF device-independent pixels relative
to the top left corner of the document.
The logical position, or null if the position is outside the document.
Gets the text view position from the specified visual position.
If the position is inside a character, the position in front of the character is returned.
The position in WPF device-independent pixels relative
to the top left corner of the document.
The logical position, or null if the position is outside the document.
Gets a service container used to associate services with the text view.
This container does not provide document services -
use TextView.GetService() instead of TextView.Services.GetService() to ensure
that document services can be found as well.
Retrieves a service from the text view.
If the service is not found in the container,
this method will also look for it in the current document's service provider.
The PreviewMouseHover event.
The MouseHover event.
The PreviewMouseHoverStopped event.
The MouseHoverStopped event.
Occurs when the mouse has hovered over a fixed location for some time.
Occurs when the mouse has hovered over a fixed location for some time.
Occurs when the mouse had previously hovered but now started moving again.
Occurs when the mouse had previously hovered but now started moving again.
Collapses lines for the purpose of scrolling. s marked as collapsed will be hidden
and not used to start the generation of a .
This method is meant for s that cause s to span
multiple s. Do not call it without providing a corresponding
.
If you want to create collapsible text sections, see .
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 on the
returned from this method.
Gets the height of the document.
Gets the document line at the specified visual position.
The pen used to draw the column ruler.
Gets/Sets the pen used to draw the column ruler.
The property.
Gets/Sets the background brush used by current line highlighter.
The property.
Gets/Sets the background brush used for the current line.
Gets/Sets highlighted line number.
Empty line selection width.
Contains weak event managers for the TextView events.
Weak event manager for the event.
Weak event manager for the event.
Weak event manager for the event.
Represents a visual line in the document.
A visual line usually corresponds to one DocumentLine, but it can span multiple lines if
all but the first are collapsed.
Gets the document to which this VisualLine belongs.
Gets the first document line displayed by this visual line.
Gets the last document line displayed by this visual line.
Gets a read-only collection of line elements.
Gets a read-only collection of text lines.
Gets the start offset of the VisualLine inside the document.
This is equivalent to FirstDocumentLine.Offset.
Length in visual line coordinates.
Length in visual line coordinates including the end of line marker, if TextEditorOptions.ShowEndOfLine is enabled.
Gets the height of the visual line in device-independent pixels.
Gets the Y position of the line. This is measured in device-independent pixels relative to the start of the document.
Replaces the single element at with the specified elements.
The replacement operation must preserve the document length, but may change the visual length.
This method may only be called by line transformers.
Replaces elements starting at with the specified elements.
The replacement operation must preserve the document length, but may change the visual length.
This method may only be called by line transformers.
Gets the visual column from a document offset relative to the first line start.
Gets the document offset (relative to the first line start) from a visual column.
Gets the text line containing the specified visual column.
Gets the text line containing the specified visual column.
Gets the visual top from the specified text line.
Distance in device-independent pixels
from the top of the document to the top of the specified text line.
Gets the start visual column from the specified text line.
Gets a TextLine by the visual position.
Gets the visual position from the specified visualColumn.
Position in device-independent pixels
relative to the top left of the document.
Gets the distance to the left border of the text area of the specified visual column.
The visual column must belong to the specified text line.
Gets the visual column from a document position (relative to top left of the document).
If the user clicks between two visual columns, rounds to the nearest column.
Gets the visual column from a document position (relative to top left of the document).
If the user clicks between two visual columns, rounds to the nearest column.
Gets the visual column from a document position (relative to top left of the document).
If the user clicks between two visual columns, rounds to the nearest column.
Validates the visual column and returns the correct one.
Validates the visual column and returns the correct one.
Gets the visual column from a document position (relative to top left of the document).
If the user clicks between two visual columns, returns the first of those columns.
Gets the visual column from a document position (relative to top left of the document).
If the user clicks between two visual columns, returns the first of those columns.
Gets the text view position from the specified visual column.
Gets the text view position from the specified visual position.
If the position is within a character, it is rounded to the next character boundary.
The position in WPF device-independent pixels relative
to the top left corner of the document.
Controls whether positions in virtual space may be returned.
Gets the text view position from the specified visual position.
If the position is inside a character, the position in front of the character is returned.
The position in WPF device-independent pixels relative
to the top left corner of the document.
Controls whether positions in virtual space may be returned.
Gets whether the visual line was disposed.
Gets the next possible caret position after visualColumn, or -1 if there is no caret position.
EventArgs for the event.
Gets/Sets the first line that is visible in the TextView.
Creates a new VisualLineConstructionStartEventArgs instance.
Represents a visual element in the document.
Creates a new VisualLineElement.
The length of the element in VisualLine coordinates. Must be positive.
The length of the element in the document. Must be non-negative.
Gets the length of this element in visual columns.
Gets the length of this element in the text document.
Gets the visual column where this element starts.
Gets the text offset where this element starts, relative to the start text offset of the visual line.
Gets the text run properties.
A unique instance is used for each
; colorizing code may assume that modifying the
will affect only this
.
Gets/sets the brush used for the background of this .
Creates the TextRun for this line element.
The visual column from which the run should be constructed.
Normally the same value as the property is used to construct the full run;
but when word-wrapping is active, partial runs might be created.
Context object that contains information relevant for text run creation.
Retrieves the text span immediately before the visual column.
This method is used for word-wrapping in bidirectional text.
Gets if this VisualLineElement can be split.
Splits the element.
Position inside this element at which it should be broken
The collection of line elements
The index at which this element is in the elements list.
Helper method for splitting this line element into two, correctly updating the
, ,
and properties.
The element before the split position.
The element after the split position.
The split position as visual column.
The split position as text offset.
Gets the visual column of a text location inside this element.
The text offset is given relative to the visual line start.
Gets the text offset of a visual column inside this element.
A text offset relative to the visual line start.
Gets the next caret position inside this element.
The visual column from which the search should be started.
The search direction (forwards or backwards).
Whether to stop only at word borders.
The visual column of the next caret position, or -1 if there is no next caret position.
In the space between two line elements, it is sufficient that one of them contains a caret position;
though in many cases, both of them contain one.
Gets whether the specified offset in this element is considered whitespace.
Gets whether the implementation handles line borders.
If this property returns false, the caller of GetNextCaretPosition should handle the line
borders (i.e. place caret stops at the start and end of the line).
This property has an effect only for VisualLineElements that are at the start or end of a
.
Queries the cursor over the visual line element.
Allows the visual line element to handle a mouse event.
Allows the visual line element to handle a mouse event.
Abstract base class for generators that produce new visual line elements.
Gets the text run construction context.
Initializes the generator for the
De-initializes the generator.
Should only be used by VisualLine.ConstructVisualElements.
Gets the first offset >= startOffset where the generator wants to construct an element.
Return -1 to signal no interest.
Constructs an element at the specified offset.
May return null if no element should be constructed.
Avoid signalling interest and then building no element by returning null - doing so
causes the generated elements to be unnecessarily split
at the position where you signalled interest.
implementation that allows changing the properties.
A instance usually is assigned to a single
.
Creates a new VisualLineElementTextRunProperties instance that copies its values
from the specified .
For the and collections, deep copies
are created if those collections are not frozen.
Creates a copy of this instance.
Sets the .
Sets the .
Sets the .
Sets the .
Sets the .
Sets the .
Sets the .
Gets the text decorations. The value may be null, a frozen
or an unfrozen .
If the value is an unfrozen , you may assume that the
collection instance is only used for this instance and it is safe
to add s.
Sets the .
Gets the text effects. The value may be null, a frozen
or an unfrozen .
If the value is an unfrozen , you may assume that the
collection instance is only used for this instance and it is safe
to add s.
Sets the .
Gets the typography properties for the text run.
Sets the .
Gets the number substitution settings for the text run.
Sets the .
VisualLineElement that represents a piece of text and is a clickable link.
Gets/Sets the URL that is navigated to when the link is clicked.
Gets/Sets the window name where the URL will be opened.
Gets/Sets whether the user needs to press Control to click the link.
The default value is true.
Creates a visual line text element with the specified length.
It uses the and its
to find the actual text string.
Gets whether the link is currently clickable.
Returns true when control is pressed; or when
is disabled.
A VisualLinesInvalidException indicates that you accessed the property
of the while the visual lines were invalid.
Creates a new VisualLinesInvalidException instance.
Creates a new VisualLinesInvalidException instance.
Creates a new VisualLinesInvalidException instance.
Creates a new VisualLinesInvalidException instance.
VisualLineElement that represents a piece of text.
Gets the parent visual line.
Creates a visual line text element with the specified length.
It uses the and its
to find the actual text string.
Override this method to control the type of new VisualLineText instances when
the visual line is split due to syntax highlighting.
WPF TextSource implementation that creates TextRuns for a VisualLine.
An enum that specifies the possible Y positions that can be returned by VisualLine.GetVisualPosition.
Returns the top of the TextLine.
Returns the top of the text.
If the line contains inline UI elements larger than the text, TextTop may be below LineTop.
For a line containing regular text (all in the editor's main font), this will be equal to LineTop.
Returns the bottom of the TextLine.
The middle between LineTop and LineBottom.
Returns the bottom of the text.
If the line contains inline UI elements larger than the text, TextBottom might be above LineBottom.
For a line containing regular text (all in the editor's main font), this will be equal to LineBottom.
The middle between TextTop and TextBottom.
Returns the baseline of the text.
A button that opens a drop-down menu when clicked.
Identifies the  dependency property.
The key that identifies the  dependency property.
Identifies the  dependency property.
Gets/Sets the popup that is used as drop-down content.
Gets whether the drop-down is opened.
Basic interface for search algorithms.
Finds all matches in the given ITextSource and the given range.
This method must be implemented thread-safe.
All segments in the result must be within the given range, and they must be returned in order
(e.g. if two results are returned, EndOffset of first result must be less than or equal StartOffset of second result).
Finds the next match in the given ITextSource and the given range.
This method must be implemented thread-safe.
Represents a search result.
Replaces parts of the replacement string with parts from the match. (e.g. $1)
Defines supported search modes.
Standard search
RegEx search
Wildcard search
Holds default texts for buttons and labels in the SearchPanel. Override properties to add other languages.
Default: 'Match case'
Default: 'Match whole words'
Default: 'Use regular expressions'
Default: 'Find next (F3)'
Default: 'Find previous (Shift+F3)'
Default: 'Error: '
Default: 'No matches found!'
Search commands for AvalonEdit.
Finds the next occurrence in the file.
Finds the previous occurrence in the file.
Closes the SearchPanel.
TextAreaInputHandler that registers all search-related commands.
Fired when SearchOptions are modified inside the SearchPanel.
Provides search functionality for AvalonEdit. It is displayed in the top-right corner of the TextArea.
Dependency property for .
Gets/sets whether the search pattern should be interpreted as regular expression.
Dependency property for .
Gets/sets whether the search pattern should be interpreted case-sensitive.
Dependency property for .
Gets/sets whether the search pattern should only match whole words.
Dependency property for .
Gets/sets the search pattern.
Dependency property for .
Gets/sets the Brush used for marking search results in the TextView.
Dependency property for .
Gets/sets the Pen used for marking search results in the TextView.
Dependency property for .
Gets/sets the corner-radius used for marking search results in the TextView.
Dependency property for .
Gets/sets the localization for the SearchPanel.
Creates a new SearchPanel.
Creates a SearchPanel and installs it to the TextEditor's TextArea.
This is a convenience wrapper.
Creates a SearchPanel and installs it to the TextArea.
Adds the commands used by SearchPanel to the given CommandBindingCollection.
Removes the SearchPanel from the TextArea.
Reactivates the SearchPanel by setting the focus on the search box and selecting all text.
Moves to the next occurrence in the file.
Moves to the previous occurrence in the file.
Gets whether the Panel is already closed.
Closes the SearchPanel.
Opens the an existing search panel.
Fired when SearchOptions are changed inside the SearchPanel.
Raises the event.
EventArgs for event.
Gets the search pattern.
Gets whether the search pattern should be interpreted case-sensitive.
Gets whether the search pattern should be interpreted as regular expression.
Gets whether the search pattern should only match whole words.
Creates a new SearchOptionsChangedEventArgs instance.
Provides factory methods for ISearchStrategies.
Creates a default ISearchStrategy with the given parameters.
Represents an active element that allows the snippet to stay interactive after insertion.
Called when the all snippet elements have been inserted.
Called when the interactive mode is deactivated.
Gets whether this element is editable (the user will be able to select it with Tab).
Gets the segment associated with this element. May be null.
Represents the context of a snippet insertion.
Creates a new InsertionContext instance.
Gets the text area.
Gets the text document.
Gets the text that was selected before the insertion of the snippet.
Gets the indentation at the insertion position.
Gets the indentation string for a single indentation level.
Gets the line terminator at the insertion position.
Gets/Sets the insertion position.
Gets the start position of the snippet insertion.
Inserts text at the insertion position and advances the insertion position.
This method will add the current indentation to every line in and will
replace newlines with the expected newline for the document.
Registers an active element. Elements should be registered during insertion and will be called back
when insertion has completed.
The snippet element that created the active element.
The active element.
Returns the active element belonging to the specified snippet element, or null if no such active element is found.
Gets the list of active elements.
Calls the method on all registered active elements
and raises the event.
The EventArgs to use
Occurs when the all snippet elements have been inserted.
Calls the method on all registered active elements.
The EventArgs to use
Occurs when the interactive mode is deactivated.
Adds existing segments as snippet elements.
A code snippet that can be inserted into the text editor.
Inserts the snippet into the text area.
Creates a named anchor that can be accessed by other SnippetElements.
Gets or sets the name of the anchor.
Creates a SnippetAnchorElement with the supplied name.
AnchorElement created by SnippetAnchorElement.
Creates a new AnchorElement.
Gets or sets the text at the anchor.
Gets or sets the name of the anchor.
An element that binds to a and displays the same text.
Gets/Sets the target element.
Converts the text before copying it.
Sets the caret position after interactive mode has finished.
Creates a new SnippetCaretElement.
Creates a new SnippetCaretElement.
If set to true, the caret is set only when some text was selected.
This is useful when both SnippetCaretElement and SnippetSelectionElement are used in the same snippet.
A snippet element that has sub-elements.
Gets the list of child elements.
An element inside a snippet.
Performs insertion of the snippet.
Converts the snippet to text, with replaceable fields in italic.
Provides information about the event that occurred during use of snippets.
Gets the reason for deactivation.
Creates a new SnippetEventArgs object, with a DeactivateReason.
Describes the reason for deactivation of a .
Unknown reason.
Snippet was deleted.
There are no active elements in the snippet.
The SnippetInputHandler was detached.
Return was pressed by the user.
Escape was pressed by the user.
Text element that is supposed to be replaced by the user.
Will register an .
Interface for active element registered by .
Gets the current text inside the element.
Occurs when the text inside the element changes.
Inserts the previously selected text at the selection marker.
Gets/Sets the new indentation of the selected text.
Represents a text element in a snippet.
The text to be inserted.
The text editor control.
Contains a scrollable TextArea.
Creates a new TextEditor instance.
Creates a new TextEditor instance.
Forward focus to TextArea.
Document property.
Gets/Sets the document displayed by the text editor.
This is a dependency property.
Occurs when the document property has changed.
Raises the event.
Options property.
Gets/Sets the options currently used by the text editor.
Occurs when a text editor option has changed.
Raises the event.
Gets/Sets the text of the current document.
Occurs when the Text property changes.
Raises the event.
Is called after the template was applied.
Gets the text area.
Gets the scroll viewer used by the text editor.
This property can return null if the template has not been applied / does not contain a scroll viewer.
The property.
Gets/sets the syntax highlighting definition used to colorize the text.
Creates the highlighting colorizer for the specified highlighting definition.
Allows derived classes to provide custom colorizer implementations for special highlighting definitions.
Word wrap dependency property.
Specifies whether the text editor uses word wrapping.
Setting WordWrap=true has the same effect as setting HorizontalScrollBarVisibility=Disabled and will override the
HorizontalScrollBarVisibility setting.
IsReadOnly dependency property.
Specifies whether the user can change the text editor content.
Setting this property will replace the
TextArea.ReadOnlySectionProvider.
Dependency property for
Gets/Sets the 'modified' flag.
ShowLineNumbers dependency property.
Specifies whether line numbers are shown on the left to the text view.
LineNumbersForeground dependency property.
Gets/sets the Brush used for displaying the foreground color of line numbers.
Appends text to the end of the document.
Begins a group of document changes.
Copies the current selection to the clipboard.
Removes the current selection and copies it to the clipboard.
Begins a group of document changes and returns an object that ends the group of document
changes when it is disposed.
Removes the current selection without copying it to the clipboard.
Ends the current group of document changes.
Scrolls one line down.
Scrolls to the left.
Scrolls to the right.
Scrolls one line up.
Scrolls one page down.
Scrolls one page up.
Scrolls one page left.
Scrolls one page right.
Pastes the clipboard content.
Redoes the most recent undone command.
True is the redo operation was successful, false is the redo stack is empty.
Scrolls to the end of the document.
Scrolls to the start of the document.
Scrolls to the specified position in the document.
Scrolls to the specified position in the document.
Selects the entire text.
Undoes the most recent command.
True is the undo operation was successful, false is the undo stack is empty.
Gets if the most recent undone command can be redone.
Gets if the most recent command can be undone.
Gets the vertical size of the document.
Gets the horizontal size of the current document region.
Gets the horizontal size of the viewport.
Gets the horizontal size of the viewport.
Gets the vertical scroll position.
Gets the horizontal scroll position.
Gets/Sets the selected text.
Gets/sets the caret position.
Gets/sets the start position of the selection.
Gets/sets the length of the selection.
Selects the specified text section.
Gets the number of lines in the document.
Clears the text.
Loads the text from the stream, auto-detecting the encoding.
This method sets to false.
Loads the text from the stream, auto-detecting the encoding.
Encoding dependency property.
Gets/sets the encoding used when the file is saved.
The method autodetects the encoding of the file and sets this property accordingly.
The method uses the encoding specified in this property.
Saves the text to the stream.
This method sets to false.
Saves the text to the file.
The PreviewMouseHover event.
The MouseHover event.
The PreviewMouseHoverStopped event.
The MouseHoverStopped event.
Occurs when the mouse has hovered over a fixed location for some time.
Occurs when the mouse has hovered over a fixed location for some time.
Occurs when the mouse had previously hovered but now started moving again.
Occurs when the mouse had previously hovered but now started moving again.
Dependency property for
Gets/Sets the horizontal scroll bar visibility.
Dependency property for
Gets/Sets the vertical scroll bar visibility.
Gets the text view position from a point inside the editor.
The position, relative to top left
corner of TextEditor control
The text view position, or null if the point is outside the document.
Scrolls to the specified line.
This method requires that the TextEditor was already assigned a size (WPF layout must have run prior).
Scrolls to the specified line/column.
This method requires that the TextEditor was already assigned a size (WPF layout must have run prior).
Scrolls to the specified line/column.
This method requires that the TextEditor was already assigned a size (WPF layout must have run prior).
Line to scroll to.
Column to scroll to (important if wrapping is 'on', and for the horizontal scroll position).
The mode how to reference the Y position of the line.
Offset from the top of the viewport to where the referenced line/column should be positioned.
The minimum vertical and/or horizontal scroll offset, expressed as fraction of the height or width of the viewport window, respectively.
Exposes to automation.
Creates a new TextEditorAutomationPeer instance.
Represents a text editor control (,
or ).
Gets the document being edited.
Occurs when the Document property changes (when the text editor is connected to another
document - not when the document content changes).
Gets the options of the text editor.
Occurs when the Options property changes, or when an option inside the current option list
changes.
A container for the text editor options.
Initializes an empty instance of TextEditorOptions.
Initializes a new instance of TextEditorOptions by copying all values
from to the new instance.
Raises the PropertyChanged event.
The name of the changed property.
Raises the PropertyChanged event.
Gets/Sets whether to show · for spaces.
The default value is false.
Gets/Sets whether to show » for tabs.
The default value is false.
Gets/Sets whether to show ¶ at the end of lines.
The default value is false.
Gets/Sets whether to show a box with the hex code for control characters.
The default value is true.
Gets/Sets whether to enable clickable hyperlinks in the editor.
The default value is true.
Gets/Sets whether to enable clickable hyperlinks for e-mail addresses in the editor.
The default value is true.
Gets/Sets whether the user needs to press Control to click hyperlinks.
The default value is true.
The default value is true.
Gets/Sets the width of one indentation unit.
The default value is 4.
Gets/Sets whether to use spaces for indentation instead of tabs.
The default value is false.
Gets the text used for indentation.
Gets text required to indent from the specified to the next indentation level.
Gets/Sets whether copying without a selection copies the whole current line.
Gets/Sets whether the user can scroll below the bottom of the document.
The default value is false; but it a good idea to set this property to true when using folding.
Gets/Sets the indentation used for all lines except the first when word-wrapping.
The default value is 0.
Gets/Sets whether the indentation is inherited from the first line when word-wrapping.
The default value is true.
When combined with , the inherited indentation is added to the word wrap indentation.
Enables rectangular selection (press ALT and select a rectangle)
Enable dragging text within the text area.
Gets/Sets whether the user can set the caret behind the line ending
(into "virtual space").
Note that virtual space is always used (independent from this setting)
when doing rectangle selections.
Gets/Sets whether the support for Input Method Editors (IME)
for non-alphanumeric scripts (Chinese, Japanese, Korean, ...) is enabled.
Gets/Sets whether the column ruler should be shown.
Gets/Sets where the column ruler should be shown.
Gets/Sets if current line should be shown.
Gets/Sets if mouse cursor should be hidden while user is typing.
Gets/Sets if the user is allowed to enable/disable overstrike mode.
Contains weak event managers for .
Weak event manager for the event.
Weak event manager for the event.
Represents a text location with a visual column.
Gets/Sets Location.
Gets/Sets the line number.
Gets/Sets the (text) column number.
Gets/Sets the visual column number.
Can be -1 (meaning unknown visual column).
When word-wrap is enabled and a line is wrapped at a position where there is no space character;
then both the end of the first TextLine and the beginning of the second TextLine
refer to the same position in the document, and also have the same visual column.
In this case, the IsAtEndOfLine property is used to distinguish between the two cases:
the value true indicates that the position refers to the end of the previous TextLine;
the value false indicates that the position refers to the beginning of the next TextLine.
If this position is not at such a wrapping position, the value of this property has no effect.
Creates a new TextViewPosition instance.
Creates a new TextViewPosition instance.
Creates a new TextViewPosition instance.
Creates a new TextViewPosition instance.
Equality test.
Equality test.
Inequality test.
Reuse the same instances for boxed booleans.
Invokes an action when it is disposed.
This class ensures the callback is invoked at most once,
even when Dispose is called on multiple threads.
This class is used to prevent stack overflows by representing a 'busy' flag
that prevents reentrance when another call is running.
However, using a simple 'bool busy' is not thread-safe, so we use a
thread-static BusyManager.
Poor man's template specialization: extension methods for Rope<char>.
Creates a new rope from the specified text.
Retrieves the text for a portion of the rope.
Runs in O(lg N + M), where M=.
offset or length is outside the valid range.
This method counts as a read access and may be called concurrently to other read accesses.
Retrieves the text for a portion of the rope and writes it to the specified text writer.
Runs in O(lg N + M), where M=.
offset or length is outside the valid range.
This method counts as a read access and may be called concurrently to other read accesses.
Appends text to this rope.
Runs in O(lg N + M).
newElements is null.
Inserts text into this rope.
Runs in O(lg N + M).
newElements is null.
index or length is outside the valid range.
Gets the index of the first occurrence of any element in the specified array.
The target rope.
Array of characters being searched.
Start index of the search.
Length of the area to search.
The first index where any character was found; or -1 if no occurrence was found.
Gets the index of the first occurrence of the search text.
Gets the index of the last occurrence of the search text.
A IList{T} implementation that has efficient insertion and removal (in O(lg n) time)
and that saves memory by allocating only one node when a value is repeated in adjacent indices.
Based on this "compression", it also supports efficient InsertRange/SetRange/RemoveRange operations.
Current memory usage: 5*IntPtr.Size + 12 + sizeof(T) per node.
Use this class only if lots of adjacent values are identical (can share one node).
Gets the inorder predecessor of the node.
Gets the inorder successor of the node.
Creates a new CompressingTreeList instance.
The equality comparer used for comparing consecutive values.
A single node may be used to store the multiple values that are considered equal.
Creates a new CompressingTreeList instance.
A function that checks two values for equality. If this
function returns true, a single node may be used to store the two values.
Inserts times at position
.
Removes items starting at position
.
Sets indices starting at to
Gets or sets an item by index.
Gets the number of items in the list.
Gets the index of the specified .
Gets the first index so that all values from the result index to
are equal.
Gets the first index after so that the value at the result index is not
equal to the value at .
That is, this method returns the exclusive end index of the run of equal values.
Applies the conversion function to all elements in this CompressingTreeList.
Applies the conversion function to the elements in the specified range.
Inserts the specified at
Removes one item at
Adds the specified to the end of the list.
Removes all items from this list.
Gets whether this list contains the specified item.
Copies all items in this list to the specified array.
Removes the specified item from this list.
Gets an enumerator for this list.
Multiply with this constant to convert from points to device-independent pixels.
Maintains a list of delayed events to raise.
Double-ended queue.
Gets/Sets an element inside the deque.
Adds an element to the end of the deque.
Pops an element from the end of the deque.
Adds an element to the front of the deque.
Pops an element from the end of the deque.
Helps printing documents.
Converts an IDocument to a Block and applies the provided highlighter.
Converts an IDocument to a RichText and applies the provided highlighter.
Creates a flow document from the editor's contents.
Provides immutable empty list instances.
Epsilon used for IsClose() implementations.
We can use up quite a few digits in front of the decimal point (due to visual positions being relative to document origin),
and there's no need to be too accurate (we're dealing with pixels here),
so we will use the value 0.01.
Previously we used 1e-8 but that was causing issues:
http://community.sharpdevelop.net/forums/t/16048.aspx
Returns true if the doubles are close (difference smaller than 0.01).
Returns true if the doubles are close (difference smaller than 0.01).
Returns true if the doubles are close (difference smaller than 0.01).
Forces the value to stay between minimum and maximum.
minimum, if value is less than minimum.
Maximum, if value is greater than maximum.
Otherwise, value.
Forces the value to stay between minimum and maximum.
minimum, if value is less than minimum.
Maximum, if value is greater than maximum.
Otherwise, value.
Creates typeface from the framework element.
Creates an IEnumerable with a single value.
Gets the value of the attribute, or null if the attribute does not exist.
Gets the value of the attribute as boolean, or null if the attribute does not exist.
Gets the value of the attribute as boolean, or null if the attribute does not exist.
Class that can open text files with auto-detection of the encoding.
Gets if the given encoding is a Unicode encoding (UTF).
Returns true for UTF-7, UTF-8, UTF-16 LE, UTF-16 BE, UTF-32 LE and UTF-32 BE.
Returns false for all other encodings.
Reads the content of the given stream.
The stream to read.
The stream must support seeking and must be positioned at its beginning.
The encoding to use if the encoding cannot be auto-detected.
The file content as string.
Reads the content of the file.
The file name.
The encoding to use if the encoding cannot be auto-detected.
The file content as string.
Opens the specified file for reading.
The file to open.
The encoding to use if the encoding cannot be auto-detected.
Returns a StreamReader that reads from the stream. Use
to get the encoding that was used.
Opens the specified stream for reading.
The stream to open.
The encoding to use if the encoding cannot be auto-detected.
Returns a StreamReader that reads from the stream. Use
to get the encoding that was used.
Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
Freezes this instance.
If the item is not frozen, this method creates and returns a frozen clone.
If the item is already frozen, it is returned without creating a clone.
Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe.
Freezes this instance.
An immutable stack.
Using 'foreach' on the stack will return the items from top to bottom (in the order they would be popped).
Gets the empty stack instance.
Pushes an item on the stack. This does not modify the stack itself, but returns a new
one with the value pushed.
Gets the item on the top of the stack.
The stack is empty.
Gets the item on the top of the stack.
Returns default(T) if the stack is empty.
Gets the stack with the top item removed.
The stack is empty.
Gets if this stack is empty.
Gets an enumerator that iterates through the stack top-to-bottom.
A collection that cannot contain null values.
A collection where adding and removing items causes a callback.
It is valid for the onAdd callback to throw an exception - this will prevent the new item from
being added to the collection.
Creates a new ObserveAddRemoveCollection using the specified callbacks.
Contains static helper methods for aligning stuff on a whole number of pixels.
Gets the pixel size on the screen containing visual.
This method does not take transforms on visual into account.
Aligns on the next middle of a pixel.
The value that should be aligned
The size of one pixel
Aligns the borders of rect on the middles of pixels.
Rounds to whole number of pixels.
Rounds val to whole number of pixels.
Rounds to a whole number of pixels.
Rounds to an whole odd number of pixels.
RichTextWriter implementation that writes plain text only
and ignores all formatted spans.
The text writer that was passed to the PlainRichTextWriter constructor.
Creates a new PlainRichTextWriter instance that writes the text to the specified text writer.
Gets/Sets the string used to indent by one level.
Writes the indentation, if necessary.
Is called after a write operation.
WeakEventManager for INotifyPropertyChanged.PropertyChanged.
A text writer that supports creating spans of highlighted text.
Gets called by the RichTextWriter base class when a BeginSpan() method
that is not overwritten gets called.
Writes the RichText instance.
Writes the RichText instance.
Begin a colored span.
Begin a span with modified font weight.
Begin a span with modified font style.
Begin a span with modified font family.
Begin a highlighted span.
Begin a span that links to the specified URI.
Marks the end of the current span.
Increases the indentation level.
Decreases the indentation level.
A kind of List<T>, but more efficient for random insertions/removal.
Also has cheap Clone() and SubRope() implementations.
This class is not thread-safe: multiple concurrent write operations or writes concurrent to reads have undefined behavior.
Concurrent reads, however, are safe.
However, clones of a rope are safe to use on other threads even though they share data with the original rope.
Creates a new rope representing the empty string.
Creates a rope from the specified input.
This operation runs in O(N).
input is null.
Creates a rope from a part of the array.
This operation runs in O(N).
input is null.
Creates a new rope that lazily initalizes its content.
The length of the rope that will be lazily loaded.
The callback that provides the content for this rope.
will be called exactly once when the content of this rope is first requested.
It must return a rope with the specified length.
Because the initializer function is not called when a rope is cloned, and such clones may be used on another threads,
it is possible for the initializer callback to occur on any thread.
Any modifications inside the rope will also cause the content to be initialized.
However, insertions at the beginning and the end, as well as inserting this rope into another or
using the method, allows constructions of larger ropes where parts are
lazily loaded.
However, even methods like Concat may sometimes cause the initializer function to be called, e.g. when
two short ropes are concatenated.
Clones the rope.
This operation runs in linear time to the number of rope nodes touched since the last clone was created.
If you count the per-node cost to the operation modifying the rope (doing this doesn't increase the complexity of the modification operations);
the remainder of Clone() runs in O(1).
This method counts as a read access and may be called concurrently to other read accesses.
Resets the rope to an empty list.
Runs in O(1).
Gets the length of the rope.
Runs in O(1).
This method counts as a read access and may be called concurrently to other read accesses.
Gets the length of the rope.
Runs in O(1).
This method counts as a read access and may be called concurrently to other read accesses.
Inserts another rope into this rope.
Runs in O(lg N + lg M), plus a per-node cost as if newElements.Clone() was called.
newElements is null.
index or length is outside the valid range.
Inserts new elements into this rope.
Runs in O(lg N + M), where N is the length of this rope and M is the number of new elements.
newElements is null.
index or length is outside the valid range.
Inserts new elements into this rope.
Runs in O(lg N + M), where N is the length of this rope and M is the number of new elements.
newElements is null.
index or length is outside the valid range.
Appends multiple elements to the end of this rope.
Runs in O(lg N + M), where N is the length of this rope and M is the number of new elements.
newElements is null.
Appends another rope to the end of this rope.
Runs in O(lg N + lg M), plus a per-node cost as if newElements.Clone() was called.
newElements is null.
Appends new elements to the end of this rope.
Runs in O(lg N + M), where N is the length of this rope and M is the number of new elements.
array is null.
Removes a range of elements from the rope.
Runs in O(lg N).
offset or length is outside the valid range.
Copies a range of the specified array into the rope, overwriting existing elements.
Runs in O(lg N + M).
Creates a new rope and initializes it with a part of this rope.
Runs in O(lg N) plus a per-node cost as if this.Clone() was called.
offset or length is outside the valid range.
This method counts as a read access and may be called concurrently to other read accesses.
Concatenates two ropes. The input ropes are not modified.
Runs in O(lg N + lg M).
This method counts as a read access and may be called concurrently to other read accesses.
Concatenates multiple ropes. The input ropes are not modified.
This method counts as a read access and may be called concurrently to other read accesses.
Gets/Sets a single character.
Runs in O(lg N) for random access. Sequential read-only access benefits from a special optimization and runs in amortized O(1).
Offset is outside the valid range (0 to Length-1).
The getter counts as a read access and may be called concurrently to other read accesses.
Creates a string from the rope. Runs in O(N).
A string consisting of all elements in the rope as comma-separated list in {}.
As a special case, Rope<char> will return its contents as string without any additional separators or braces,
so it can be used like StringBuilder.ToString().
This method counts as a read access and may be called concurrently to other read accesses.
Finds the first occurrence of item.
Runs in O(N).
The index of the first occurrence of item, or -1 if it cannot be found.
This method counts as a read access and may be called concurrently to other read accesses.
Gets the index of the first occurrence the specified item.
Item to search for.
Start index of the search.
Length of the area to search.
The first index where the item was found; or -1 if no occurrence was found.
This method counts as a read access and may be called concurrently to other read accesses.
Gets the index of the last occurrence of the specified item in this rope.
Gets the index of the last occurrence of the specified item in this rope.
The search item
Start index of the area to search.
Length of the area to search.
The last index where the item was found; or -1 if no occurrence was found.
The search proceeds backwards from (startIndex+count) to startIndex.
This is different than the meaning of the parameters on Array.LastIndexOf!
Inserts the item at the specified index in the rope.
Runs in O(lg N).
Removes a single item from the rope.
Runs in O(lg N).
Appends the item at the end of the rope.
Runs in O(lg N).
Searches the item in the rope.
Runs in O(N).
This method counts as a read access and may be called concurrently to other read accesses.
Copies the whole content of the rope into the specified array.
Runs in O(N).
This method counts as a read access and may be called concurrently to other read accesses.
Copies the a part of the rope into the specified array.
Runs in O(lg N + M).
This method counts as a read access and may be called concurrently to other read accesses.
Removes the first occurrence of an item from the rope.
Runs in O(N).
Retrieves an enumerator to iterate through the rope.
The enumerator will reflect the state of the rope from the GetEnumerator() call, further modifications
to the rope will not be visible to the enumerator.
This method counts as a read access and may be called concurrently to other read accesses.
Creates an array and copies the contents of the rope into it.
Runs in O(N).
This method counts as a read access and may be called concurrently to other read accesses.
Creates an array and copies the contents of the rope into it.
Runs in O(N).
This method counts as a read access and may be called concurrently to other read accesses.
Balances this node and recomputes the 'height' field.
This method assumes that the children of this node are already balanced and have an up-to-date 'height' value.
Copies from the array to this node.
Copies from this node to the array.
Splits this leaf node at offset and returns a new node with the part of the text after offset.
Gets the root node of the subtree from a lazily evaluated function node.
Such nodes are always marked as shared.
GetContentNode() will return either a Concat or Leaf node, never another FunctionNode.
TextReader implementation that reads text from a rope.
Creates a new RopeTextReader.
Internally, this method creates a Clone of the rope; so the text reader will always read through the old
version of the rope if it is modified.
Represents a string with a segment.
Similar to System.ArraySegment<T>, but for strings instead of arrays.
Creates a new StringSegment.
Creates a new StringSegment.
Gets the string used for this segment.
Gets the start offset of the segment with the text.
Gets the length of the segment.
Equality operator.
Inequality operator.
Creates TextFormatter instances that with the correct TextFormattingMode, if running on .NET 4.0.
Creates a using the formatting mode used by the specified owner object.
Returns whether the specified dependency property affects the text formatter creation.
Controls should re-create their text formatter for such property changes.
Creates formatted text.
The owner element. The text formatter setting are read from this element.
The text.
The typeface to use. If this parameter is null, the typeface of the will be used.
The font size. If this parameter is null, the font size of the will be used.
The foreground color. If this parameter is null, the foreground of the will be used.
A FormattedText object using the specified settings.
Contains exception-throwing helper methods.
Throws an ArgumentNullException if is null; otherwise
returns val.
Use this method to throw an ArgumentNullException when using parameters for base
constructor calls.
public VisualLineText(string text) : base(ThrowUtil.CheckNotNull(text, "text").Length)
WeakEventManager with AddListener/RemoveListener and CurrentManager implementation.
Helps implementing the WeakEventManager pattern with less code.
Creates a new WeakEventManagerBase instance.
Adds a weak event listener.
Removes a weak event listener.
Attaches the event handler.
Detaches the event handler.
Gets the current manager.
Wrapper around Win32 functions.
Gets the caret blink time.
Creates an invisible Win32 caret for the specified Visual with the specified size (coordinates local to the owner visual).
Sets the position of the caret previously created using . position is relative to the owner visual.
Destroys the caret previously created using .
GeneratedInternalTypeHelper
CreateInstance
GetPropertyValue
SetPropertyValue
CreateDelegate
AddEventHandler