Selection

open class Selection : Range(source)

Represents a text selection in an editor.

Online Documentation

Constructors

Link copied to clipboard
constructor(anchor: Position, active: Position)

Create a selection from two positions.

constructor(anchorLine: Int, anchorCharacter: Int, activeLine: Int, activeCharacter: Int)

Create a selection from four coordinates.

Properties

Link copied to clipboard
external val active: Position

The position of the cursor. This position might be before or after anchor.

Link copied to clipboard
external val anchor: Position

The position at which the selection starts. This position might be before or after active.

Link copied to clipboard
external val end: Position

The end position. It is after or equal to start.

Link copied to clipboard
external var isEmpty: Boolean

true if start and end are equal.

Link copied to clipboard
external val isReversed: Boolean

A selection is reversed if its anchor is the end position.

Link copied to clipboard
external var isSingleLine: Boolean

true if start.line and end.line are equal.

Link copied to clipboard
external val start: Position

The start position. It is before or equal to end.

Functions

Link copied to clipboard
external fun contains(positionOrRange: Position): Boolean

Check if a position or a range is contained in this range.

external fun contains(positionOrRange: Range): Boolean
Link copied to clipboard
external fun intersection(range: Range): Range?

Intersect range with this range and returns a new range or undefined if the ranges have no overlap.

Link copied to clipboard
external fun isEqual(other: Range): Boolean

Check if other equals this range.

Link copied to clipboard
external fun union(other: Range): Range

Compute the union of other with this range.

Link copied to clipboard
external fun with(change: Range.WithChange): Range
external fun with(start: Position = definedExternally, end: Position = definedExternally): Range

Derived a new range from this range.