Represents a text selection in an editor.

Constructor

new(anchor:Position, active:Position)

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

Create a selection from two positions.

Parameters:

anchor

A position.

active

A position.

Variables

active:Position

The position of the cursor. This position might be before or after {@link Selection.anchor anchor}.

anchor:Position

The position at which the selection starts. This position might be before or after {@link Selection.active active}.

isReversed:Bool

A selection is reversed if its {@link Selection.anchor anchor} is the {@link Selection.end end} position.

Inherited Variables

Defined by Range

read onlyend:Position

The end position. It is after or equal to {@link Range.start start}.

isEmpty:Bool

true if start and end are equal.

isSingleLine:Bool

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

read onlystart:Position

The start position. It is before or equal to {@link Range.end end}.

Inherited Methods

Defined by Range

contains(positionOrRange:EitherType<Position, Range>):Bool

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

Parameters:

positionOrRange

A position or a range.

Returns:

true if the position or range is inside or equal to this range.

intersection(range:Range):Null<Range>

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

Parameters:

range

A range.

Returns:

A range of the greater start and smaller end positions. Will return undefined when there is no overlap.

isEqual(other:Range):Bool

Check if other equals this range.

@link Position.isEqual equal} to start and end of this range.

Parameters:

other

A range.

Returns:

true when start and end are {

union(other:Range):Range

Compute the union of other with this range.

Parameters:

other

A range.

Returns:

A range of smaller start position and the greater end position.

with(?start:Position, ?end:Position):Range

with(change:{start:Null<Position>, end:Null<Position>}):Range

Derived a new range from this range.

@link Range.start current start}. @link Range.end current end}.

Parameters:

start

A position that should be used as start. The default value is the {

end

A position that should be used as end. The default value is the {

Returns:

A range derived from this range with the given start and end position. If start and end are not different this range will be returned.