new RelativePosition(type, tname, item, assoc)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
type |
ID | null | ||
tname |
string | null | ||
item |
ID | null | ||
assoc |
number | 0 |
Example
// Current cursor position is at position 10
const relativePosition = createRelativePositionFromIndex(yText, 10)
// modify yText
yText.insert(0, 'abc')
yText.delete(3, 10)
// Compute the cursor position
const absolutePosition = createAbsolutePositionFromRelativePosition(y, relativePosition)
absolutePosition.type === yText // => true
console.log('cursor location is ' + absolutePosition.index) // => cursor location is 3
Classes
Members
-
assoc :number
-
A relative position is associated to a specific character. By default assoc >= 0, the relative position is associated to the character after the meant position. I.e. position 1 in 'ab' is associated to character 'b'.
If assoc < 0, then the relative position is associated to the caharacter before the meant position.
-
item :ID|null
-
-
tname :string|null
-
-
type :ID|null
-