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.

Hierarchy (View Summary)

Constructors

Properties

Accessors

Methods

_dispatchEvent _emit _signal $addFoldLine $cloneFoldData $setFolding $toggleFoldWidget addDynamicMarker addEventListener addFold addFolds addGutterDecoration addMarker adjustWrapLimit clearAnnotations clearBreakpoint clearBreakpoints destroy documentToScreenColumn documentToScreenPosition documentToScreenRow duplicateLines endOperation expandFold expandFolds foldAll foldAllComments foldToLevel getAllFolds getAnnotations getAWordRange getBreakpoints getCommentFoldRange getDisplayLine getDocument getDocumentLastRowColumn getDocumentLastRowColumnPosition getFoldAt getFoldDisplayLine getFoldedRowCount getFoldLine getFoldsInRange getFoldsInRangeList getFoldStringAt getLength getLine getLines getLineWidgetMaxWidth getMarkers getMode getNavigateWithinSoftTabs getNewLineMode getNextFoldLine getOption getOptions getOverwrite getParentFoldRangeData getPrecedingCharacter getRowFoldEnd getRowFoldStart getRowLength getRowLineCount getRowSplitData getRowWrapIndent getScreenLastRowColumn getScreenLength getScreenTabSize getScreenWidth getScrollLeft getScrollTop getSelection getSelectionMarkers getState getTabSize getTabString getTextRange getTokenAt getTokens getUndoManager getUseSoftTabs getUseWorker getUseWrapMode getWordRange getWrapLimit getWrapLimitRange highlight highlightLines indentRows insert isRowFolded isTabStop markUndoGroup moveLinesDown moveLinesUp moveText off on once onFoldWidgetClick onSelectionChange outdentRows redoChanges remove removeAllListeners removeDefaultHandler removeEventListener removeFold removeFolds removeFullLines removeGutterDecoration removeListener removeMarker replace resetCaches screenToDocumentColumn screenToDocumentPosition screenToDocumentRow setAnnotations setBreakpoint setBreakpoints setDefaultHandler setDocument setFoldStyle setMode setNavigateWithinSoftTabs setNewLineMode setOption setOptions setOverwrite setScrollLeft setScrollTop setTabSize setUndoManager setUndoSelect setUseSoftTabs setUseWorker setUseWrapMode setValue setWrapLimit setWrapLimitRange startOperation toggleFold toggleFoldWidget toggleOverwrite toJSON tokenizerUpdateFoldWidgets undoChanges unfold updateFoldWidgets fromJSON

Constructors

Properties

$brackets: {
    "(": string;
    ")": string;
    "[": string;
    "]": string;
    "{": string;
    "}": string;
    "<": string;
    ">": string;
}
$findClosingBracket: (
    bracket: string,
    position: Point,
    typeRe?: RegExp,
) => Point
$findClosingTag: (
    iterator: any,
    token: any,
) => {
    closeTag: Range;
    closeTagName: Range;
    openTag: Range;
    openTagName: Range;
}
$findOpeningBracket: (
    bracket: string,
    position: Point,
    typeRe?: RegExp,
) => Point
$findOpeningTag: (
    iterator: any,
    token: any,
) => {
    closeTag: Range;
    closeTagName: Range;
    openTag: Range;
    openTagName: Range;
}
$findTagName: (iterator: any) => any
$foldData: FoldLine[]
$foldMode: any
$foldStyle: string
$foldStyles: { manual: number; markbegin: number; markbeginend: number }
$modified: boolean
$tokenizerUpdateFoldWidgets: any
$updateFoldWidgets: any
bgTokenizer: BackgroundTokenizer
curOp: Operation
destroyed: boolean
findMatchingBracket: (position: Point, chr?: string) => Point
foldWidgets: any[]
getBracketRange: (pos: Point) => Range
getFoldWidget: any
getFoldWidgetRange: any
getMatchingBracketRanges: (pos: Point, isBackwards?: boolean) => Range[]

Returns:

  • null if there is no any bracket at pos;
  • two Ranges if there is opening and closing brackets;
  • one Range if there is only one bracket
getMatchingTags: (
    pos: Point,
) => {
    closeTag: Range;
    closeTagName: Range;
    openTag: Range;
    openTagName: Range;
}

Returns [[Range]]'s for matching tags and tag names, if there are any

getValue: () => string

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

getValue

EditSession.toString

