Partager via


IMultiSelectionBroker Interface

Definition

Manages all the caret and selecting behavior for an ITextView. Handles multiple selections, and box selection. Throughout this namespace carets are considered to be part of Selections, and are represented by InsertionPoint.

public interface class IMultiSelectionBroker
public interface IMultiSelectionBroker
type IMultiSelectionBroker = interface
Public Interface IMultiSelectionBroker

Properties

ActivationTracksFocus

Determines whether AreSelectionsActive should track when the ITextView gains and loses aggregate focus. The default is true.

AllSelections

Gets a list of all selections associated with TextView. They will be sorted in the order of appearence in the underlying snapshot. This property is intended for edit operations and may be computationally expensive. If not all selections are required, use GetSelectionsIntersectingSpan(SnapshotSpan) instead.

This returns a selection as an Selection.

AreSelectionsActive

Whether or not selections are active within TextView.

BoxSelection

If IsBoxSelection is true, returns an instantiated Selection which the caller can interrogate or manipulate to work with the box itself. Calls to AllSelections or GetSelectionsIntersectingSpan(SnapshotSpan) will return individual per line entries rather than the full box.

If IsBoxSelection is false, this will return null.

CurrentSnapshot

Gets the current ITextSnapshot that is associated with anchor, active, and insertion points for everything managed by this broker. This snapshot will always be based in the EditBuffer for the associated ITextView.

HasMultipleSelections

Gets whether there are multiple selections in AllSelections.

IsBoxSelection

Returns true if SetBoxSelection(Selection) has been called, and selections are being managed by the box geometry, instead of manually by the user. ClearSecondarySelections() and BreakBoxSelection() will both revert this to false, and several other methods like AddSelection(Selection) will indirectly also set this back to false.

PrimarySelection

Gets the primary selection which should remain after invoking ClearSecondarySelections().

SelectedSpans

Gets the list of spans within CurrentSnapshot that are selected. While two selections cannot overlap, they may inhabit virtual space, and selections may be adjacent. This will merge those spans and return the minimum set of spans that could be used to describe the selection. This can be a costly operation and should only be run when needed.

SelectionExtent

Gets the span containing all selections, complete with virtual space.

TextView

Gets the view for which this broker manages selections.

VirtualSelectedSpans

Gives the set of spans selected. There is exactly one span per selection, but it may be empty. They will be sorted in the order of appearence in the document.

Methods

AddSelection(Selection)

Adds a selection to AllSelections.

AddSelectionRange(IEnumerable<Selection>)

Adds a list of selections to AllSelections.

BeginBatchOperation()

Temporarily disables MultiSelectionSessionChanged, but instead queues up all actions to be included in the resultant MultiSelectionSessionChanged once the operation is completed. Selection merges will also be deferred until the end of batch operations.

BreakBoxSelection()

Clears BoxSelection, but retains the current state of selections. This is a useful utility when performing gestures like End and Home where each selection moves, but the result is not necessarily a box.

ClearSecondarySelections()

Removes all but the PrimarySelection from the session.

GetSelectionsIntersectingSpan(SnapshotSpan)

Gets a list of all the selections that intersect the given span. Virtual whitespace is ignored for this method.

GetSelectionsIntersectingSpans(NormalizedSnapshotSpanCollection)

Gets a list of all the selections that intersect the given span collection. Virtual whitespace is ignored for this method.

PerformActionOnAllSelections(Action<ISelectionTransformer>)

Performs a custom action on all Selections contained by TextView.

PerformActionOnAllSelections(PredefinedSelectionTransformations)

Performs a predefined manipulation on all Selections contained by TextView.

SetBoxSelection(Selection)

Adds a box of selections with the given points as its corners.

SetSelection(Selection)

Clears the current selections and adds one as the new value. This also becomes the PrimarySelection.

SetSelectionRange(IEnumerable<Selection>, Selection)

Clears the current selections, adds the provided range, and sets the primary selection.

TransformSelection(Selection, PredefinedSelectionTransformations)

Performs the given transformation on the given Selection without updating AllSelections. The behavior of Preferred X and Y coordinates for selections that are already in the broker is undefined.

TryEnsureVisible(Selection, EnsureSpanVisibleOptions)

Attempts to make the given Selection visible in the view.

TryGetSelectionPresentationProperties(Selection, AbstractSelectionPresentationProperties)

Trys to get the UI properties associated with the given Selection.

TryPerformActionOnSelection(Selection, Action<ISelectionTransformer>, Selection)

Attempts to perform a custom action on a single Selection.

TryPerformActionOnSelection(Selection, PredefinedSelectionTransformations, Selection)

Attempts to perform a predefined action on a single Selection.

TryRemoveSelection(Selection)

Removes a selection from the view.

TrySetAsPrimarySelection(Selection)

Attempts to set the provided selection to be the new PrimarySelection.

Events

MultiSelectionSessionChanged

Occurs when selections are added/removed/updated. Also when the primary selection is changed, and when box selection mode is entered/exited.

Applies to