Interface IEditSession

Stores all the data about [[Editor Editor]] state providing easy way to change editors state. EditSession can be attached to only one [[Document Document]]. Same Document can be attached to several EditSessions.

Index

Properties

Methods

Properties

public bgTokenizer: BackgroundTokenizer

public doc: Document

public selection: Selection

Methods

public $detectNewLine(text: string): any

If text contains either the newline (\n) or carriage-return ('\r') characters, $autoNewLine stores that value.

Parameters

  • text: string

    A block of text

Returns

any

public $getDisplayTokens(str: string, offset: number): any

Given a string, returns an array of the display characters, including tabs and spaces.

Parameters

  • str: string

    The string to check

  • offset: number

    The value to start at

Returns

any

public $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): Array<number>

Calculates the width of the string str on the screen while assuming that the string starts at the first column on the screen.

Parameters

  • str: string

    The string to calculate the screen width of

  • maxScreenColumn: number
  • screenColumn: number

Returns

Array<number>

public $mode(mode: TextMode): any

Sets a new text mode for the EditSession. This method also emits the 'changeMode' event. If a [[BackgroundTokenizer BackgroundTokenizer]] is set, the 'tokenizerUpdate' event is also emitted.

Parameters

Returns

any

public $resetRowCache(row: number): any

undefined

Parameters

  • row: number

    The row to work with

Returns

any

public addDynamicMarker(marker: any, inFront: boolean): any

Adds a dynamic marker to the session.

Parameters

  • marker: any

    object with update method

  • inFront: boolean

    Set to true to establish a front marker

Returns

any

public addFold(text: string, range: Range): any

Parameters

  • text: string
  • range: Range

Returns

any

public addGutterDecoration(row: number, className: string): any

Adds className to the row, to be used for CSS stylings and whatnot.

Parameters

  • row: number

    The row number

  • className: string

    The class to add

Returns

any

public addMarker(range: Range, clazz: string, type: Function, inFront: boolean): any

Adds a new marker to the given Range. If inFront is true, a front marker is defined, and the 'changeFrontMarker' event fires; otherwise, the 'changeBackMarker' event fires.

Parameters

  • range: Range

    Define the range of the marker

  • clazz: string

    Set the CSS class for the marker

  • type: Function

    Identify the type of the marker

  • inFront: boolean

    Set to true to establish a front marker

Returns

any

public addMarker(range: Range, clazz: string, type: string, inFront: boolean): any

Adds a new marker to the given Range. If inFront is true, a front marker is defined, and the 'changeFrontMarker' event fires; otherwise, the 'changeBackMarker' event fires.

Parameters

  • range: Range

    Define the range of the marker

  • clazz: string

    Set the CSS class for the marker

  • type: string

    Identify the type of the marker

  • inFront: boolean

    Set to true to establish a front marker

Returns

any

public adjustWrapLimit(desiredLimit: number): boolean

This should generally only be called by the renderer when a resize is detected.

Parameters

  • desiredLimit: number

    The new wrap limit

Returns

boolean

public clearAnnotations(): any

Clears all the annotations for this session. This function also triggers the 'changeAnnotation' event.

Returns

any

public clearBreakpoint(row: number): any

Removes a breakpoint on the row number given by rows. This function also emites the 'changeBreakpoint' event.

Parameters

  • row: number

    A row index

Returns

any

public clearBreakpoints(): any

Removes all breakpoints on the rows. This function also emites the 'changeBreakpoint' event.

Returns

any

public documentToScreenColumn(row: number, docColumn: number): number

For the given document row and column, returns the screen column.

Parameters

  • row: number
  • docColumn: number

Returns

number

public documentToScreenPosition(docRow: number, docColumn: number): any

Converts document coordinates to screen coordinates. {:conversionConsiderations}

Parameters

  • docRow: number

    The document row to check

  • docColumn: number

    The document column to check

Returns

any

public documentToScreenRow(docRow: number, docColumn: number): any

For the given document row and column, returns the screen row.

Parameters

  • docRow: number
  • docColumn: number

Returns

any