gutterRenderer?: any
id: string
isFullWidth: (c: any) => boolean
lineWidgets: LineWidget[]
lineWidgetsWidth?: number
lineWidgetWidth: number
mergeUndoDeltas: boolean
multiSelect?: any
nonTokenRe: RegExp
prevOp: {}
screenWidth: any
selection: Selection
selectionMarkerCount?: number
tokenRe: RegExp

Accessors

Methods

  • 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 void

  • 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

    • Optionaltype: "fullLine" | "screenLine" | "text" | "line" | MarkerRenderer

      Identify the renderer type of the marker. If string provided, corresponding built-in renderer is used. Supported string types are "fullLine", "screenLine", "text" or "line". If a Function is provided, that Function is used as renderer.

    • OptionalinFront: boolean

      Set to true to establish a front marker

    Returns number

    The new marker id

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

    Parameters

    • desiredLimit: number

      The new wrap limit

    • Optional$printMargin: any

    Returns boolean

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

    Returns void

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

    Parameters

    • row: number

      A row index

    Returns void

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

    Returns void

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

    Parameters

    • row: number | Point
    • OptionaldocColumn: number

    Returns number

  • Converts document coordinates to screen coordinates. {:conversionConsiderations}

    Parameters

    • docRow: number | Point

      The document row to check

    • OptionaldocColumn: number

      The document column to check

    Returns Point

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

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

    Parameters

    • docRow: number | Point
    • OptionaldocColumn: number

    Returns 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

    Returns the number of new rows added; in other words, lastRow - firstRow + 1.

  • End current Ace operation. Emits "beforeEndOperation" event just before clearing everything, where the current operation can be accessed through curOp property.

    Parameters

    • Optionale: any

    Returns void

  • Parameters

    • OptionalstartRow: number
    • OptionalendRow: number
    • Optionaldepth: number
    • Optionaltest: Function

    Returns void

  • 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 Range

  • Returns an array of strings, indicating the breakpoint class (if any) applied to each row.

    Returns string[]

  • Parameters

    • row: number
    • endColumn: number
    • startRow: number
    • startColumn: number

    Returns string

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

    Parameters

    • docRow: number
    • docColumn: number

    Returns number

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

    Parameters

    • docRow: number
    • docColumn: number

    Returns Point

  • Looks up a fold at a given row/column. Possible values for side: -1: ignore a fold if fold.start = row/column +1: ignore a fold if fold.end = row/column

    Parameters

    • row: number
    • column: number
    • Optionalside: number

    Returns Fold

  • Parameters

    • foldLine: FoldLine
    • OptionalendRow: number
    • OptionalendColumn: number
    • OptionalstartRow: number
    • OptionalstartColumn: number

    Returns string

  • Returns the string between folds at the given position. E.g. foob|arwolrd -> "bar" foobarwol|rd -> "world" foobar<fo|ld>wolrd ->

    where | means the position of row/column

    The trim option determs if the return string should be trimed according to the "side" passed with the trim value:

    E.g. foob|arwolrd -trim=-1> "b" foobarwol|rd -trim=+1> "rld" fo|obarwolrd -trim=00> "foo"

    Parameters

    • row: number
    • column: number
    • Optionaltrim: number
    • OptionalfoldLine: FoldLine

    Returns string

  • Returns the number of rows in the document.

    Returns number

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

    Parameters

    • row: number

      The row to retrieve from

    Returns 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 string[]

  • Returns an object containing all of the markers, either front or back.

    Parameters

    • OptionalinFront: boolean

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

    Returns { [id: number]: MarkerLike }

  • Returns true if keyboard navigation moves the cursor within soft tabs, false if it moves the cursor over soft tabs.

    Returns boolean

  • Returns true if overwrites are enabled; false otherwise.

    Returns boolean

  • Returns string

    the last character preceding the cursor in the editor

  • Returns number of screenrows in a wrapped line.

    Parameters

    • row: number

      The row number to check

    Returns number

  • For the given row, this returns the split data.

    Parameters

    • row: number

    Returns string

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

    Parameters

    • screenRow: number

      The screen row to check

    Returns number

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

    Parameters

    • screenColumn: number

      The screen column to check

    Returns 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

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

    Returns number

  • Returns any[]

  • Returns any[]

  • {:BackgroundTokenizer.getState}

    Parameters

    • row: number

      The row to start at

    Returns string | 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

  • {:Document.getTextRange.desc}

    Parameters

    • Optionalrange: IRange

      The range to work with

    Returns string

  • 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 Token

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

    Parameters

    • row: number

      The row to start at

    Returns Token[]

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

    Returns boolean

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

    Returns boolean

  • 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

  • Returns the value of wrap limit.

    Returns number

    The wrap limit.

  • 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 { max: number; min: number }

  • experimental

    Parameters

    • startRow: number
    • endRow: number
    • clazz: string
    • OptionalinFront: boolean

    Returns Range

  • 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 void

  • Inserts a block of text and the indicated position.

    Parameters

    • position: Point

      The position {row, column} to start inserting at

    • text: string

      A chunk of text to insert

    Returns Point

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

  • Checks if a given documentRow is folded. This is true if there are some folded parts such that some parts of the line is still visible.

    Parameters

    • docRow: number
    • OptionalstartFoldRow: FoldLine

    Returns boolean

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

    Parameters

    • position: Point

      The position to check

    Returns boolean

  • 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

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

    Parameters

    • firstRow: number

      The starting row to move up

    • lastRow: number

      The final row to move up

    Returns number

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

  • 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: Point

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

    • Optionalcopy: boolean

    Returns Range

    The new range where the text was moved to.

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

    Parameters

    • range: Range

      A range of rows

    Returns void

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

    Parameters

    • deltas: Delta[]

      An array of previous changes

    • OptionaldontSelect: boolean

    Returns void

  • Removes the range from the document.

    Parameters

    • range: IRange

      A specified Range to remove

    Returns Point

    The new start property of the range, which contains startRow and startColumn. If range is empty, this function returns the unmodified value of range.start.

  • Removes a range of full lines. This method also triggers the 'change' event.

    Parameters

    • firstRow: number

      The first row to be removed

    • lastRow: number

      The last row to be removed

    Returns string[]

    Returns all the removed lines.

  • Removes className from the row.

    Parameters

    • row: number

      The row number

    • className: string

      The class to add

    Returns void

  • 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 void

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

    Parameters

    • range: IRange

      A specified Range to replace

    • text: string

      The new text to use as a replacement

    Returns Point

    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.

  • Parameters

    • screenRow: number
    • screenColumn: number

    Returns number

  • 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

    • OptionaloffsetX: number

      screen character x-offset [optional]

    Returns Point

    The object returned has two properties: row and column.

  • Parameters

    • screenRow: number
    • screenColumn: number

    Returns number

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

    Parameters

    Returns void

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

    Parameters

    • row: number

      A row index

    • className: string

      Class of the breakpoint

    Returns void

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

    Parameters

    • rows: number[]

      An array of row indices

    Returns void

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

    Parameters

    Returns void

  • 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

    • mode: string | SyntaxMode

      Set a new text mode

    • Optionalcb: () => void

      optional callback

    Returns void

  • Set whether keyboard navigation of soft tabs moves the cursor within the soft tab, rather than over

    Parameters

    • navigateWithinSoftTabs: boolean

      Value indicating whether or not to navigate within soft tabs

    Returns void

  • 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 emits the changeOverwrite event.

    Parameters

    • overwrite: boolean

      Defines whether or not to set overwrites

    Returns void

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

    Parameters

    • scrollLeft: number

    Returns void

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

    Parameters

    • scrollTop: number

      The new scroll top value

    Returns void

  • 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 void

  • Enables or disables highlighting of the range where an undo occurred.

    Parameters

    • enable: boolean

      If true, selects the range of the reinserted change

    Returns void

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

    Parameters

    • val: boolean

      Value indicating whether or not to use soft tabs

    Returns void

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

    Parameters

    • useWorker: boolean

      Set to true to use a worker

    Returns void

  • 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 void

  • Sets the session text.

    Parameters

    • text: string

      The new text to place

    Returns void

  • Sets the line length for soft wrap in the editor. Lines will break at a minimum of the given length minus 20 chars and at a maximum of the given number of chars.

    Parameters

    • limit: number

      The maximum line length in chars, for soft wrapping lines.

    Returns void

  • 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 void

  • Start an Ace operation, which will then batch all the subsequent changes (to either content or selection) under a single atomic operation.

    Parameters

    • OptionalcommandEvent: { args?: any; command?: { name?: string } }

      Optional name for the operation

    Returns void

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

    Returns void

  • Reverts previous changes to your document.

    Parameters

    • deltas: Delta[]

      An array of previous changes

    • OptionaldontSelect: boolean

      If true, doesn't select the range of where the change occured

    Returns void

  • Returns a new instance of EditSession with state from JSON.

    Parameters

    • session: string | object

      The EditSession state.

    Returns EditSession

    fromJSON