Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Position

Represents a line and character position, such as the position of the cursor.

Position objects are immutable. Use the with or translate methods to derive new positions from an existing position.

Hierarchy

  • Position

Index

Constructors(1)

Properties(2)

Methods(8)

Constructors(1)

constructor

  • new Position(line: number, character: number): Position
  • Parameters

    • line: number

      A zero-based line value.

    • character: number

      A zero-based character value.

    Returns Position

Properties(2)

Readonly line

line: number

The zero-based line value.

Readonly character

character: number

The zero-based character value.

Methods(8)

isBefore

  • Check if this position is before other.

    Parameters

    Returns boolean

    true if position is on a smaller line or on the same line on a smaller character.

isBeforeOrEqual

  • isBeforeOrEqual(other: Position): boolean
  • Check if this position is before or equal to other.

    Parameters

    Returns boolean

    true if position is on a smaller line or on the same line on a smaller or equal character.

isAfter

  • Check if this position is after other.

    Parameters

    Returns boolean

    true if position is on a greater line or on the same line on a greater character.

isAfterOrEqual

  • isAfterOrEqual(other: Position): boolean
  • Check if this position is after or equal to other.

    Parameters

    Returns boolean

    true if position is on a greater line or on the same line on a greater or equal character.

isEqual

  • Check if this position is equal to other.

    Parameters

    Returns boolean

    true if the line and character of the given position are equal to the line and character of this position.

compareTo

  • Compare this to other.

    Parameters

    Returns number

    A number smaller than zero if this position is before the given position, a number greater than zero if this position is after the given position, or zero when this and the given position are equal.

translate

  • translate(lineDelta?: number, characterDelta?: number): Position
  • translate(change: { lineDelta?: number; characterDelta?: number }): Position
  • Create a new position relative to this position.

    Parameters

    • Optional lineDelta: number

      Delta value for the line value, default is 0.

    • Optional characterDelta: number

      Delta value for the character value, default is 0.

    Returns Position

    A position which line and character is the sum of the current line and character and the corresponding deltas.

  • Derived a new position relative to this position.

    Parameters

    • change: { lineDelta?: number; characterDelta?: number }

      An object that describes a delta to this position.

      • Optional lineDelta?: number

        Delta value for the line value, default is 0.

      • Optional characterDelta?: number

        Delta value for the character value, default is 0.

    Returns Position

    A position that reflects the given delta. Will return this position if the change is not changing anything.

with

  • with(line?: number, character?: number): Position
  • with(change: { line?: number; character?: number }): Position
  • Create a new position derived from this position.

    Parameters

    • Optional line: number

      Value that should be used as line value, default is the existing value

    • Optional character: number

      Value that should be used as character value, default is the existing value

    Returns Position

    A position where line and character are replaced by the given values.

  • Derived a new position from this position.

    Parameters

    • change: { line?: number; character?: number }

      An object that describes a change to this position.

      • Optional line?: number

        New line value, defaults the line value of this.

      • Optional character?: number

        New character value, defaults the character value of this.

    Returns Position

    A position that reflects the given change. Will return this position if the change is not changing anything.

Generated by TypeDoc. Maintained by 紫升

Links: 搜外友链, 69中文网