Editor[edit]

The main entry point into the Ace functionality. The Editor manages the EditSession (which manages Documents), as well as the VirtualRenderer, which draws everything to the screen. Event sessions dealing with the mouse and keyboard are bubbled up from Document to the Editor, which decides what to do with them.

Constructors

Creates a new Editor object. ...

Creates a new Editor object.

   

Arguments

rendererVirtualRendererRequired. Associated VirtualRenderer that draws everything
sessionEditSessionRequired. The EditSession to refer to

Events

    • Editor.on("onBlur", function())

Emitted once the editor has been blurred. ...

Emitted once the editor has been blurred.

   

    • Editor.on("onChangeAnnotation", function())

Emitted when an annotation changes. ...

Emitted when an annotation changes.

   

    • Editor.on("onChangeBackMarker", function())

Emitted when a back marker changes. ...

Emitted when a back marker changes.

   

    • Editor.on("onChangeBreakpoint", function())

Emitted when a breakpoint changes. ...

Emitted when a breakpoint changes.

   

    • Editor.on("onChangeFold", function())

Emitted when the code folds change. ...

Emitted when the code folds change.

   

    • Editor.on("onChangeFrontMarker", function())

Emitted when a front marker changes. ...

Emitted when a front marker changes.

   

    • Editor.on("onChangeMode", function())

Emitted when the mode changes. ...

Emitted when the mode changes.

   

    • Editor.on("onChangeWrapLimit", function())

Emitted when the wrap limit changes. ...

Emitted when the wrap limit changes.

   

    • Editor.on("onChangeWrapMode", function())

Emitted when the wrap mode changes. ...

Emitted when the wrap mode changes.

   

    • Editor.on("onCommandKey", function(e, hashId, keyCode))

Emitted when the command-key is pressed. ...

Emitted when the command-key is pressed.

   

    • Editor.on("onCursorChange", function())

Emitted when the cursor changes. ...

Emitted when the cursor changes.

   

    • Editor.on("onDocumentChange", function(Object e))

Emitted whenever the document is changed. ...

Emitted whenever the document is changed.

   

Arguments

eObjectRequired. Contains a single property, data, which has the delta of changes
    • Editor.on("onFocus", function())

Emitted once the editor comes into focus. ...

Emitted once the editor comes into focus.

   

    • Editor.on("onScrollLeftChange", function())

Emitted when the scroll left changes. ...

Emitted when the scroll left changes.

   

    • Editor.on("onScrollTopChange", function())

Emitted when the scroll top changes. ...

Emitted when the scroll top changes.

   

    • Editor.on("onSelectionChange", function(Object e))

Emitted when a selection has changed. ...

Emitted when a selection has changed.

   

Arguments

eObjectRequired. Contains a single property, data, which has the delta of changes
    • Editor.on("onTextInput", function(String text, Boolean pasted))

Emitted when text is entered. ...

Emitted when text is entered.

   

Arguments

textStringRequired. The text entered
pastedBooleanRequired. Identifies whether the text was pasted (true) or not
    • Editor.on("onTokenizerUpdate", function(Object e))

Emitted when the a tokenizer is updated. ...

Emitted when the a tokenizer is updated.

   

Arguments

eObjectRequired. Contains a single property, data, which indicates the changed rows

Methods

    • Editor.$getSelectedRows()

Returns an object indicating the currently selected rows. The object looks like this: ...

Returns an object indicating the currently selected rows. The object looks like this:

   

{ first: range.start.row, last: range.end.row }

    • Editor.$getVisibleRowCount()

Returns the number of currently visibile rows. ...

Returns the number of currently visibile rows.

   

Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicati...

Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them.

   

Arguments

moverFunctionRequired. A method to call on each selected row
    • Editor.addSelectionMarker(Range orientedRange)

Adds the selection and cursor. ...

Adds the selection and cursor.

   

Arguments

orientedRangeRangeRequired. A range containing a cursor

Outdents the current line. ...

Outdents the current line.

   

    • Editor.blur()

Blurs the current textInput. ...

