diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 7e4cc06e..eaf6dca3 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -86,7 +86,7 @@ var EditSession = function(text, mode) { return str; } - if (text instanceof Document) { + if (typeof text == "object") { this.setDocument(text); } else { this.setDocument(new Document(text)); @@ -102,7 +102,7 @@ var EditSession = function(text, mode) { oop.implement(this, EventEmitter); /** - * EditSession.setDocument(doc) + * EditSession.setDocument(doc) * - doc (Document): The new `Document` to use * * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`. @@ -125,7 +125,7 @@ var EditSession = function(text, mode) { /** * EditSession.getDocument() -> Document * - * Returns the `Document` associated with this session. + * Returns the `Document` associated with this session. * **/ this.getDocument = function() { @@ -133,10 +133,10 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.$resetRowCache(row) + * EditSession.$resetRowCache(row) * - row (Number): The row to work with * - * + * * **/ this.$resetRowCache = function(row) { @@ -154,8 +154,8 @@ var EditSession = function(text, mode) { }; /** - * EditSession@onChangeFold(e) - * + * EditSession@onChangeFold(e) + * * Emitted when a code fold changes its state. * **/ @@ -165,8 +165,8 @@ var EditSession = function(text, mode) { }; /** - * EditSession@onChange(e) - * + * EditSession@onChange(e) + * * Emitted when the document changes. **/ this.onChange = function(e) { @@ -193,7 +193,7 @@ var EditSession = function(text, mode) { }; /** - * EditSession.setValue(text) + * EditSession.setValue(text) * - text (String): The new text to place * * Sets the session text. @@ -213,14 +213,14 @@ var EditSession = function(text, mode) { /** alias of: EditSession.toString * EditSession.getValue() -> String - * - * Returns the current [[Document `Document`]] as a string. + * + * Returns the current [[Document `Document`]] as a string. * **/ /** alias of: EditSession.getValue * EditSession.toString() -> String - * - * Returns the current [[Document `Document`]] as a string. + * + * Returns the current [[Document `Document`]] as a string. * **/ this.getValue = @@ -230,7 +230,7 @@ var EditSession = function(text, mode) { /** * EditSession.getSelection() -> String - * + * * Returns the string of the current selection. **/ this.getSelection = function() { @@ -289,9 +289,9 @@ var EditSession = function(text, mode) { }; /** - * EditSession.setUndoManager(undoManager) + * EditSession.setUndoManager(undoManager) * - undoManager (UndoManager): The new undo manager - * + * * Sets the undo manager. **/ this.setUndoManager = function(undoManager) { @@ -307,9 +307,9 @@ var EditSession = function(text, mode) { if (undoManager) { var self = this; /** internal, hide - * EditSession.$syncInformUndoManager() - * - * + * EditSession.$syncInformUndoManager() + * + * **/ this.$syncInformUndoManager = function() { self.$informUndoManager.cancel(); @@ -352,7 +352,7 @@ var EditSession = function(text, mode) { /** * EditSession.getUndoManager() -> UndoManager - * + * * Returns the current undo manager. **/ this.getUndoManager = function() { @@ -361,7 +361,7 @@ var EditSession = function(text, mode) { /** * EditSession.getTabString() -> 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'`. **/ this.getTabString = function() { @@ -374,9 +374,9 @@ var EditSession = function(text, mode) { this.$useSoftTabs = true; /** - * EditSession.setUseSoftTabs(useSoftTabs) + * EditSession.setUseSoftTabs(useSoftTabs) * - useSoftTabs (Boolean): Value indicating whether or not to use soft tabs - * + * * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`). * **/ @@ -388,7 +388,7 @@ var EditSession = function(text, mode) { /** * EditSession.getUseSoftTabs() -> Boolean - * + * * Returns `true` if soft tabs are being used, `false` otherwise. * **/ @@ -398,9 +398,9 @@ var EditSession = function(text, mode) { this.$tabSize = 4; /** - * EditSession.setTabSize(tabSize) + * EditSession.setTabSize(tabSize) * - tabSize (Number): The new tab size - * + * * 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. **/ this.setTabSize = function(tabSize) { @@ -413,7 +413,7 @@ var EditSession = function(text, mode) { /** * EditSession.getTabSize() -> Number - * + * * Returns the current tab size. **/ this.getTabSize = function() { @@ -423,7 +423,7 @@ var EditSession = function(text, mode) { /** * EditSession.isTabStop(position) -> Boolean * - position (Object): The position to check - * + * * Returns `true` if the character at the position is a soft tab. **/ this.isTabStop = function(position) { @@ -432,9 +432,9 @@ var EditSession = function(text, mode) { this.$overwrite = false; /** - * EditSession.setOverwrite(overwrite) + * EditSession.setOverwrite(overwrite) * - overwrite (Boolean): Defines wheter or not to set overwrites - * + * * 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. * **/ @@ -447,7 +447,7 @@ var EditSession = function(text, mode) { /** * EditSession.getOverwrite() -> Boolean - * + * * Returns `true` if overwrites are enabled; `false` otherwise. **/ this.getOverwrite = function() { @@ -455,8 +455,8 @@ var EditSession = function(text, mode) { }; /** - * EditSession.toggleOverwrite() - * + * EditSession.toggleOverwrite() + * * Sets the value of overwrite to the opposite of whatever it currently is. **/ this.toggleOverwrite = function() { @@ -465,7 +465,7 @@ var EditSession = function(text, mode) { /** * EditSession.getBreakpoints() -> Array - * + * * Returns an array of numbers, indicating which rows have breakpoints. **/ this.getBreakpoints = function() { @@ -473,9 +473,9 @@ var EditSession = function(text, mode) { }; /** - * EditSession.setBreakpoints(rows) + * EditSession.setBreakpoints(rows) * - rows (Array): An array of row indicies - * + * * Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event. * **/ @@ -488,8 +488,8 @@ var EditSession = function(text, mode) { }; /** - * EditSession.clearBreakpoints() - * + * EditSession.clearBreakpoints() + * * Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event. **/ this.clearBreakpoints = function() { @@ -498,9 +498,9 @@ var EditSession = function(text, mode) { }; /** - * EditSession.setBreakpoint(row) + * EditSession.setBreakpoint(row) * - row (Number): A row index - * + * * Sets a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event. **/ this.setBreakpoint = function(row) { @@ -509,9 +509,9 @@ var EditSession = function(text, mode) { }; /** - * EditSession.clearBreakpoint(row) + * EditSession.clearBreakpoint(row) * - row (Number): A row index - * + * * Removes a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event. **/ this.clearBreakpoint = function(row) { @@ -552,11 +552,11 @@ var EditSession = function(text, mode) { }; /** - * EditSession.removeMarker(markerId) + * EditSession.removeMarker(markerId) * - markerId (Number): A number representing a marker * * 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. - * + * **/ this.removeMarker = function(markerId) { var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId]; @@ -575,7 +575,7 @@ var EditSession = function(text, mode) { * - inFront (Boolean): If `true`, indicates you only want front markers; `false` indicates only back markers * * Returns an array containing the IDs of all the markers, either front or back. - * + * **/ this.getMarkers = function(inFront) { return inFront ? this.$frontMarkers : this.$backMarkers; @@ -591,7 +591,7 @@ var EditSession = function(text, mode) { * } */ /** - * EditSession.setAnnotations(annotations) + * EditSession.setAnnotations(annotations) * - annotations (Array): A list of annotations * * Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event. @@ -611,16 +611,16 @@ var EditSession = function(text, mode) { /** * EditSession.getAnnotations() -> Object - * - * Returns the annotations for the `EditSession`. + * + * Returns the annotations for the `EditSession`. **/ this.getAnnotations = function() { return this.$annotations || {}; }; /** - * EditSession.clearAnnotations() - * + * EditSession.clearAnnotations() + * * Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event. **/ this.clearAnnotations = function() { @@ -629,9 +629,9 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.$detectNewLine(text) + * EditSession.$detectNewLine(text) * - text (String): A block of text - * + * * If `text` contains either the newline (`\n`) or carriage-return ('\r') characters, `$autoNewLine` stores that value. * **/ @@ -687,7 +687,7 @@ var EditSession = function(text, mode) { * EditSession.getAWordRange(row, column) -> Range * - row (Number): The row number to start from * - column (Number): The column number to start from - * + * * Gets the range of a word, including its right whitespace. **/ this.getAWordRange = function(row, column) { @@ -701,7 +701,7 @@ var EditSession = function(text, mode) { }; /** related to: Document.setNewLineMode - * EditSession.setNewLineMode(newLineMode) + * EditSession.setNewLineMode(newLineMode) * - newLineMode (String): {:Document.setNewLineMode.param} * * {:Document.setNewLineMode.desc} @@ -712,7 +712,7 @@ var EditSession = function(text, mode) { /** related to: Document.getNewLineMode * EditSession.getNewLineMode() -> String - * + * * Returns the current new line mode. **/ this.getNewLineMode = function() { @@ -722,9 +722,9 @@ var EditSession = function(text, mode) { this.$useWorker = true; /** - * EditSession.setUseWorker(useWorker) + * EditSession.setUseWorker(useWorker) * - useWorker (Boolean): Set to `true` to use a worker - * + * * Identifies if you want to use a worker for the `EditSession`. * **/ @@ -741,7 +741,7 @@ var EditSession = function(text, mode) { /** * EditSession.getUseWorker() -> Boolean - * + * * Returns `true` if workers are being used. **/ this.getUseWorker = function() { @@ -749,8 +749,8 @@ var EditSession = function(text, mode) { }; /** - * EditSession@onReloadTokenizer(e) - * + * EditSession@onReloadTokenizer(e) + * * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event. **/ this.onReloadTokenizer = function(e) { @@ -826,7 +826,7 @@ var EditSession = function(text, mode) { }; /** - * EditSession.setMode(mode) + * EditSession.setMode(mode) * - mode (TextMode): Set a new text mode * * 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. @@ -890,7 +890,7 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.stopWorker() + * EditSession.stopWorker() * * **/ @@ -902,7 +902,7 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.$startWorker() + * EditSession.$startWorker() * * **/ @@ -922,7 +922,7 @@ var EditSession = function(text, mode) { /** * EditSession.getMode() -> TextMode - * + * * Returns the current text mode. **/ this.getMode = function() { @@ -931,7 +931,7 @@ var EditSession = function(text, mode) { this.$scrollTop = 0; /** - * EditSession.setScrollTop(scrollTop) + * EditSession.setScrollTop(scrollTop) * - scrollTop (Number): The new scroll top value * * This function sets the scroll top value. It also emits the `'changeScrollTop'` event. @@ -947,7 +947,7 @@ var EditSession = function(text, mode) { /** * EditSession.getScrollTop() -> Number - * + * * [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop} **/ this.getScrollTop = function() { @@ -956,8 +956,8 @@ var EditSession = function(text, mode) { this.$scrollLeft = 0; /** - * EditSession.setScrollLeft(scrollLeft) - * + * 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} **/ this.setScrollLeft = function(scrollLeft) { @@ -971,7 +971,7 @@ var EditSession = function(text, mode) { /** * EditSession.getScrollLeft() -> Number - * + * * [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft} **/ this.getScrollLeft = function() { @@ -980,7 +980,7 @@ var EditSession = function(text, mode) { /** * EditSession.getWidth() -> Number - * + * * Returns the width of the document. **/ this.getWidth = function() { @@ -990,7 +990,7 @@ var EditSession = function(text, mode) { /** * EditSession.getScreenWidth() -> Number - * + * * Returns the width of the screen. **/ this.getScreenWidth = function() { @@ -1040,7 +1040,7 @@ var EditSession = function(text, mode) { /** related to: Document.getLine * EditSession.getLine(row) -> String * - row (Number): The row to retrieve from - * + * * Returns a verbatim copy of the given line as it is in the document * **/ @@ -1052,7 +1052,7 @@ var EditSession = function(text, mode) { * EditSession.getLines(firstRow, lastRow) -> Array * - firstRow (Number): The first row index to retrieve * - lastRow (Number): The final row index to retrieve - * + * * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. * **/ @@ -1062,7 +1062,7 @@ var EditSession = function(text, mode) { /** related to: Document.getLength * EditSession.getLength()-> Number - * + * * Returns the number of rows in the document. **/ this.getLength = function() { @@ -1072,7 +1072,7 @@ var EditSession = function(text, mode) { /** related to: Document.getTextRange * EditSession.getTextRange(range) -> Array * - range (String): The range to work with - * + * * {:Document.getTextRange.desc} **/ this.getTextRange = function(range) { @@ -1081,13 +1081,13 @@ var EditSession = function(text, mode) { /** related to: Document.insert * EditSession.insert(position, text) -> Number - * - position (Number): The position to start inserting at + * - position (Number): The position to start inserting at * - text (String): A chunk of text to insert - * + (Number): The position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`. + * + (Number): The position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`. * * Inserts a block of `text` and the indicated `position`. * - * + * **/ this.insert = function(position, text) { return this.doc.insert(position, text); @@ -1097,10 +1097,10 @@ var EditSession = function(text, mode) { * EditSession.remove(range) -> Object * - range (Range): A specified Range to remove * + (Object): 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 the `range` from the document. * - * + * **/ this.remove = function(range) { return this.doc.remove(range); @@ -1167,9 +1167,9 @@ var EditSession = function(text, mode) { this.selection.setSelectionRange(lastUndoRange); return lastUndoRange; }; - + /** - * EditSession.setUndoSelect(enable) + * EditSession.setUndoSelect(enable) * - enable (Boolean): If `true`, selects the range of the reinserted change * * ENables or disables highlighting of the range where an undo occured. @@ -1180,8 +1180,8 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.$getUndoSelection(deltas, isUndo, lastUndoRange) -> Range - * - * + * + * **/ this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) { function isInsert(delta) { @@ -1248,7 +1248,7 @@ var EditSession = function(text, mode) { * * Replaces a range in the document with the new `text`. * - * + * * **/ this.replace = function(range, text) { @@ -1263,7 +1263,7 @@ var EditSession = function(text, mode) { * 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 } - * + * * * **/ @@ -1298,11 +1298,11 @@ var EditSession = function(text, mode) { }; /** - * EditSession.indentRows(startRow, endRow, indentString) + * EditSession.indentRows(startRow, endRow, indentString) * - startRow (Number): Starting row * - endRow (Number): Ending row * - indentString (String): The indent token - * + * * 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()`]]. @@ -1315,9 +1315,9 @@ var EditSession = function(text, mode) { }; /** - * EditSession.outdentRows(range) + * EditSession.outdentRows(range) * - range (Range): A range of rows - * + * * Outdents all the rows defined by the `start` and `end` properties of `range`. * **/ @@ -1369,7 +1369,7 @@ var EditSession = function(text, mode) { * - lastRow (Number): The final row to move down * + (Number): If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1. * - * + * * **/ this.moveLinesDown = function(firstRow, lastRow) { @@ -1388,7 +1388,7 @@ var EditSession = function(text, mode) { * * Duplicates all the text between `firstRow` and `lastRow`. * - * + * * **/ this.duplicateLines = function(firstRow, lastRow) { @@ -1469,7 +1469,7 @@ var EditSession = function(text, mode) { }; /** - * EditSession.setUseWrapMode(useWrapMode) + * EditSession.setUseWrapMode(useWrapMode) * - useWrapMode (Boolean): Enable (or disable) wrap mode * * Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted. @@ -1496,7 +1496,7 @@ var EditSession = function(text, mode) { /** * EditSession.getUseWrapMode() -> Boolean - * + * * Returns `true` if wrap mode is being used; `false` otherwise. **/ this.getUseWrapMode = function() { @@ -1508,7 +1508,7 @@ var EditSession = function(text, mode) { // in that direction. Or set both parameters to the same number to pin // the limit to that value. /** - * EditSession.setWrapLimitRange(min, max) + * EditSession.setWrapLimitRange(min, max) * - min (Number): The minimum wrap value (the left side wrap) * - max (Number): The maximum wrap value (the right side wrap) * @@ -1546,9 +1546,9 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.$constrainWrapLimit(wrapLimit) + * EditSession.$constrainWrapLimit(wrapLimit) + * * - * **/ this.$constrainWrapLimit = function(wrapLimit) { var min = this.$wrapLimitRange.min; @@ -1565,7 +1565,7 @@ var EditSession = function(text, mode) { /** * EditSession.getWrapLimit() -> Number - * + * * Returns the value of wrap limit. **/ this.getWrapLimit = function() { @@ -1574,7 +1574,7 @@ var EditSession = function(text, mode) { /** * EditSession.getWrapLimitRange() -> Object - * + * * Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: * * { min: wrapLimitRange_min, max: wrapLimitRange_max } @@ -1589,9 +1589,9 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.$updateInternalDataOnChange() + * EditSession.$updateInternalDataOnChange() + * * - * **/ this.$updateInternalDataOnChange = function(e) { var useWrapMode = this.$useWrapMode; @@ -1709,9 +1709,9 @@ var EditSession = function(text, mode) { }; /** internal, hide - * EditSession.$updateWrapData(firstRow, lastRow) + * EditSession.$updateWrapData(firstRow, lastRow) + * * - * **/ this.$updateWrapData = function(firstRow, lastRow) { var lines = this.doc.getAllLines(); @@ -1775,7 +1775,7 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.$computeWrapSplits(tokens, wrapLimit) -> Array * - * + * **/ this.$computeWrapSplits = function(tokens, wrapLimit) { if (tokens.length == 0) { @@ -1934,15 +1934,15 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.$getStringScreenWidth(str, maxScreenColumn, screenColumn) -> [Number] * - str (String): The string to calculate the screen width of - * - maxScreenColumn (Number): - * - screenColumn (Number): + * - maxScreenColumn (Number): + * - screenColumn (Number): * + ([Number]): Returns an `int[]` array with two elements:
* The first position indicates the number of columns for `str` on screen.
* The second value contains the position of the document column that this function read until. * * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen. * - * + * **/ this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { if (maxScreenColumn == 0) { @@ -1978,7 +1978,7 @@ var EditSession = function(text, mode) { /** * EditSession.getRowLength(row) -> Number * - row (Number): The row number to check - * + * * * Returns the length of the indicated row. **/ @@ -2015,8 +2015,8 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.getDocumentLastRowColumn(docRow, docColumn) -> Number - * - docRow (Number): - * - docColumn (Number): + * - docRow (Number): + * - docColumn (Number): * **/ this.getDocumentLastRowColumn = function(docRow, docColumn) { @@ -2026,7 +2026,7 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.getDocumentLastRowColumnPosition(docRow, docColumn) -> Number - * + * **/ this.getDocumentLastRowColumnPosition = function(docRow, docColumn) { var screenRow = this.documentToScreenRow(docRow, docColumn); @@ -2048,7 +2048,7 @@ var EditSession = function(text, mode) { /** * EditSession.getScreenTabSize(screenColumn) -> Number * - screenColumn (Number): The screen column to check - * + * * The distance to the next tab stop at the specified screen column. **/ this.getScreenTabSize = function(screenColumn) { @@ -2057,7 +2057,7 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.screenToDocumentRow(screenRow, screenColumn) -> Number - * + * * **/ this.screenToDocumentRow = function(screenRow, screenColumn) { @@ -2066,7 +2066,7 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.screenToDocumentColumn(screenRow, screenColumn) -> Number - * + * * **/ this.screenToDocumentColumn = function(screenRow, screenColumn) { @@ -2081,7 +2081,7 @@ var EditSession = function(text, mode) { * * 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} * - * + * **/ this.screenToDocumentPosition = function(screenRow, screenColumn) { if (screenRow < 0) { @@ -2294,8 +2294,8 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.documentToScreenColumn(row, docColumn) -> Number - * - * + * + * **/ this.documentToScreenColumn = function(row, docColumn) { return this.documentToScreenPosition(row, docColumn).column; @@ -2303,8 +2303,8 @@ var EditSession = function(text, mode) { /** internal, hide * EditSession.documentToScreenRow(docRow, docColumn) -> Number - * - * + * + * **/ this.documentToScreenRow = function(docRow, docColumn) { return this.documentToScreenPosition(docRow, docColumn).row; @@ -2312,7 +2312,7 @@ var EditSession = function(text, mode) { /** * EditSession.getScreenLength() -> Number - * + * * Returns the length of the screen. **/ this.getScreenLength = function() {