Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Selection

Contains the cursor position and the text selection of an edit session.

The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.

Hierarchy

  • Selection

Implements

Index

Constructors

constructor

Events

on

  • on(name: "changeSelection"): void
  • on(name: "changeCursor"): void
  • on(name: string, callback: Function, capturing?: boolean): void
  • Emitted when the cursor selection changes.

    Parameters

    • name: "changeSelection"

    Returns void

  • Emitted when the cursor position changes.

    Parameters

    • name: "changeCursor"

    Returns void

  • Parameters

    • name: string
    • callback: Function
    • Optional capturing: boolean

    Returns void

Methods

addRange

  • addRange(range: Range): void
  • Adds a range to a selection by entering multiselect mode, if necessary.

    method

    Selection.addRange

    Parameters

    • range: Range

      The new range to add

    Returns void

clearSelection

  • clearSelection(): void
  • [Empties the selection (by de-selecting it). This function also emits the 'changeSelection' event.]{: #Selection.clearSelection}

    Returns void

detach

  • detach(): void

getAllRanges

  • getAllRanges(): Range[]

getAnchor

  • Returns an object containing the row and column of the calling selection anchor.

    related

    Anchor.getPosition

    Returns Position

getCursor

getRange

getRangeOfMovements

  • getRangeOfMovements(func: any): Range
  • Saves the current cursor position and calls func that can change the cursor postion. The result is the range of the starting and eventual cursor position. Will reset the cursor position.

    Parameters

    • func: any

    Returns Range

getSelectionAnchor

  • getSelectionAnchor(): Object
  • Returns an object containing the row and column of the calling selection anchor.

    related

    Anchor.getPosition

    Returns Object

getSelectionLead

  • getSelectionLead(): Object
  • Returns an object containing the row and column of the calling selection lead.

    Returns Object

getWordRange

  • getWordRange(): void
  • Moves the selection to highlight the entire word.

    related

    EditSession.getWordRange

    Returns void

isBackwards

  • isBackwards(): boolean
  • Returns true if the selection is going backwards in the document.

    Returns boolean

isEmpty

  • isEmpty(): boolean

isMultiLine

  • isMultiLine(): boolean
  • Returns true if the selection is a multi-line.

    Returns boolean

mergeOverlappingRanges

  • mergeOverlappingRanges(): void
  • Merges overlapping ranges ensuring consistency after changes

    method

    Selection.mergeOverlappingRanges

    Returns void

moveCursorBy

  • moveCursorBy(rows: number, chars: number): void
  • Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.

    related

    EditSession.documentToScreenPosition

    Parameters

    • rows: number

      The number of rows to move by

    • chars: number

      The number of characters to move by

    Returns void

moveCursorDown

  • moveCursorDown(): void

moveCursorFileEnd

  • moveCursorFileEnd(): void

moveCursorFileStart

  • moveCursorFileStart(): void

moveCursorLeft

  • moveCursorLeft(): void

moveCursorLineEnd

  • moveCursorLineEnd(): void

moveCursorLineStart

  • moveCursorLineStart(): void

moveCursorLongWordLeft

  • moveCursorLongWordLeft(): void

moveCursorLongWordRight

  • moveCursorLongWordRight(): void

moveCursorRight

  • moveCursorRight(): void

moveCursorTo

  • moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void
  • Moves the cursor to the row and column provided. [If preventUpdateDesiredColumn is true, then the cursor stays in the same column position as its original point.]{: #preventUpdateBoolDesc}

    Parameters

    • row: number

      The row to move to

    • column: number

      The column to move to

    • Optional keepDesiredColumn: boolean

      {: #preventUpdateBool}

    Returns void

moveCursorToPosition

  • moveCursorToPosition(position: any): void
  • Moves the selection to the position indicated by its row and column.

    Parameters

    • position: any

      The position to move to

    Returns void

moveCursorToScreen

  • moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void
  • Moves the cursor to the screen position indicated by row and column. {:preventUpdateBoolDesc}

    Parameters

    • row: number

      The row to move to

    • column: number

      The column to move to

    • keepDesiredColumn: boolean

    Returns void

moveCursorUp

  • moveCursorUp(): void

moveTo

  • moveTo(row: Number, column: Number): void
  • Moves the selection cursor to the indicated row and column.

    Parameters

    • row: Number

      The row to select to

    • column: Number

      The column to select to

    Returns void

moveToPosition

  • moveToPosition(pos: Object): void
  • Moves the selection cursor to the row and column indicated by pos.

    Parameters

    • pos: Object

      An object containing the row and column

    Returns void

rectangularRangeBlock

  • rectangularRangeBlock(screenCursor: Cursor, screenAnchor: Anchor, includeEmptyLines: Boolean): Range
  • Gets list of ranges composing rectangular block on the screen

    method

    Selection.rectangularRangeBlock

    Parameters

    • screenCursor: Cursor

      The cursor to use

    • screenAnchor: Anchor

      The anchor to use

    • includeEmptyLines: Boolean

      If true, this includes ranges inside the block which are empty due to clipping

    Returns Range

selectAWord

  • selectAWord(): void
  • Selects a word, including its right whitespace.

    related

    EditSession.getAWordRange

    Returns void

selectAll

  • selectAll(): void

selectDown

  • selectDown(): void

selectFileEnd

  • selectFileEnd(): void

selectFileStart

  • selectFileStart(): void

selectLeft

  • selectLeft(): void

selectLine

  • selectLine(): void

selectLineEnd

  • selectLineEnd(): void

selectLineStart

  • selectLineStart(): void
  • Moves the selection to the beginning of the current line.

    Returns void

selectRight

  • selectRight(): void

selectTo

  • selectTo(row: number, column: number): void
  • Moves the selection cursor to the indicated row and column.

    Parameters

    • row: number

      The row to select to

    • column: number

      The column to select to

    Returns void

selectToPosition

  • selectToPosition(pos: any): void
  • Moves the selection cursor to the row and column indicated by pos.

    Parameters

    • pos: any

      An object containing the row and column

    Returns void

selectUp

  • selectUp(): void

selectWord

  • selectWord(): void

selectWordLeft

  • selectWordLeft(): void

selectWordRight

  • selectWordRight(): void

setRange

  • setRange(range: Range, reverse?: boolean): void
  • Sets the selection to the provided range.

    method

    setSelectionRange

    alias

    setRange

    Parameters

    • range: Range

      The range of text to select

    • Optional reverse: boolean

      Indicates if the range should go backwards (true) or not

    Returns void

setSelectionAnchor

  • setSelectionAnchor(row: Number, column: Number): void
  • Sets the row and column position of the anchor. This function also emits the 'changeSelection' event.

    Parameters

    • row: Number

      The new row

    • column: Number

      The new column

    Returns void

setSelectionRange

  • setSelectionRange(match: any): void
  • Sets the selection to the provided range.

    method

    setSelectionRange

    alias

    setRange

    Parameters

    • match: any

    Returns void

splitIntoLines

  • splitIntoLines(): void
  • Splits all the ranges into lines.

    method

    Selection.splitIntoLines

    Returns void

substractPoint

  • substractPoint(pos: Range): any
  • Removes a Range containing pos (if it exists).

    method

    Selection.substractPoint

    Parameters

    • pos: Range

      The position to remove, as a {row, column} object

    Returns any

toSingleRange

  • toSingleRange(range: any): void

toggleBlockSelection

  • toggleBlockSelection(): void

wouldMoveIntoSoftTab

  • wouldMoveIntoSoftTab(cursor: Object, tabSize: Number, direction: Number): boolean
  • Returns true if moving the character next to the cursor in the specified direction is a soft tab.

    Parameters

    • cursor: Object

      the current cursor position

    • tabSize: Number

      the tab size

    • direction: Number

      1 for right, -1 for left

    Returns boolean

Generated using TypeDoc