Blurs the current textInput.

   

    • Editor.centerSelection()

Attempts to center the current selection on the screen. ...

Attempts to center the current selection on the screen.

   

Empties the selection (by de-selecting it). This function also emits the 'changeSelection' event. ...

Empties the selection (by de-selecting it). This function also emits the 'changeSelection' event.

   

Copies all the selected lines down one row. ...

Copies all the selected lines down one row.

   

Returns

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

Copies all the selected lines up one row. ...

Copies all the selected lines up one row.

   

Returns

NumberOn success, returns 0.
    • Editor.destroy()

Cleans up the entire editor. ...

Cleans up the entire editor.

   

    • Editor.exitMultiSelectMode()

Removes all the selections except the last added one. ...

Removes all the selections except the last added one.

   

Attempts to find needle within the document. For more information on options, see Search. ...

Attempts to find needle within the document. For more information on options, see Search.

   

Arguments

needleStringRequired. The text to search for
optionsObjectRequired. An object defining various search properties

Finds and selects all the occurences of needle. ...

Finds and selects all the occurences of needle.

   

Arguments

needleStringRequired. The text to find
optionsObjectRequired. Any of the additional search options
additiveBooleanRequired. TODO

Returns

NumberThe number of found ranges.

Performs another search for needle in the document. For more information on options, see Search. ...

Performs another search for needle in the document. For more information on options, see Search.

   

Performs a search for needle backwards. For more information on options, see Search. ...

Performs a search for needle backwards. For more information on options, see Search.

   

    • Editor.focus()

Brings the current textInput into focus. ...

Brings the current textInput into focus.

   

Executes a command for each selection range. ...

Executes a command for each selection range.

   

Arguments

cmdStringRequired. The command to execute
argsStringRequired. Any arguments for the command
    • Editor.getBehavioursEnabled()

Returns true if the behaviors are currently enabled. "Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets. ...

Returns true if the behaviors are currently enabled. "Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.

   

Returns the string of text currently highlighted. ...

Returns the string of text currently highlighted.

   

Gets the current position of the cursor. ...

Gets the current position of the cursor.

   

Returns

ObjectThis returns an object that looks something like this:
{ row: currRow, column: currCol }
    • Editor.getDragDelay()

Returns the current mouse drag delay. ...

Returns the current mouse drag delay.

   

    • Editor.getHighlightActiveLine()

Returns true if current lines are always highlighted. ...

Returns true if current lines are always highlighted.

   

    • Editor.getHighlightSelectedWord()

Returns true if currently highlighted words are to be highlighted. ...

Returns true if currently highlighted words are to be highlighted.

   

Returns the keyboard handler. ...

Returns the keyboard handler.

   

Returns an object containing all the search options. For more information on options, see Search. ...

Returns an object containing all the search options. For more information on options, see Search.

   

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

Returns true if overwrites are enabled; false otherwise.

   

    • Editor.getPrintMarginColumn()

Returns the column number of where the print margin is. ...

Returns the column number of where the print margin is.

   

Returns true if the editor is set to read-only mode. ...

Returns true if the editor is set to read-only mode.

   

    • Editor.getScrollSpeed()

Returns the value indicating how fast the mouse scroll speed is. ...

Returns the value indicating how fast the mouse scroll speed is.

   

    • Editor.getSelection()

Returns the currently highlighted selection. ...

Returns the currently highlighted selection.

   

    • Editor.getSelectionStyle()

Returns the current selection style. ...

Returns the current selection style.

   

Returns the current session being used. ...

Returns the current session being used.

   

    • Editor.getShowFoldWidgets()

Returns true if the fold widgets are shown. ...

Returns true if the fold widgets are shown.

   

    • Editor.getShowInvisibles()

Returns true if invisible characters are being shown. ...

Returns true if invisible characters are being shown.

   

    • Editor.getShowPrintMargin()

Returns true if the print margin is being shown. ...

Returns true if the print margin is being shown.

   

Returns the path of the current theme. ...

Returns the path of the current theme.

   

Moves the cursor to the specified line number, and also into the indiciated column. ...

