EditSession[edit]
Constructors
Sets up a new EditSession and associates it with the given Document and TextMode.
Events
-
- EditSession.on("change", function(e))
Emitted when the document changes.
-
- EditSession.on("changeFold", function(e))
Emitted when a code fold added or removed.
-
- EditSession.on("changeScrollLeft", function())
Emitted when the scroll left changes.
-
- EditSession.on("changeScrollTop", function())
Emitted when the scroll top changes.
-
- EditSession.on("tokenizerUpdate", function(e))
Emitted when a background tokenizer asynchronousely processes new rows.
Methods
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.
-
- EditSession.clearAnnotations()
Clears all the annotations for this session. This function also triggers the 'changeAnnotation' event.
-
- EditSession.clearBreakpoints()
Removes all breakpoints on the rows. This function also emites the 'changeBreakpoint' event.
-
- EditSession.getAnnotations()
Returns the annotations for the EditSession.
-
- EditSession.getBreakpoints()
Returns an array of numbers, indicating which rows have breakpoints.
-
- EditSession.getDocument()
Returns the Document associated with this session.
-
- EditSession.getLength()
Returns the number of rows in the document.
-
- EditSession.getMode()
Returns the current text mode.
-
- EditSession.getNewLineMode()
Returns the current new line mode.
-
- EditSession.getOverwrite()
Returns true if overwrites are enabled; false otherwise.
-
- EditSession.getScreenLength()
Returns the length of the screen.
-
- EditSession.getScreenWidth()
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.]{: #EditSession.getScrollLeft}
-
- EditSession.getScrollTop()
[Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop}
-
- EditSession.getSelection()
Returns the string of the current selection.
-
- EditSession.getTabSize()
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 getTabSize); otherwise it's simply '\t'.
-
- EditSession.getUndoManager()
Returns the current undo manager.
-
- EditSession.getUseSoftTabs()
Returns true if soft tabs are being used, false otherwise.
-
- EditSession.getUseWorker()
Returns true if workers are being used.
-
- EditSession.getUseWrapMode()
Returns true if wrap mode is being used; false otherwise.
-
- EditSession.getWrapLimit()
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:
{ min: wrapLimitRange_min, max: wrapLimitRange_max }
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
| startRow | Number | Required. Starting row |
| endRow | Number | Required. Ending row |
| indentString | String | Required. The indent token |
Shifts all the lines in the document up one, starting from firstRow and ending at lastRow.
{ row: newRowLocation, column: newColumnLocation }
Arguments
| fromRange | Range | Required. The range of text you want moved within the document |
| toPosition | Object | Required. The location (row and column) where you want to move the text to |
Returns
| Range | The 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.onReloadTokenizer(e)
Reloads all the tokens on the current session. This function calls start to all the rows; it also emits the 'tokenizerUpdate' event.
Replaces a range in the document with the new text.
Arguments
| range | Range | Required. A specified Range to replace |
| text | String | Required. The new text to use as a replacement |
Returns
| Object | Returns 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 account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations}
-
- EditSession.setMode(TextMode mode)
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
| mode | TextMode | Required. Set a new text mode |
-
- EditSession.setOverwrite(Boolean overwrite)
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
| overwrite | Boolean | Required. 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.]{: #EditSession.setScrollLeft}
-
- EditSession.setUndoManager(UndoManager undoManager)
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.
-
- EditSession.toggleOverwrite()
Sets the value of overwrite to the opposite of whatever it currently is.