public duplicateLines(firstRow: number, lastRow: number): number

Duplicates all the text between firstRow and lastRow.

Parameters

  • firstRow: number

    The starting row to duplicate

  • lastRow: number

    The final row to duplicate

Returns

number

public expandFold(arg: any): any

Parameters

  • arg: any

Returns

any

public findMatchingBracket(position: Position): any

Parameters

Returns

any

public getAWordRange(row: number, column: number): any

Gets the range of a word, including its right whitespace.

Parameters

  • row: number

    The row number to start from

  • column: number

    The column number to start from

Returns

any

public getAnnotations(): any

Returns the annotations for the EditSession.

Returns

any

public getBreakpoints(): Array<number>

Returns an array of numbers, indicating which rows have breakpoints.

Returns

Array<number>

public getDocument(): Document

Returns the Document associated with this session.

Returns

Document

public getDocumentLastRowColumn(docRow: number, docColumn: number): number

For the given document row and column, this returns the column position of the last screen row.

Parameters

  • docRow: number
  • docColumn: number

Returns

number

public getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number

For the given document row and column, this returns the document position of the last row.

Parameters

  • docRow: number
  • docColumn: number

Returns

number

public getFoldAt(row: number, column: number): any

Parameters

  • row: number
  • column: number

Returns

any

public getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any

Parameters

  • foldLine: any
  • docRow: number
  • docColumn: number

Returns

any

public getFoldsInRange(range: Range): any

Parameters

Returns

any

public getLength(): number

Returns the number of rows in the document.

Returns

number

public getLine(row: number): string

Returns a verbatim copy of the given line as it is in the document

Parameters

  • row: number

    The row to retrieve from

Returns

string

public getLines(firstRow: number, lastRow: number): Array<string>

Returns an array of strings of the rows between firstRow and lastRow. This function is inclusive of lastRow.

Parameters

  • firstRow: number

    The first row index to retrieve

  • lastRow: number

    The final row index to retrieve

Returns

Array<string>

public getMarkers(inFront: boolean): Array<any>

Returns an array containing the IDs of all the markers, either front or back.

Parameters

  • inFront: boolean

    If true, indicates you only want front markers; false indicates only back markers

Returns

Array<any>

public getMode(): TextMode

Returns the current text mode.

Returns

TextMode

public getNewLineMode(): string

Returns the current new line mode.

Returns

string

public getOverwrite(): boolean

Returns true if overwrites are enabled; false otherwise.

Returns

boolean

public getRowLength(row: number): number

Returns number of screenrows in a wrapped line.

Parameters

  • row: number

    The row number to check

Returns

number

public getRowSplitData(): string

For the given row, this returns the split data.

Returns

string

public getScreenLastRowColumn(screenRow: number): number

Returns the position (on screen) for the last character in the provided screen row.

Parameters

  • screenRow: number

    The screen row to check

Returns

number

public getScreenLength(): number

Returns the length of the screen.

Returns

number

public getScreenTabSize(screenColumn: number): number

The distance to the next tab stop at the specified screen column.

Parameters

  • screenColumn: number

    The screen column to check

Returns

number

public getScreenWidth(): number

Returns the width of the screen.

Returns

number

public getScrollLeft(): number

[Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}

Returns

number

public getScrollTop(): number

[Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop}

Returns

number

public getSelection(): Selection

Returns the string of the current selection.

Returns

Selection

public getState(row: number): string

{:BackgroundTokenizer.getState}

Parameters

  • row: number

    The row to start at

Returns

string

public getTabSize(): string

Returns the current tab size.

Returns

string

public getTabString(): string

Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize getTabSize()]]); otherwise it's simply '\t'.

Returns

string

public getTextRange(range: Range): string

{:Document.getTextRange.desc}

Parameters

  • range: Range

    The range to work with

Returns

string

public getTokenAt(row: number, column: number): TokenInfo

Returns an object indicating the token at the current row. The object has two properties: index and start.

Parameters

  • row: number

    The row number to retrieve from

  • column: number

    The column number to retrieve from

Returns

TokenInfo

public getTokens(row: number): TokenInfo[]

Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.