Moves the cursor to the specified line number, and also into the indiciated column.

   

Arguments

lineNumberNumberRequired. The line number to go to
columnNumberRequired. A column number to go to
    • Editor.gotoPageDown()

Shifts the document to wherever "page down" is, as well as moving the cursor position. ...

Shifts the document to wherever "page down" is, as well as moving the cursor position.

   

    • Editor.gotoPageUp()

Shifts the document to wherever "page up" is, as well as moving the cursor position. ...

Shifts the document to wherever "page up" is, as well as moving the cursor position.

   

Indents the current line. ...

Indents the current line.

   

Inserts text into wherever the cursor is pointing. ...

Inserts text into wherever the cursor is pointing.

   

Arguments

textStringRequired. The new text to add

Returns true if the current textInput is in focus. ...

Returns true if the current textInput is in focus.

   

Indicates if the entire row is currently visible on the screen. ...

Indicates if the entire row is currently visible on the screen.

   

Arguments

rowNumberRequired. The row to check

Indicates if the row is currently visible on the screen. ...

Indicates if the row is currently visible on the screen.

   

Arguments

rowNumberRequired. The row to check
    • Editor.jumpToMatching()

Moves the cursor's row and column to the next matching bracket. ...

Moves the cursor's row and column to the next matching bracket.

   

Moves the cursor to the specified row and column. Note that this does not de-select the current selection. ...

Moves the cursor to the specified row and column. Note that this does not de-select the current selection.

   

Arguments

rowNumberRequired. The new row number
columnNumberRequired. The new column number

Moves the cursor to the position indicated by pos.row and pos.column. ...

Moves the cursor to the position indicated by pos.row and pos.column.

   

Arguments

posObjectRequired. An object with two properties, row and column

Shifts all the selected lines down one row. ...

Shifts all the selected lines down one row.

   

Returns

NumberOn success, it returns -1.

Shifts all the selected lines up one row. ...

Shifts all the selected lines up one row.

   

Returns

NumberOn 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: ...

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 }

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.
    • Editor.navigateDown(Number times)

Moves the cursor down in the document the specified number of times. Note that this does de-select the current selec...

Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.

   

Arguments

timesNumberRequired. The number of times to change navigation
    • Editor.navigateFileEnd()

Moves the cursor to the end of the current file. Note that this does de-select the current selection. ...

Moves the cursor to the end of the current file. Note that this does de-select the current selection.

   

    • Editor.navigateFileStart()

Moves the cursor to the start of the current file. Note that this does de-select the current selection. ...

Moves the cursor to the start of the current file. Note that this does de-select the current selection.

   

    • Editor.navigateLeft(Number times)

Moves the cursor left in the document the specified number of times. Note that this does de-select the current selec...

Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.

   

Arguments

timesNumberRequired. The number of times to change navigation
    • Editor.navigateLineEnd()

Moves the cursor to the end of the current line. Note that this does de-select the current selection. ...

Moves the cursor to the end of the current line. Note that this does de-select the current selection.

   

    • Editor.navigateLineStart()

Moves the cursor to the start of the current line. Note that this does de-select the current selection. ...

Moves the cursor to the start of the current line. Note that this does de-select the current selection.

   

    • Editor.navigateRight(Number times)

Moves the cursor right in the document the specified number of times. Note that this does de-select the current sele...

Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.

   

Arguments

timesNumberRequired. The number of times to change navigation

Moves the cursor to the specified row and column. Note that this does de-select the current selection. ...

Moves the cursor to the specified row and column. Note that this does de-select the current selection.

   

Arguments

rowNumberRequired. The new row number
columnNumberRequired. The new column number
    • Editor.navigateUp(Number times)

Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection. ...

Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.

   

Arguments

timesNumberRequired. The number of times to change navigation
    • Editor.navigateWordLeft()

Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the curr...

Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection.

   

    • Editor.navigateWordRight()

Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the cur...

Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection.

   

    • Editor.removeSelectionMarker(Range range)

Removes the selection marker. ...

Removes the selection marker.

   

Arguments

