Class: Selection
libs/common/types/Selection.Selection
Hierarchy
↳
Selection
Constructors
constructor
• new Selection(anchor, active)
Create a selection from two positions.
Parameters
| Name | Type | Description |
|---|---|---|
anchor | Position | A position. |
active | Position | A position. |
Overrides
Defined in
libs/common/types/Selection.ts:29
• new Selection(anchorLine, anchorCharacter, activeLine, activeCharacter)
Create a selection from four coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
anchorLine | number | A zero-based line value. |
anchorCharacter | number | A zero-based character value. |
activeLine | number | A zero-based line value. |
activeCharacter | number | A zero-based character value. |
Overrides
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
Defined in
libs/common/types/Range.ts:12
start
• Readonly start: Position
The start position. It is before or equal to end.
Inherited from
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
| Name | Type | Description |
|---|---|---|
positionOrRange | Range | Position | A position or a range. |
Returns
boolean
true if the position or range is inside or equal
to this range.
Inherited from
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
| Name | Type | Description |
|---|---|---|
other | Range | A range. |
Returns
undefined | Range
A range of the greater start and smaller end positions. Will return undefined when there is no overlap.
Inherited from
Defined in
libs/common/types/Range.ts:108
isEqual
▸ isEqual(other): boolean
Check if other equals this range.
Parameters
| Name | Type | Description |
|---|---|---|
other | Selection | A 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
| Name | Type | Description |
|---|---|---|
other | Range | A range. |
Returns
boolean
true when start and end are equal to
start and end of this range.
Inherited from
Defined in
libs/common/types/Range.ts:81
toSelection
▸ toSelection(isReversed): Selection
Construct a new selection from this range
Parameters
| Name | Type | Description |
|---|---|---|
isReversed | boolean | If true active is before anchor |
Returns
A new selection
Inherited from
Defined in
libs/common/types/Range.ts:144
union
▸ union(other): Range
Compute the union of other with this range.
Parameters
| Name | Type | Description |
|---|---|---|
other | Range | A range. |
Returns
A range of smaller start position and the greater end position.
Inherited from
Defined in
libs/common/types/Range.ts:120
with
▸ with(start?, end?): Range
Derived a new range from this range.
Parameters
| Name | Type | Description |
|---|---|---|
start? | Position | A position that should be used as start. The default value is the current start. |
end? | Position | A position that should be used as end. The default value is the current end. |
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.
Inherited from
Defined in
libs/common/types/Range.ts:135