Skip to main content

Class: Selection

libs/common/types/Selection.Selection

Hierarchy

Constructors

constructor

new Selection(anchor, active)

Create a selection from two positions.

Parameters

NameTypeDescription
anchorPositionA position.
activePositionA position.

Overrides

Range.constructor

Defined in

libs/common/types/Selection.ts:29

new Selection(anchorLine, anchorCharacter, activeLine, activeCharacter)

Create a selection from four coordinates.

Parameters

NameTypeDescription
anchorLinenumberA zero-based line value.
anchorCharacternumberA zero-based character value.
activeLinenumberA zero-based line value.
activeCharacternumberA zero-based character value.

Overrides

Range.constructor

Defined in

libs/common/types/Selection.ts:39

Properties

active

Readonly active: Position

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

Defined in

libs/common/types/Selection.ts:14


anchor

Readonly anchor: Position

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

Defined in

libs/common/types/Selection.ts:8


end

Readonly end: Position

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

Inherited from

Range.end

Defined in

libs/common/types/Range.ts:12


start

Readonly start: Position

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

Inherited from

Range.start

Defined in

libs/common/types/Range.ts:7

Accessors

isEmpty

get isEmpty(): boolean

true if start and end are equal.

Returns

boolean

Inherited from

Range.isEmpty

Defined in

libs/common/types/Range.ts:63


isReversed

get isReversed(): boolean

Is true if active position is before anchor position.

Returns

boolean

Defined in

libs/common/types/Selection.ts:19


isSingleLine

get isSingleLine(): boolean

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

Returns

boolean

Inherited from

Range.isSingleLine

Defined in

libs/common/types/Range.ts:70

Methods

contains

contains(positionOrRange): boolean

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

Parameters

NameTypeDescription
positionOrRangeRange | PositionA position or a range.

Returns

boolean

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

Inherited from

Range.contains

Defined in

libs/common/types/Range.ts:92


intersection

intersection(other): undefined | Range

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

Parameters

NameTypeDescription
otherRangeA range.

Returns

undefined | Range

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

Inherited from

Range.intersection

Defined in

libs/common/types/Range.ts:108


isEqual

isEqual(other): boolean

Check if other equals this range.

Parameters

NameTypeDescription
otherSelectionA selection.

Returns

boolean

true when anchor and active are equal to anchor and active of this range.

Defined in

libs/common/types/Selection.ts:70


isRangeEqual

isRangeEqual(other): boolean

Check if other equals this range.

Parameters

NameTypeDescription
otherRangeA range.

Returns

boolean

true when start and end are equal to start and end of this range.

Inherited from

Range.isRangeEqual

Defined in

libs/common/types/Range.ts:81


toSelection

toSelection(isReversed): Selection

Construct a new selection from this range

Parameters

NameTypeDescription
isReversedbooleanIf true active is before anchor

Returns

Selection

A new selection

Inherited from

Range.toSelection

Defined in

libs/common/types/Range.ts:144


union

union(other): Range

Compute the union of other with this range.

Parameters

NameTypeDescription
otherRangeA range.

Returns

Range

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

Inherited from

Range.union

Defined in

libs/common/types/Range.ts:120


with

with(start?, end?): Range

Derived a new range from this range.

Parameters

NameTypeDescription
start?PositionA position that should be used as start. The default value is the current start.
end?PositionA position that should be used as end. The default value is the current end.

Returns

Range

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.

Inherited from

Range.with

Defined in

libs/common/types/Range.ts:135