rangeRangeRequired. The selection range added with addSelectionMarker().

Finds the next occurence of text in an active selection and adds it to the selections. ...

Finds the next occurence of text in an active selection and adds it to the selections.

   

Arguments

dirNumberRequired. The direction of lines to select: -1 for up, 1 for down
skipBooleanRequired. If true, removes the active selection range

Adds a cursor above or below the active cursor. ...

Adds a cursor above or below the active cursor.

   

Arguments

dirNumberRequired. The direction of lines to select: -1 for up, 1 for down
skipBooleanRequired. If true, removes the active selection range
    • Editor.transposeSelections(Number dir)

Transposes the selected ranges. ...

Transposes the selected ranges.

   

Arguments

dirNumberRequired. The direction to rotate selections
    • Editor.onCut()

Emitted whenever a text "cut" happens. ...

Emitted whenever a text "cut" happens.

   

Perform a redo operation on the document, reimplementing the last change. ...

Perform a redo operation on the document, reimplementing the last change.

   

Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace. ...

Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace.

   

Arguments

dirStringRequired. The direction of the deletion to occur, either "left" or "right"

Removes all the lines in the current selection ...

Removes all the lines in the current selection

   

    • Editor.removeToLineEnd()

Removes all the words to the right of the current selection, until the end of the line. ...

Removes all the words to the right of the current selection, until the end of the line.

   

    • Editor.removeToLineStart()

Removes all the words to the left of the current selection, until the start of the line. ...

Removes all the words to the left of the current selection, until the start of the line.

   

    • Editor.removeWordLeft()

Removes the word directly to the left of the current selection. ...

Removes the word directly to the left of the current selection.

   

    • Editor.removeWordRight()

Removes the word directly to the right of the current selection. ...

Removes the word directly to the right of the current selection.

   

Replaces the first occurance of options.needle with the value in replacement. ...

Replaces the first occurance of options.needle with the value in replacement.

   

Arguments

replacementStringRequired. The text to replace with
optionsObjectRequired. The Search options to use

Replaces all occurances of options.needle with the value in replacement. ...

Replaces all occurances of options.needle with the value in replacement.

   

Arguments

replacementStringRequired. The text to replace with
optionsObjectRequired. The Search options to use

Triggers a resize of the editor. ...

Triggers a resize of the editor.

   

    • Editor.scrollPageDown()

Scrolls the document to wherever "page down" is, without changing the cursor position. ...

Scrolls the document to wherever "page down" is, without changing the cursor position.

   

    • Editor.scrollPageUp()

Scrolls the document to wherever "page up" is, without changing the cursor position. ...

Scrolls the document to wherever "page up" is, without changing the cursor position.

   

TODO scrollsa to line, if center == true, puts line in middle of screen or attempts to) ...

TODO scrollsa to line, if center == true, puts line in middle of screen or attempts to)

   

Arguments

lineNumberRequired. The line to scroll to
centerBooleanRequired. If true

Moves the editor to the specified row. ...

Moves the editor to the specified row.

   

Arguments

rowNumberRequired. The row to move to

Selects all the text in editor. ...

Selects all the text in editor.

   

    • Editor.selectPageDown()

Selects the text from the current position of the document until where a "page down" finishes. ...

Selects the text from the current position of the document until where a "page down" finishes.

   

    • Editor.selectPageUp()

Selects the text from the current position of the document until where a "page up" finishes. ...

Selects the text from the current position of the document until where a "page up" finishes.

   

    • Editor.setBehavioursEnabled()

Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like...

"Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.

   

Arguments

enabledBooleanRequired. Enables or disables behaviors
    • Editor.setDragDelay(Number dragDelay)

Sets the delay (in milliseconds) of the mouse drag. ...

Sets the delay (in milliseconds) of the mouse drag.

   

Arguments

dragDelayNumberRequired. A value indicating the new delay
    • Editor.setFontSize(Number size)

Set a new font size (in pixels) for the editor text. ...

Set a new font size (in pixels) for the editor text.

   

Arguments

sizeNumberRequired. A font size
    • Editor.setHighlightActiveLine(Boolean shouldHighlight)