Parameters

  • row: number

    The row to start at

Returns

TokenInfo[]

public getUndoManager(): UndoManager

Returns the current undo manager.

Returns

UndoManager

public getUseSoftTabs(): boolean

Returns true if soft tabs are being used, false otherwise.

Returns

boolean

public getUseWorker(): boolean

Returns true if workers are being used.

Returns

boolean

public getUseWrapMode(): boolean

Returns true if wrap mode is being used; false otherwise.

Returns

boolean

public getValue(): string

Returns the current [[Document Document]] as a string.

Returns

string

public getWordRange(row: number, column: number): Range

Given a starting row and column, this method returns the Range of the first word boundary it finds.

Parameters

  • row: number

    The row to start at

  • column: number

    The column to start at

Returns

Range

public getWrapLimit(): number

Returns the value of wrap limit.

Returns

number

public getWrapLimitRange(): any

Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: { min: wrapLimitRange_min, max: wrapLimitRange_max }

Returns

any

public highlight(text: string): any

Parameters

  • text: string

Returns

any

public indentRows(startRow: number, endRow: number, indentString: string): any

Indents all the rows, from startRow to endRow (inclusive), by prefixing each row with the token in indentString. If indentString contains the '\t' character, it's replaced by whatever is defined by [[EditSession.getTabString getTabString()]].

Parameters

  • startRow: number

    Starting row

  • endRow: number

    Ending row

  • indentString: string

    The indent token

Returns

any

public insert(position: Position, text: string): any

Inserts a block of text and the indicated position.

Parameters

  • position: Position

    The position {row, column} to start inserting at

  • text: string

    A chunk of text to insert

Returns

any

public isTabStop(position: any): boolean

Returns true if the character at the position is a soft tab.

Parameters

  • position: any

    The position to check

Returns

boolean

public moveLinesDown(firstRow: number, lastRow: number): number

Shifts all the lines in the document down one, starting from firstRow and ending at lastRow.

Parameters

  • firstRow: number

    The starting row to move down

  • lastRow: number

    The final row to move down

Returns

number

public moveLinesUp(firstRow: number, lastRow: number): number

Shifts all the lines in the document up one, starting from firstRow and ending at lastRow.

Parameters

  • firstRow: number

    The starting row to move up

  • lastRow: number

    The final row to move up

Returns

number

public moveText(fromRange: Range, toPosition: any): Range

Moves a range of text from the given range to the given position. toPosition is an object that looks like this:

{ row: newRowLocation, column: newColumnLocation }

Parameters

  • fromRange: Range

    The range of text you want moved within the document

  • toPosition: any

    The location (row and column) where you want to move the text to

Returns

Range

public on(event: string, fn: (e: any) => any): any

Parameters

  • event: string
  • fn: (e: any) => any

Returns

any

public onReloadTokenizer(): any

Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start BackgroundTokenizer.start ()]] to all the rows; it also emits the 'tokenizerUpdate' event.

Returns

any

public outdentRows(range: Range): any

Outdents all the rows defined by the start and end properties of range.

Parameters

  • range: Range

    A range of rows

Returns

any

public redoChanges(deltas: Array<any>, dontSelect: boolean): Range

Re-implements a previously undone change to your document.

Parameters

  • deltas: Array<any>

    An array of previous changes

  • dontSelect: boolean

Returns

Range

public remove(range: Range): any

Removes the range from the document.

Parameters

  • range: Range

    A specified Range to remove

Returns

any

public removeFold(arg: any): any

Parameters

  • arg: any

Returns

any

public removeGutterDecoration(row: number, className: string): any

Removes className from the row.

Parameters

  • row: number

    The row number

  • className: string

    The class to add

Returns

any

public removeMarker(markerId: number): any

Removes the marker with the specified ID. If this marker was in front, the 'changeFrontMarker' event is emitted. If the marker was in the back, the 'changeBackMarker' event is emitted.

Parameters

  • markerId: number

    A number representing a marker

Returns

any

public replace(range: Range, text: string): any

Replaces a range in the document with the new text.

