Stores various states related to a Document. A single EditSession can be in charge of several Documents.

Constructors

Sets up a new EditSession and associates it with the given Document and TextMode. ...

Sets up a new EditSession and associates it with the given Document and TextMode.

   

Arguments

textDocument | StringRequired. If text is a Document, it associates the EditSession with it. Otherwise, a new Document is created, with the initial text
modeTextModeRequired. The inital language mode to use for the document

Events

    • EditSession.on("onChange", function(e))

Emitted when the document changes. ...

Emitted when the document changes.

   

    • EditSession.on("onChangeFold", function(e))

Emitted when a code fold changes its state. ...

Emitted when a code fold changes its state.

   

    • EditSession.on("onReloadTokenizer", function(e))

Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer....

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

   

Methods

Adds a new marker to the given Range. If inFront is true, a front marker is defined, and the `'changeFrontMark...

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.

   

Arguments

rangeRangeRequired. Define the range of the marker
clazzStringRequired. Set the CSS class for the marker
typeFunction | StringRequired. Identify the type of the marker
inFrontBooleanRequired. Set to true to establish a front marker
    • EditSession.clearAnnotations()

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

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

   

    • EditSession.clearBreakpoint(Number row)

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

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

   

Arguments

rowNumberRequired. A row index
    • EditSession.clearBreakpoints()

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

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

   

Converts document coordinates to screen coordinates. This takes into account code folding, word wrap, tab size, and any other visual modifications. ...

Converts document coordinates to screen coordinates. This takes into account code folding, word wrap, tab size, and any other visual modifications.

   

Arguments

docRowNumberRequired. The document row to check
docColumnNumberRequired. The document column to check

Returns

ObjectThe object returned by this method has two properties: row and column.

Duplicates all the text between firstRow and lastRow. ...

Duplicates all the text between firstRow and lastRow.

   

Arguments

firstRowNumberRequired. The starting row to duplicate
lastRowNumberRequired. The final row to duplicate

Returns

NumberReturns the number of new rows added; in other words, lastRow - firstRow + 1.
    • EditSession.getAnnotations()

Returns the annotations for the EditSession. ...

Returns the annotations for the EditSession.

   

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

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

   

Arguments

rowNumberRequired. The row number to start from
columnNumberRequired. The column number to start from
    • EditSession.getBreakpoints()

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

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

   

Returns the Document associated with this session. ...

Returns the Document associated with this session.

   

Returns the number of rows in the document. ...

Returns the number of rows in the document.

   

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

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

   

Arguments

rowNumberRequired. The row to retrieve from

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

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

   

Arguments

firstRowNumberRequired. The first row index to retrieve
lastRowNumberRequired. The final row index to retrieve

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

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

   

Arguments

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

Returns the current text mode. ...

Returns the current text mode.

   

Returns the current new line mode. ...

Returns the current new line mode.

   

    • EditSession.getOverwrite()

Returns true if overwrites are enabled; false otherwise. ...

Returns true if overwrites are enabled; false otherwise.

   

Returns the height of the indicated row. This is mostly relevant for situations where wrapping occurs, and a single ...

Returns the height of the indicated row. This is mostly relevant for situations where wrapping occurs, and a single line spans across multiple rows.

   

Arguments

configObjectRequired. An object containing a parameter indicating the lineHeight.
rowNumberRequired. The row number to check

Returns the length of the indicated row. ...

Returns the length of the indicated row.

   

Arguments

rowNumberRequired. The row number to check
    • EditSession.getScreenLength()

Returns the length of the screen. ...

Returns the length of the screen.

   

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

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

   

Arguments

screenColumnNumberRequired. The screen column to check
    • EditSession.getScreenWidth()

Returns the width of the screen. ...

Returns the width of the screen.

   

    • EditSession.getScrollLeft()

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

Returns the value of the distance between the left of the editor and the leftmost part of the visible content.

   

    • EditSession.getScrollTop()

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

Returns the value of the distance between the top of the editor and the topmost part of the visible content.

   

    • EditSession.getSelection()

Returns the string of the current selection. ...

Returns the string of the current selection.

   

Returns the state of tokenization for a row. ...

Returns the state of tokenization for a row.

   

Arguments

rowNumberRequired. The row to start at
    • EditSession.getTabSize()

Returns the current tab size. ...

Returns the current tab size.

   

    • EditSession.getTabString()

Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[Ed...

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

   

Given a range within the document, this function returns all the text within that range as a single string. ...

Given a range within the document, this function returns all the text within that range as a single string.

   

Arguments

rangeStringRequired. The range to work with

Returns an array of tokens at the indicated row and column. ...

Returns an array of tokens at the indicated row and column.

   

Arguments

rowNumberRequired. The row number to retrieve from
columnNumberRequired. The column number to retrieve from

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

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

   

Arguments

firstRowNumberRequired. The row to start at
lastRowNumberRequired. The row to finish at

Returns the current undo manager. ...

Returns the current undo manager.

   

    • EditSession.getUseSoftTabs()

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

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

   

    • EditSession.getUseWorker()

Returns true if workers are being used. ...

Returns true if workers are being used.

   

    • EditSession.getUseWrapMode()

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

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

   

    • EditSession.getWidth()

Returns the width of the document. ...

Returns the width of the document.

   

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

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

   

Arguments

rowNumberRequired. The row to start at
columnNumberRequired. The column to start at
    • EditSession.getWrapLimit()

Returns the value of wrap limit. ...

Returns the value of wrap limit.

   

    • EditSession.getWrapLimitRange()

Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: ...

Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this:

   

{ min: wrapLimitRange_min, max: wrapLimitRange_max }

Indents all the rows, from startRow to endRow (inclusive), by prefixing each row with the token in indentString. ...

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 getTabString.

Arguments

startRowNumberRequired. Starting row
endRowNumberRequired. Ending row
indentStringStringRequired. The indent token

Inserts a block of text and the indicated position. ...

Inserts a block of text and the indicated position.

   

Arguments

positionNumberRequired. The position to start inserting at
textStringRequired. A chunk of text to insert

Returns

NumberThe position of the last line of text. If the length of text is 0, this function simply returns position.

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

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

   

Arguments

positionObjectRequired. The position to check

...

   

Arguments

firstRowNumberRequired. The starting row to move down
lastRowNumberRequired. The final row to move down

Returns

NumberIf firstRow is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.

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

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

   

Arguments

firstRowNumberRequired. The starting row to move up
lastRowNumberRequired. The final row to move up

Returns

NumberIf firstRow is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.

{ row: newRowLocation, column: newColumnLocation } ...

{ row: newRowLocation, column: newColumnLocation }

   

Arguments

fromRangeRangeRequired. The range of text you want moved within the document
toPositionObjectRequired. The location (row and column) where you want to move the text to

Returns

RangeThe new range where the text was moved to. Moves a range of text from the given range to the given position. toPosition is an object that looks like this:
    • EditSession.outdentRows(Range range)

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

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

   

Arguments

rangeRangeRequired. A range of rows

Re-implements a previously undone change to your document. ...

Re-implements a previously undone change to your document.

   

Arguments

deltasArrayRequired. An array of previous changes
dontSelectBooleanRequired. If true, doesn't select the range of where the change occured

Removes the range from the document. ...

Removes the range from the document.

   

Arguments

rangeRangeRequired. A specified Range to remove

Returns

ObjectThe new start property of the range, which contains startRow and startColumn. If range is empty, this function returns the unmodified value of range.start.
    • EditSession.removeMarker(Number markerId)

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

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.

   

Arguments

markerIdNumberRequired. A number representing a marker

Replaces a range in the document with the new text. ...

Replaces a range in the document with the new text.

   

Arguments

rangeRangeRequired. A specified Range to replace
textStringRequired. The new text to use as a replacement

Returns

ObjectReturns an object containing the final row and column, like this:
{row: endRow, column: 0}
If the text and range are empty, this function returns an object containing the current range.start value.
If the text is the exact same as what currently exists, this function returns an object containing the current range.end value.

Converts characters coordinates on the screen to characters coordinates within the document. [This takes into accoun...

This takes into account code folding, word wrap, tab size, and any other visual modifications.

   

Arguments

screenRowNumberRequired. The screen row to check
screenColumnNumberRequired. The screen column to check

Returns

ObjectThe object returned has two properties: row and column.
    • EditSession.setAnnotations(Array annotations)

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

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

   

Arguments

annotationsArrayRequired. A list of annotations
    • EditSession.setBreakpoint(Number row)

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

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

   

Arguments

rowNumberRequired. A row index
    • EditSession.setBreakpoints(Array rows)

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

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

   

Arguments

rowsArrayRequired. An array of row indicies

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

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

   

Arguments

docDocumentRequired. The new Document to use

Sets a new text mode for the EditSession. This method also emits the 'changeMode' event. If a [[BackgroundTokeni...

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

   

Arguments

modeTextModeRequired. Set a new text mode

Sets the new line mode. ...

Sets the new line mode.

   

Arguments

newLineModeStringRequired. The newline mode to use; can be either windows, unix, or auto
    • EditSession.setOverwrite(Boolean overwrite)

Pass in true to enable overwrites in your session, or false to disable. If overwrites is enabled, any text you e...

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.

   

Arguments

overwriteBooleanRequired. Defines wheter or not to set overwrites
    • EditSession.setScrollLeft(scrollLeft)

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

Sets the value of the distance between the left of the editor and the leftmost part of the visible content.

   

    • EditSession.setScrollTop(Number scrollTop)

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

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

   

Arguments

scrollTopNumberRequired. The new scroll top value
    • EditSession.setTabSize(Number tabSize)

Set the number of spaces that define a soft tab; for example, passing in 4 transforms the soft tabs to be equivale...

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.

   

Arguments

tabSizeNumberRequired. The new tab size

Sets the undo manager. ...

Sets the undo manager.

   

Arguments

undoManagerUndoManagerRequired. The new undo manager
    • EditSession.setUndoSelect(Boolean enable)

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

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

   

Arguments

enableBooleanRequired. If true, selects the range of the reinserted change
    • EditSession.setUseSoftTabs(Boolean useSoftTabs)

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

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

   

Arguments

useSoftTabsBooleanRequired. Value indicating whether or not to use soft tabs
    • EditSession.setUseWorker(Boolean useWorker)

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

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

   

Arguments

useWorkerBooleanRequired. Set to true to use a worker
    • EditSession.setUseWrapMode(Boolean useWrapMode)

Sets whether or not line wrapping is enabled. If useWrapMode is different than the current value, the `'changeWrap...

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

   

Arguments

useWrapModeBooleanRequired. Enable (or disable) wrap mode
    • EditSession.setValue(String text)

Sets the session text. ...

Sets the session text.

   

Arguments

textStringRequired. The new text to place

Sets the boundaries of wrap. Either value can be null to have an unconstrained wrap, or, they can be the same numb...

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.

   

Arguments

minNumberRequired. The minimum wrap value (the left side wrap)
maxNumberRequired. The maximum wrap value (the right side wrap)
    • EditSession.toggleOverwrite()

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

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

   

Reverts previous changes to your document. ...

Reverts previous changes to your document.

   

Arguments

deltasArrayRequired. An array of previous changes
dontSelectBooleanRequired. If true, doesn't select the range of where the change occured