Determines whether or not the current line should be highlighted. ...

Determines whether or not the current line should be highlighted.

   

Arguments

shouldHighlightBooleanRequired. Set to true to highlight the current line
    • Editor.setHighlightSelectedWord(Boolean shouldHighlight)

Determines if the currently selected word should be highlighted. ...

Determines if the currently selected word should be highlighted.

   

Arguments

shouldHighlightBooleanRequired. Set to true to highlight the currently selected word
    • Editor.setKeyboardHandler(keyboardHandler)

Sets a new keyboard handler. ...

Sets a new keyboard handler.

   

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
    • Editor.setPrintMarginColumn(Number showPrintMargin)

Sets the column defining where the print margin should be. ...

Sets the column defining where the print margin should be.

   

Arguments

showPrintMarginNumberRequired. Specifies the new print margin
    • Editor.setReadOnly(Boolean readOnly)

If readOnly is true, then the editor is set to read-only mode, and none of the content can change. ...

If readOnly is true, then the editor is set to read-only mode, and none of the content can change.

   

Arguments

readOnlyBooleanRequired. Specifies whether the editor can be modified or not
    • Editor.setScrollSpeed(Number speed)

Sets how fast the mouse scrolling should do. ...

Sets how fast the mouse scrolling should do.

   

Arguments

speedNumberRequired. A value indicating the new speed
    • Editor.setSelectionStyle(String style)

Indicates how selections should occur. By default, selections are set to "line". This function also emits the `'chan...

Indicates how selections should occur. By default, selections are set to "line". This function also emits the 'changeSelectionStyle' event.

   

Arguments

styleStringRequired. The new selection style

Sets a new editsession to use. This method also emits the 'changeSession' event. ...

Sets a new editsession to use. This method also emits the 'changeSession' event.

   

Arguments

sessionEditSessionRequired. The new session to use
    • Editor.setShowFoldWidgets(Boolean show)

Indicates whether the fold widgets are shown or not. ...

Indicates whether the fold widgets are shown or not.

   

Arguments

showBooleanRequired. Specifies whether the fold widgets are shown
    • Editor.setShowInvisibles(Boolean showInvisibles)

If showInvisibiles is set to true, invisible characters—like spaces or new lines—are show in the editor. ...

If showInvisibiles is set to true, invisible characters—like spaces or new lines—are show in the editor.

   

Arguments

showInvisiblesBooleanRequired. Specifies whether or not to show invisible characters
    • Editor.setShowPrintMargin(Boolean showPrintMargin)

If showPrintMargin is set to true, the print margin is shown in the editor. ...

If showPrintMargin is set to true, the print margin is shown in the editor.

   

Arguments

showPrintMarginBooleanRequired. Specifies whether or not to show the print margin

Adds a new class, style, to the editor. ...

Adds a new class, style, to the editor.

   

    • Editor.setTheme(theme)

Sets a new theme for the editor. theme should exist, and be a directory path, like ace/theme/textmate. ...

Sets a new theme for the editor. theme should exist, and be a directory path, like ace/theme/textmate.

   

    • Editor.splitLine()

Splits the line at the current selection (by inserting an '\n'). ...

Splits the line at the current selection (by inserting an '\n').

   

    • Editor.toggleCommentLines()

Given the currently selected range, this function either comments all lines or uncomments all lines (depending on wh...

Given the currently selected range, this function either comments all lines or uncomments all lines (depending on whether it's commented or not).

   

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.

   

    • Editor.toLowerCase()

Converts the current selection entirely into lowercase. ...

Converts the current selection entirely into lowercase.

   

    • Editor.toUpperCase()

Converts the current selection entirely into uppercase. ...

Converts the current selection entirely into uppercase.

   

    • Editor.transposeLetters()

Transposes current line. ...

Transposes current line.

   

Perform an undo operation on the document, reverting the last change. Returns the range of the undo. ...

Perform an undo operation on the document, reverting the last change. Returns the range of the undo.

   

Removes the class style from the editor. ...

Removes the class style from the editor.