This interface is implemented by the selection object. Each document view has a read-only selection object, which you can query using the IDocumentView.selection property.
Use the properties and methods of this interface to control the editor window's multiple selection.
Use the special wholeFile global variable to specify the “whole file” selection. This virtual selection object may be used with any document.
interface ISelection {
// Properties
readonly ${startOffset}: number;
readonly ${endOffset}: number;
readonly ${singleRange}: boolean;
readonly ${rangeCount}: number;
readonly ${size}: number;
readonly ${empty}: boolean;
// Methods
${selectRange}(startOffset: number, size: number, mode = ${SelectRangeMode}.Add): void;
${invert}(size: number): void;
${clear}(): void;
}
// This interface is not available in managed environment
// This interface is not available in native environment
readonly startOffset: number;
// This property is not available in managed environment
// This property is not available in native environment
The first offset in a selection. Throws an exception if selection is empty.
readonly endOffset: number;
// This property is not available in managed environment
// This property is not available in native environment
The last offset in a selection. Throws an exception if selection is empty.
readonly singleRange: boolean;
// This property is not available in managed environment
// This property is not available in native environment
true
if selection has single range, false
otherwise.
readonly rangeCount: number;
// This property is not available in managed environment
// This property is not available in native environment
Returns the number of ranges in a selection.
readonly size: number;
// This property is not available in managed environment
// This property is not available in native environment
Total size of a selection (the sum of sizes of all ranges).
readonly empty: boolean;
// This property is not available in managed environment
// This property is not available in native environment
true
if selection is empty, false
otherwise.
selectRange(startOffset: number, size: number, mode = ${SelectRangeMode}.Add): void;
// This method is not available in managed environment
// This method is not available in native environment
startOffset
size
mode
Performs a selection operation. The result of the operation depends on the value of a mode
parameter:
Value | Result |
---|---|
Replace | Replace a current selection with a given range. |
Add | Adds the new range to a current selection. |
Subtract | Subtract the range from a current selection. |
Overlap | Overlap a given range with a current selection. |
invert(size: number): void;
// This method is not available in managed environment
// This method is not available in native environment
size
Invert the current selection. A required size
parameter is used to perform this operation.
clear(): void;
// This method is not available in managed environment
// This method is not available in native environment
Clear the current selection.