diff --git a/Lib/ICSharpCode.AvalonEdit.dll b/Lib/ICSharpCode.AvalonEdit.dll deleted file mode 100644 index 30d1f1a..0000000 Binary files a/Lib/ICSharpCode.AvalonEdit.dll and /dev/null differ diff --git a/Lib/ICSharpCode.AvalonEdit.xml b/Lib/ICSharpCode.AvalonEdit.xml deleted file mode 100644 index f5fe466..0000000 --- a/Lib/ICSharpCode.AvalonEdit.xml +++ /dev/null @@ -1,9641 +0,0 @@ - - - - ICSharpCode.AvalonEdit - - - - - Custom commands for AvalonEdit. - - - - - 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 list box used inside the CompletionList. - - - - - - - - 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. - - - - - Gets the number of the first visible item. - - - - - Gets the number of visible items. - - - - - Base class for completion windows. Handles positioning the window at the caret. - - - - - Creates a new CompletionWindowBase. - - - - - Detaches events from the text area. - - - - - - - - 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. - - - - - - - - - - - - - - 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 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. - - - - - Gets whether the completion window should automatically close when the text editor looses focus. - - - - - 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. - - - - 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. - - - - - Stacked input handler. - Uses OnEvent-methods instead of registering event handlers to ensure that the events are handled in the correct order. - - - - - 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. - - - - - - Attaches an input handler to the text area. - - - - - Detaches the input handler from the text area. - - - - - Gets the text area that the input handler belongs to. - - - - - Creates a new TextAreaInputHandler. - - - - - - - - - - - Called for the PreviewKeyDown event. - - - - - Called for the PreviewKeyUp event. - - - - - - - - The listbox used inside the CompletionWindow, contains CompletionListBox. - - - - - Dependency property for . - - - - - Raises the InsertionRequested event. - - - - - - - - - - - Handles a key press. Used to let the completion list handle key presses while the - focus is still on the text editor. - - - - - - - - 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. - - - - - 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. - - - - - 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. - - - - - Gets the list box. - - - - - Gets the scroll viewer used in this list box. - - - - - Gets the list to which completion data can be added. - - - - - Gets/Sets the selected item. - - - - - Occurs when the SelectedItem property changes. - - - - - The code completion window. - - - - - Creates a new code completion window. - - - - - - - - - - - - - - Gets the completion list used in this 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. - - - - - Describes an entry in the . - - - - - 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. - - - - 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. - - - - - Provides icons for code-completion. - - - - - Gets the CompletionImage instance for the specified entity. - Returns null when no image is available for the entity type. - - - - - Gets the CompletionImage instance for the specified entity. - Returns null when no image is available for the entity type. - - - - - Gets the image for the specified entity. - Returns null when no image is available for the entity type. - - - - - Gets the image for the specified entity. - Returns null when no image is available for the entity type. - - - - - Gets an overlay image for the specified accessibility. - Returns null if no overlay exists (for example, public members don't use overlays). - - - - - Gets this image combined with the specified accessibility overlay. - - - - - - - - Gets the image for namespaces. - - - - Gets the image used for non-static classes. - - - Gets the image used for structs. - - - Gets the image used for interfaces. - - - Gets the image used for delegates. - - - Gets the image used for enums. - - - Gets the image used for modules/static classes. - - - Gets the image used for non-static classes. - - - Gets the image used for structs. - - - Gets the image used for constants. - - - Gets the image used for enum values. - - - Gets the image used for methods. - - - Gets the image used for constructos. - - - Gets the image used for virtual methods. - - - Gets the image used for operators. - - - Gets the image used for extension methods. - - - Gets the image used for P/Invoke methods. - - - Gets the image used for properties. - - - Gets the image used for indexers. - - - Gets the image used for events. - - - - Gets the overlay image for the static modifier. - - - - - Gets the image without any overlays. - - - - - 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. - - - - - - - - The ItemProvider property. - - - - - Changes the selected index. - - The relative index change - usual values are +1 or -1. - - - - Gets/Sets the text between the Up and Down buttons. - - - - - Gets/Sets the item provider. - - - - - Describes a change to a TextDocument. - - - - - This Interface describes a the basic Undo/Redo operation - all Undo Operations must implement this interface. - - - - - Undo the last operation - - - - - Redo the last operation - - - - - 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. - - - - - 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. - - - - - - 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 - - - - - Gets a string with debug output showing the line number and offset. - Does not include the line's text. - - - - - 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 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). - - - - - - - - - - - - - - - - - Freezes this instance. - - - - - Gets if this instance is frozen. Frozen instances are immutable and thus thread-safe. - - - - - An entry in the OffsetChangeMap. - This represents the offset of a document change (either insertion or removal, not both at once). - - - - - 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. - - - - - 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. - - - - - 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. - - - - - - - - - - - - - - - - - Contains weak event managers for the TextDocument events. - - - - - Weak event manager for the event. - - - - - 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. - - - - - - - - - - - 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. - - - - - - - - - - - Weak event manager for the event. - - - - - - - - - - - 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. - - - - - 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 whether this tree contains the specified item. - - - - - Copies all segments in this SegmentTree to the specified array. - - - - - Gets an enumerator to enumerate the segments. - - - - - 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 number of segments in the tree. - - - - - 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. - - - - - 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. - - - - - Gets the inorder successor of the node. - - - - - Gets the inorder predecessor of the node. - - - - - Specifies the mode for getting the next caret position. - - - - - Normal positioning (stop at every caret position) - - - - - 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. - - - - - 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). - - - - - 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 noone 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 - - - - - Marks the current state as original. Discards any previous "original" markers. - - - - - Discards the current "original" marker. - - - - - 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. - - - - - Gets whether the document is currently in its original state (no modifications). - - - - - 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. - - - - 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! - - - - - 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. - - - - - TextView property. - - - - - Called when the is changing. - - - - - Called when the is changing. - - - - - 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. - - - - - Helper class with caret-related methods. - - - - - Minimum distance of the caret to the view border. - - - - - 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. - - - - - 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 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. - - - - - Gets/Sets the color of the caret. - - - - - Base class for known layers. - - - - - 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. - - - - - 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. - - - - - 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. - - - - - Replaces the selection with the specified text. - - - - - Updates the selection when the document changes. - - - - - 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 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. - - - - - 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. - - - - - Gets whether the selection is empty. - - - - - Gets whether virtual space is enabled for this selection. - - - - - Gets the selection length. - - - - - Gets whether the selection is multi-line. - - - - - Native API required for IME support. - - - - - 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 that produces line elements for folded s. - - - - - Abstract base class for generators that produce new visual line elements. - - - - - 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. - - - - - Gets the text run construction context. - - - - - - - - - - - - - - Default brush for folding element text. Value: Brushes.Gray - - - - - Gets/Sets the folding manager from which the foldings should be shown. - - - - - Gets/sets the brush used for folding element text. - - - - - 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. - - - - - 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. - - - - 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. - - - - 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. - - - - - 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. - - - - - 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 . - - - - - Gets if this VisualLineElement can be split. - - - - - 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 - . - - - - - 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. - - - - - - - - Constructs a TextLine from a simple text. - - - - - 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'. - - - - - This is the TextRun implementation used by the class. - - - - - Creates a new FormattedTextRun. - - - - - - - - - - - - - - Gets the element for which the FormattedTextRun was created. - - - - - - - - - - - - - - - - - - - - - - - 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 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 . - - - - 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. - - - - - A margin that shows markers for foldings and allows to expand/collapse the foldings. - - - - - FoldingMarkerBrush dependency property. - - - - - FoldingMarkerBackgroundBrush dependency property. - - - - - SelectedFoldingMarkerBrush dependency property. - - - - - SelectedFoldingMarkerBackgroundBrush dependency property. - - - - - - - - - - - - - - - - - - - - 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. - - - - - Gets/Sets the folding manager from which the foldings should be shown. - - - - - Gets/sets the Brush used for displaying the lines of folding markers. - - - - - Gets/sets the Brush used for displaying the background of folding markers. - - - - - Gets/sets the Brush used for displaying the lines of selected folding markers. - - - - - Gets/sets the Brush used for displaying the background of selected folding markers. - - - - - - - - A section that can be folded. - - - - - Creates new collapsed section when a text view is added to the folding manager. - - - - - 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 the content of the collapsed lines as tooltip text. - - - - - Gets/Sets an additional object associated with this folding section. - - - - - 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - that has no read-only sections; all text is editable. - - - - - that completely disables editing. - - - - - Rectangular selection ("box selection"). - - - - - Gets the name of the entry in the DataObject that signals rectangle selections. - - - - - 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 left 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 up 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Base class for that helps - splitting visual elements so that colors (and other text properties) can be easily assigned - to individual words/characters. - - - - - Allows transforming visual line elements. - - - - - Applies the transformation to the specified list of visual line elements. - - - - - 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. - - - - - Gets the list of elements currently being transformed. - - - - - Handles selection of text using the mouse. - - - - - 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) - - - - - A simple selection. - - - - - Creates a new SimpleSelection instance. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Control that wraps a TextView and adds support for user input and the caret. - - - - - 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. - - - - - Creates a new TextArea instance. - - - - - Creates a new TextArea instance. - - - - - 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. - - - - - Options property. - - - - - Raises the event. - - - - - - - - - - - Clears the current selection. - - - - - The property. - - - - - The property. - - - - - The property. - - - - - The property. - - - - - 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. - - - - - - - - - - - - - - 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 the requested service. - - Returns the requested service instance, or null if the service cannot be found. - - - - 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. - - - - - - Gets/Sets the document displayed by the text editor. - - - - - - - - Gets/Sets the document displayed by the text editor. - - - - - Occurs when a text editor option has changed. - - - - - 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. - - - - - Gets/Sets the background brush used for the selection. - - - - - Gets/Sets the foreground brush used selected text. - - - - - Gets/Sets the background brush used for the selection. - - - - - Gets/Sets the corner radius of the selection. - - - - - 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. - - - - - Gets/Sets the indentation strategy used when inserting new lines. - - - - - Occurs when text inside the TextArea was copied. - - - - - EventArgs with text. - - - - - Creates a new TextEventArgs instance. - - - - - Gets the text. - - - - - Contains the predefined input handlers. - - - - - Default-implementation of . - - - - - - Creates a new TextAreaInputHandler. - - - - - 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 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. - - - - - Gets the collection of nested input handlers. NestedInputHandlers are activated and deactivated - together with this input handler. - - - - - Creates a new TextAreaDefaultInputHandler instance. - - - - - Gets the caret navigation input handler. - - - - - Gets the editing input handler. - - - - - Gets the mouse selection input handler. - - - - - Implementation for that stores the segments - in a . - - - - - 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. - - - - - Gets the collection storing the read-only segments. - - - - - Helper class used for . - - - - - Creates a new NewFolding instance. - - - - - Creates a new NewFolding instance. - - - - - 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. - - - - - Holds information about the start of a fold in an xml string. - - - - - Determines folds for an xml string in the editor. - - - - - 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. - - - - - Flag indicating whether attributes should be displayed on folded - elements. - - - - - This class can syntax-highlight a document. - It automatically manages invalidating the highlighting when the document changes. - - - - - Represents a highlighted document. - - This interface is used by the to register the highlighter as a TextView service. - - - - 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. - - - - - 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 underlying text document. - - - - - 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. - - - - - Gets the default text color. - - - - - Stores the span state at the end of each line. - storedSpanStacks[0] = state at beginning of document - storedSpanStacks[i] = state after line i - - - - - Creates a new DocumentHighlighter instance. - - - - - Creates a new DocumentHighlighter instance. - - - - - Disposes the document highlighter. - - - - - 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. - - - - - - - - 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). - - - - - - - - - - - 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. - - - - the HighlightedLine where highlighting output is being written to. - if this variable is null, nothing is highlighted and only the span state is updated - - - - - Returns the first match from the array or endSpanMatch. - - - - - - - - - - - - - - Gets the document that this DocumentHighlighter is highlighting. - - - - - Gets/sets the the initial span stack of the document. Default value is . - - - - - - - - - - - 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. - - - - - 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. - - - - - Sets the font family on the specified text segment. - - - - - Creates WPF Run instances that can be used for TextBlock.Inlines. - - - - - Clones this HighlightedInlineBuilder. - - - - - Gets the text. - - - - - Represents a highlighted document line. - - - - - Creates a new HighlightedLine instance. - - - - - Validates that the sections are sorted correctly, and that they are not overlapping. - - - - - - Merges the additional line into this line. - - - - - 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. - - - - - 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. - - - - - 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. - - - - - HighlightingBrush implementation that finds a brush using a resource. - - - - - A highlighting color is a set of font properties and foreground and background color. - - - - - Creates a new HighlightingColor instance. - - - - - Deserializes a HighlightingColor. - - - - - Serializes this HighlightingColor instance. - - - - - Gets CSS code for the color. - - - - - - - - Gets/Sets the name of the color. - - - - - 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 foreground color applied by the highlighting. - - - - - Gets/sets the background color applied by the highlighting. - - - - - A colorizes that interprets a highlighting rule set and colors the document accordingly. - - - - - 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. - - - - - - - - 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 . - - - - Gets the current ITextRunConstructionContext. - - - - - 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). - - - - - - - - - - - - - - - - - Manages a list of syntax highlighting definitions. - - - All memers on this class (including instance members) are thread-safe. - - - - - Interface for resolvers that can solve cross-definition references. - - - - - Gets the highlighting definition by name, or null if it is not found. - - - - - Gets a highlighting definition by name. - Returns null if the definition is not found. - - - - - 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 a copy of all highlightings. - - - - - Gets the default HighlightingManager instance. - The default HighlightingManager comes with built-in highlightings. - - - - - A highlighting definition. - - - - - 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 name of the highlighting definition. - - - - - Gets the main rule set. - - - - - Gets the list of named highlighting colors. - - - - - Gets the list of properties. - - - - - 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. - - - - Escapes text and writes the result to the StringBuilder. - - - - - Holds options for converting text to HTML. - - - - - Creates a default HtmlOptions instance. - - - - - Creates a new HtmlOptions instance that copies applicable options from the . - - - - - Writes the HTML attribute for the style to the text writer. - - - - - Gets whether the color needs to be written out to HTML. - - - - - The amount of spaces a tab gets converted to. - - - - - Event handler for - - - - - 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. - - - - - Static class with helper methods to load XSHD highlighting files. - - - - - Lodas 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. - - - - - - - - - - - - - - - - - - - - - - - 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. - - - - - An element in a XSHD rule set. - - - - - Applies the visitor to this element. - - - - - Gets the line number in the .xshd file. - - - - - Gets the column number in the .xshd file. - - - - - Creates a new XshdColor instance. - - - - - Deserializes an XshdColor. - - - - - Serializes this XshdColor instance. - - - - - - - - Gets/sets the name. - - - - - Gets/sets the foreground brush. - - - - - Gets/sets the background brush. - - - - - Gets/sets the font weight. - - - - - Gets/sets the font style. - - - - - Gets/Sets the example text that demonstrates where the color is used. - - - - - <Import> element. - - - - - - - - Gets/sets the referenced rule set. - - - - - A property in an Xshd file. - - - - - Creates a new XshdColor instance. - - - - - - - - Gets/sets the name. - - - - - Gets/sets the value. - - - - - A reference to an xshd color, or an inline xshd color. - - - - - 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. - - - - - Gets the reference. - - - - - Gets the reference. - - - - - Gets the inline element. - - - - - A list of keywords. - - - - - - - - The color. - - - - - Gets the list of key words. - - - - - <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. - - - - - Applies the visitor to all elements. - - - - - - - - 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. - - - - - 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. - - - - - Applies the visitor to all elements. - - - - - Gets/sets the definition name - - - - - Gets the associated extensions. - - - - - Gets the collection of elements. - - - - 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. - - - - - Smart indentation for C#. - - - - - Handles indentation by copying the indentation from the previous line. - Does not support indenting multiple lines. - - - - - 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. - - - - - - - - Does nothing: indenting multiple lines is useless without a smart indentation strategy. - - - - - Creates a new CSharpIndentationStrategy. - - - - - Creates a new CSharpIndentationStrategy and initializes the settings using the text editor options. - - - - - Performs indentation using the specified document accessor. - - Object used for accessing the document line-by-line - Specifies whether empty lines should be kept - - - - - - - - - - Gets/Sets the indentation string. - - - - - Interface used for the indentation class to access the document. - - - - Advances to the next line. - - - 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. - - - - Adapter IDocumentAccessor -> TextDocument - - - - - Creates a new TextDocumentAccessor. - - - - - Creates a new TextDocumentAccessor that indents only a part of the document. - - - - - - - - - - - - - - - - - Helper for creating a PathGeometry. - - - - - 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 - or . - 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! - - - - - Gets/sets the radius of the rounded corners. - - - - - Gets/Sets whether to align the geometry to whole pixels. - - - - - Gets/Sets whether to align the geometry to the middle of pixels. - - - - - Gets/Sets whether to extend the rectangles to full width at line end. - - - - - Represents a collapsed line section. - Use the Uncollapse() method to uncollapse the section. - - - - - 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. - - - - - 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. - - - - - Renders a ruler at a certain column. - - - - - 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. - - - - - Causes the background renderer to draw. - - - - - Gets the layer on which this background renderer should draw. - - - - - Default implementation for TextRunTypographyProperties. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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. - - - - - 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). - - - - - Gets the inorder successor of the node. - - - - - A inline UIElement in the document. - - - - - Creates a new InlineObjectElement. - - The length of the element in the document. Must be non-negative. - The element to display. - - - - - - - Gets the inline element that is displayed. - - - - - 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 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. - - - - - 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. - - - - - 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 - . - - - - - 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. - - - - - Gets/Sets whether the user needs to press Control to click the link. - The default value is true. - - - - - 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. - - - - - Raises the event. - - - - - Raises the event. - - - - - Removes the MouseHover support from the target UIElement. - - - - - Occurs when the mouse starts hovering over a certain location. - - - - - Occurs when the mouse stops hovering over a certain location. - - - - - 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 - . - - - - - Creates a new SingleCharacterElementGenerator instance. - - - - - 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. - - - - - 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. - - - - - 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. - - - - - Creates a new TextView instance. - - - - - Document property. - - - - - Recreates the text formatter that is used internally - by calling . - - - - - - - - Options property. - - - - - Raises the event. - - - - - 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. - - - - - LinkTextForegroundBrush dependency property. - - - - - LinkTextBackgroundBrush dependency property. - - - - - 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. - - - - - 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. - - - - - - - Build all VisualLines in the visible range. - - Width the longest line - - - - Arrange implementation. - - - - - - - - Size of the document, in pixels. - - - - - Offset of the scroll position. - - - - - Size of the viewport. - - - - - Scrolls the text view so that the specified rectangle gets visible. - - - - - - - - Updates the mouse cursor by calling , but with input 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. - - - - 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. - - - - - 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 document line at the specified visual position. - - - - - - - - The pen used to draw the column ruler. - - - - - - Gets/Sets the document displayed by the text editor. - - - - - Occurs when the document property has changed. - - - - - Gets/Sets the options used by the text editor. - - - - - Occurs when a text editor option has changed. - - - - - 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. - - - - - - - - - - - Gets/sets the Brush used for displaying non-printable characters. - - - - - Gets/sets the Brush used for displaying link texts. - - - - - Gets/sets the Brush used for the background of link texts. - - - - - 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. - - - - - Gets the list of background renderers. - - - - - 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. - - - - - 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. - - - - - 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. - - - - - Gets the height of the document. - - - - - Gets/Sets the pen used to draw the column ruler. - - - - - - 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. - - - - - 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 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 next possible caret position after visualColumn, or -1 if there is no caret position. - - - - - 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. - - - - - Gets whether the visual line was disposed. - - - - - EventArgs for the event. - - - - - Creates a new VisualLineConstructionStartEventArgs instance. - - - - - Gets/Sets the first line that is visible in the TextView. - - - - - 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 . - - - - - 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. - - - - - 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. - - - - - Gets the typography properties for the text run. - - - - - Gets the number substitution settings for the text run. - - - - - VisualLineElement that represents a piece of text and is a clickable link. - - - - - VisualLineElement that represents a piece of text. - - - - - 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. - - - - - - - - - - - - - - - - - - - - - - - - - - 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. - - - - - - - - Gets whether the link is currently clickable. - - Returns true when control is pressed; or when - is disabled. - - - - - - - - - - - - - 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. - - - - - 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. - - - - - 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. - - - - - 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!' - - - - - 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) - - - - - A button that opens a drop-down menu when clicked. - - - - - Defines supported search modes. - - - - - Standard search - - - - - RegEx search - - - - - Wildcard search - - - - - - - - - - - - - - - - - - - - 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. - - - - - Creates a new SearchInputHandler and registers the 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 . - - - - - Dependency property for . - - - - - Dependency property for . - - - - - Dependency property for . - - - - - Dependency property for . - - - - - Dependency property for . - - - - - Creates a new SearchPanel. - - - - - Attaches this SearchPanel to a TextArea instance. - - - - - - - - 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. - - - - - Closes the SearchPanel. - - - - - Closes the SearchPanel and removes it. - - - - - Opens the an existing search panel. - - - - - Raises the event. - - - - - Gets/sets whether the search pattern should be interpreted as regular expression. - - - - - Gets/sets whether the search pattern should be interpreted case-sensitive. - - - - - Gets/sets whether the search pattern should only match whole words. - - - - - Gets/sets the search pattern. - - - - - Gets/sets the Brush used for marking search results in the TextView. - - - - - Gets/sets the localization for the SearchPanel. - - - - - Gets whether the Panel is already closed. - - - - - Fired when SearchOptions are changed inside the SearchPanel. - - - - - EventArgs for event. - - - - - Creates a new SearchOptionsChangedEventArgs instance. - - - - - 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. - - - - - 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. - - - - - Creates a named anchor that can be accessed by other SnippetElements. - - - - - An element inside a snippet. - - - - - Performs insertion of the snippet. - - - - - Converts the snippet to text, with replaceable fields in italic. - - - - - Creates a SnippetAnchorElement with the supplied name. - - - - - - - - Gets or sets the name of the anchor. - - - - - AnchorElement created by SnippetAnchorElement. - - - - - Creates a new AnchorElement. - - - - - - - - - - - - - - - - - Gets or sets the text at the anchor. - - - - - Gets or sets the name of the anchor. - - - - - Provides information about the event that occured during use of snippets. - - - - - Creates a new SnippetEventArgs object, with a DeactivateReason. - - - - - Gets the reason for deactivation. - - - - - 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. - - - - - A code snippet that can be inserted into the text editor. - - - - - A snippet element that has sub-elements. - - - - - - - - - - - Gets the list of child elements. - - - - - Inserts the snippet into the text area. - - - - - An element that binds to a and displays the same text. - - - - - Converts the text before copying it. - - - - - - - - - - - Gets/Sets the target element. - - - - - 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. - - - - - - - - Represents the context of a snippet insertion. - - - - - Creates a new InsertionContext instance. - - - - - 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. - - - - - Calls the method on all registered active elements - and raises the event. - - The EventArgs to use - - - - Calls the method on all registered active elements. - - The EventArgs to use - - - - - - - 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. - - - - - Gets the list of active elements. - - - - - Occurs when the all snippet elements have been inserted. - - - - - Occurs when the interactive mode is deactivated. - - - - - Text element that is supposed to be replaced by the user. - Will register an . - - - - - Represents a text element in a snippet. - - - - - - - - - - - The text to be inserted. - - - - - - - - - - - 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. - - - - - The text editor control. - Contains a scrollable TextArea. - - - - - Creates a new TextEditor instance. - - - - - Creates a new TextEditor instance. - - - - - - - Forward focus to TextArea. - - - - - Document property. - - - - - Raises the event. - - - - - Options property. - - - - - Raises the event. - - - - - - - - Raises the event. - - - - - Is called after the template was applied. - - - - - The property. - - - - - 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. - - - - - IsReadOnly dependency property. - - - - - Dependency property for - - - - - ShowLineNumbers dependency property. - - - - - LineNumbersForeground dependency property. - - - - - 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. - - - - - 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. - - - - Selects the specified text section. - - - - - 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. - - - - - 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. - - - - - Dependency property for - - - - - Dependency property for - - - - - 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). - - - - - Gets/Sets the document displayed by the text editor. - This is a dependency property. - - - - - Occurs when the document property has changed. - - - - - Gets/Sets the options currently used by the text editor. - - - - - Occurs when a text editor option has changed. - - - - - Gets/Sets the text of the current document. - - - - - Occurs when the Text property changes. - - - - - 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. - - - - - Gets/sets the syntax highlighting definition used to colorize the text. - - - - - 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. - - - - - Specifies whether the user can change the text editor content. - Setting this property will replace the - TextArea.ReadOnlySectionProvider. - - - - - Gets/Sets the 'modified' flag. - - - - - Specifies whether line numbers are shown on the left to the text view. - - - - - Gets/sets the Brush used for displaying the foreground color of line numbers. - - - - - 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. - - - - - Gets the number of lines in the document. - - - - - Gets/sets the encoding used when the file is saved. - - - - - 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. - - - - - Gets/Sets the horizontal scroll bar visibility. - - - - - Gets/Sets the vertical scroll bar visibility. - - - - - Exposes to automation. - - - - - Creates a new TextEditorAutomationPeer instance. - - - - - - - - Describes a change of the document text. - This class is thread-safe. - - - - - 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. - - - - - - - - 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. - - - - - 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. - - - - 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 - - - - - 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. - - - - - - - - - - - - - - - - - - - - - - - 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. - - - - - - - - - - - - - - - - - - - - - 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. - - - - - - 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 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. - - - - - - Creates a new at the specified offset. - - - - - - Gets the document lines tree in string form. - - - - - Gets the text anchor tree in string form. - - - - - Gets/Sets the text of the whole document. - - - - - - - - - - - - Is raised when the TextLength property changes. - - - - - - 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. - - - - - - - - - Gets if an update is running. - - - - - - Occurs when a document change starts. - - - - - - Occurs when a document change is finished. - - - - - - Gets a read-only list of lines. - - - - - - 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. - - - - Gets the total number of lines in the document. - Runtime: O(1). - - - - - Is raised when the LineCount property changes. - - - - - 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 . - - - - - - - - - - - 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 text required to indent from the specified to the next indentation level. - - - - - - - - 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/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. - - - - - 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. - - - - - 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. - - - - - 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). - - - - - Reuse the same instances for boxed booleans. - - - - - 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). - - - - - 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 the index of the specified . - - - - - Gets the 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. - - - - - Gets the number of elements after that have the same value as each other. - - - - - Applies the conversion function to all elements in this CompressingTreeList. - - - - - 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. - - - - - Gets or sets an item by index. - - - - - Gets the number of items in the list. - - - - - Gets the inorder predecessor of the node. - - - - - Gets the inorder successor of the node. - - - - - Multiply with this constant to convert from points to device-independent pixels. - - - - - Maintains a list of delayed events to raise. - - - - - Double-ended queue. - - - - - - - - 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. - - - - - - - - - - - - - - - - - Gets/Sets an element inside the deque. - - - - - 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. - Previosly 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 mininum and maximum. - - minimum, if value is less than minimum. - Maximum, if value is greater than maximum. - Otherwise, value. - - - - Forces the value to stay between mininum 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. - - - - 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. - - - - - - - - - - - - - - - - - WeakEventManager for INotifyPropertyChanged.PropertyChanged. - - - - - - - - - - - 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 behaviour. - 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). - - - - - 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 elemetns 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. - - - - - 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 occurance of item. - Runs in O(N). - - The index of the first occurance 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 occurance 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. - - - - - 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. - - - - - 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. - - - - - 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. - - - - - - - - - - - - - - Equality operator. - - - - - Inequality operator. - - - - - Gets the string used for this segment. - - - - - Gets the start offset of the segment with the text. - - - - - Gets the length of the segment. - - - - - 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 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. - - - - - 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) - - - - - - Wrapper around Win32 functions. - - - - - 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 . - - - - - Gets the caret blink time. - - - - - GeneratedInternalTypeHelper - - - - - CreateInstance - - - - - GetPropertyValue - - - - - SetPropertyValue - - - - - CreateDelegate - - - - - AddEventHandler - - - - diff --git a/Lib/ICSharpCode.CodeCompletion.dll b/Lib/ICSharpCode.CodeCompletion.dll deleted file mode 100644 index 322b0f2..0000000 Binary files a/Lib/ICSharpCode.CodeCompletion.dll and /dev/null differ diff --git a/Lib/ICSharpCode.CodeCompletion.xml b/Lib/ICSharpCode.CodeCompletion.xml deleted file mode 100644 index 9b3daef..0000000 --- a/Lib/ICSharpCode.CodeCompletion.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - ICSharpCode.CodeCompletion - - - - - Gets the document used for code completion, can be overridden to provide a custom document - - - The document of this text editor. - - - - Initializes a new instance of the class. - - The document, make sure the FileName property is set on the document. - The offset. - Content of the project. - The usings. - - - - Converts a member to text. - Returns the declaration of the member as C# or VB code, e.g. - "public void MemberName(string parameter)" - - - - - Completion item that introduces a using declaration. - - - - - Item for 'override' completion. - - - - - This interface allows to provide more information for scripts such as using statements, etc. - - - - - Output formatter that creates a dictionary from AST nodes to segments in the output text. - - - - diff --git a/Lib/Mono.CSharp.dll b/Lib/Mono.CSharp.dll deleted file mode 100644 index ced1850..0000000 Binary files a/Lib/Mono.CSharp.dll and /dev/null differ diff --git a/Lib/README.txt b/Lib/README.txt index 2440bb5..6d1dc6a 100644 --- a/Lib/README.txt +++ b/Lib/README.txt @@ -1,3 +1,7 @@ Most packages are installed using NuGet (see main readme.md). -But AvalonEdit and NRefactory is installed from a custom build. The source code can be found here: https://github.com/lukebuehler/NRefactory-Completion-Sample \ No newline at end of file +NRefactory is installed from the latest build from GitHub since they update NuGet too infrequently. +https://github.com/icsharpcode/NRefactory + +The XhtmlDumper project can be found on GitHub as well. +https://github.com/lukebuehler/XhtmlDumper \ No newline at end of file diff --git a/Scripts/Tutorial.csx b/Scripts/Tutorial.csx index c119ffa..23d3736 100644 --- a/Scripts/Tutorial.csx +++ b/Scripts/Tutorial.csx @@ -29,8 +29,8 @@ x + x; // The state is preserved now just enter "x" in the REPL and hit enter: The variable "x" containing the value 7 is still there. -// Methods can be declared too, but only in classes. Select the class and send it to the REPL: -// (It's commented out so as not to mess up the code completion, execute it without the comments) +// Methods can be declared too, but only in classes. Select the class and send it to the REPL. +// Select lines 35-45 and press Alt+Enter, to evaluate the class an make it available for later. /* static class MyMath { diff --git a/Src/CShell.sln b/Src/CShell.sln index 787239d..c9f162e 100644 --- a/Src/CShell.sln +++ b/Src/CShell.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Files", "Files", "{CE1B7BD1-A200-4887-8090-42C10D816D2F}" ProjectSection(SolutionItems) = preProject ..\Doc\Links.txt = ..\Doc\Links.txt @@ -19,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{4A604F EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CShell", "CShell\CShell.csproj", "{751E2557-C070-480D-A3B9-662CDFE03907}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CShellCore.CodeCompletion", "CShellCore.CodeCompletion\CShellCore.CodeCompletion.csproj", "{2ADF8E19-B896-4778-8391-BC55FB100852}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +45,12 @@ Global {751E2557-C070-480D-A3B9-662CDFE03907}.Release|Any CPU.Build.0 = Release|Any CPU {751E2557-C070-480D-A3B9-662CDFE03907}.Release|x86.ActiveCfg = Release|x86 {751E2557-C070-480D-A3B9-662CDFE03907}.Release|x86.Build.0 = Release|x86 + {2ADF8E19-B896-4778-8391-BC55FB100852}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2ADF8E19-B896-4778-8391-BC55FB100852}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2ADF8E19-B896-4778-8391-BC55FB100852}.Debug|x86.ActiveCfg = Debug|Any CPU + {2ADF8E19-B896-4778-8391-BC55FB100852}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2ADF8E19-B896-4778-8391-BC55FB100852}.Release|Any CPU.Build.0 = Release|Any CPU + {2ADF8E19-B896-4778-8391-BC55FB100852}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Src/CShell/AppBootstrapper.cs b/Src/CShell/AppBootstrapper.cs index c35ee61..c63f0d4 100644 --- a/Src/CShell/AppBootstrapper.cs +++ b/Src/CShell/AppBootstrapper.cs @@ -56,6 +56,27 @@ protected override void Configure() { //to start we just add the already loaded assemblies to the container & the assemblies in exe folder var directoryCatalog = new DirectoryCatalog(@"./"); + + //use this code to look into loader exceptions, the code bellow is faster. + //try + //{ + // // load the assembly or type + // foreach (var part in directoryCatalog.Parts) + // { + // var assembly = ReflectionModelServices.GetPartType(part).Value.Assembly; + // if (!AssemblySource.Instance.Contains(assembly)) + // AssemblySource.Instance.Add(assembly); + // } + //} + //catch (Exception ex) + //{ + // if (ex is System.Reflection.ReflectionTypeLoadException) + // { + // var typeLoadException = ex as ReflectionTypeLoadException; + // var loaderExceptions = typeLoadException.LoaderExceptions; + // } + //} + AssemblySource.Instance.AddRange( directoryCatalog.Parts .AsParallel() diff --git a/Src/CShell/CShell.csproj b/Src/CShell/CShell.csproj index 02da1ba..a5fa972 100644 --- a/Src/CShell/CShell.csproj +++ b/Src/CShell/CShell.csproj @@ -71,12 +71,9 @@ False ..\..\Lib\Caliburn.Micro.1.5.2\lib\net40\Caliburn.Micro.dll - + False - ..\..\Lib\ICSharpCode.AvalonEdit.dll - - - ..\..\Lib\ICSharpCode.CodeCompletion.dll + ..\..\Lib\AvalonEdit.4.4.2.9744\lib\Net40\ICSharpCode.AvalonEdit.dll False @@ -96,14 +93,20 @@ - - ..\..\Lib\Extended.Wpf.Toolkit.2.0.0\lib\net40\Xceed.Wpf.AvalonDock.dll + + False + ..\..\Lib\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.dll + + + False + ..\..\Lib\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll - - ..\..\Lib\Extended.Wpf.Toolkit.2.0.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll + + ..\..\Lib\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.DataGrid.dll - - ..\..\Lib\Extended.Wpf.Toolkit.2.0.0\lib\net40\Xceed.Wpf.Toolkit.dll + + False + ..\..\Lib\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.Toolkit.dll ..\..\Lib\XhtmlDumper.dll @@ -326,6 +329,10 @@ + + {2adf8e19-b896-4778-8391-bc55fb100852} + CShellCore.CodeCompletion + {5D2479EA-0D1E-4381-AD9C-998CCEC2DC21} CShellCore diff --git a/Src/CShell/Modules/Editors/ViewModels/EditorViewModel.cs b/Src/CShell/Modules/Editors/ViewModels/EditorViewModel.cs index 02d50b8..26c9a90 100644 --- a/Src/CShell/Modules/Editors/ViewModels/EditorViewModel.cs +++ b/Src/CShell/Modules/Editors/ViewModels/EditorViewModel.cs @@ -25,13 +25,13 @@ using CShell.Framework; using CShell.Framework.Services; using CShell.Modules.Editors.Views; +using CShellCore.CodeCompletion; using ICSharpCode.AvalonEdit; using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting.Xshd; using Execute = CShell.Framework.Services.Execute; -using ICSharpCode.CodeCompletion; namespace CShell.Modules.Editors.ViewModels { @@ -112,8 +112,7 @@ protected override void OnViewLoaded(object view) editorView = (EditorView)view; textEditor = editorView.textEditor; if(System.IO.File.Exists(path)) - textEditor.Load(path); - textEditor.Document.FileName = path; + textEditor.OpenFile(path); originalText = textEditor.Text; textEditor.TextChanged += delegate diff --git a/Src/CShell/Modules/Editors/Views/EditorView.xaml b/Src/CShell/Modules/Editors/Views/EditorView.xaml index 9c166d7..f4e0132 100644 --- a/Src/CShell/Modules/Editors/Views/EditorView.xaml +++ b/Src/CShell/Modules/Editors/Views/EditorView.xaml @@ -4,11 +4,11 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit" - xmlns:completion="clr-namespace:ICSharpCode.CodeCompletion;assembly=ICSharpCode.CodeCompletion" + xmlns:codeCompletion="clr-namespace:CShellCore.CodeCompletion;assembly=CShellCore.CodeCompletion" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> - diff --git a/Src/CShell/Modules/Repl/Controls/CSRepl.xaml.cs b/Src/CShell/Modules/Repl/Controls/CSRepl.xaml.cs index eaf4d77..7b8ea06 100644 --- a/Src/CShell/Modules/Repl/Controls/CSRepl.xaml.cs +++ b/Src/CShell/Modules/Repl/Controls/CSRepl.xaml.cs @@ -68,7 +68,7 @@ public CSRepl() textEditor.TextArea.PreviewKeyDown += TextAreaOnPreviewKeyDown; textEditor.IsEnabled = false; textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); - textEditor.Document.FileName = "repl.csx"; + textEditor.FileName = "repl.csx"; textEditor.Repl = this; this.Content = textEditor; @@ -434,7 +434,7 @@ internal IDocument GetCompletionDocument(out int offset) var vars = ScriptingEngine.GetVars(); var code = vars + lineText; offset += vars.Length; - var doc = new ReadOnlyDocument(new StringTextSource(code), textEditor.Document.FileName); + var doc = new ReadOnlyDocument(new ICSharpCode.NRefactory.Editor.StringTextSource(code), textEditor.FileName); return doc; } #endregion diff --git a/Src/CShell/Modules/Repl/Controls/CSReplTextEditor.cs b/Src/CShell/Modules/Repl/Controls/CSReplTextEditor.cs index 137a7cf..4624463 100644 --- a/Src/CShell/Modules/Repl/Controls/CSReplTextEditor.cs +++ b/Src/CShell/Modules/Repl/Controls/CSReplTextEditor.cs @@ -1,4 +1,4 @@ -using ICSharpCode.CodeCompletion; +using CShellCore.CodeCompletion; using ICSharpCode.NRefactory.Editor; using System; using System.Collections.Generic; diff --git a/Src/CShell/Properties/AssemblyInfo.cs b/Src/CShell/Properties/AssemblyInfo.cs index a911ff8..d64d6ca 100644 --- a/Src/CShell/Properties/AssemblyInfo.cs +++ b/Src/CShell/Properties/AssemblyInfo.cs @@ -29,7 +29,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Arnova")] [assembly: AssemblyProduct("CShell")] -[assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2013")] +[assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Src/CShell/packages.config b/Src/CShell/packages.config index 1b09647..cf33777 100644 --- a/Src/CShell/packages.config +++ b/Src/CShell/packages.config @@ -1,6 +1,7 @@  - + + - + \ No newline at end of file diff --git a/Src/CShellCore.CodeCompletion/CSharpCompletion.cs b/Src/CShellCore.CodeCompletion/CSharpCompletion.cs new file mode 100644 index 0000000..76c9298 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CSharpCompletion.cs @@ -0,0 +1,210 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using CShellCore.CodeCompletion.DataItems; +using ICSharpCode.AvalonEdit.CodeCompletion; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.CSharp.Completion; +using ICSharpCode.NRefactory.Documentation; +using ICSharpCode.NRefactory.Editor; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion +{ + public class CSharpCompletion + { + private IProjectContent projectContent; + + public CSharpCompletion() + { + projectContent = new CSharpProjectContent(); + var assemblies = new List + { + typeof(object).Assembly, // mscorlib + typeof(Uri).Assembly, // System.dll + typeof(Enumerable).Assembly, // System.Core.dll +// typeof(System.Xml.XmlDocument).Assembly, // System.Xml.dll +// typeof(System.Drawing.Bitmap).Assembly, // System.Drawing.dll +// typeof(Form).Assembly, // System.Windows.Forms.dll +// typeof(ICSharpCode.NRefactory.TypeSystem.IProjectContent).Assembly, + }; + + var unresolvedAssemblies = new IUnresolvedAssembly[assemblies.Count]; + Stopwatch total = Stopwatch.StartNew(); + Parallel.For( + 0, assemblies.Count, + delegate(int i) + { + var loader = new CecilLoader(); + var path = assemblies[i].Location; + loader.DocumentationProvider = GetXmlDocumentation(assemblies[i].Location); + unresolvedAssemblies[i] = loader.LoadAssemblyFile(assemblies[i].Location); + }); + Debug.WriteLine("Init project content, loading base assemblies: " + total.Elapsed); + projectContent = projectContent.AddAssemblyReferences((IEnumerable)unresolvedAssemblies); + } + + public CSharpCompletion(ICSharpScriptProvider scriptProvider) + :this() + { + ScriptProvider = scriptProvider; + } + + public ICSharpScriptProvider ScriptProvider { get; set; } + + private XmlDocumentationProvider GetXmlDocumentation(string dllPath) + { + if(string.IsNullOrEmpty(dllPath)) + return null; + + var xmlFileName = Path.GetFileNameWithoutExtension(dllPath) + ".xml"; + var localPath = Path.Combine(Path.GetDirectoryName(dllPath), xmlFileName); + if(File.Exists(localPath)) + return new XmlDocumentationProvider(localPath); + + //if it's a .NET framework assembly it's in one of following folders + var netPath = Path.Combine(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0", xmlFileName); + if (File.Exists(netPath)) + return new XmlDocumentationProvider(netPath); + + return null; + } + + public void AddAssembly(string file) + { + if (String.IsNullOrEmpty(file)) + return; + + var loader = new CecilLoader(); + loader.DocumentationProvider = GetXmlDocumentation(file); + var unresolvedAssembly = loader.LoadAssemblyFile(file); + projectContent = projectContent.AddAssemblyReferences(unresolvedAssembly); + } + + public void ProcessInput(string input, string sourceFile) + { + if (string.IsNullOrEmpty(sourceFile)) + return; + //see if it contains the word class, enum or struct + //todo: this is buggy because if two classes are evaluated seperately, the original file will overwrite it + // if the file is a script we should try to extract the class name and use it as the file name. sciptname + class + // we can probably use the AST for that. + if (input.Contains("class ") || input.Contains("enum ") || input.Contains("struct ")) + { + var syntaxTree = new CSharpParser().Parse(input, sourceFile); + syntaxTree.Freeze(); + var unresolvedFile = syntaxTree.ToTypeSystem(); + projectContent = projectContent.AddOrUpdateFiles(unresolvedFile); + } + } + + public CodeCompletionResult GetCompletions(IDocument document, int offset) + { + return GetCompletions(document, offset, false); + } + + public CodeCompletionResult GetCompletions(IDocument document, int offset, bool controlSpace) + { + //get the using statements from the script provider + string usings = null; + if (ScriptProvider != null) + usings = ScriptProvider.GetUsing(); + return GetCompletions(document, offset, controlSpace, usings); + } + + public CodeCompletionResult GetCompletions(IDocument document, int offset, bool controlSpace, string usings) + { + var result = new CodeCompletionResult(); + + if (String.IsNullOrEmpty(document.FileName)) + return result; + + var completionContext = new CSharpCompletionContext(document, offset, projectContent, usings); + + var completionFactory = new CSharpCompletionDataFactory(completionContext.TypeResolveContextAtCaret, completionContext); + var cce = new CSharpCompletionEngine( + completionContext.Document, + completionContext.CompletionContextProvider, + completionFactory, + completionContext.ProjectContent, + completionContext.TypeResolveContextAtCaret + ); + + cce.EolMarker = Environment.NewLine; + cce.FormattingPolicy = FormattingOptionsFactory.CreateSharpDevelop(); + + + var completionChar = completionContext.Document.GetCharAt(completionContext.Offset - 1); + int startPos, triggerWordLength; + IEnumerable completionData; + if (controlSpace) + { + if (!cce.TryGetCompletionWord(completionContext.Offset, out startPos, out triggerWordLength)) + { + startPos = completionContext.Offset; + triggerWordLength = 0; + } + completionData = cce.GetCompletionData(startPos, true); + //this outputs tons of available entities + //if (triggerWordLength == 0) + // completionData = completionData.Concat(cce.GetImportCompletionData(startPos)); + } + else + { + startPos = completionContext.Offset; + + if (char.IsLetterOrDigit(completionChar) || completionChar == '_') + { + if (startPos > 1 && char.IsLetterOrDigit(completionContext.Document.GetCharAt(startPos - 2))) + return result; + completionData = cce.GetCompletionData(startPos, false); + startPos--; + triggerWordLength = 1; + } + else + { + completionData = cce.GetCompletionData(startPos, false); + triggerWordLength = 0; + } + } + + result.TriggerWordLength = triggerWordLength; + result.TriggerWord = completionContext.Document.GetText(completionContext.Offset - triggerWordLength, triggerWordLength); + Debug.Print("Trigger word: '{0}'", result.TriggerWord); + + //cast to AvalonEdit completion data and add to results + foreach (var completion in completionData) + { + var cshellCompletionData = completion as CompletionData; + if (cshellCompletionData != null) + { + cshellCompletionData.TriggerWord = result.TriggerWord; + cshellCompletionData.TriggerWordLength = result.TriggerWordLength; + result.CompletionData.Add(cshellCompletionData); + } + } + + //method completions + if (!controlSpace) + { + // Method Insight + var pce = new CSharpParameterCompletionEngine( + completionContext.Document, + completionContext.CompletionContextProvider, + completionFactory, + completionContext.ProjectContent, + completionContext.TypeResolveContextAtCaret + ); + + var parameterDataProvider = pce.GetParameterDataProvider(completionContext.Offset, completionChar); + result.OverloadProvider = parameterDataProvider as IOverloadProvider; + } + + return result; + } + } +} diff --git a/Src/CShellCore.CodeCompletion/CSharpCompletionContext.cs b/Src/CShellCore.CodeCompletion/CSharpCompletionContext.cs new file mode 100644 index 0000000..c578736 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CSharpCompletionContext.cs @@ -0,0 +1,109 @@ +#region License +// CShell, A Simple C# Scripting IDE +// Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +#endregion + +using System; +using System.IO; +using System.Text.RegularExpressions; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.CSharp.Completion; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using ICSharpCode.NRefactory.Editor; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion +{ + public sealed class CSharpCompletionContext + { + public readonly IDocument OriginalDocument; + public readonly int OriginalOffset; + public readonly string OriginalUsings; + + public readonly int Offset; + public readonly IDocument Document; + public readonly ICompilation Compilation; + public readonly IProjectContent ProjectContent; + public readonly CSharpResolver Resolver; + public readonly CSharpTypeResolveContext TypeResolveContextAtCaret; + public readonly ICompletionContextProvider CompletionContextProvider; + + /// + /// Initializes a new instance of the class. + /// + /// The document, make sure the FileName property is set on the document. + /// The offset. + /// Content of the project. + /// The usings. + public CSharpCompletionContext(IDocument document, int offset, IProjectContent projectContent, string usings = null) + { + OriginalDocument = document; + OriginalOffset = offset; + OriginalUsings = usings; + + //if the document is a c# script we have to soround the document with some code. + Document = PrepareCompletionDocument(document, ref offset, usings); + Offset = offset; + + var syntaxTree = new CSharpParser().Parse(Document, Document.FileName); + syntaxTree.Freeze(); + var unresolvedFile = syntaxTree.ToTypeSystem(); + + ProjectContent = projectContent.AddOrUpdateFiles(unresolvedFile); + //note: it's important that the project content is used that is returned after adding the unresolved file + Compilation = ProjectContent.CreateCompilation(); + + var location = Document.GetLocation(Offset); + Resolver = unresolvedFile.GetResolver(Compilation, location); + TypeResolveContextAtCaret = unresolvedFile.GetTypeResolveContext(Compilation, location); + CompletionContextProvider = new DefaultCompletionContextProvider(Document, unresolvedFile); + } + + private static Regex replaceRegex = new Regex("[^a-zA-Z0-9_]"); + private static IDocument PrepareCompletionDocument(IDocument document, ref int offset, string usings = null) + { + if (String.IsNullOrEmpty(document.FileName)) + return document; + + //if the code is just a script it it will contain no namestpace, class and method structure and so the code completion will not work properly + // for it to work we have to suround the code with the appropriate code structure + //we only process the file if its a .csx file + var fileExtension = Path.GetExtension(document.FileName); + var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(document.FileName); + if (String.IsNullOrEmpty(fileExtension) || String.IsNullOrEmpty(fileNameWithoutExtension)) + return document; + + if (fileExtension.ToLower() == ".csx") + { + var className = replaceRegex.Replace(fileNameWithoutExtension, ""); + className = className.TrimStart('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); //there can be no number at the beginning of the class name + var header = ""; + header += (usings ?? "") + Environment.NewLine; + header += "static class " + className + " {" + Environment.NewLine; + header += "static void Script(){" + Environment.NewLine; + var footer = ""; + footer += Environment.NewLine + "}}"; + + var code = header + document.Text + footer; + offset += header.Length; + return new ReadOnlyDocument(new StringTextSource(code), document.FileName); + } + return document; + } + } + +} diff --git a/Src/CShellCore.CodeCompletion/CSharpCompletionDataFactory.cs b/Src/CShellCore.CodeCompletion/CSharpCompletionDataFactory.cs new file mode 100644 index 0000000..83de09d --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CSharpCompletionDataFactory.cs @@ -0,0 +1,204 @@ +#region License +// CShell, A Simple C# Scripting IDE +// Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// This file is based on code from the SharpDevelop project: +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \Doc\sharpdevelop-copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \Doc\COPYING.LESSER.txt) +#endregion + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using CShellCore.CodeCompletion.DataItems; +using CShellCore.CodeCompletion.Images; +using ICSharpCode.NRefactory.Completion; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.CSharp.Completion; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion +{ + sealed class CSharpCompletionDataFactory : ICompletionDataFactory, IParameterCompletionDataFactory + { + readonly CSharpTypeResolveContext contextAtCaret; + private readonly CSharpCompletionContext context; + + public CSharpCompletionDataFactory(CSharpTypeResolveContext contextAtCaret, CSharpCompletionContext context) + { + Debug.Assert(contextAtCaret != null); + this.contextAtCaret = contextAtCaret; + this.context = context; + } + + #region ICompletionDataFactory implementation + ICompletionData ICompletionDataFactory.CreateEntityCompletionData(IEntity entity) + { + return new EntityCompletionData(entity); + } + + ICompletionData ICompletionDataFactory.CreateEntityCompletionData(IEntity entity, string text) + { + return new EntityCompletionData(entity) + { + CompletionText = text, + DisplayText = text + }; + } + + ICompletionData ICompletionDataFactory.CreateTypeCompletionData(IType type, bool showFullName, bool isInAttributeContext, bool addForTypeCreation) + { + var typeDef = type.GetDefinition(); + if (typeDef != null) + return new EntityCompletionData(typeDef); + else + { + string name = showFullName ? type.FullName : type.Name; + if (isInAttributeContext && name.EndsWith("Attribute") && name.Length > "Attribute".Length) + { + name = name.Substring(0, name.Length - "Attribute".Length); + } + return new CompletionData(name); + } + } + + ICompletionData ICompletionDataFactory.CreateMemberCompletionData(IType type, IEntity member) + { + return new CompletionData(type.Name + "." + member.Name); + } + + ICompletionData ICompletionDataFactory.CreateLiteralCompletionData(string title, string description, string insertText) + { + return new CompletionData(title) + { + Description = description, + CompletionText = insertText ?? title, + Image = CompletionImage.Literal.BaseImage, + Priority = 2 + }; + } + + ICompletionData ICompletionDataFactory.CreateNamespaceCompletionData(INamespace name) + { + return new CompletionData(name.Name) + { + Image = CompletionImage.NamespaceImage, + }; + } + + ICompletionData ICompletionDataFactory.CreateVariableCompletionData(IVariable variable) + { + return new VariableCompletionData(variable); + } + + ICompletionData ICompletionDataFactory.CreateVariableCompletionData(ITypeParameter parameter) + { + return new CompletionData(parameter.Name); + } + + ICompletionData ICompletionDataFactory.CreateEventCreationCompletionData(string varName, IType delegateType, IEvent evt, string parameterDefinition, IUnresolvedMember currentMember, IUnresolvedTypeDefinition currentType) + { + return new CompletionData("TODO: event creation"); + } + + ICompletionData ICompletionDataFactory.CreateNewOverrideCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IMember m) + { + return new OverrideCompletionData(declarationBegin, m, contextAtCaret); + } + + ICompletionData ICompletionDataFactory.CreateNewPartialCompletionData(int declarationBegin, IUnresolvedTypeDefinition type, IUnresolvedMember m) + { + return new CompletionData("TODO: partial completion"); + } + + IEnumerable ICompletionDataFactory.CreateCodeTemplateCompletionData() + { + yield break; + } + + IEnumerable ICompletionDataFactory.CreatePreProcessorDefinesCompletionData() + { + yield return new CompletionData("DEBUG"); + yield return new CompletionData("TEST"); + } + + ICompletionData ICompletionDataFactory.CreateImportCompletionData(IType type, bool useFullName, bool addForTypeCreation) + { + ITypeDefinition typeDef = type.GetDefinition(); + if (typeDef != null) + return new ImportCompletionData(typeDef, contextAtCaret, useFullName); + else + throw new InvalidOperationException("Should never happen"); + } + + ICompletionData ICompletionDataFactory.CreateFormatItemCompletionData(string format, string description, object example) + { + throw new NotImplementedException(); + } + + ICompletionData ICompletionDataFactory.CreateXmlDocCompletionData(string tag, string description = null, string tagInsertionText = null) + { + throw new NotImplementedException(); + } + #endregion + + #region IParameterCompletionDataFactory implementation + IParameterDataProvider CreateMethodDataProvider(int startOffset, IEnumerable methods) + { + return new CSharpOverloadProvider(context, startOffset, from m in methods where m != null select new CSharpInsightItem(m)); + } + + IParameterDataProvider IParameterCompletionDataFactory.CreateConstructorProvider(int startOffset, IType type) + { + return CreateMethodDataProvider(startOffset, type.GetConstructors()); + } + + IParameterDataProvider IParameterCompletionDataFactory.CreateConstructorProvider(int startOffset, IType type, AstNode thisInitializer) + { + return CreateMethodDataProvider(startOffset, type.GetConstructors()); + } + + IParameterDataProvider IParameterCompletionDataFactory.CreateMethodDataProvider(int startOffset, IEnumerable methods) + { + return CreateMethodDataProvider(startOffset, methods); + } + + IParameterDataProvider IParameterCompletionDataFactory.CreateDelegateDataProvider(int startOffset, IType type) + { + return CreateMethodDataProvider(startOffset, new[] { type.GetDelegateInvokeMethod() }); + } + + public IParameterDataProvider CreateIndexerParameterDataProvider(int startOffset, IType type, IEnumerable accessibleIndexers, AstNode resolvedNode) + { + throw new NotImplementedException(); + //return CreateMethodDataProvider(startOffset, accessibleIndexers); + } + + IParameterDataProvider IParameterCompletionDataFactory.CreateTypeParameterDataProvider(int startOffset, IEnumerable types) + { + return null; + } + + public IParameterDataProvider CreateTypeParameterDataProvider(int startOffset, IEnumerable methods) + { + return CreateMethodDataProvider(startOffset, methods); + } + #endregion + + } +} diff --git a/Src/CShellCore.CodeCompletion/CSharpInsightItem.cs b/Src/CShellCore.CodeCompletion/CSharpInsightItem.cs new file mode 100644 index 0000000..17b8fe5 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CSharpInsightItem.cs @@ -0,0 +1,139 @@ +#region License +// CShell, A Simple C# Scripting IDE +// Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// This file is based on code from the SharpDevelop project: +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \Doc\sharpdevelop-copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \Doc\COPYING.LESSER.txt) +#endregion + +using System.IO; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using CShellCore.CodeCompletion.DataItems; +using ICSharpCode.AvalonEdit.Highlighting; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion +{ + public sealed class CSharpInsightItem + { + public readonly IParameterizedMember Method; + + public CSharpInsightItem(IParameterizedMember method) + { + this.Method = method; + } + + TextBlock header; + + public object Header + { + get + { + if (header == null) + { + header = new TextBlock(); + GenerateHeader(); + } + return header; + } + } + + int highlightedParameterIndex = -1; + + public void HighlightParameter(int parameterIndex) + { + if (highlightedParameterIndex == parameterIndex) + return; + this.highlightedParameterIndex = parameterIndex; + if (header != null) + GenerateHeader(); + } + + void GenerateHeader() + { + CSharpAmbience ambience = new CSharpAmbience(); + ambience.ConversionFlags = ConversionFlags.StandardConversionFlags; + var stringBuilder = new StringBuilder(); + var formatter = new ParameterHighlightingOutputFormatter(stringBuilder, highlightedParameterIndex); + ambience.ConvertEntity(Method, formatter, FormattingOptionsFactory.CreateSharpDevelop()); + var inlineBuilder = new HighlightedInlineBuilder(stringBuilder.ToString()); + inlineBuilder.SetFontWeight(formatter.parameterStartOffset, formatter.parameterLength, FontWeights.Bold); + header.Inlines.Clear(); + header.Inlines.AddRange(inlineBuilder.CreateRuns()); + } + + public object Content + { + get { return Documentation; } + } + + private string documentation; + public string Documentation + { + get + { + if (documentation == null) + { + if (Method.Documentation == null) + documentation = ""; + else + documentation = EntityCompletionData.XmlDocumentationToText(Method.Documentation); + } + return documentation; + } + } + + sealed class ParameterHighlightingOutputFormatter : TextWriterOutputFormatter + { + StringBuilder b; + int highlightedParameterIndex; + int parameterIndex; + internal int parameterStartOffset; + internal int parameterLength; + + public ParameterHighlightingOutputFormatter(StringBuilder b, int highlightedParameterIndex) + : base(new StringWriter(b)) + { + this.b = b; + this.highlightedParameterIndex = highlightedParameterIndex; + } + + public override void StartNode(AstNode node) + { + if (parameterIndex == highlightedParameterIndex && node is ParameterDeclaration) + { + parameterStartOffset = b.Length; + } + base.StartNode(node); + } + + public override void EndNode(AstNode node) + { + base.EndNode(node); + if (node is ParameterDeclaration) + { + if (parameterIndex == highlightedParameterIndex) + parameterLength = b.Length - parameterStartOffset; + parameterIndex++; + } + } + } + } +} diff --git a/Src/CShellCore.CodeCompletion/CSharpOverloadProvider.cs b/Src/CShellCore.CodeCompletion/CSharpOverloadProvider.cs new file mode 100644 index 0000000..5ac67d7 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CSharpOverloadProvider.cs @@ -0,0 +1,181 @@ +#region License +// CShell, A Simple C# Scripting IDE +// Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// This file is based on code from the SharpDevelop project: +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \Doc\sharpdevelop-copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \Doc\COPYING.LESSER.txt) +#endregion + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using ICSharpCode.AvalonEdit.CodeCompletion; +using ICSharpCode.NRefactory.Completion; +using ICSharpCode.NRefactory.CSharp.Completion; +using ICSharpCode.NRefactory.Editor; + +namespace CShellCore.CodeCompletion +{ + public class CSharpOverloadProvider : INotifyPropertyChanged, IOverloadProvider, IParameterDataProvider + { + private readonly CSharpCompletionContext context; + private readonly int startOffset; + internal readonly IList items; + private int selectedIndex; + + public CSharpOverloadProvider(CSharpCompletionContext context, int startOffset, IEnumerable items) + { + Debug.Assert(items != null); + this.context = context; + this.startOffset = startOffset; + this.selectedIndex = 0; + this.items = items.ToList(); + + Update(context); + } + + public bool RequestClose { get; set; } + + public int Count + { + get { return items.Count; } + } + + public object CurrentContent + { + get { return items[selectedIndex].Content; } + } + + public object CurrentHeader + { + get { return items[selectedIndex].Header; } + } + + public string CurrentIndexText + { + get { return (selectedIndex + 1).ToString() + " of " + this.Count.ToString(); } + } + + public int SelectedIndex + { + get { return selectedIndex; } + set + { + selectedIndex = value; + if (selectedIndex >= items.Count) + selectedIndex = items.Count - 1; + if (selectedIndex < 0) + selectedIndex = 0; + OnPropertyChanged("SelectedIndex"); + OnPropertyChanged("CurrentIndexText"); + OnPropertyChanged("CurrentHeader"); + OnPropertyChanged("CurrentContent"); + } + } + + public void Update(IDocument document, int offset) + { + var completionContext = new CSharpCompletionContext(document, offset, context.ProjectContent, context.OriginalUsings); + Update(completionContext); + } + + public void Update(CSharpCompletionContext completionContext) + { + var completionFactory = new CSharpCompletionDataFactory(completionContext.TypeResolveContextAtCaret, completionContext); + var pce = new CSharpParameterCompletionEngine( + completionContext.Document, + completionContext.CompletionContextProvider, + completionFactory, + completionContext.ProjectContent, + completionContext.TypeResolveContextAtCaret + ); + + var completionChar = completionContext.Document.GetCharAt(completionContext.Offset - 1); + var docText = completionContext.Document.Text; + Debug.Print("Update Completion char: '{0}'", completionChar); + int parameterIndex = pce.GetCurrentParameterIndex(startOffset, completionContext.Offset); + if (parameterIndex < 0) + { + RequestClose = true; + return; + } + else + { + if (parameterIndex > items[selectedIndex].Method.Parameters.Count) + { + var newItem = items.FirstOrDefault(i => parameterIndex <= i.Method.Parameters.Count); + SelectedIndex = items.IndexOf(newItem); + } + if (parameterIndex > 0) + parameterIndex--; // NR returns 1-based parameter index + foreach (var item in items) + { + item.HighlightParameter(parameterIndex); + } + } + } + + #region IParameterDataProvider implementation + int IParameterDataProvider.StartOffset + { + get { return startOffset; } + } + + string IParameterDataProvider.GetHeading(int overload, string[] parameterDescription, int currentParameter) + { + throw new NotImplementedException(); + } + + string IParameterDataProvider.GetDescription(int overload, int currentParameter) + { + throw new NotImplementedException(); + } + + string IParameterDataProvider.GetParameterDescription(int overload, int paramIndex) + { + throw new NotImplementedException(); + } + + string IParameterDataProvider.GetParameterName(int overload, int currentParameter) + { + throw new NotImplementedException(); + } + + int IParameterDataProvider.GetParameterCount(int overload) + { + throw new NotImplementedException(); + } + + bool IParameterDataProvider.AllowParameterList(int overload) + { + throw new NotImplementedException(); + } + #endregion + + + public event PropertyChangedEventHandler PropertyChanged; + + private void OnPropertyChanged(string propertyName) + { + var args = new PropertyChangedEventArgs(propertyName); + if (PropertyChanged != null) + PropertyChanged(this, args); + } + } +} diff --git a/Src/CShellCore.CodeCompletion/CShellCore.CodeCompletion.csproj b/Src/CShellCore.CodeCompletion/CShellCore.CodeCompletion.csproj new file mode 100644 index 0000000..4d6b5d7 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CShellCore.CodeCompletion.csproj @@ -0,0 +1,166 @@ + + + + + Debug + AnyCPU + {2ADF8E19-B896-4778-8391-BC55FB100852} + Library + Properties + CShellCore.CodeCompletion + CShellCore.CodeCompletion + v4.5 + 512 + ..\ + true + + + true + full + false + ..\..\Bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Bin\Release\ + TRACE + prompt + 4 + + + + ..\..\Lib\AvalonEdit.4.4.2.9744\lib\Net40\ICSharpCode.AvalonEdit.dll + + + ..\..\Lib\ICSharpCode.NRefactory.dll + + + ..\..\Lib\ICSharpCode.NRefactory.Cecil.dll + + + ..\..\Lib\ICSharpCode.NRefactory.CSharp.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/Src/CShellCore.CodeCompletion/CodeCompletionResult.cs b/Src/CShellCore.CodeCompletion/CodeCompletionResult.cs new file mode 100644 index 0000000..5b25c9f --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CodeCompletionResult.cs @@ -0,0 +1,33 @@ +#region License +// CShell, A Simple C# Scripting IDE +// Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +#endregion + +using System.Collections.Generic; +using ICSharpCode.AvalonEdit.CodeCompletion; + +namespace CShellCore.CodeCompletion +{ + public class CodeCompletionResult + { + public List CompletionData = new List(); + public ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData SuggestedCompletionDataItem; + public int TriggerWordLength; + public string TriggerWord; + + public IOverloadProvider OverloadProvider; + } +} diff --git a/Src/CShellCore.CodeCompletion/CodeTextEditor.cs b/Src/CShellCore.CodeCompletion/CodeTextEditor.cs new file mode 100644 index 0000000..520f93b --- /dev/null +++ b/Src/CShellCore.CodeCompletion/CodeTextEditor.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Windows.Controls; +using System.Windows.Input; +using ICSharpCode.AvalonEdit.CodeCompletion; +using ICSharpCode.AvalonEdit.Highlighting; +using ICSharpCode.NRefactory.Editor; + +namespace CShellCore.CodeCompletion +{ + public class CodeTextEditor : ICSharpCode.AvalonEdit.TextEditor + { + CompletionWindow completionWindow; + OverloadInsightWindow insightWindow; + + public CodeTextEditor() + { + TextArea.TextEntering += OnTextEntering; + TextArea.TextEntered += OnTextEntered; + ShowLineNumbers = true; + + + var ctrlSpace = new RoutedCommand(); + ctrlSpace.InputGestures.Add(new KeyGesture(Key.Space, ModifierKeys.Control)); + var cb = new CommandBinding(ctrlSpace, OnCtrlSpaceCommand); + + this.CommandBindings.Add(cb); + } + + public CSharpCompletion Completion { get; set; } + + #region Open & Save File + public string FileName { get; set; } + + + public void OpenFile(string fileName) + { + if (!System.IO.File.Exists(fileName)) + throw new FileNotFoundException(fileName); + + if (completionWindow != null) + completionWindow.Close(); + if (insightWindow != null) + insightWindow.Close(); + + FileName = fileName; + Load(fileName); + SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName)); + } + + public bool SaveFile() + { + if (String.IsNullOrEmpty(FileName)) + return false; + + Save(FileName); + return true; + } + #endregion + + + #region Code Completion + private void OnTextEntered(object sender, TextCompositionEventArgs textCompositionEventArgs) + { + ShowCompletion(textCompositionEventArgs.Text, false); + } + + private void OnCtrlSpaceCommand(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) + { + ShowCompletion(null, true); + } + + private void ShowCompletion(string enteredText, bool controlSpace) + { + if (!controlSpace) + Debug.WriteLine("Code Completion: TextEntered: " + enteredText); + else + Debug.WriteLine("Code Completion: Ctrl+Space"); + + //only process csharp files and if there is a code completion engine available + if (String.IsNullOrEmpty(FileName)) + { + Debug.WriteLine("No document file name, cannot run code completion"); + return; + } + + + if (Completion == null) + { + Debug.WriteLine("Code completion is null, cannot run code completion"); + return; + } + + var fileExtension = Path.GetExtension(FileName); + fileExtension = fileExtension != null ? fileExtension.ToLower() : null; + //check file extension to be a c# file (.cs, .csx, etc.) + if (fileExtension == null || (!fileExtension.StartsWith(".cs"))) + { + Debug.WriteLine("Wrong file extension, cannot run code completion"); + return; + } + + if (completionWindow == null) + { + CodeCompletionResult results = null; + try + { + var offset = 0; + var doc = GetCompletionDocument(out offset); + results = Completion.GetCompletions(doc, offset, controlSpace); + } + catch (Exception exception) + { + Debug.WriteLine("Error in getting completion: " + exception); + } + if (results == null) + return; + + if (insightWindow == null && results.OverloadProvider != null) + { + insightWindow = new OverloadInsightWindow(TextArea); + insightWindow.Provider = results.OverloadProvider; + insightWindow.Show(); + insightWindow.Closed += (o, args) => insightWindow = null; + return; + } + + if (completionWindow == null && results != null && results.CompletionData.Any()) + { + // Open code completion after the user has pressed dot: + completionWindow = new CompletionWindow(TextArea); + completionWindow.CloseWhenCaretAtBeginning = controlSpace; + completionWindow.StartOffset -= results.TriggerWordLength; + //completionWindow.EndOffset -= results.TriggerWordLength; + + IList data = completionWindow.CompletionList.CompletionData; + foreach (var completion in results.CompletionData.OrderBy(item => item.Text)) + { + data.Add(completion); + } + if (results.TriggerWordLength > 0) + { + //completionWindow.CompletionList.IsFiltering = false; + completionWindow.CompletionList.SelectItem(results.TriggerWord); + } + completionWindow.Show(); + completionWindow.Closed += (o, args) => completionWindow = null; + } + }//end if + + + //update the insight window + if (!string.IsNullOrEmpty(enteredText) && insightWindow != null) + { + //whenver text is entered update the provider + var provider = insightWindow.Provider as CSharpOverloadProvider; + if (provider != null) + { + //since the text has not been added yet we need to tread it as if the char has already been inserted + var offset = 0; + var doc = GetCompletionDocument(out offset); + provider.Update(doc, offset); + //if the windows is requested to be closed we do it here + if (provider.RequestClose) + { + insightWindow.Close(); + insightWindow = null; + } + } + } + }//end method + + private void OnTextEntering(object sender, TextCompositionEventArgs textCompositionEventArgs) + { + Debug.WriteLine("TextEntering: " + textCompositionEventArgs.Text); + if (textCompositionEventArgs.Text.Length > 0 && completionWindow != null) + { + if (!char.IsLetterOrDigit(textCompositionEventArgs.Text[0])) + { + // Whenever a non-letter is typed while the completion window is open, + // insert the currently selected element. + completionWindow.CompletionList.RequestInsertion(textCompositionEventArgs); + } + } + // Do not set e.Handled=true. + // We still want to insert the character that was typed. + } + + /// + /// Gets the document used for code completion, can be overridden to provide a custom document + /// + /// + /// The document of this text editor. + protected virtual IDocument GetCompletionDocument(out int offset) + { + offset = CaretOffset; + return new ReadOnlyDocument(new StringTextSource(Text), FileName); + } + #endregion + + + } +} diff --git a/Src/CShellCore.CodeCompletion/DataItems/CompletionData.cs b/Src/CShellCore.CodeCompletion/DataItems/CompletionData.cs new file mode 100644 index 0000000..5ded699 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/DataItems/CompletionData.cs @@ -0,0 +1,102 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using ICSharpCode.AvalonEdit.Editing; +using ICSharpCode.NRefactory.Completion; + +namespace CShellCore.CodeCompletion.DataItems +{ + class CompletionData : ICompletionData, ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData + { + protected CompletionData() + { } + + public CompletionData(string text) + { + DisplayText = CompletionText = Description = text; + } + + public string TriggerWord { get; set; } + public int TriggerWordLength { get; set; } + + #region NRefactory ICompletionData implementation + public CompletionCategory CompletionCategory { get; set; } + public string DisplayText { get; set; } + public virtual string Description { get; set; } + public string CompletionText { get; set; } + public DisplayFlags DisplayFlags { get; set; } + + public bool HasOverloads + { + get { return overloadedData.Count > 0; } + } + + readonly List overloadedData = new List(); + public IEnumerable OverloadedData + { + get { return overloadedData; } + } + + public void AddOverload(ICompletionData data) + { + if (overloadedData.Count == 0) + overloadedData.Add(this); + overloadedData.Add(data); + } + #endregion + + #region AvalonEdit ICompletionData implementation + + public System.Windows.Media.ImageSource Image { get; set; } + + public void Complete(TextArea textArea, ICSharpCode.AvalonEdit.Document.ISegment completionSegment, EventArgs insertionRequestEventArgs) + { + textArea.Document.Replace(completionSegment, this.CompletionText); + } + + public object Content + { + get { return DisplayText; } + } + + object ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData.Description + { + get { return this.Description; } + } + + private double priority = 1; + public virtual double Priority + { + get { return priority; } + set { priority = value; } + } + + public string Text + { + get { return this.CompletionText; } + } + #endregion + + #region Equals, ToString, GetHashCode... + public override string ToString() + { + return DisplayText; + } + + public override bool Equals(object obj) + { + var other = obj as CompletionData; + return other != null && DisplayText == other.DisplayText; + } + + public override int GetHashCode() + { + return DisplayText.GetHashCode(); + } + #endregion + + + } //end class CompletionData +} diff --git a/Src/CShellCore.CodeCompletion/DataItems/EntityCompletionData.cs b/Src/CShellCore.CodeCompletion/DataItems/EntityCompletionData.cs new file mode 100644 index 0000000..7f46b73 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/DataItems/EntityCompletionData.cs @@ -0,0 +1,158 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; +using CShellCore.CodeCompletion.Images; +using ICSharpCode.NRefactory.Completion; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion.DataItems +{ + class EntityCompletionData : CompletionData, IEntityCompletionData + { + readonly IEntity entity; + static readonly CSharpAmbience csharpAmbience = new CSharpAmbience(); + + public IEntity Entity + { + get { return entity; } + } + + public EntityCompletionData(IEntity entity) + { + if (entity == null) throw new ArgumentNullException("entity"); + this.entity = entity; + IAmbience ambience = new CSharpAmbience(); + ambience.ConversionFlags = entity is ITypeDefinition ? ConversionFlags.ShowTypeParameterList : ConversionFlags.None; + DisplayText = entity.Name; + this.CompletionText = ambience.ConvertEntity(entity); + ambience.ConversionFlags = ConversionFlags.StandardConversionFlags; + if (entity is ITypeDefinition) + { + // Show fully qualified Type name + ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames; + } + this.Image = CompletionImage.GetImage(entity); + } + + #region Description & Documentation + private string description; + public override string Description + { + get + { + if (description == null) + { + description = GetText(Entity); + if (HasOverloads) + { + description += " (+" + OverloadedData.Count() + " overloads)"; + } + description += Environment.NewLine + XmlDocumentationToText(Entity.Documentation); + } + return description; + } + set + { + description = value; + } + } + + /// + /// Converts a member to text. + /// Returns the declaration of the member as C# or VB code, e.g. + /// "public void MemberName(string parameter)" + /// + static string GetText(IEntity entity) + { + IAmbience ambience = csharpAmbience; + ambience.ConversionFlags = ConversionFlags.StandardConversionFlags; + if (entity is ITypeDefinition) + { + // Show fully qualified Type name + ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames; + } + if(entity is IMethod) + { + //if the method is an extension method we wanna see the whole method for the description + //the original method (not reduced) can be obtained by calling ReducedFrom + var reducedFromMethod = ((IMethod)entity).ReducedFrom; + if(reducedFromMethod != null) + entity = reducedFromMethod; + } + return ambience.ConvertEntity(entity); + } + + public static string XmlDocumentationToText(string xmlDoc) + { + //.Diagnostics.Debug.WriteLine(xmlDoc); + StringBuilder b = new StringBuilder(); + try + { + using (XmlTextReader reader = new XmlTextReader(new StringReader("" + xmlDoc + ""))) + { + reader.XmlResolver = null; + while (reader.Read()) + { + switch (reader.NodeType) + { + case XmlNodeType.Text: + b.Append(reader.Value); + break; + case XmlNodeType.Element: + switch (reader.Name) + { + case "filterpriority": + reader.Skip(); + break; + case "returns": + b.AppendLine(); + b.Append("Returns: "); + break; + case "param": + b.AppendLine(); + b.Append(reader.GetAttribute("name") + ": "); + break; + case "remarks": + b.AppendLine(); + b.Append("Remarks: "); + break; + case "see": + if (reader.IsEmptyElement) + { + b.Append(reader.GetAttribute("cref")); + } + else + { + reader.MoveToContent(); + if (reader.HasValue) + { + b.Append(reader.Value); + } + else + { + b.Append(reader.GetAttribute("cref")); + } + } + break; + } + break; + } + } + } + return b.ToString(); + } + catch (XmlException) + { + return xmlDoc; + } + } + + #endregion + } //end class EntityCompletionData +} diff --git a/Src/CShellCore.CodeCompletion/DataItems/ImportCompletionData.cs b/Src/CShellCore.CodeCompletion/DataItems/ImportCompletionData.cs new file mode 100644 index 0000000..96cca96 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/DataItems/ImportCompletionData.cs @@ -0,0 +1,35 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion.DataItems +{ + /// + /// Completion item that introduces a using declaration. + /// + class ImportCompletionData : EntityCompletionData + { + string insertUsing; + string insertionText; + + public ImportCompletionData(ITypeDefinition typeDef, CSharpTypeResolveContext contextAtCaret, bool useFullName) + : base(typeDef) + { + this.Description = "using " + typeDef.Namespace + ";"; + if (useFullName) + { + var astBuilder = new TypeSystemAstBuilder(new CSharpResolver(contextAtCaret)); + insertionText = astBuilder.ConvertType(typeDef).GetText(); + } + else + { + insertionText = typeDef.Name; + insertUsing = typeDef.Namespace; + } + } + } //end class ImportCompletionData +} diff --git a/Src/CShellCore.CodeCompletion/DataItems/OverrideCompletionData.cs b/Src/CShellCore.CodeCompletion/DataItems/OverrideCompletionData.cs new file mode 100644 index 0000000..d024d8e --- /dev/null +++ b/Src/CShellCore.CodeCompletion/DataItems/OverrideCompletionData.cs @@ -0,0 +1,124 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; +using ICSharpCode.AvalonEdit; +using ICSharpCode.AvalonEdit.Editing; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.CSharp.Refactoring; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion.DataItems +{ + /// + /// Item for 'override' completion. + /// + internal class OverrideCompletionData : EntityCompletionData + { + readonly int declarationBegin; + readonly CSharpTypeResolveContext contextAtCaret; + + public OverrideCompletionData(int declarationBegin, IMember m, CSharpTypeResolveContext contextAtCaret) + : base(m) + { + this.declarationBegin = declarationBegin; + this.contextAtCaret = contextAtCaret; + var ambience = new CSharpAmbience(); + ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames; + this.CompletionText = ambience.ConvertEntity(m); + } + + #region Complete Override + //TODO: this is never called, on completion + public void XXXComplete(ICSharpCode.AvalonEdit.Editing.TextArea textArea, ICSharpCode.AvalonEdit.Document.ISegment completionSegment, EventArgs insertionRequestEventArgs) + { + if (declarationBegin > completionSegment.Offset) + { + base.Complete(textArea, completionSegment, insertionRequestEventArgs); + return; + } + TypeSystemAstBuilder b = new TypeSystemAstBuilder(new CSharpResolver(contextAtCaret)); + b.ShowTypeParameterConstraints = false; + b.GenerateBody = true; + + var entityDeclaration = b.ConvertEntity(this.Entity); + entityDeclaration.Modifiers &= ~(Modifiers.Virtual | Modifiers.Abstract); + entityDeclaration.Modifiers |= Modifiers.Override; + + if (!this.Entity.IsAbstract) + { + // modify body to call the base method + if (this.Entity.EntityType == EntityType.Method) + { + var baseCall = new BaseReferenceExpression().Invoke(this.Entity.Name, ParametersToExpressions(this.Entity)); + var body = entityDeclaration.GetChildByRole(Roles.Body); + body.Statements.Clear(); + if (((IMethod)this.Entity).ReturnType.IsKnownType(KnownTypeCode.Void)) + body.Statements.Add(new ExpressionStatement(baseCall)); + else + body.Statements.Add(new ReturnStatement(baseCall)); + } + else if (this.Entity.EntityType == EntityType.Indexer || this.Entity.EntityType == EntityType.Property) + { + Expression baseCall; + if (this.Entity.EntityType == EntityType.Indexer) + baseCall = new BaseReferenceExpression().Indexer(ParametersToExpressions(this.Entity)); + else + baseCall = new BaseReferenceExpression().Member(this.Entity.Name); + var getterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.GetterRole).Body; + if (!getterBody.IsNull) + { + getterBody.Statements.Clear(); + getterBody.Add(new ReturnStatement(baseCall.Clone())); + } + var setterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.SetterRole).Body; + if (!setterBody.IsNull) + { + setterBody.Statements.Clear(); + setterBody.Add(new AssignmentExpression(baseCall.Clone(), new IdentifierExpression("value"))); + } + } + } + + var document = textArea.Document; + StringWriter w = new StringWriter(); + var formattingOptions = FormattingOptionsFactory.CreateSharpDevelop(); + var segmentDict = SegmentTrackingOutputFormatter.WriteNode(w, entityDeclaration, formattingOptions, textArea.Options); + + string newText = w.ToString().TrimEnd(); + document.Replace(declarationBegin, completionSegment.EndOffset - declarationBegin, newText); + var throwStatement = entityDeclaration.Descendants.FirstOrDefault(n => n is ThrowStatement); + if (throwStatement != null) + { + var segment = segmentDict[throwStatement]; + textArea.Selection = new RectangleSelection(textArea, new TextViewPosition(textArea.Document.GetLocation(declarationBegin + segment.Offset)), new TextViewPosition(textArea.Document.GetLocation(declarationBegin + segment.Offset + segment.Length))); + } + + //format the inserted code nicely + //AvalonEdit and NRefactory dont play nice together. + //var formatter = new CSharpFormatter(formattingOptions); + //formatter.AddFormattingRegion(new DomRegion(document.GetLocation(declarationBegin), document.GetLocation(declarationBegin + newText.Length))); + //var syntaxTree = new CSharpParser().Parse(document); + //formatter.AnalyzeFormatting(document, syntaxTree).ApplyChanges(); + } + + IEnumerable ParametersToExpressions(IEntity entity) + { + foreach (var p in ((IParameterizedMember)entity).Parameters) + { + if (p.IsRef || p.IsOut) + yield return new DirectionExpression(p.IsOut ? FieldDirection.Out : FieldDirection.Ref, new IdentifierExpression(p.Name)); + else + yield return new IdentifierExpression(p.Name); + } + } + #endregion + }//end class OverrideCompletionData +} diff --git a/Src/CShellCore.CodeCompletion/DataItems/VariableCompletionData.cs b/Src/CShellCore.CodeCompletion/DataItems/VariableCompletionData.cs new file mode 100644 index 0000000..def9cbf --- /dev/null +++ b/Src/CShellCore.CodeCompletion/DataItems/VariableCompletionData.cs @@ -0,0 +1,29 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using CShellCore.CodeCompletion.Images; +using ICSharpCode.NRefactory.Completion; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion.DataItems +{ + internal class VariableCompletionData : CompletionData, IVariableCompletionData + { + public VariableCompletionData(IVariable variable) + { + if (variable == null) throw new ArgumentNullException("variable"); + Variable = variable; + + IAmbience ambience = new CSharpAmbience(); + DisplayText = variable.Name; + Description = ambience.ConvertVariable(variable); + CompletionText = Variable.Name; + this.Image = CompletionImage.Field.BaseImage; + } + + public IVariable Variable { get; private set; } + } //end class VariableCompletionData + +} diff --git a/Src/CShellCore.CodeCompletion/ICSharpScriptProvider.cs b/Src/CShellCore.CodeCompletion/ICSharpScriptProvider.cs new file mode 100644 index 0000000..c9cf674 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/ICSharpScriptProvider.cs @@ -0,0 +1,11 @@ +namespace CShellCore.CodeCompletion +{ + /// + /// This interface allows to provide more information for scripts such as using statements, etc. + /// + public interface ICSharpScriptProvider + { + string GetUsing(); + string GetVars(); + } +} diff --git a/Src/CShellCore.CodeCompletion/Images/Class.png b/Src/CShellCore.CodeCompletion/Images/Class.png new file mode 100644 index 0000000..762c9f2 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Class.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/CompletionImage.cs b/Src/CShellCore.CodeCompletion/Images/CompletionImage.cs new file mode 100644 index 0000000..5169ffd --- /dev/null +++ b/Src/CShellCore.CodeCompletion/Images/CompletionImage.cs @@ -0,0 +1,358 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Threading; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using ICSharpCode.NRefactory.TypeSystem; + +namespace CShellCore.CodeCompletion.Images +{ + /// + /// Provides icons for code-completion. + /// + public class CompletionImage + { + #region non-entity Images + static readonly BitmapImage namespaceImage = LoadBitmap("NameSpace"); + + /// + /// Gets the image for namespaces. + /// + public static ImageSource NamespaceImage { + get { return namespaceImage; } + } + + static BitmapImage LoadBitmap(string name) + { + BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/CShellCore.CodeCompletion;component/Images/" + name + ".png")); + image.Freeze(); + return image; + } + #endregion + + #region Entity Images + static readonly CompletionImage imageClass = new CompletionImage("Class", false); + static readonly CompletionImage imageStruct = new CompletionImage("Struct", false); + static readonly CompletionImage imageInterface = new CompletionImage("Interface", false); + static readonly CompletionImage imageDelegate = new CompletionImage("Delegate", false); + static readonly CompletionImage imageEnum = new CompletionImage("Enum", false); + static readonly CompletionImage imageStaticClass = new CompletionImage("StaticClass", false); + + /// Gets the image used for non-static classes. + public static CompletionImage Class { get { return imageClass; } } + + /// Gets the image used for structs. + public static CompletionImage Struct { get { return imageStruct; } } + + /// Gets the image used for interfaces. + public static CompletionImage Interface { get { return imageInterface; } } + + /// Gets the image used for delegates. + public static CompletionImage Delegate { get { return imageDelegate; } } + + /// Gets the image used for enums. + public static CompletionImage Enum { get { return imageEnum; } } + + /// Gets the image used for modules/static classes. + public static CompletionImage StaticClass { get { return imageStaticClass; } } + + static readonly CompletionImage imageField = new CompletionImage("Field", true); + static readonly CompletionImage imageFieldReadOnly = new CompletionImage("FieldReadOnly", true); + static readonly CompletionImage imageLiteral = new CompletionImage("Literal", false); + static readonly CompletionImage imageEnumValue = new CompletionImage("EnumValue", false); + + /// Gets the image used for non-static classes. + public static CompletionImage Field { get { return imageField; } } + + /// Gets the image used for structs. + public static CompletionImage ReadOnlyField { get { return imageFieldReadOnly; } } + + /// Gets the image used for constants. + public static CompletionImage Literal { get { return imageLiteral; } } + + /// Gets the image used for enum values. + public static CompletionImage EnumValue { get { return imageEnumValue; } } + + static readonly CompletionImage imageMethod = new CompletionImage("Method", true); + static readonly CompletionImage imageConstructor = new CompletionImage("Constructor", true); + static readonly CompletionImage imageVirtualMethod = new CompletionImage("VirtualMethod", true); + static readonly CompletionImage imageOperator = new CompletionImage("Operator", false); + static readonly CompletionImage imageExtensionMethod = new CompletionImage("ExtensionMethod", true); + static readonly CompletionImage imagePInvokeMethod = new CompletionImage("PInvokeMethod", true); + static readonly CompletionImage imageProperty = new CompletionImage("Property", true); + static readonly CompletionImage imageIndexer = new CompletionImage("Indexer", true); + static readonly CompletionImage imageEvent = new CompletionImage("Event", true); + + /// Gets the image used for methods. + public static CompletionImage Method { get { return imageMethod; } } + + /// Gets the image used for constructos. + public static CompletionImage Constructor { get { return imageConstructor; } } + + /// Gets the image used for virtual methods. + public static CompletionImage VirtualMethod { get { return imageVirtualMethod; } } + + /// Gets the image used for operators. + public static CompletionImage Operator { get { return imageOperator; } } + + /// Gets the image used for extension methods. + public static CompletionImage ExtensionMethod { get { return imageExtensionMethod; } } + + /// Gets the image used for P/Invoke methods. + public static CompletionImage PInvokeMethod { get { return imagePInvokeMethod; } } + + /// Gets the image used for properties. + public static CompletionImage Property { get { return imageProperty; } } + + /// Gets the image used for indexers. + public static CompletionImage Indexer { get { return imageIndexer; } } + + /// Gets the image used for events. + public static CompletionImage Event { get { return imageEvent; } } + + /// + /// Gets the CompletionImage instance for the specified entity. + /// Returns null when no image is available for the entity type. + /// + public static CompletionImage GetCompletionImage(IEntity entity) + { + if (entity == null) + throw new ArgumentNullException("entity"); + switch (entity.EntityType) { + case EntityType.TypeDefinition: + return GetCompletionImageForType(((ITypeDefinition)entity).Kind, entity.IsStatic); + case EntityType.Field: + IField field = (IField)entity; + if (field.IsConst) { + if (field.DeclaringTypeDefinition != null && field.DeclaringTypeDefinition.Kind == TypeKind.Enum) + return imageEnumValue; + else + return imageLiteral; + } + return field.IsReadOnly ? imageFieldReadOnly : imageField; + case EntityType.Method: + IMethod method = (IMethod)entity; + if (method.IsExtensionMethod) + return imageExtensionMethod; + else + return method.IsOverridable ? imageVirtualMethod : imageMethod; + case EntityType.Property: + return imageProperty; + case EntityType.Indexer: + return imageIndexer; + case EntityType.Event: + return imageEvent; + case EntityType.Operator: + case EntityType.Destructor: + return imageOperator; + case EntityType.Constructor: + return imageConstructor; + default: + return null; + } + } + + /// + /// Gets the CompletionImage instance for the specified entity. + /// Returns null when no image is available for the entity type. + /// + public static CompletionImage GetCompletionImage(IUnresolvedEntity entity) + { + if (entity == null) + throw new ArgumentNullException("entity"); + switch (entity.SymbolKind) { + case SymbolKind.TypeDefinition: + return GetCompletionImageForType(((IUnresolvedTypeDefinition)entity).Kind, entity.IsStatic); + case SymbolKind.Field: + IUnresolvedField field = (IUnresolvedField)entity; + if (field.IsConst) { + if (field.DeclaringTypeDefinition != null && field.DeclaringTypeDefinition.Kind == TypeKind.Enum) + return imageEnumValue; + else + return imageLiteral; + } + return field.IsReadOnly ? imageFieldReadOnly : imageField; + case SymbolKind.Method: + IUnresolvedMethod method = (IUnresolvedMethod)entity; + return method.IsOverridable ? imageVirtualMethod : imageMethod; + case SymbolKind.Property: + return imageProperty; + case SymbolKind.Indexer: + return imageIndexer; + case SymbolKind.Event: + return imageEvent; + case SymbolKind.Operator: + case SymbolKind.Destructor: + return imageOperator; + case SymbolKind.Constructor: + return imageConstructor; + default: + return null; + } + } + + static CompletionImage GetCompletionImageForType(TypeKind typeKind, bool isStatic) + { + switch (typeKind) { + case TypeKind.Interface: + return imageInterface; + case TypeKind.Struct: + case TypeKind.Void: + return imageStruct; + case TypeKind.Delegate: + return imageDelegate; + case TypeKind.Enum: + return imageEnum; + case TypeKind.Class: + return isStatic ? imageStaticClass : imageClass; + case TypeKind.Module: + return imageStaticClass; + default: + return null; + } + } + + /// + /// Gets the image for the specified entity. + /// Returns null when no image is available for the entity type. + /// + public static ImageSource GetImage(IEntity entity) + { + CompletionImage image = GetCompletionImage(entity); + if (image != null) + return image.GetImage(entity.Accessibility, entity.IsStatic); + else + return null; + } + + /// + /// Gets the image for the specified entity. + /// Returns null when no image is available for the entity type. + /// + public static ImageSource GetImage(IUnresolvedEntity entity) + { + CompletionImage image = GetCompletionImage(entity); + if (image != null) + return image.GetImage(entity.Accessibility, entity.IsStatic); + else + return null; + } + #endregion + + #region Overlays + static readonly BitmapImage overlayStatic = LoadBitmap("OverlayStatic"); + + /// + /// Gets the overlay image for the static modifier. + /// + public ImageSource StaticOverlay { get { return overlayStatic; } } + + const int AccessibilityOverlaysLength = 5; + + static readonly BitmapImage[] accessibilityOverlays = new BitmapImage[AccessibilityOverlaysLength] { + null, + LoadBitmap("OverlayPrivate"), + LoadBitmap("OverlayProtected"), + LoadBitmap("OverlayInternal"), + LoadBitmap("OverlayProtectedInternal") + }; + + /// + /// Gets an overlay image for the specified accessibility. + /// Returns null if no overlay exists (for example, public members don't use overlays). + /// + public static ImageSource GetAccessibilityOverlay(Accessibility accessibility) + { + return accessibilityOverlays[GetAccessibilityOverlayIndex(accessibility)]; + } + + static int GetAccessibilityOverlayIndex(Accessibility accessibility) + { + switch (accessibility) { + case Accessibility.Private: + return 1; + case Accessibility.Protected: + return 2; + case Accessibility.Internal: + return 3; + case Accessibility.ProtectedOrInternal: + case Accessibility.ProtectedAndInternal: + return 4; + default: + return 0; + } + } + #endregion + + #region Instance Members (add overlay to entity image) + readonly string imageName; + readonly bool showStaticOverlay; + + private CompletionImage(string imageName, bool showStaticOverlay) + { + this.imageName = imageName; + this.showStaticOverlay = showStaticOverlay; + } + + ImageSource[] images = new ImageSource[2 * AccessibilityOverlaysLength]; + // 0..N-1 = base image + accessibility overlay + // N..2N-1 = base image + static overlay + accessibility overlay + + /// + /// Gets the image without any overlays. + /// + public ImageSource BaseImage { + get { + ImageSource image = images[0]; + if (image == null) { + image = LoadBitmap(imageName); + Thread.MemoryBarrier(); + images[0] = image; + } + return image; + } + } + + /// + /// Gets this image combined with the specified accessibility overlay. + /// + public ImageSource GetImage(Accessibility accessibility, bool isStatic = false) + { + int accessibilityIndex = GetAccessibilityOverlayIndex(accessibility); + int index; + if (isStatic && showStaticOverlay) + index = accessibilityOverlays.Length + accessibilityIndex; + else + index = accessibilityIndex; + + if (index == 0) + return this.BaseImage; + + ImageSource image = images[index]; + if (image == null) { + DrawingGroup g = new DrawingGroup(); + Rect iconRect = new Rect(0, 0, 16, 16); + g.Children.Add(new ImageDrawing(this.BaseImage, iconRect)); + + if (accessibilityOverlays[accessibilityIndex] != null) + g.Children.Add(new ImageDrawing(accessibilityOverlays[accessibilityIndex], iconRect)); + + image = new DrawingImage(g); + image.Freeze(); + Thread.MemoryBarrier(); + images[index] = image; + } + return image; + } + + /// + public override string ToString() + { + return "[CompletionImage " + imageName + "]"; + } + #endregion + } +} diff --git a/Src/CShellCore.CodeCompletion/Images/Constructor.png b/Src/CShellCore.CodeCompletion/Images/Constructor.png new file mode 100644 index 0000000..0d60fe5 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Constructor.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Delegate.png b/Src/CShellCore.CodeCompletion/Images/Delegate.png new file mode 100644 index 0000000..84339ed Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Delegate.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Enum.png b/Src/CShellCore.CodeCompletion/Images/Enum.png new file mode 100644 index 0000000..28e989f Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Enum.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/EnumValue.png b/Src/CShellCore.CodeCompletion/Images/EnumValue.png new file mode 100644 index 0000000..5affdbf Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/EnumValue.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Event.png b/Src/CShellCore.CodeCompletion/Images/Event.png new file mode 100644 index 0000000..9ceb807 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Event.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/ExtensionMethod.png b/Src/CShellCore.CodeCompletion/Images/ExtensionMethod.png new file mode 100644 index 0000000..8545a4d Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/ExtensionMethod.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Field.png b/Src/CShellCore.CodeCompletion/Images/Field.png new file mode 100644 index 0000000..6030397 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Field.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/FieldReadOnly.png b/Src/CShellCore.CodeCompletion/Images/FieldReadOnly.png new file mode 100644 index 0000000..3f33852 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/FieldReadOnly.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Indexer.png b/Src/CShellCore.CodeCompletion/Images/Indexer.png new file mode 100644 index 0000000..86a9082 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Indexer.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Interface.png b/Src/CShellCore.CodeCompletion/Images/Interface.png new file mode 100644 index 0000000..788cc17 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Interface.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Literal.png b/Src/CShellCore.CodeCompletion/Images/Literal.png new file mode 100644 index 0000000..55a693d Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Literal.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Method.png b/Src/CShellCore.CodeCompletion/Images/Method.png new file mode 100644 index 0000000..7cce8ba Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Method.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/NameSpace.png b/Src/CShellCore.CodeCompletion/Images/NameSpace.png new file mode 100644 index 0000000..9660524 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/NameSpace.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Operator.png b/Src/CShellCore.CodeCompletion/Images/Operator.png new file mode 100644 index 0000000..6fa32b9 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Operator.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/OverlayInternal.png b/Src/CShellCore.CodeCompletion/Images/OverlayInternal.png new file mode 100644 index 0000000..3c1cbc6 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/OverlayInternal.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/OverlayPrivate.png b/Src/CShellCore.CodeCompletion/Images/OverlayPrivate.png new file mode 100644 index 0000000..13ee614 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/OverlayPrivate.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/OverlayProtected.png b/Src/CShellCore.CodeCompletion/Images/OverlayProtected.png new file mode 100644 index 0000000..8f789ba Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/OverlayProtected.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/OverlayProtectedInternal.png b/Src/CShellCore.CodeCompletion/Images/OverlayProtectedInternal.png new file mode 100644 index 0000000..8267681 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/OverlayProtectedInternal.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/OverlayStatic.png b/Src/CShellCore.CodeCompletion/Images/OverlayStatic.png new file mode 100644 index 0000000..d87bc89 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/OverlayStatic.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/PInvokeMethod.png b/Src/CShellCore.CodeCompletion/Images/PInvokeMethod.png new file mode 100644 index 0000000..4b7e9fc Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/PInvokeMethod.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Property.png b/Src/CShellCore.CodeCompletion/Images/Property.png new file mode 100644 index 0000000..69899b4 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Property.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/StaticClass.png b/Src/CShellCore.CodeCompletion/Images/StaticClass.png new file mode 100644 index 0000000..af9ebd0 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/StaticClass.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/Struct.png b/Src/CShellCore.CodeCompletion/Images/Struct.png new file mode 100644 index 0000000..6b17b61 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/Struct.png differ diff --git a/Src/CShellCore.CodeCompletion/Images/VirtualMethod.png b/Src/CShellCore.CodeCompletion/Images/VirtualMethod.png new file mode 100644 index 0000000..6a3dfe7 Binary files /dev/null and b/Src/CShellCore.CodeCompletion/Images/VirtualMethod.png differ diff --git a/Src/CShellCore.CodeCompletion/Properties/AssemblyInfo.cs b/Src/CShellCore.CodeCompletion/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f97ccd2 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CShell")] +[assembly: AssemblyDescription("A Simple C# Scripting IDE")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Arnova")] +[assembly: AssemblyProduct("CShell")] +[assembly: AssemblyCopyright("Copyright © Arnova Asset Management Ltd 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("380faaad-c726-4460-8667-998e05e10c33")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.1.2.*")] +[assembly: AssemblyFileVersion("0.1.2.*")] diff --git a/Src/CShellCore.CodeCompletion/SegmentTrackingOutputFormatter.cs b/Src/CShellCore.CodeCompletion/SegmentTrackingOutputFormatter.cs new file mode 100644 index 0000000..625f6e0 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/SegmentTrackingOutputFormatter.cs @@ -0,0 +1,76 @@ +#region License +// CShell, A Simple C# Scripting IDE +// Copyright (C) 2013 Arnova Asset Management Ltd., Lukas Buhler +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// This file is based on code from the SharpDevelop project: +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \Doc\sharpdevelop-copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \Doc\COPYING.LESSER.txt) +#endregion +using System.Collections.Generic; +using System.IO; +using System.Text; +using ICSharpCode.AvalonEdit.Document; +using ICSharpCode.NRefactory.CSharp; + +namespace CShellCore.CodeCompletion +{ + /// + /// Output formatter that creates a dictionary from AST nodes to segments in the output text. + /// + public class SegmentTrackingOutputFormatter : TextWriterOutputFormatter + { + Dictionary segments = new Dictionary(); + Stack startOffsets = new Stack(); + readonly StringWriter stringWriter; + + public IDictionary Segments + { + get { return segments; } + } + + public SegmentTrackingOutputFormatter(StringWriter stringWriter) + : base(stringWriter) + { + this.stringWriter = stringWriter; + } + + public static IDictionary WriteNode(StringWriter writer, AstNode node, CSharpFormattingOptions policy, ICSharpCode.AvalonEdit.TextEditorOptions options) + { + var formatter = new SegmentTrackingOutputFormatter(writer); + formatter.IndentationString = options.IndentationString; + var visitor = new CSharpOutputVisitor(formatter, policy); + node.AcceptVisitor(visitor); + return formatter.Segments; + } + + public override void StartNode(AstNode node) + { + base.StartNode(node); + startOffsets.Push(stringWriter.GetStringBuilder().Length); + } + + public override void EndNode(AstNode node) + { + int startOffset = startOffsets.Pop(); + StringBuilder b = stringWriter.GetStringBuilder(); + int endOffset = b.Length; + while (endOffset > 0 && b[endOffset - 1] == '\r' || b[endOffset - 1] == '\n') + endOffset--; + segments.Add(node, new TextSegment { StartOffset = startOffset, EndOffset = endOffset }); + base.EndNode(node); + } + } +} diff --git a/Src/CShellCore.CodeCompletion/packages.config b/Src/CShellCore.CodeCompletion/packages.config new file mode 100644 index 0000000..5ce5fa7 --- /dev/null +++ b/Src/CShellCore.CodeCompletion/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Src/CShellCore/CShellCore.csproj b/Src/CShellCore/CShellCore.csproj index 897d263..0acab65 100644 --- a/Src/CShellCore/CShellCore.csproj +++ b/Src/CShellCore/CShellCore.csproj @@ -42,26 +42,20 @@ False ..\..\Lib\Caliburn.Micro.1.5.2\lib\net40\Caliburn.Micro.dll - - ..\..\Lib\ICSharpCode.CodeCompletion.dll - - + False - ..\..\Lib\ICSharpCode.NRefactory.dll - global - - - ..\..\Lib\Mono.CSharp.dll + ..\..\Lib\Mono.CSharp.3.2.6\lib\net40\Mono.CSharp.dll - + False - ..\..\Lib\NLog.2.0.1.2\lib\net40\NLog.dll + ..\..\Lib\NLog.2.1.0\lib\net45\NLog.dll + @@ -70,9 +64,14 @@ - + + False ..\..\Lib\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.dll + + False + ..\..\Lib\AvalonDock.2.0.2000\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll + @@ -172,7 +171,12 @@ - + + + {2adf8e19-b896-4778-8391-bc55fb100852} + CShellCore.CodeCompletion + +