Parameters

  • range: Range

    A specified Range to replace

  • text: string

    The new text to use as a replacement

Returns

any

public screenToDocumentColumn(row: number, column: number): any

Parameters

  • row: number
  • column: number

Returns

any

public screenToDocumentPosition(screenRow: number, screenColumn: number): any

Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations}

Parameters

  • screenRow: number

    The screen row to check

  • screenColumn: number

    The screen column to check

Returns

any

public setAnnotations(annotations: Annotation[]): any

Sets annotations for the EditSession. This functions emits the 'changeAnnotation' event.

Parameters

Returns

any

public setBreakpoint(row: number, className: string): any

Sets a breakpoint on the row number given by rows. This function also emites the 'changeBreakpoint' event.

Parameters

  • row: number

    A row index

  • className: string

    Class of the breakpoint

Returns

any

public setBreakpoints(rows: Array<any>): any

Sets a breakpoint on every row number given by rows. This function also emites the 'changeBreakpoint' event.

Parameters

  • rows: Array<any>

    An array of row indices

Returns

any

public setDocument(doc: Document): any

Sets the EditSession to point to a new Document. If a BackgroundTokenizer exists, it also points to doc.

Parameters

Returns

any

public setMode(mode: string): any

Parameters

  • mode: string

Returns

any

public setNewLineMode(newLineMode: string): any

{:Document.setNewLineMode.desc}

Parameters

  • newLineMode: string

Returns

any

public setOverwrite(overwrite: boolean): any

Pass in true to enable overwrites in your session, or false to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of overwrite changes, this function also emites the changeOverwrite event.

Parameters

  • overwrite: boolean

    Defines wheter or not to set overwrites

Returns

any

public setScrollLeft(): any

[Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}

Returns

any

public setScrollTop(scrollTop: number): any

This function sets the scroll top value. It also emits the 'changeScrollTop' event.

Parameters

  • scrollTop: number

    The new scroll top value

Returns

any

public setTabSize(tabSize: number): any

Set the number of spaces that define a soft tab; for example, passing in 4 transforms the soft tabs to be equivalent to four spaces. This function also emits the changeTabSize event.

Parameters

  • tabSize: number

    The new tab size

Returns

any

public setUndoManager(undoManager: UndoManager): any

Sets the undo manager.

Parameters

Returns

any

public setUndoSelect(enable: boolean): any

Enables or disables highlighting of the range where an undo occured.

Parameters

  • enable: boolean

    If true, selects the range of the reinserted change

Returns

any

public setUseSoftTabs(useSoftTabs: boolean): any

Pass true to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character ('\t').

Parameters

  • useSoftTabs: boolean

    Value indicating whether or not to use soft tabs

Returns

any

public setUseWorker(useWorker: boolean): any

Identifies if you want to use a worker for the EditSession.

Parameters

  • useWorker: boolean

    Set to true to use a worker

Returns

any

public setUseWrapMode(useWrapMode: boolean): any

Sets whether or not line wrapping is enabled. If useWrapMode is different than the current value, the 'changeWrapMode' event is emitted.

Parameters

  • useWrapMode: boolean

    Enable (or disable) wrap mode

Returns

any

public setValue(text: string): any

Sets the session text.

Parameters

  • text: string

    The new text to place

Returns

any

public setWrapLimitRange(min: number, max: number): any

Sets the boundaries of wrap. Either value can be null to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for min or max are different, this method also emits the 'changeWrapMode' event.

Parameters

  • min: number

    The minimum wrap value (the left side wrap)

  • max: number

    The maximum wrap value (the right side wrap)

Returns

any

public toggleOverwrite(): any

Sets the value of overwrite to the opposite of whatever it currently is.

Returns

any

public undoChanges(deltas: Array<any>, dontSelect: boolean): Range

Reverts previous changes to your document.

Parameters

  • deltas: Array<any>

    An array of previous changes

  • dontSelect: boolean

    {: #dontSelect}

Returns

Range

public unfold(arg1: any, arg2: boolean): any

Parameters

  • arg1: any
  • arg2: boolean

Returns

any