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.
Editor [edit]
Constructors
- new Editor(VirtualRenderer renderer, EditSession session)
Creates a new Editor object.
Creates a new Editor object.
Arguments
| renderer | VirtualRenderer | Required. Associated |
| session | EditSession | Required. The |
Events
- Editor.on("blur", function())
Emitted once the editor has been blurred.
Emitted once the editor has been blurred.
- Editor.on("changeSelection", function())
Emitted when the selection changes.
Emitted when the selection changes.
- Editor.on("changeSelectionStyle", function(Object data))
Emitted when the selection style changes, via Editor.setSelectionStyle().
Emitted when the selection style changes, via Editor.setSelectionStyle().
Arguments
| data | Object | Required. Contains one property, |
- Editor.on("changeSession", function(Object e))
Emitted whenever the EditSession changes.
Emitted whenever the EditSession changes.
Arguments
| e | Object | Required. An object with two properties, |
- Editor.on("focus", function())
Emitted once the editor comes into focus.
Emitted once the editor comes into focus.
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.
- Editor.$highlightBrackets()
- Editor.$moveLines(Function mover)
Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them.
Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them.
Arguments
| mover | Function | Required. A method to call on each selected row |
- Editor.$updateHighlightActiveLine()
- Editor.blockOutdent()
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.
- Editor.clearSelection()
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.
- Editor.destroy()
Cleans up the entire editor.
Cleans up the entire editor.
- Editor.exitMultiSelectMode()
- Void
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.
- Editor.focus()
Brings the current textInput into focus.
Brings the current textInput into focus.
- 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.
- Editor.getCopyText()
Returns the string of text currently highlighted.
Returns the string of text currently highlighted.
- Editor.getCursorPositionScreen()
Returns the screen position of the cursor.
Returns the screen position of the cursor.
- Editor.getDragDelay()
Returns the current mouse drag delay.
Returns the current mouse drag delay.
- Editor.getFirstVisibleRow()
Returns the index of the first visible row.
Returns the index of the first visible row.
- 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.
- Editor.getKeyboardHandler()
Returns the keyboard handler.
Returns the keyboard handler.
- Editor.getLastVisibleRow()
Returns the index of the last visible row.
Returns the index of the last visible row.
- Editor.getOverwrite()
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.
- Editor.getReadOnly()
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.
- Editor.getSession()
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.
- Editor.getTheme()
Returns the path of the current theme.
Returns the path of the current theme.
- Editor.getValue()
Returns the current session's content.
Returns the current session's content.
Moves the cursor to the specified line number, and also into the indiciated column.
- 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.
- Editor.indent()
Indents the current line.
Indents the current line.
- Editor.isFocused()
Returns true if the current textInput is in focus.
Returns true if the current textInput is in focus.
- 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 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
| 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 the cursor to the end 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.
- ()
Moves the cursor to the end 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.
- ()
Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection.
- ()
Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection.
- Editor.onCopy()
Called whenever a text "copy" happens.
Called whenever a text "copy" happens.
- Editor.onCut()
called whenever a text "cut" happens.
called whenever a text "cut" happens.
- Editor.redo()
Perform a redo operation on the document, reimplementing the last change.
Perform a redo operation on the document, reimplementing the last change.
- Editor.remove(String dir)
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
| dir | String | Required. The direction of the deletion to occur, either "left" or "right" |
- Editor.removeLines()
Removes all the lines in the current selection
Removes all the lines in the current selection
- Editor.removeSelectionMarker(Range range)
Removes the selection marker.
Removes the selection marker.
Arguments
| range | Range | Required. The selection range added with |
- 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.
- 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 scrolls a to line, if center == true, puts line in middle of screen or attempts to)
TODO scrolls a to line, if center == true, puts line in middle of screen or attempts to)
Arguments
| line | Number | Required. The line to scroll to |
| center | Boolean | Required. If |
| animate | Boolean | Required. If |
| callback | Function | Required. Function to be called when the animation has finished |
- Editor.selectAll()
Selects all the text in editor.
Selects all the text in editor.
Finds the next occurence of text in an active selection and adds it to the selections.
- 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(Boolean enabled)
Specifies whether to use behaviors or not. "Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.
Specifies whether to use behaviors or not. "Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.
Arguments
| enabled | Boolean | Required. Enables or disables behaviors |
- Editor.setKeyboardHandler(keyboardHandler)
Sets a new keyboard handler.
Sets a new keyboard handler.
- Editor.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.
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 |
- 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
| readOnly | Boolean | Required. Specifies whether the editor can be modified or not |
- Editor.setSelectionStyle(String style)
Indicates how selections should occur. By default, selections are set to "line". This function also emits the 'changeSelectionStyle' event.
Indicates how selections should occur. By default, selections are set to "line". This function also emits the 'changeSelectionStyle' event.
Arguments
| style | String | Required. The new selection style |
- Editor.setSession(EditSession session)
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
| session | EditSession | Required. The new session to use |
- 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
| showInvisibles | Boolean | Required. Specifies whether or not to show invisible characters |
- 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 whether it's commented or not).
Given the currently selected range, this function either comments all lines or uncomments all lines (depending on whether it's commented or not).
- Editor.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.
- 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.
- Editor.undo()
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.
- Editor.unsetStyle(style)
Removes the class style from the editor.
Removes the class style from the editor.
- Editor.updateSelectionMarkers()
Updates the cursor and marker layers.
Updates the cursor and marker layers.