First dump of doc stuff

This commit is contained in:
Garen Torikian 2012-02-02 17:00:18 -08:00
commit 79886c3e07
83 changed files with 8598 additions and 554 deletions

View file

@ -35,6 +35,14 @@
*
* ***** END LICENSE BLOCK ***** */
/**
* class Ace
*
* TODO
*
*
**/
define(function(require, exports, module) {
"use strict";
@ -48,6 +56,13 @@ var EditSession = require("./edit_session").EditSession;
var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer;
/**
* Ace.edit(el) -> Editor
* - el (String | Element): Either the id of an element to edit, or the element itself
*
* Edits an element. TODO.
*
**/
exports.edit = function(el) {
if (typeof(el) == "string") {
el = document.getElementById(el);
@ -74,4 +89,4 @@ exports.edit = function(el) {
return editor;
};
});
});

View file

@ -42,9 +42,22 @@ var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
* An Anchor is a floating pointer in the document. Whenever text is inserted or
* deleted before the cursor, the position of the cursor is updated
*/
* class Anchor
*
* Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated
*
**/
/**
* new Anchor(doc, row, column)
* - doc (Document): The document to associate with the anchor
* - row (Number): The starting row position
* - column (Number): The starting column position
*
* Creates a new `Anchor` and associates it with a document.
*
**/
var Anchor = exports.Anchor = function(doc, row, column) {
this.document = doc;
@ -61,14 +74,36 @@ var Anchor = exports.Anchor = function(doc, row, column) {
oop.implement(this, EventEmitter);
/**
* Anchor.getPosition() -> Object
*
* Returns an object identifying the `row` and `column` position of the current anchor.
*
**/
this.getPosition = function() {
return this.$clipPositionToDocument(this.row, this.column);
};
/**
* Anchor.getDocument() -> Document
*
* Returns the current document.
*
**/
this.getDocument = function() {
return this.document;
};
/**
* Anchor@onChange(e)
* - e (Event): TODO
*
* Fires whenever the anchor position changes.
*
**/
this.onChange = function(e) {
var delta = e.data;
var range = delta.range;
@ -134,6 +169,16 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.setPosition(row, column, true);
};
/**
* Anchor.setPosition(row, column, noClip) -> Void
* - row (Number): The row index to move the anchor to
* - column (Number): The column index to move the anchor to
* - noClip (Boolean): Identifies if you want the position to be clipped
*
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
*
**/
this.setPosition = function(row, column, noClip) {
var pos;
if (noClip) {
@ -162,10 +207,26 @@ var Anchor = exports.Anchor = function(doc, row, column) {
});
};
/**
* Anchor.detach()
*
* When called, the `'change'` event listener is removed.
*
**/
this.detach = function() {
this.document.removeEventListener("change", this.$onChange);
};
/**
* Anchor.clipPositionToDocument(row, column) -> Void
* - row (Number): The row index to clip the anchor to
* - column (Number): The column index to clip the anchor to
*
* Clips the anchor position to the specified row and column. TODO
*
**/
this.$clipPositionToDocument = function(row, column) {
var pos = {};

View file

@ -41,6 +41,24 @@ define(function(require, exports, module) {
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
* class Background_Tokenizer
*
* Tokenizes items..in the background? TODO
*
*
**/
/**
* new Background_Tokenizer(tokenizer, editor)
* - tokenizer (Tokenizer): The tokenizer to use
* - editor (Editor): The editor to associate with
*
* Creates a new `BackgroundTokenizer` object.
*
*
**/
var BackgroundTokenizer = function(tokenizer, editor) {
this.running = false;
this.lines = [];
@ -82,6 +100,14 @@ var BackgroundTokenizer = function(tokenizer, editor) {
oop.implement(this, EventEmitter);
/**
* Background_Tokenizer.setTokenizer(tokenizer) -> Void
* - tokenizer (Tokenizier): The new tokenizer to use
*
* Sets a new tokenizer for this object.
*
**/
this.setTokenizer = function(tokenizer) {
this.tokenizer = tokenizer;
this.lines = [];
@ -89,6 +115,14 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.start(0);
};
/**
* Background_Tokenizer.setDocument(doc) -> Void
* - doc (Document): The new document to associate with
*
* Sets a new document to associate with this object.
*
**/
this.setDocument = function(doc) {
this.doc = doc;
this.lines = [];
@ -96,6 +130,15 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.stop();
};
/**
* Background_Tokenizer.fireUpdateEvent(firstRow, lastRow) -> Void
* - firstRow (Number): The starting row region
* - lastRow (Number): The final row region
*
* Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated.
*
**/
this.fireUpdateEvent = function(firstRow, lastRow) {
var data = {
first: firstRow,
@ -104,6 +147,15 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this._emit("update", {data: data});
};
/**
* Background_Tokenizer.start(startRow, lastRow) -> Void
* - startRow (Number): The row to start at
* - lastRow (Number): The row to finish at
*
* Starts tokenizing at the row indicated. TODO
*
**/
this.start = function(startRow) {
this.currentLine = Math.min(startRow || 0, this.currentLine,
this.doc.getLength());
@ -116,20 +168,56 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.running = setTimeout(this.$worker, 700);
};
/**
* Background_Tokenizer.stop() -> Void
*
* Stops tokenizing.
*
**/
this.stop = function() {
if (this.running)
clearTimeout(this.running);
this.running = false;
};
/** related to: BackgroundTokenizer.$tokenizeRows
* Background_Tokenizer.getTokens(firstRow, lastRow) -> Array
* - firstRow (Number): The row to start at
* - lastRow (Number): The row to finish at
*
* Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.
*
**/
this.getTokens = function(firstRow, lastRow) {
return this.$tokenizeRows(firstRow, lastRow);
};
/** related to: BackgroundTokenizer.$tokenizeRows
* Background_Tokenizer.getState(row) -> Array
* - row (Number): The row to start at
*
* Retrieves the state of tokenization for a row. Returns the tokenized row.
*
**/
this.getState = function(row) {
return this.$tokenizeRows(row, row)[0].state;
};
/**
* Background_Tokenizer.$tokenizeRows(firstRow, lastRow) -> Array
* - startRow (Number): The row to start at
* - lastRow (Number): The row to finish at
*
* Tokenizes all the rows within the specified region.
*
* #### Returns
*
* Returns a list of the tokenized rows. Each item in the list is an object with two properties, `state` and `start`.
*
**/
this.$tokenizeRows = function(firstRow, lastRow) {
if (!this.doc || isNaN(firstRow) || isNaN(lastRow))
return [{'state':'start','tokens':[]}];

View file

@ -43,6 +43,21 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;
/**
* class Document
*
* Documentation about Document. Is this recursion? TODO
*
*
**/
/**
* new Document(text)
* - text (String | Array): The starting text
*
* Creates a new `Document`. TODO
*
**/
var Document = function(text) {
this.$lines = [];
@ -62,20 +77,48 @@ var Document = function(text) {
oop.implement(this, EventEmitter);
this.setValue = function(text) {
/**
* Document.setValue(text) -> Void
* - text (String): The value to set
*
*
**/
this.setValue = function(text) {
var len = this.getLength();
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
this.insert({row: 0, column:0}, text);
};
this.getValue = function() {
/**
* Document.getValue() -> String
*
* Returns all the lines in the document, split by the new line character.
**/
this.getValue = function() {
return this.getAllLines().join(this.getNewLineCharacter());
};
this.createAnchor = function(row, column) {
/**
* Document.createAnchor(row, column) -> Anchor
*
*
**/
this.createAnchor = function(row, column) {
return new Anchor(this, row, column);
};
/**
* Document.$split(text) -> Array
* - text (String): The text to work with
*
* Splits a string of text on any newline (`\n`) or carriage-return ('\r') characters.
*
* #### Returns
*
* A String array, with each index containing a piece of the original `text` string.
*
**/
// check for IE split bug
if ("aaa".split(/a/).length == 0)
this.$split = function(text) {
@ -87,7 +130,12 @@ var Document = function(text) {
};
this.$detectNewLine = function(text) {
/**
* Document.$detectNewLine(text) -> Void
*
*
**/
this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r\n|\r|\n)/m);
if (match) {
this.$autoNewLine = match[1];
@ -96,7 +144,20 @@ var Document = function(text) {
}
};
this.getNewLineCharacter = function() {
/**
* Document.getNewLineCharacter() -> String
*
* Returns the new line character that's being used, depending on the value of `newLineMode`.
*
* #### Returns
*
* If `newLineMode == windows`, `\r\n` is returned.
* If `newLineMode == unix`, `\n` is returned.
* If `newLineMode == auto`, the value of `autoNewLine` is returned.
*
*
**/
this.getNewLineCharacter = function() {
switch (this.$newLineMode) {
case "windows":
return "\r\n";
@ -111,45 +172,88 @@ var Document = function(text) {
this.$autoNewLine = "\n";
this.$newLineMode = "auto";
this.setNewLineMode = function(newLineMode) {
/**
* Document.setNewLineMode(newLineMode) -> Void
* - newLineMode(String): The newline mode to use; can be either `windows`, `unix`, or `auto`
*
* Sets the new line mode.
**/
this.setNewLineMode = function(newLineMode) {
if (this.$newLineMode === newLineMode)
return;
this.$newLineMode = newLineMode;
};
this.getNewLineMode = function() {
/**
* Document.getNewLineMode() -> String
*
* Returns the type of newlines being used; either `windows`, `unix`, or `auto`
*
**/
this.getNewLineMode = function() {
return this.$newLineMode;
};
this.isNewLine = function(text) {
/**
* Document.isNewLine(text) -> Boolean
* - text (String): The text to check
*
* Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
*
**/
this.isNewLine = function(text) {
return (text == "\r\n" || text == "\r" || text == "\n");
};
/**
* Get a verbatim copy of the given line as it is in the document
*/
this.getLine = function(row) {
* Document.getLine(row) -> String
* - row (Number): The row index to retrieve
*
* Returns a verbatim copy of the given line as it is in the document
*
**/
this.getLine = function(row) {
return this.$lines[row] || "";
};
this.getLines = function(firstRow, lastRow) {
/**
* Document.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`.
*
**/
this.getLines = function(firstRow, lastRow) {
return this.$lines.slice(firstRow, lastRow + 1);
};
/**
* Returns all lines in the document as string array. Warning: The caller
* should not modify this array!
*/
this.getAllLines = function() {
* Document.getAllLines() -> Array
*
* Returns all lines in the document as string array. <Warning>The caller should not modify this array!</Warning>
**/
this.getAllLines = function() {
return this.getLines(0, this.getLength());
};
this.getLength = function() {
/**
* Document.getLength() -> Number
*
* Returns the number of rows in the document.
**/
this.getLength = function() {
return this.$lines.length;
};
this.getTextRange = function(range) {
/**
* Document.getTextRange(range) -> Array
* - range (String): blah
*
* TODO
**/
this.getTextRange = function(range) {
if (range.start.row == range.end.row) {
return this.$lines[range.start.row].substring(range.start.column,
range.end.column);
@ -163,7 +267,13 @@ var Document = function(text) {
}
};
this.$clipPosition = function(position) {
/**
* Document.$clipPosition(position) -> Number
* - position (Number): blah
*
* TODO
**/
this.$clipPosition = function(position) {
var length = this.getLength();
if (position.row >= length) {
position.row = Math.max(0, length - 1);
@ -172,7 +282,19 @@ var Document = function(text) {
return position;
};
this.insert = function(position, text) {
/**
* Document.insert(position, text) -> Number
* - position (Number): The position to start inserting at
* - text (String): A chunk of text to insert
*
* Inserts a block of `text` and the indicated `position`.
*
* #### Returns
*
* Returns the position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`.
*
**/
this.insert = function(position, text) {
if (text.length == 0)
return position;
@ -194,7 +316,25 @@ var Document = function(text) {
return position;
};
this.insertLines = function(row, lines) {
/**
* Document.insertLines(row, lines) -> Object
* - row (Number): The index of the row to insert at
* - lines (Array): An array of strings
*
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
*
* #### Returns
*
* Returns an object containing the final row and column, like this:
*
* {row: endRow, column: 0}
*
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
*
* {row: row, column: 0}
*
**/
this.insertLines = function(row, lines) {
if (lines.length == 0)
return {row: row, column: 0};
@ -212,7 +352,20 @@ var Document = function(text) {
return range.end;
};
this.insertNewLine = function(position) {
/**
* Document.insertNewLine(position) -> Object
* - position (String): The position to insert at
*
* Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
*
* #### Returns
*
* Returns an object containing the final row and column, like this:
*
* {row: endRow, column: 0}
*
**/
this.insertNewLine = function(position) {
position = this.$clipPosition(position);
var line = this.$lines[position.row] || "";
@ -234,7 +387,23 @@ var Document = function(text) {
return end;
};
this.insertInLine = function(position, text) {
/**
* Document.insertInLine(position, text) -> Object | Integer
* - position (Number): The position to insert at
* - text (String): A chunk of text
*
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
*
* #### Returns
*
* Returns an object containing the final row and column, like this:
*
* {row: endRow, column: 0}
*
* If `text` is empty, this function returns the value of `position`.
*
**/
this.insertInLine = function(position, text) {
if (text.length == 0)
return position;
@ -258,7 +427,17 @@ var Document = function(text) {
return end;
};
this.remove = function(range) {
/**
* Document.remove(range) -> Object
* - range (Range): A specified Range to remove
*
* Removes the `range` from the document.
*
* #### Returns
*
* Returns 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`.
**/
this.remove = function(range) {
// clip to document
range.start = this.$clipPosition(range.start);
range.end = this.$clipPosition(range.end);
@ -290,7 +469,19 @@ var Document = function(text) {
return range.start;
};
this.removeInLine = function(row, startColumn, endColumn) {
/**
* Document.removeInLine(row, startColumn, endColumn) -> Object | Void
* - row (Number): The row to remove from
* - startColumn (Number): The column to start removing at
* - endColumn (Number): The column to stop removing at
*
* Removes the specified columns from the `row`. This method also triggers the `'change'` event.
*
* #### Returns
*
* Returns an object containing `startRow` and `startColumn`, indicating the new row and column values. If `startColumn` is equal to `endColumn`, this function returns nothing.
**/
this.removeInLine = function(row, startColumn, endColumn) {
if (startColumn == endColumn)
return;
@ -310,13 +501,19 @@ var Document = function(text) {
};
/**
* Removes a range of full lines
*
* @param firstRow {Integer} The first row to be removed
* @param lastRow {Integer} The last row to be removed
* @return {String[]} The removed lines
*/
this.removeLines = function(firstRow, lastRow) {
* Document.removeLines(firstRow, lastRow) -> Array
* - firstRow (Number): The first row to be removed
* - lastRow (Number): The last row to be removed
*
* Removes a range of full lines. This method also triggers the `'change'` event.
*
*
* #### Returns
*
* Returns all the removed lines.
*
**/
this.removeLines = function(firstRow, lastRow) {
var range = new Range(firstRow, 0, lastRow + 1, 0);
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
@ -330,7 +527,14 @@ var Document = function(text) {
return removed;
};
this.removeNewLine = function(row) {
/**
* Document.removeNewLine(row) -> Void
* - row (Number): The row to be removed
*
* TODO Removes the row from the document. This method also triggers the `'change'` event.
*
**/
this.removeNewLine = function(row) {
var firstLine = this.getLine(row);
var secondLine = this.getLine(row+1);
@ -347,7 +551,25 @@ var Document = function(text) {
this._emit("change", { data: delta });
};
this.replace = function(range, text) {
/**
* Document.replace(range, text) -> Object
* - range (Range): A specified Range to replace
* - text (String): The new text to use as a replacement
*
* Replaces a range in the document with the new `text`.
*
* #### Returns
*
* 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.
*
**/
this.replace = function(range, text) {
if (text.length == 0 && range.isEmpty())
return range.start;
@ -367,7 +589,12 @@ var Document = function(text) {
return end;
};
this.applyDeltas = function(deltas) {
/**
* Document.applyDeltas(deltas) -> Void
*
* TODO
**/
this.applyDeltas = function(deltas) {
for (var i=0; i<deltas.length; i++) {
var delta = deltas[i];
var range = Range.fromPoints(delta.range.start, delta.range.end);
@ -383,7 +610,12 @@ var Document = function(text) {
}
};
this.revertDeltas = function(deltas) {
/**
* Document.revertDeltas(deltas) -> Void
*
* TODO
**/
this.revertDeltas = function(deltas) {
for (var i=deltas.length-1; i>=0; i--) {
var delta = deltas[i];

File diff suppressed because it is too large Load diff

View file

@ -39,7 +39,7 @@
define(function(require, exports, module) {
"use strict";
/**
/*
* Simple fold-data struct.
**/
var Fold = exports.Fold = function(range, placeholder) {

View file

@ -41,7 +41,7 @@ define(function(require, exports, module) {
var Range = require("../range").Range;
/**
/*
* If an array is passed in, the folds are expected to be sorted already.
*/
function FoldLine(foldData, folds) {
@ -64,7 +64,7 @@ function FoldLine(foldData, folds) {
}
(function() {
/**
/*
* Note: This doesn't update wrapData!
*/
this.shiftRow = function(shift) {

View file

@ -45,7 +45,7 @@ var Fold = require("./fold").Fold;
var TokenIterator = require("../token_iterator").TokenIterator;
function Folding() {
/**
/*
* 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
@ -69,7 +69,7 @@ function Folding() {
}
};
/**
/*
* Returns all folds in the given range. Note, that this will return folds
*
*/
@ -115,7 +115,7 @@ function Folding() {
return foundFolds;
};
/**
/*
* Returns all folds in the document
*/
this.getAllFolds = function() {
@ -138,7 +138,7 @@ function Folding() {
return folds;
};
/**
/*
* Returns the string between folds at the given position.
* E.g.
* foo<fold>b|ar<fold>wolrd -> "bar"
@ -257,7 +257,7 @@ function Folding() {
return foldLine;
};
/**
/*
* Adds a new fold.
*
* @returns
@ -457,7 +457,7 @@ function Folding() {
}
};
/**
/*
* 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.
**/

File diff suppressed because it is too large Load diff

View file

@ -44,7 +44,7 @@ var EditSession = require("../edit_session").EditSession;
var TextLayer = require("../layer/text").Text;
var baseStyles = require("../requirejs/text!./static.css");
/** Transforms a given input code snippet into HTML using the given mode
/* Transforms a given input code snippet into HTML using the given mode
*
* @param {string} input Code snippet
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')

View file

@ -46,7 +46,7 @@ var ace = require("../ace");
require("ace/theme/textmate");
/**
/*
* Returns the CSS property of element.
* 1) If the CSS property is on the style object of the element, use it, OR
* 2) Compute the CSS property

View file

@ -93,7 +93,7 @@ function HashHandler(config) {
this.$config.reverse = objectReverse.call(this, this.$config, "|");
};
/**
/*
* This function is called by keyBinding.
*/
this.handleKeyboard = function(data, hashId, textOrKey, keyCode) {

View file

@ -47,7 +47,7 @@ function StateHandler(keymapping) {
}
StateHandler.prototype = {
/**
/*
* Build the RegExp from the keymapping as RegExp can't stored directly
* in the metadata JSON and as the RegExp used to match the keys/buffer
* need to be adapted.
@ -198,7 +198,7 @@ StateHandler.prototype = {
}
},
/**
/*
* This function is called by keyBinding.
*/
handleKeyboard: function(data, hashId, key, keyCode, e) {
@ -224,7 +224,7 @@ StateHandler.prototype = {
}
}
/**
/*
* This is a useful matching function and therefore is defined here so that
* users of KeyboardStateMapper can use it.
*

View file

@ -111,7 +111,7 @@ var Marker = function(parentEl) {
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
};
/**
/*
* Draws a marker, which spans a range of text in a single line
*/
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
@ -137,7 +137,7 @@ var Marker = function(parentEl) {
}
};
/**
/*
* Draws a multi line marker, where lines span the full width
*/
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
@ -186,7 +186,7 @@ var Marker = function(parentEl) {
);
};
/**
/*
* Draws a marker which covers one single full line
*/
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, type) {

View file

@ -45,7 +45,7 @@ var oop = require("./oop");
var event = require("./event");
var EventEmitter = require("./event_emitter").EventEmitter;
/**
/*
* This class keeps track of the focus state of the given window.
* Focus changes for example when the user switches a browser tab,
* goes to the location bar or switches to another application.

View file

@ -63,7 +63,7 @@ exports.hasCssClass = function(el, name) {
return classes.indexOf(name) !== -1;
};
/**
/*
* Add a CSS class to the list of classes on the given node
*/
exports.addCssClass = function(el, name) {
@ -72,7 +72,7 @@ exports.addCssClass = function(el, name) {
}
};
/**
/*
* Remove a CSS class from the list of classes on the given node
*/
exports.removeCssClass = function(el, name) {
@ -104,7 +104,7 @@ exports.toggleCssClass = function(el, name) {
return add;
};
/**
/*
* Add or remove a CSS class from the list of classes on the given node
* depending on the value of <tt>include</tt>
*/
@ -255,7 +255,7 @@ exports.scrollbarWidth = function(document) {
return noScrollbar-withScrollbar;
};
/**
/*
* Optimized set innerHTML. This is faster than plain innerHTML if the element
* already contains a lot of child elements.
*

View file

@ -26,7 +26,7 @@
define(function(require, exports, module) {
/**
/*
* Brings an environment as close to ECMAScript 5 compliance
* as is possible with the facilities of erstwhile engines.
*

View file

@ -64,7 +64,7 @@ exports.removeListener = function(elem, type, callback) {
}
};
/**
/*
* Prevents propagation and clobbers the default action of the passed event
*/
exports.stopEvent = function(e) {
@ -103,7 +103,7 @@ exports.getDocumentY = function(e) {
}
};
/**
/*
* @return {Number} 0 for left button, 1 for middle button, 2 for right button
*/
exports.getButton = function(e) {

View file

@ -36,7 +36,7 @@ define(function(require, exports, module) {
var oop = require("./oop");
/**
/*
* Helper functions and hashes for key handling.
*/
var Keys = (function() {

View file

@ -101,7 +101,7 @@ exports.arrayToMap = function(arr) {
};
/**
/*
* splice out of 'array' anything that === 'value'
*/
exports.arrayRemove = function(array, value) {

View file

@ -1,4 +1,4 @@
/**
/*
* based on code from:
*
* @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.

View file

@ -1,4 +1,4 @@
/**
/*
* Based on code from:
*
* XRegExp 1.5.0

View file

@ -41,13 +41,13 @@ define(function(require, exports, module) {
var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
var ua = navigator.userAgent;
/** Is the user using a browser that identifies itself as Windows */
// Is the user using a browser that identifies itself as Windows
exports.isWin = (os == "win");
/** Is the user using a browser that identifies itself as Mac OS */
// Is the user using a browser that identifies itself as Mac OS
exports.isMac = (os == "mac");
/** Is the user using a browser that identifies itself as Linux */
// Is the user using a browser that identifies itself as Linux
exports.isLinux = (os == "linux");
exports.isIE =
@ -56,16 +56,16 @@ exports.isIE =
exports.isOldIE = exports.isIE && exports.isIE < 9;
/** Is this Firefox or related? */
// Is this Firefox or related?
exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
/** oldGecko == rev < 2.0 **/
// oldGecko == rev < 2.0
exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4;
/** Is this Opera */
// Is this Opera
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
/** Is the user using a browser that identifies itself as WebKit */
// Is the user using a browser that identifies itself as WebKit
exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
@ -76,7 +76,7 @@ exports.isIPad = ua.indexOf("iPad") >= 0;
exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
/**
/*
* I hate doing this, but we need some way to determine if the user is on a Mac
* The reason is that users have different expectations of their key combinations.
*
@ -89,7 +89,7 @@ exports.OS = {
WINDOWS: "WINDOWS"
};
/**
/*
* Return an exports.OS constant
*/
exports.getOS = function() {

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2011 Jeremy Ashkenas
*
* Permission is hereby granted, free of charge, to any person

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2011 Jeremy Ashkenas
*
* Permission is hereby granted, free of charge, to any person

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2011 Jeremy Ashkenas
*
* Permission is hereby granted, free of charge, to any person

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2011 Jeremy Ashkenas
*
* Permission is hereby granted, free of charge, to any person

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2011 Jeremy Ashkenas
*
* Permission is hereby granted, free of charge, to any person

View file

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2011 Jeremy Ashkenas
*
* Permission is hereby granted, free of charge, to any person

View file

@ -49,7 +49,7 @@ THE SOFTWARE.
var parserlib = {};
(function(){
/**
/*
* A generic base to inherit from for any object
* that needs event handling.
* @class EventTarget
@ -57,7 +57,7 @@ var parserlib = {};
*/
function EventTarget(){
/**
/*
* The array of listeners for various events.
* @type Object
* @property _listeners
@ -71,7 +71,7 @@ EventTarget.prototype = {
//restore constructor
constructor: EventTarget,
/**
/*
* Adds a listener for a given event type.
* @param {String} type The type of event to add a listener for.
* @param {Function} listener The function to call when the event occurs.
@ -86,7 +86,7 @@ EventTarget.prototype = {
this._listeners[type].push(listener);
},
/**
/*
* Fires an event based on the passed-in object.
* @param {Object|String} event An object with at least a 'type' attribute
* or a string indicating the event name.
@ -115,7 +115,7 @@ EventTarget.prototype = {
}
},
/**
/*
* Removes a listener for a given event type.
* @param {String} type The type of event to remove a listener from.
* @param {Function} listener The function to remove from the event.
@ -136,7 +136,7 @@ EventTarget.prototype = {
}
}
};
/**
/*
* Convenient way to read through strings.
* @namespace parserlib.util
* @class StringReader
@ -145,7 +145,7 @@ EventTarget.prototype = {
*/
function StringReader(text){
/**
/*
* The input text with line endings normalized.
* @property _input
* @type String
@ -154,7 +154,7 @@ function StringReader(text){
this._input = text.replace(/\n\r?/g, "\n");
/**
/*
* The row for the character to be read next.
* @property _line
* @type int
@ -163,7 +163,7 @@ function StringReader(text){
this._line = 1;
/**
/*
* The column for the character to be read next.
* @property _col
* @type int
@ -171,7 +171,7 @@ function StringReader(text){
*/
this._col = 1;
/**
/*
* The index of the character in the input to be read next.
* @property _cursor
* @type int
@ -189,7 +189,7 @@ StringReader.prototype = {
// Position info
//-------------------------------------------------------------------------
/**
/*
* Returns the column of the character to be read next.
* @return {int} The column of the character to be read next.
* @method getCol
@ -198,7 +198,7 @@ StringReader.prototype = {
return this._col;
},
/**
/*
* Returns the row of the character to be read next.
* @return {int} The row of the character to be read next.
* @method getLine
@ -207,7 +207,7 @@ StringReader.prototype = {
return this._line ;
},
/**
/*
* Determines if you're at the end of the input.
* @return {Boolean} True if there's no more input, false otherwise.
* @method eof
@ -220,7 +220,7 @@ StringReader.prototype = {
// Basic reading
//-------------------------------------------------------------------------
/**
/*
* Reads the next character without advancing the cursor.
* @param {int} count How many characters to look ahead (default is 1).
* @return {String} The next character or null if there is no next character.
@ -240,7 +240,7 @@ StringReader.prototype = {
return c;
},
/**
/*
* Reads the next character from the input and adjusts the row and column
* accordingly.
* @return {String} The next character or null if there is no next character.
@ -272,7 +272,7 @@ StringReader.prototype = {
// Misc
//-------------------------------------------------------------------------
/**
/*
* Saves the current location so it can be returned to later.
* @method mark
* @return {void}
@ -298,7 +298,7 @@ StringReader.prototype = {
// Advanced reading
//-------------------------------------------------------------------------
/**
/*
* Reads up to and including the given string. Throws an error if that
* string is not found.
* @param {String} pattern The string to read.
@ -329,7 +329,7 @@ StringReader.prototype = {
},
/**
/*
* Reads characters while each character causes the given
* filter function to return true. The function is passed
* in each character and either returns true to continue
@ -353,7 +353,7 @@ StringReader.prototype = {
},
/**
/*
* Reads characters that match either text or a regular expression and
* returns those characters. If a match is found, the row and column
* are adjusted; if no match is found, the reader's state is unchanged.
@ -385,7 +385,7 @@ StringReader.prototype = {
},
/**
/*
* Reads a given number of characters. If the end of the input is reached,
* it reads only the remaining characters and does not throw an error.
* @param {int} count The number of characters to read.
@ -403,7 +403,7 @@ StringReader.prototype = {
}
};
/**
/*
* Type to use when a syntax error occurs.
* @class SyntaxError
* @namespace parserlib.util
@ -414,21 +414,21 @@ StringReader.prototype = {
*/
function SyntaxError(message, line, col){
/**
/*
* The column at which the error occurred.
* @type int
* @property col
*/
this.col = col;
/**
/*
* The line at which the error occurred.
* @type int
* @property line
*/
this.line = line;
/**
/*
* The text representation of the unit.
* @type String
* @property text
@ -439,7 +439,7 @@ function SyntaxError(message, line, col){
//inherit from Error
SyntaxError.prototype = new Error();
/**
/*
* Base type to represent a single syntactic unit.
* @class SyntaxUnit
* @namespace parserlib.util
@ -451,21 +451,21 @@ SyntaxError.prototype = new Error();
function SyntaxUnit(text, line, col){
/**
/*
* The column of text on which the unit resides.
* @type int
* @property col
*/
this.col = col;
/**
/*
* The line of text on which the unit resides.
* @type int
* @property line
*/
this.line = line;
/**
/*
* The text representation of the unit.
* @type String
* @property text
@ -474,7 +474,7 @@ function SyntaxUnit(text, line, col){
}
/**
/*
* Create a new syntax unit based solely on the given token.
* Convenience method for creating a new syntax unit when
* it represents a single token instead of multiple.
@ -492,7 +492,7 @@ SyntaxUnit.prototype = {
//restore constructor
constructor: SyntaxUnit,
/**
/*
* Returns the text representation of the unit.
* @return {String} The text representation of the unit.
* @method valueOf
@ -501,7 +501,7 @@ SyntaxUnit.prototype = {
return this.toString();
},
/**
/*
* Returns the text representation of the unit.
* @return {String} The text representation of the unit.
* @method toString
@ -511,7 +511,7 @@ SyntaxUnit.prototype = {
}
};
/**
/*
* Generic TokenStream providing base functionality.
* @class TokenStreamBase
* @namespace parserlib.util
@ -521,7 +521,7 @@ SyntaxUnit.prototype = {
*/
function TokenStreamBase(input, tokenData){
/**
/*
* The string reader for easy access to the text.
* @type StringReader
* @property _reader
@ -530,7 +530,7 @@ function TokenStreamBase(input, tokenData){
//this._reader = (typeof input == "string") ? new StringReader(input) : input;
this._reader = input ? new StringReader(input.toString()) : null;
/**
/*
* Token object for the last consumed token.
* @type Token
* @property _token
@ -538,7 +538,7 @@ function TokenStreamBase(input, tokenData){
*/
this._token = null;
/**
/*
* The array of token information.
* @type Array
* @property _tokenData
@ -546,7 +546,7 @@ function TokenStreamBase(input, tokenData){
*/
this._tokenData = tokenData;
/**
/*
* Lookahead token buffer.
* @type Array
* @property _lt
@ -554,7 +554,7 @@ function TokenStreamBase(input, tokenData){
*/
this._lt = [];
/**
/*
* Lookahead token buffer index.
* @type int
* @property _ltIndex
@ -565,7 +565,7 @@ function TokenStreamBase(input, tokenData){
this._ltIndexCache = [];
}
/**
/*
* Accepts an array of token information and outputs
* an array of token data containing key-value mappings
* and matching functions that the TokenStream needs.
@ -613,7 +613,7 @@ TokenStreamBase.prototype = {
// Matching methods
//-------------------------------------------------------------------------
/**
/*
* Determines if the next token matches the given token type.
* If so, that token is consumed; if not, the token is placed
* back onto the token stream. You can pass in any number of
@ -649,7 +649,7 @@ TokenStreamBase.prototype = {
return false;
},
/**
/*
* Determines if the next token matches the given token type.
* If so, that token is consumed; if not, an error is thrown.
* @param {int|int[]} tokenTypes Either a single token type or an array of
@ -678,7 +678,7 @@ TokenStreamBase.prototype = {
// Consuming methods
//-------------------------------------------------------------------------
/**
/*
* Keeps reading from the token stream until either one of the specified
* token types is found or until the end of the input is reached.
* @param {int|int[]} tokenTypes Either a single token type or an array of
@ -698,7 +698,7 @@ TokenStreamBase.prototype = {
return this.LA(0);
},
/**
/*
* Consumes the next token from the token stream.
* @return {int} The token type of the token that was just consumed.
* @method get
@ -783,7 +783,7 @@ TokenStreamBase.prototype = {
}
},
/**
/*
* Looks ahead a certain number of tokens and returns the token type at
* that position. This will throw an error if you lookahead past the
* end of input, past the size of the lookahead buffer, or back past
@ -829,7 +829,7 @@ TokenStreamBase.prototype = {
},
/**
/*
* Looks ahead a certain number of tokens and returns the token at
* that position. This will throw an error if you lookahead past the
* end of input, past the size of the lookahead buffer, or back past
@ -848,7 +848,7 @@ TokenStreamBase.prototype = {
return this._lt[this._ltIndex+index-1];
},
/**
/*
* Returns the token type for the next token in the stream without
* consuming it.
* @return {int} The token type of the next token in the stream.
@ -858,7 +858,7 @@ TokenStreamBase.prototype = {
return this.LA(1);
},
/**
/*
* Returns the actual token object for the last consumed token.
* @return {Token} The token object for the last consumed token.
* @method token
@ -867,7 +867,7 @@ TokenStreamBase.prototype = {
return this._token;
},
/**
/*
* Returns the name of the token for the given token type.
* @param {int} tokenType The type of token to get the name of.
* @return {String} The name of the token or "UNKNOWN_TOKEN" for any
@ -882,7 +882,7 @@ TokenStreamBase.prototype = {
}
},
/**
/*
* Returns the token type value for the given token name.
* @param {String} tokenName The name of the token whose value should be returned.
* @return {int} The token type value for the given token name or -1
@ -893,7 +893,7 @@ TokenStreamBase.prototype = {
return this._tokenData[tokenName] || -1;
},
/**
/*
* Returns the last consumed token to the token stream.
* @method unget
*/
@ -1093,7 +1093,7 @@ var Colors = {
yellow :"#ffff00",
yellowgreen :"#9acd32"
};
/**
/*
* Represents a selector combinator (whitespace, +, >).
* @namespace parserlib.css
* @class Combinator
@ -1107,7 +1107,7 @@ function Combinator(text, line, col){
SyntaxUnit.call(this, text, line, col);
/**
/*
* The type of modifier.
* @type String
* @property type
@ -1307,7 +1307,7 @@ var Level2Properties = {
"word-spacing": 1,
"z-index": 1
};
/**
/*
* Represents a media feature, such as max-width:500.
* @namespace parserlib.css
* @class MediaFeature
@ -1320,14 +1320,14 @@ function MediaFeature(name, value){
SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol);
/**
/*
* The name of the media feature
* @type String
* @property name
*/
this.name = name;
/**
/*
* The value for the feature or null if there is none.
* @type SyntaxUnit
* @property value
@ -1339,7 +1339,7 @@ MediaFeature.prototype = new SyntaxUnit();
MediaFeature.prototype.constructor = MediaFeature;
/**
/*
* Represents an individual media query.
* @namespace parserlib.css
* @class MediaQuery
@ -1355,21 +1355,21 @@ function MediaQuery(modifier, mediaType, features, line, col){
SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType + " " : "") + features.join(" and "), line, col);
/**
/*
* The media modifier ("not" or "only")
* @type String
* @property modifier
*/
this.modifier = modifier;
/**
/*
* The mediaType (i.e., "print")
* @type String
* @property mediaType
*/
this.mediaType = mediaType;
/**
/*
* The parts that make up the selector.
* @type Array
* @property features
@ -1382,7 +1382,7 @@ MediaQuery.prototype = new SyntaxUnit();
MediaQuery.prototype.constructor = MediaQuery;
/**
/*
* A CSS3 parser.
* @namespace parserlib.css
* @class Parser
@ -1799,7 +1799,7 @@ Parser.prototype = function(){
return this._media_feature();
},
/**
/*
* Note: in CSS3 Media Queries, this is called "expression".
* Renamed here to avoid conflict with CSS3 Selectors
* definition of "expression". Also note that "expr" in the
@ -3210,7 +3210,7 @@ Parser.prototype = function(){
// Helper methods
//-----------------------------------------------------------------
/**
/*
* Not part of CSS grammar, but useful for skipping over
* combination of white space and HTML-style comments.
* @return {void}
@ -3223,7 +3223,7 @@ Parser.prototype = function(){
}
},
/**
/*
* Not part of CSS grammar, but this pattern occurs frequently
* in the official CSS grammar. Split out here to eliminate
* duplicate code.
@ -3312,7 +3312,7 @@ Parser.prototype = function(){
},
/**
/*
* In some cases, you can end up with two white space tokens in a
* row. Instead of making a change in every function that looks for
* white space, this function is used to match as much white space
@ -3334,7 +3334,7 @@ Parser.prototype = function(){
},
/**
/*
* Throws an error when an unexpected token is found.
* @param {Object} token The token that was found.
* @method _unexpectedToken
@ -3345,7 +3345,7 @@ Parser.prototype = function(){
throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
},
/**
/*
* Helper method used for parsing subparts of a style sheet.
* @return {void}
* @method _verifyEnd
@ -3382,7 +3382,7 @@ Parser.prototype = function(){
return result;
},
/**
/*
* Parses a property value (everything after the semicolon).
* @return {parserlib.css.PropertyValue} The property value.
* @throws parserlib.util.SyntaxError If an unexpected token is found.
@ -3405,7 +3405,7 @@ Parser.prototype = function(){
return result;
},
/**
/*
* Parses a complete CSS rule, including selectors and
* properties.
* @param {String} input The text to parser.
@ -3430,7 +3430,7 @@ Parser.prototype = function(){
return result;
},
/**
/*
* Parses a single CSS selector (no comma)
* @param {String} input The text to parse as a CSS selector.
* @return {Selector} An object representing the selector.
@ -3473,7 +3473,7 @@ nth
['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
;
*/
/**
/*
* Represents a selector combinator (whitespace, +, >).
* @namespace parserlib.css
* @class PropertyName
@ -3488,7 +3488,7 @@ function PropertyName(text, hack, line, col){
SyntaxUnit.call(this, (hack||"") + text, line, col);
/**
/*
* The type of IE hack applied ("*", "_", or null).
* @type String
* @property hack
@ -3501,7 +3501,7 @@ PropertyName.prototype = new SyntaxUnit();
PropertyName.prototype.constructor = PropertyName;
/**
/*
* Represents a single part of a CSS property value, meaning that it represents
* just everything single part between ":" and ";". If there are multiple values
* separated by commas, this type represents just one of the values.
@ -3517,7 +3517,7 @@ function PropertyValue(parts, line, col){
SyntaxUnit.call(this, parts.join(" "), line, col);
/**
/*
* The parts that make up the selector.
* @type Array
* @property parts
@ -3530,7 +3530,7 @@ PropertyValue.prototype = new SyntaxUnit();
PropertyValue.prototype.constructor = PropertyValue;
/**
/*
* Represents a single part of a CSS property value, meaning that it represents
* just one part of the data between ":" and ";".
* @param {String} text The text representation of the unit.
@ -3545,7 +3545,7 @@ function PropertyValuePart(text, line, col){
SyntaxUnit.apply(this,arguments);
/**
/*
* Indicates the type of value unit.
* @type String
* @property type
@ -3662,7 +3662,7 @@ function PropertyValuePart(text, line, col){
PropertyValuePart.prototype = new SyntaxUnit();
PropertyValuePart.prototype.constructor = PropertyValue;
/**
/*
* Create a new syntax unit based solely on the given token.
* Convenience method for creating a new syntax unit when
* it represents a single token instead of multiple.
@ -3674,7 +3674,7 @@ PropertyValuePart.prototype.constructor = PropertyValue;
PropertyValuePart.fromToken = function(token){
return new PropertyValuePart(token.value, token.startLine, token.startCol);
};
/**
/*
* Represents an entire single selector, including all parts but not
* including multiple selectors (those separated by commas).
* @namespace parserlib.css
@ -3689,7 +3689,7 @@ function Selector(parts, line, col){
SyntaxUnit.call(this, parts.join(" "), line, col);
/**
/*
* The parts that make up the selector.
* @type Array
* @property parts
@ -3702,7 +3702,7 @@ Selector.prototype = new SyntaxUnit();
Selector.prototype.constructor = Selector;
/**
/*
* Represents a single part of a selector string, meaning a single set of
* element name and modifiers. This does not include combinators such as
* spaces, +, >, etc.
@ -3722,7 +3722,7 @@ function SelectorPart(elementName, modifiers, text, line, col){
SyntaxUnit.call(this, text, line, col);
/**
/*
* The tag name of the element to which this part
* of the selector affects.
* @type String
@ -3730,7 +3730,7 @@ function SelectorPart(elementName, modifiers, text, line, col){
*/
this.elementName = elementName;
/**
/*
* The parts that come after the element name, such as class names, IDs,
* pseudo classes/elements, etc.
* @type Array
@ -3744,7 +3744,7 @@ SelectorPart.prototype = new SyntaxUnit();
SelectorPart.prototype.constructor = SelectorPart;
/**
/*
* Represents a selector modifier string, meaning a class name, element name,
* element ID, pseudo rule, etc.
* @namespace parserlib.css
@ -3760,14 +3760,14 @@ function SelectorSubPart(text, type, line, col){
SyntaxUnit.call(this, text, line, col);
/**
/*
* The type of modifier.
* @type String
* @property type
*/
this.type = type;
/**
/*
* Some subparts have arguments, this represents them.
* @type Array
* @property args
@ -3833,7 +3833,7 @@ function mix(receiver, supplier){
//-----------------------------------------------------------------------------
/**
/*
* A token stream that produces CSS tokens.
* @param {String|Reader} input The source of text to tokenize.
* @constructor
@ -3846,7 +3846,7 @@ function TokenStream(input){
TokenStream.prototype = mix(new TokenStreamBase(), {
/**
/*
* Overrides the TokenStreamBase method of the same name
* to produce CSS tokens.
* @param {variant} channel The name of the channel to use
@ -4076,7 +4076,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
// Methods to create tokens
//-------------------------------------------------------------------------
/**
/*
* Produces a token based on available data and the current
* reader position information. This method is called by other
* private methods to create tokens and is never called directly.
@ -4111,7 +4111,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
// Methods to create specific tokens
//-------------------------------------------------------------------------
/**
/*
* Produces a token for any at-rule. If the at-rule is unknown, then
* the token is for a single "@" character.
* @param {String} first The first character for the token.
@ -4152,7 +4152,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(tt, rule, startLine, startCol);
},
/**
/*
* Produces a character token based on the given character
* and location in the stream. If there's a special (non-standard)
* token name, this is used; otherwise CHAR is used.
@ -4172,7 +4172,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(tt, c, startLine, startCol);
},
/**
/*
* Produces a character token based on the given character
* and location in the stream. If there's a special (non-standard)
* token name, this is used; otherwise CHAR is used.
@ -4189,7 +4189,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
},
/**
/*
* Produces a comparison token based on the given character
* and location in the stream. The next character must be
* read and is already known to be an equals sign.
@ -4207,7 +4207,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(tt, comparison, startLine, startCol);
},
/**
/*
* Produces a hash token based on the specified information. The
* first character provided is the pound sign (#) and then this
* method reads a name afterward.
@ -4224,7 +4224,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(Tokens.HASH, name, startLine, startCol);
},
/**
/*
* Produces a CDO or CHAR token based on the specified information. The
* first character is provided and the rest is read by the function to determine
* the correct token to create.
@ -4249,7 +4249,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
}
},
/**
/*
* Produces a CDC or CHAR token based on the specified information. The
* first character is provided and the rest is read by the function to determine
* the correct token to create.
@ -4274,7 +4274,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
}
},
/**
/*
* Produces an IDENT or FUNCTION token based on the specified information. The
* first character is provided and the rest is read by the function to determine
* the correct token to create.
@ -4315,7 +4315,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(tt, ident, startLine, startCol);
},
/**
/*
* Produces an IMPORTANT_SYM or CHAR token based on the specified information. The
* first character is provided and the rest is read by the function to determine
* the correct token to create.
@ -4376,7 +4376,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
},
/**
/*
* Produces a NOT or CHAR token based on the specified information. The
* first character is provided and the rest is read by the function to determine
* the correct token to create.
@ -4401,7 +4401,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
}
},
/**
/*
* Produces a number token based on the given character
* and location in the stream. This may return a token of
* NUMBER, EMS, EXS, LENGTH, ANGLE, TIME, FREQ, DIMENSION,
@ -4445,7 +4445,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(tt, value, startLine, startCol);
},
/**
/*
* Produces a string token based on the given character
* and location in the stream. Since strings may be indicated
* by single or double quotes, a failure to match starting
@ -4535,7 +4535,7 @@ TokenStream.prototype = mix(new TokenStreamBase(), {
return this.createToken(tt, value, startLine, startCol);
},
/**
/*
* Produces a S token based on the specified information. Since whitespace
* may have multiple characters, this consumes all whitespace characters
* into a single token.
@ -5005,7 +5005,7 @@ Tokens :Tokens
};
})();
/**
/*
* Main CSSLint object.
* @class CSSLint
* @static
@ -5023,7 +5023,7 @@ var CSSLint = (function(){
// Rule Management
//-------------------------------------------------------------------------
/**
/*
* Adds a new rule to the engine.
* @param {Object} rule The rule to add.
* @method addRule
@ -5033,7 +5033,7 @@ var CSSLint = (function(){
rules[rule.id] = rule;
};
/**
/*
* Clears all rule from the engine.
* @method clearRules
*/
@ -5045,7 +5045,7 @@ var CSSLint = (function(){
// Formatters
//-------------------------------------------------------------------------
/**
/*
* Adds a new formatter to the engine.
* @param {Object} formatter The formatter to add.
* @method addFormatter
@ -5055,7 +5055,7 @@ var CSSLint = (function(){
formatters[formatter.id] = formatter;
};
/**
/*
* Retrieves a formatter for use.
* @param {String} formatId The name of the format to retrieve.
* @return {Object} The formatter or undefined.
@ -5065,7 +5065,7 @@ var CSSLint = (function(){
return formatters[formatId];
};
/**
/*
* Formats the results in a particular format for a single file.
* @param {Object} result The results returned from CSSLint.verify().
* @param {String} filename The filename for which the results apply.
@ -5086,7 +5086,7 @@ var CSSLint = (function(){
return result;
}
/**
/*
* Indicates if the given format is supported.
* @param {String} formatId The ID of the format to check.
* @return {Boolean} True if the format exists, false if not.
@ -5100,7 +5100,7 @@ var CSSLint = (function(){
// Verification
//-------------------------------------------------------------------------
/**
/*
* Starts the verification process for the given CSS text.
* @param {String} text The CSS text to verify.
* @param {Object} ruleset (Optional) List of rules to apply. If null, then
@ -5155,7 +5155,7 @@ var CSSLint = (function(){
return api;
})();
/**
/*
* An instance of Report is used to report results of the
* verification back to the main API.
* @class Reporter
@ -5164,21 +5164,21 @@ var CSSLint = (function(){
*/
function Reporter(lines){
/**
/*
* List of messages being reported.
* @property messages
* @type String[]
*/
this.messages = [];
/**
/*
* List of statistics being reported.
* @property stats
* @type String[]
*/
this.stats = [];
/**
/*
* Lines of code being reported on. Used to provide contextual information
* for messages.
* @property lines
@ -5192,7 +5192,7 @@ Reporter.prototype = {
//restore constructor
constructor: Reporter,
/**
/*
* Report an error.
* @param {String} message The message to store.
* @param {int} line The line number.
@ -5211,7 +5211,7 @@ Reporter.prototype = {
});
},
/**
/*
* Report an warning.
* @param {String} message The message to store.
* @param {int} line The line number.
@ -5230,7 +5230,7 @@ Reporter.prototype = {
});
},
/**
/*
* Report some informational text.
* @param {String} message The message to store.
* @param {int} line The line number.
@ -5249,7 +5249,7 @@ Reporter.prototype = {
});
},
/**
/*
* Report some rollup error information.
* @param {String} message The message to store.
* @param {Object} rule The rule this message relates to.
@ -5264,7 +5264,7 @@ Reporter.prototype = {
});
},
/**
/*
* Report some rollup warning information.
* @param {String} message The message to store.
* @param {Object} rule The rule this message relates to.
@ -5279,7 +5279,7 @@ Reporter.prototype = {
});
},
/**
/*
* Report a statistic.
* @param {String} name The name of the stat to store.
* @param {Variant} value The value of the stat.

View file

@ -101,7 +101,7 @@ oop.inherits(FoldMode, BaseFoldMode);
};
};
/**
/*
* reads a full tag and places the iterator after the tag
*/
this._readTagForward = function(iterator) {

View file

@ -41,7 +41,7 @@ define(function(require, exports, module) {
var event = require("../lib/event");
/**
/*
* Custom Ace mouse event
*/
var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
@ -78,7 +78,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
this.preventDefault();
};
/**
/*
* Get the document position below the mouse cursor
*
* @return {Object} 'row' and 'column' of the document position
@ -94,7 +94,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
return this.$pos;
};
/**
/*
* Check if the mouse cursor is inside of the text selection
*
* @return {Boolean} whether the mouse cursor is inside of the selection
@ -120,7 +120,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
return this.$inSelection;
};
/**
/*
* Get the clicked mouse button
*
* @return {Number} 0 for left button, 1 for middle button, 2 for right button
@ -129,7 +129,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
return event.getButton(this.domEvent);
};
/**
/*
* @return {Boolean} whether the shift key was pressed when the event was emitted
*/
this.getShiftKey = function() {

View file

@ -41,6 +41,26 @@ var Range = require('./range').Range;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var oop = require("./lib/oop");
/**
* class PlaceHolder
*
* TODO
*
**/
/**
* new PlaceHolder(session, length, pos, others, mainClass, othersClass)
* - session (Document): The document to associate with the anchor
* - length (Number): The starting row position
* - pos (Number): The starting column position
* - others (String):
* - mainClass (String):
* - othersClass (String):
*
* TODO
*
**/
var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
var _self = this;
this.length = length;
@ -70,6 +90,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
oop.implement(this, EventEmitter);
/**
* PlaceHolder.setup() -> Void
*
* TODO
*
**/
this.setup = function() {
var _self = this;
var doc = this.doc;
@ -90,6 +116,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
session.setUndoSelect(false);
};
/**
* PlaceHolder.showOtherMarkers() -> Void
*
* TODO
*
**/
this.showOtherMarkers = function() {
if(this.othersActive) return;
var session = this.session;
@ -104,6 +136,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
});
};
/**
* PlaceHolder.hideOtherMarkers() -> Void
*
* TODO
*
**/
this.hideOtherMarkers = function() {
if(!this.othersActive) return;
this.othersActive = false;
@ -112,6 +150,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
}
};
/**
* PlaceHolder@onUpdate(e)
*
* Emitted when the place holder updates.
*
**/
this.onUpdate = function(event) {
var delta = event.data;
var range = delta.range;
@ -174,6 +218,13 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
this.$updating = false;
};
/**
* PlaceHolder@onCursorChange(e)
*
* Emitted when the cursor changes.
*
**/
this.onCursorChange = function(event) {
if (this.$updating) return;
var pos = this.session.selection.getCursor();
@ -186,6 +237,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
}
};
/**
* PlaceHolder.detach()
*
* TODO
*
**/
this.detach = function() {
this.session.removeMarker(this.markerId);
this.hideOtherMarkers();
@ -198,6 +255,12 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
this.session.setUndoSelect(true);
};
/**
* PlaceHolder.cancel()
*
* TODO
*
**/
this.cancel = function() {
if(this.$undoStackDepth === -1)
throw Error("Canceling placeholders only supported with undo manager attached to session.");

View file

@ -38,6 +38,23 @@
define(function(require, exports, module) {
"use strict";
/**
* class Range
*
* This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column.
*
**/
/**
* new Range(startRow, startColumn, endRow, endColumn)
* - startRow (Number): The starting row
* - startColumn (Number): The starting column
* - endRow (Number): The ending row
* - endColumn (Number): The ending column
*
* Creates a new `Range` object with the given starting and ending row and column points.
*
**/
var Range = function(startRow, startColumn, endRow, endColumn) {
this.start = {
row: startRow,
@ -51,6 +68,13 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
};
(function() {
/**
* Range.isEequal(range) -> Boolean
* - range (Range): A range to check against
*
* Returns `true` if and only if the starting row and column, and ending tow and column, are equivalent to those given by `range`.
*
**/
this.isEequal = function(range) {
return this.start.row == range.start.row &&
this.end.row == range.end.row &&
@ -58,28 +82,54 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
this.end.column == range.end.column
};
/**
* Range.toString() -> String
*
* Returns a string containing the range's row and column information, given like this:
*
* [start.row/start.column] -> [end.row/end.column]
*
**/
this.toString = function() {
return ("Range: [" + this.start.row + "/" + this.start.column +
"] -> [" + this.end.row + "/" + this.end.column + "]");
};
/** related to: Range.compare
* Range.contains(row, column) -> Boolean
* - row (Number): A row to check for
* - column (Number): A column to check for
*
* Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if:
*
* this.start.row <= row <= this.end.row &&
* this.start.column <= column <= this.end.column
*
**/
this.contains = function(row, column) {
return this.compare(row, column) == 0;
};
/**
* Compares this range (A) with another range (B), where B is the passed in
* range.
/** related to: Range.compare
* Range.compareRange(range) -> Number
* - range (Range): A range to compare with
*
* Return values:
* -2: (B) is infront of (A) and doesn't intersect with (A)
* -1: (B) begins before (A) but ends inside of (A)
* 0: (B) is completly inside of (A) OR (A) is complety inside of (B)
* +1: (B) begins inside of (A) but ends outside of (A)
* +2: (B) is after (A) and doesn't intersect with (A)
* Compares `this` range (A) with another range (B).
*
* 42: FTW state: (B) ends in (A) but starts outside of (A)
*/
* #### Returns
*
* This method returns one of the following numbers:
*
* * -2: (B) is in front of (A), and doesn't intersect with (A)
* * -1: (B) begins before (A) but ends inside of (A)
* * 0: (B) is completely inside of (A) OR (A) is completely inside of (B)
* * +1: (B) begins inside of (A) but ends outside of (A)
* * +2: (B) is after (A) and doesn't intersect with (A)
* * 42: FTW state: (B) ends in (A) but starts outside of (A)
*
**/
this.compareRange = function(range) {
var cmp,
end = range.end,
@ -109,22 +159,74 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
/** related to: Range.compare
* Range.comparePoint(p) -> Number
* - p (Range): A point to compare with
*
* Checks the row and column points of `p` with the row and column points of the calling range.
*
* #### Returns
*
* * `0` if the two points are exactly equal
* * `-1` if `p.row` is less then the calling range
* * `1` if `p.row` is greater than the calling range
*
* If the starting row of the calling range is equal to `p.row`, and:
* * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
* * Otherwise, it returns -1
*
* If the ending row of the calling range is equal to `p.row`, and:
* * `p.column` is less than or equal to the calling range's ending column, this returns `0`
* * Otherwise, it returns 1
*
**/
this.comparePoint = function(p) {
return this.compare(p.row, p.column);
}
/** related to: Range.comparePoint
* Range.containsRange(range) -> Boolean
* - range (Range): A range to compare with
*
* Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.
*
**/
this.containsRange = function(range) {
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
}
/**
* Range.isEnd(row, column) -> Boolean
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.
*
**/
this.isEnd = function(row, column) {
return this.end.row == row && this.end.column == column;
}
/**
* Range.isStart(row, column) -> Boolean
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.
*
**/
this.isStart = function(row, column) {
return this.start.row == row && this.start.column == column;
}
/**
* Range.setStart(row, column) -> Void
* - row (Number): A row point to set
* - column (Number): A column point to set
*
* Sets the starting row and column for the range.
*
**/
this.setStart = function(row, column) {
if (typeof row == "object") {
this.start.column = row.column;
@ -135,6 +237,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
/**
* Range.setEnd(row, column) -> Void
* - row (Number): A row point to set
* - column (Number): A column point to set
*
* Sets the starting row and column for the range.
*
**/
this.setEnd = function(row, column) {
if (typeof row == "object") {
this.end.column = row.column;
@ -145,6 +255,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
/** related to: Range.compare
* Range.inside(row, column) -> Boolean
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Returns `true` if the `row` and `column` are within the given range.
*
**/
this.inside = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isEnd(row, column) || this.isStart(row, column)) {
@ -156,6 +274,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return false;
}
/** related to: Range.compare
* Range.insideStart(row, column) -> Boolean
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Returns `true` if the `row` and `column` are within the given range's starting points.
*
**/
this.insideStart = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isEnd(row, column)) {
@ -167,6 +293,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return false;
}
/** related to: Range.compare
* Range.insideEnd(row, column) -> Boolean
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Returns `true` if the `row` and `column` are within the given range's ending points.
*
**/
this.insideEnd = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isStart(row, column)) {
@ -178,6 +312,28 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return false;
}
/**
* Range.compare(row, column) -> Number
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Checks the row and column points with the row and column points of the calling range.
*
* #### Returns
*
* * `0` if the two points are exactly equal
* * `-1` if `p.row` is less then the calling range
* * `1` if `p.row` is greater than the calling range
*
* If the starting row of the calling range is equal to `p.row`, and:
* * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
* * Otherwise, it returns -1
*
* If the ending row of the calling range is equal to `p.row`, and:
* * `p.column` is less than or equal to the calling range's ending column, this returns `0`
* * Otherwise, it returns 1
*
**/
this.compare = function(row, column) {
if (!this.isMultiLine()) {
if (row === this.start.row) {
@ -200,9 +356,28 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return 0;
};
/**
* Like .compare(), but if isStart is true, return -1;
*/
/**
* Range.compareStart(row, column) -> Number
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Checks the row and column points with the row and column points of the calling range.
*
* #### Returns
*
* * `0` if the two points are exactly equal
* * `-1` if `p.row` is less then the calling range
* * `1` if `p.row` is greater than the calling range, or if `isStart` is `true.
*
* If the starting row of the calling range is equal to `p.row`, and:
* * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
* * Otherwise, it returns -1
*
* If the ending row of the calling range is equal to `p.row`, and:
* * `p.column` is less than or equal to the calling range's ending column, this returns `0`
* * Otherwise, it returns 1
*
**/
this.compareStart = function(row, column) {
if (this.start.row == row && this.start.column == column) {
return -1;
@ -211,9 +386,28 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
/**
* Like .compare(), but if isEnd is true, return 1;
*/
/**
* Range.compareEnd(row, column) -> Number
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Checks the row and column points with the row and column points of the calling range.
*
* #### Returns
*
* * `0` if the two points are exactly equal
* * `-1` if `p.row` is less then the calling range
* * `1` if `p.row` is greater than the calling range, or if `isEnd` is `true.
*
* If the starting row of the calling range is equal to `p.row`, and:
* * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
* * Otherwise, it returns -1
*
* If the ending row of the calling range is equal to `p.row`, and:
* * `p.column` is less than or equal to the calling range's ending column, this returns `0`
* * Otherwise, it returns 1
*
**/
this.compareEnd = function(row, column) {
if (this.end.row == row && this.end.column == column) {
return 1;
@ -222,6 +416,21 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
/**
* Range.compareInside(row, column) -> Number
* - row (Number): A row point to compare with
* - column (Number): A column point to compare with
*
* Checks the row and column points with the row and column points of the calling range.
*
* #### Returns
*
* * `1` if the ending row of the calling range is equal to `row`, and the ending column of the calling range is equal to `column`
* * `-1` if the starting row of the calling range is equal to `row`, and the starting column of the calling range is equal to `column`
*
* Otherwise, it returns the value after calling [[Range.compare `compare()`]].
*
**/
this.compareInside = function(row, column) {
if (this.end.row == row && this.end.column == column) {
return 1;
@ -232,6 +441,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
/**
* Range.clipRows(firstRow, lastRow) -> Range
* - firstRow (Number):
* - lastRow (Number):
*
* TODO
*
**/
this.clipRows = function(firstRow, lastRow) {
if (this.end.row > lastRow) {
var end = {
@ -263,6 +480,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return Range.fromPoints(start || this.start, end || this.end);
};
/**
* Range.extend(row, column) -> Range
* - row (Number): A new row to extend to
* - column (Number): A new column to extend to
*
* Changes the row and column points for the calling range for both the starting and ending points. This method returns that range with a new row.
*
**/
this.extend = function(row, column) {
var cmp = this.compare(row, column);
@ -276,18 +501,42 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return Range.fromPoints(start || this.start, end || this.end);
};
/**
* Range.isEmpty() -> Boolean
*
* Checks if the range is empty; that is, the starting and ending points for row and column are equivalent. Returns `true` if the range is indeed empty.
*
**/
this.isEmpty = function() {
return (this.start.row == this.end.row && this.start.column == this.end.column);
};
/**
* Range.isMultiLine() -> Boolean
*
* Returns true if the range spans across multiple lines.
*
**/
this.isMultiLine = function() {
return (this.start.row !== this.end.row);
};
/**
* Range.clone() -> Range
*
* Returns a duplicate of the calling range.
*
**/
this.clone = function() {
return Range.fromPoints(this.start, this.end);
};
/**
* Range.collapseRows() -> Range
*
* Returns a range containing the starting and ending rows of the original range, but with a column value of `0`.
*
**/
this.collapseRows = function() {
if (this.end.column == 0)
return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
@ -295,6 +544,12 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return new Range(this.start.row, 0, this.end.row, 0)
};
/**
* Range.toScreenRange() -> Range
*
* TODO
*
**/
this.toScreenRange = function(session) {
var screenPosStart =
session.documentToScreenPosition(this.start);
@ -309,7 +564,14 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}).call(Range.prototype);
/**
* Range#fromPoints(start, end) -> Range
* - start (Range): A starting point to use
* - end (Range): An ending point to use
*
* Creates and returns a new `Range` based on the row and column of the given parameters.
*
**/
Range.fromPoints = function(start, end) {
return new Range(start.row, start.column, end.row, end.column);
};

View file

@ -41,6 +41,19 @@ define(function(require, exports, module) {
var event = require("./lib/event");
/**
* class RenderLoop
*
* TODO
*
**/
/**
* new RenderLoop(onRender, win)
*
* TODO
*
**/
var RenderLoop = function(onRender, win) {
this.onRender = onRender;
this.pending = false;
@ -50,6 +63,12 @@ var RenderLoop = function(onRender, win) {
(function() {
/**
* RenderLoop.schedule(change) -> Void
* - change (Array):
*
* TODO
**/
this.schedule = function(change) {
//this.onRender(change);
//return;

View file

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
/**
/*
* Extremely simplified version of the requireJS text plugin
*/

View file

@ -44,6 +44,20 @@ var dom = require("./lib/dom");
var event = require("./lib/event");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
* class ScrollBar
*
* A set of methods for setting and retrieving the editor's scrollbar.
*
**/
/**
* new ScrollBar(parent)
* - parent (TODO)
*
* Creates a new `ScrollBar`.
*
**/
var ScrollBar = function(parent) {
this.element = dom.createElement("div");
this.element.className = "ace_sb";
@ -67,22 +81,55 @@ var ScrollBar = function(parent) {
(function() {
oop.implement(this, EventEmitter);
/**
* ScrollBar@onScroll
*
* Emitted when the scroll bar, well, scrolls.
*
**/
this.onScroll = function() {
this._emit("scroll", {data: this.element.scrollTop});
};
/**
* ScrollBar.getWidth() -> Number
*
* Returns the width of the scroll bar.
*
**/
this.getWidth = function() {
return this.width;
};
/**
* ScrollBar.setHeight(height) -> Void
* - height (Number): The new height
*
* Sets the height of the scroll bar, in pixels.
*
**/
this.setHeight = function(height) {
this.element.style.height = height + "px";
};
/**
* ScrollBar.setInnerHeight(height) -> Void
* - height (Number): The new inner height
*
* Sets the inner height of the scroll bar, in pixels.
*
**/
this.setInnerHeight = function(height) {
this.inner.style.height = height + "px";
};
/**
* ScrollBar.setScrollTop(scrollTop) -> Void
* - scrollTop (Number): The new scroll top
*
* Sets the scroll top of the scroll bar.
*
**/
this.setScrollTop = function(scrollTop) {
this.element.scrollTop = scrollTop;
};

View file

@ -44,6 +44,28 @@ var lang = require("./lib/lang");
var oop = require("./lib/oop");
var Range = require("./range").Range;
/**
* class Search
*
* TODO
*
**/
/**
* new Search()
*
* Creates a new `Search` object. The search options contain the following defaults:
*
* * `needle`: `""`
* * `backwards`: `false`
* * `wrap`: `false`
* * `caseSensitive`: `false`
* * `wholeWord`: `false`
* * `scope`: `ALL`
* * `regExp`: `false`
*
**/
var Search = function() {
this.$options = {
needle: "",
@ -61,15 +83,35 @@ Search.SELECTION = 2;
(function() {
/**
* Search.set(options) -> Search
* - options (Object): An object containing all the new search properties
*
* Sets the search options via the `options` parameter.
*
**/
this.set = function(options) {
oop.mixin(this.$options, options);
return this;
};
/**
* Search.getOptions() -> Object
*
* [Returns an object containing all the search options.](~Search.getOptions)
*
**/
this.getOptions = function() {
return lang.copyObject(this.$options);
};
/**
* Search.find(session) -> Range | null
* - session (EditSession): The session to search with
*
* Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
*
**/
this.find = function(session) {
if (!this.$options.needle)
return null;
@ -89,6 +131,13 @@ Search.SELECTION = 2;
return firstRange;
};
/**
* Search.findAll(session) -> Array | null
* - session (EditSession): The session to search with
*
* Searches for all occurances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
*
**/
this.findAll = function(session) {
var options = this.$options;
if (!options.needle)
@ -115,6 +164,20 @@ Search.SELECTION = 2;
return ranges;
};
/**
* Search.replace(input, replacement) -> String | null
* - input (String): The text to search in
* - replacement (String): The replacing text
*
* Searches for `options.needle` in `input`, and, if found, replaces it with `replacement`.
*
* #### Returns
*
* If `options.regExp` is `true`, this function returns `input` with the replacement already made. Otherwise, this function just returns `replacement`.
*
* If `options.needle` was not found, this function returns `null`.
*
**/
this.replace = function(input, replacement) {
var re = this.$assembleRegExp();
var match = re.exec(input);
@ -129,6 +192,13 @@ Search.SELECTION = 2;
}
};
/**
* Search.$forwardMatchIterator(session) -> String | Boolean
* - session (EditSession): The session to search with
*
* TODO--not doing the below $ signs, they look internal
*
**/
this.$forwardMatchIterator = function(session) {
var re = this.$assembleRegExp();
var self = this;
@ -163,6 +233,13 @@ Search.SELECTION = 2;
};
};
/**
* Search.$backwardMatchIterator(session) -> String | null
* - session (EditSession): The session to search with
*
* TODO
*
**/
this.$backwardMatchIterator = function(session) {
var re = this.$assembleRegExp();
var self = this;

View file

@ -45,12 +45,20 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range;
/**
* Keeps cursor position and the text selection of an edit session.
* class Selection
*
* The row/columns used in the selection are in document coordinates
* representing ths coordinates as thez appear in the document
* before applying soft wrap and folding.
*/
* Contains the cursor position and the text selection of an edit session.
*
* The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.
**/
/**
* new Selection(session)
* - session (EditSession): The session to use
*
* Creates a new `Selection` object.
*
**/
var Selection = function(session) {
this.session = session;
this.doc = session.getDocument();
@ -78,14 +86,24 @@ var Selection = function(session) {
oop.implement(this, EventEmitter);
this.isEmpty = function() {
/**
* Selection.isEmpty() -> Boolean
*
* Returns `true` if the selection is empty.
**/
this.isEmpty = function() {
return (this.$isEmpty || (
this.selectionAnchor.row == this.selectionLead.row &&
this.selectionAnchor.column == this.selectionLead.column
));
};
this.isMultiLine = function() {
/**
* Selection.isMultiLine() -> Boolean
*
* Returns `true` if the selection is a multi-line.
**/
this.isMultiLine = function() {
if (this.isEmpty()) {
return false;
}
@ -93,11 +111,23 @@ var Selection = function(session) {
return this.getRange().isMultiLine();
};
this.getCursor = function() {
/**
* Selection.getCursor() -> Number
*
* Gets the current position of the cursor.
**/
this.getCursor = function() {
return this.selectionLead.getPosition();
};
this.setSelectionAnchor = function(row, column) {
/**
* Selection.setSelectionAnchor(row, column) -> Void
* - row (Number): The new row
* - column (Number): The new column
*
* Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event.
**/
this.setSelectionAnchor = function(row, column) {
this.selectionAnchor.setPosition(row, column);
if (this.$isEmpty) {
@ -106,18 +136,36 @@ var Selection = function(session) {
}
};
this.getSelectionAnchor = function() {
/** related to: Anchor.getPosition
* Selection.getSelectionAnchor() -> Object
*
* Returns an object containing the `row` and `column` of the calling selection anchor.
*
**/
this.getSelectionAnchor = function() {
if (this.$isEmpty)
return this.getSelectionLead()
else
return this.selectionAnchor.getPosition();
};
this.getSelectionLead = function() {
/** related to: Lead.getPosition
* Selection.getSelectionLead() -> Object
*
* Returns an object containing the `row` and `column` of the calling selection lead.
**/
this.getSelectionLead = function() {
return this.selectionLead.getPosition();
};
this.shiftSelection = function(columns) {
/**
* Selection.shiftSelection(columns) -> Void
* - columns (Number): The number of columns to shift by
*
* TODO
*
**/
this.shiftSelection = function(columns) {
if (this.$isEmpty) {
this.moveCursorTo(this.selectionLead.row, this.selectionLead.column + columns);
return;
@ -138,13 +186,23 @@ var Selection = function(session) {
}
};
this.isBackwards = function() {
/**
* Selection.isBackwards() -> Boolean
*
* Returns `true` if the selection is going backwards in the document.
**/
this.isBackwards = function() {
var anchor = this.selectionAnchor;
var lead = this.selectionLead;
return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
};
this.getRange = function() {
/**
* Selection.getRange() -> Range
*
* [Returns the [[Range `Range`]] for the selected text.](~Selection.getRange)
**/
this.getRange = function() {
var anchor = this.selectionAnchor;
var lead = this.selectionLead;
@ -159,20 +217,38 @@ var Selection = function(session) {
}
};
this.clearSelection = function() {
/**
* Selection.clearSelection() -> Void
*
* [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.](~Selection.clearSelection)
**/
this.clearSelection = function() {
if (!this.$isEmpty) {
this.$isEmpty = true;
this._emit("changeSelection");
}
};
this.selectAll = function() {
/**
* Selection.selectAll() -> Void
*
* Selects all the text in the document.
**/
this.selectAll = function() {
var lastRow = this.doc.getLength() - 1;
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
this.moveCursorTo(0, 0);
};
this.setSelectionRange = function(range, reverse) {
/**
* Selection.setSelectionRange(range, reverse) -> Void
* - range (Range): The range of text to select
* - reverse (Boolean): Indicates if the range should go backwards (`true`) or not
*
* Sets the selection to the provided range.
*
**/
this.setSelectionRange = function(range, reverse) {
if (reverse) {
this.setSelectionAnchor(range.end.row, range.end.column);
this.selectTo(range.start.row, range.start.column);
@ -196,72 +272,151 @@ var Selection = function(session) {
mover.call(this);
};
this.selectTo = function(row, column) {
/**
* Selection.selectTo(row, column) -> Void
* - row (Number): The row to select to
* - column (Number): The column to select to
*
* Moves the selection cursor to the indicated row and column.
*
**/
this.selectTo = function(row, column) {
this.$moveSelection(function() {
this.moveCursorTo(row, column);
});
};
this.selectToPosition = function(pos) {
/**
* Selection.selectToPosition(pos) -> Void
* - pos (Object): An object containing the row and column
*
* Moves the selection cursor to the row and column indicated by `pos`.
*
**/
this.selectToPosition = function(pos) {
this.$moveSelection(function() {
this.moveCursorToPosition(pos);
});
};
this.selectUp = function() {
/**
* Selection.selectUp() -> Void
*
* Moves the selection up one row.
**/
this.selectUp = function() {
this.$moveSelection(this.moveCursorUp);
};
this.selectDown = function() {
/**
* Selection.selectDown() -> Void
*
* Moves the selection down one row.
**/
this.selectDown = function() {
this.$moveSelection(this.moveCursorDown);
};
this.selectRight = function() {
/**
* Selection.selectRight() -> Void
*
* Moves the selection right one column.
**/
this.selectRight = function() {
this.$moveSelection(this.moveCursorRight);
};
this.selectLeft = function() {
/**
* Selection.selectLeft() -> Void
*
* Moves the selection left one column.
**/
this.selectLeft = function() {
this.$moveSelection(this.moveCursorLeft);
};
this.selectLineStart = function() {
/**
* Selection.selectLineStart() -> Void
*
* Moves the selection to the beginning of the current line.
**/
this.selectLineStart = function() {
this.$moveSelection(this.moveCursorLineStart);
};
this.selectLineEnd = function() {
/**
* Selection.selectLineEnd() -> Void
*
* Moves the selection to the end of the current line.
**/
this.selectLineEnd = function() {
this.$moveSelection(this.moveCursorLineEnd);
};
this.selectFileEnd = function() {
/**
* Selection.selectFileEnd() -> Void
*
* Moves the selection to the end of the file.
**/
this.selectFileEnd = function() {
this.$moveSelection(this.moveCursorFileEnd);
};
this.selectFileStart = function() {
/**
* Selection.selectFileStart() -> Void
*
* Moves the selection to the start of the file.
**/
this.selectFileStart = function() {
this.$moveSelection(this.moveCursorFileStart);
};
this.selectWordRight = function() {
/**
* Selection.selectWordRight() -> Void
*
* Moves the selection to the first word on the right.
**/
this.selectWordRight = function() {
this.$moveSelection(this.moveCursorWordRight);
};
this.selectWordLeft = function() {
/**
* Selection.selectWordLeft() -> Void
*
* Moves the selection to the first word on the left.
**/
this.selectWordLeft = function() {
this.$moveSelection(this.moveCursorWordLeft);
};
this.selectWord = function() {
/** related to: EditSession.getWordRange
* Selection.selectWord() -> Void
*
* Moves the selection to highlight the entire word.
**/
this.selectWord = function() {
var cursor = this.getCursor();
var range = this.session.getWordRange(cursor.row, cursor.column);
this.setSelectionRange(range);
};
// Selects a word including its right whitespace
this.selectAWord = function() {
/** related to: EditSession.getAWordRange
* Selection.selectAWord() -> Void
*
* Selects a word, including its right whitespace.
**/
this.selectAWord = function() {
var cursor = this.getCursor();
var range = this.session.getAWordRange(cursor.row, cursor.column);
this.setSelectionRange(range);
};
this.selectLine = function() {
/**
* Selection.selectLine() -> Void
*
* Selects the entire line.
**/
this.selectLine = function() {
var rowStart = this.selectionLead.row;
var rowEnd;
@ -278,15 +433,30 @@ var Selection = function(session) {
});
};
this.moveCursorUp = function() {
/**
* Selection.moveCursorUp() -> Void
*
* Moves the cursor up one row.
**/
this.moveCursorUp = function() {
this.moveCursorBy(-1, 0);
};
this.moveCursorDown = function() {
/**
* Selection.moveCursorDown() -> Void
*
* Moves the cursor down one row.
**/
this.moveCursorDown = function() {
this.moveCursorBy(1, 0);
};
this.moveCursorLeft = function() {
/**
* Selection.moveCursorLeft() -> Void
*
* Moves the cursor left one column.
**/
this.moveCursorLeft = function() {
var cursor = this.selectionLead.getPosition(),
fold;
@ -307,7 +477,12 @@ var Selection = function(session) {
}
};
this.moveCursorRight = function() {
/**
* Selection.moveCursorRight() -> Void
*
* Moves the cursor right one column.
**/
this.moveCursorRight = function() {
var cursor = this.selectionLead.getPosition(),
fold;
if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
@ -328,7 +503,12 @@ var Selection = function(session) {
}
};
this.moveCursorLineStart = function() {
/**
* Selection.moveCursorLineStart() -> Void
*
* Moves the cursor to the start of the line.
**/
this.moveCursorLineStart = function() {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
var screenRow = this.session.documentToScreenRow(row, column);
@ -356,7 +536,12 @@ var Selection = function(session) {
}
};
this.moveCursorLineEnd = function() {
/**
* Selection.moveCursorLineEnd() -> Void
*
* Moves the cursor to the end of the line.
**/
this.moveCursorLineEnd = function() {
var lead = this.selectionLead;
var lastRowColumnPosition =
this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
@ -366,17 +551,32 @@ var Selection = function(session) {
);
};
this.moveCursorFileEnd = function() {
/**
* Selection.moveCursorFileEnd() -> Void
*
* Moves the cursor to the end of the file.
**/
this.moveCursorFileEnd = function() {
var row = this.doc.getLength() - 1;
var column = this.doc.getLine(row).length;
this.moveCursorTo(row, column);
};
this.moveCursorFileStart = function() {
/**
* Selection.moveCursorFileStart() -> Void
*
* Moves the cursor to the start of the file.
**/
this.moveCursorFileStart = function() {
this.moveCursorTo(0, 0);
};
this.moveCursorWordRight = function() {
/**
* Selection.moveCursorWordRight() -> Void
*
* Moves the cursor to the word on the right.
**/
this.moveCursorWordRight = function() {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
var line = this.doc.getLine(row);
@ -418,7 +618,12 @@ var Selection = function(session) {
this.moveCursorTo(row, column);
};
this.moveCursorWordLeft = function() {
/**
* Selection.moveCursorWordLeft() -> Void
*
* Moves the cursor to the word on the left.
**/
this.moveCursorWordLeft = function() {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
@ -464,7 +669,14 @@ var Selection = function(session) {
this.moveCursorTo(row, column);
};
this.moveCursorBy = function(rows, chars) {
/** related to: EditSession.documentToScreenPosition
* Selection.moveCursorBy(rows, chars) -> Void
* - rows (Number): The number of rows to move by
* - chars (Number): The number of characters to move by
*
* Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.
**/
this.moveCursorBy = function(rows, chars) {
var screenPos = this.session.documentToScreenPosition(
this.selectionLead.row,
this.selectionLead.column
@ -477,11 +689,25 @@ var Selection = function(session) {
this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
};
this.moveCursorToPosition = function(position) {
/**
* Selection.moveCursorToPosition(position) -> Void
* - position (Object): The position to move to
*
* Moves the selection to the position indicated by its `row` and `column`.
**/
this.moveCursorToPosition = function(position) {
this.moveCursorTo(position.row, position.column);
};
this.moveCursorTo = function(row, column, preventUpdateDesiredColumn) {
/**
* Selection.moveCursorTo(row, column, preventUpdateDesiredColumn) -> Void
* - row (Number): The row to move to
* - column (Number): The column to move to
* - preventUpdateDesiredColumn (Boolean): Indicates if the column should be updated (`true`) or not (`false`)
*
* TODO
**/
this.moveCursorTo = function(row, column, preventUpdateDesiredColumn) {
// Ensure the row/column is not inside of a fold.
var fold = this.session.getFoldAt(row, column, 1);
if (fold) {
@ -497,7 +723,15 @@ var Selection = function(session) {
this.$updateDesiredColumn(this.selectionLead.column);
};
this.moveCursorToScreen = function(row, column, preventUpdateDesiredColumn) {
/**
* Selection.moveCursorToScreen(row, column, preventUpdateDesiredColumn) -> Void
* - row (Number): The row to move to
* - column (Number): The column to move to
* - preventUpdateDesiredColumn (Boolean): Indicates if the column should be updated (`true`) or not (`false`)
*
* TODO
**/
this.moveCursorToScreen = function(row, column, preventUpdateDesiredColumn) {
var pos = this.session.screenToDocumentPosition(row, column);
row = pos.row;
column = pos.column;

View file

@ -47,6 +47,23 @@ var Editor = require("./editor").Editor;
var Renderer = require("./virtual_renderer").VirtualRenderer;
var EditSession = require("./edit_session").EditSession;
/**
* class Split
*
* TODO
*
**/
/**
* new Split(container, theme, splits)
* - container (Document): The document to associate with the anchor
* - theme (Number): The starting row position
* - splits (Number): The starting column position
*
* TODO
*
**/
var Split = function(container, theme, splits) {
this.BELOW = 1;
this.BESIDE = 0;
@ -87,6 +104,13 @@ var Split = function(container, theme, splits) {
return editor;
};
/**
* Split.setSplits(splits) -> Void
* - splits (Number): The new number of splits
*
* TODO
*
**/
this.setSplits = function(splits) {
var editor;
if (splits < 1) {
@ -116,42 +140,100 @@ var Split = function(container, theme, splits) {
this.resize();
};
/**
* Split.getSplits() -> Number
*
* Returns the number of splits.
*
**/
this.getSplits = function() {
return this.$splits;
};
/**
* Split.getEditor(idx) -> Editor
* -idx (Number): The index of the editor you want
*
* Returns the editor identified by the index `idx`.
*
**/
this.getEditor = function(idx) {
return this.$editors[idx];
};
/**
* Split.getCurrentEditor() -> Editor
*
* Returns the current editor.
*
**/
this.getCurrentEditor = function() {
return this.$cEditor;
};
/** related to: Editor.focus
* Split.focus() -> Void
*
* Focuses the current editor.
*
**/
this.focus = function() {
this.$cEditor.focus();
};
/** related to: Editor.blur
* Split.blur() -> Void
*
* Blurs the current editor.
*
**/
this.blur = function() {
this.$cEditor.blur();
};
/** related to: Editor.setTheme
* Split.setTheme(theme) -> Void
* - theme (String):
*
* Sets a theme for each of the available editors.
**/
this.setTheme = function(theme) {
this.$editors.forEach(function(editor) {
editor.setTheme(theme);
});
};
/**
* Split.setKeyboardHandler(keybinding) -> Void
* - keybinding (String):
*
* TODO
**/
this.setKeyboardHandler = function(keybinding) {
this.$editors.forEach(function(editor) {
editor.setKeyboardHandler(keybinding);
});
};
/**
* Split.forEach(callback, scope) -> Void
* - callback (Function): A callback function to execute
* - scope (String): TODO
*
* Executes `callback` on all of the available editors. TODO
*
**/
this.forEach = function(callback, scope) {
this.$editors.forEach(callback, scope);
};
/** related to: editor.setFontSize
* Split.setFontSize(size) -> Void
* - size (Number): The new font size
*
* Sets the font size, in pixels, for all the available editors.
*
**/
this.$fontSize = "";
this.setFontSize = function(size) {
this.$fontSize = size;
@ -187,6 +269,14 @@ var Split = function(container, theme, splits) {
return s;
};
/** related to: editor.setSession
* Split.setSession(session, idx) -> Void
* - session (EditSession): The new edit session
* - idx (Number): The editor's index you're interested in
*
* Sets a new [[EditSession `EditSession`]] for the indicated editor.
*
**/
this.setSession = function(session, idx) {
var editor;
if (idx == null) {
@ -213,10 +303,23 @@ var Split = function(container, theme, splits) {
return session;
};
/**
* Split.getOriantation() -> Number
*
* Returns the orientation. TODO
*
**/
this.getOriantation = function() {
return this.$oriantation;
};
/**
* Split.setOriantation(oriantation) -> Void
* - oriantation (Number):
*
* Sets the orientation. TODO
*
**/
this.setOriantation = function(oriantation) {
if (this.$oriantation == oriantation) {
return;
@ -225,6 +328,12 @@ var Split = function(container, theme, splits) {
this.resize();
};
/**
* Split.resize() -> Void
*
* TODO
*
**/
this.resize = function() {
var width = this.$container.clientWidth;
var height = this.$container.clientHeight;
@ -255,6 +364,12 @@ var Split = function(container, theme, splits) {
}).call(Split.prototype);
/**
* Split.UndoManagerProxy() -> Void
*
* TODO
*
**/
function UndoManagerProxy(undoManager, session) {
this.$u = undoManager;
this.$doc = session;

View file

@ -467,7 +467,7 @@ exports.keys = function(map, construct) {
return exports.list(keys, construct)
}
/**
/*
* range([start,] stop[, step]) -> generator of integers
*
* Return a generator containing an arithmetic progression of integers.

View file

@ -39,6 +39,22 @@
define(function(require, exports, module) {
"use strict";
/**
* class Token_Iterator
*
* This class handles all sorts of token iterizing. Is that even a word? TODO
*
**/
/**
* new Token_Iterator(session, initialRow, initialColumn)
* - session (EditSession): The session to associate with
* - initialRow (Number): The row to start the tokenizing at
* - initialColumn (Number): The column to start the tokenizing at
*
* Creates a new token iterator object. The inital token index is set to the row and column coordinates.
*
**/
var TokenIterator = function(session, initialRow, initialColumn) {
this.$session = session;
this.$row = initialRow;
@ -49,7 +65,12 @@ var TokenIterator = function(session, initialRow, initialColumn) {
};
(function() {
/**
* Token_Iterator.stepBackward() -> Array | null
*
* Tokenizes all the items from the current point to the row prior in the document. If the current point is at the top of the file, this function returns `null`. Otherwise, it returns an array of the tokenized strings.
**/
this.stepBackward = function() {
this.$tokenIndex -= 1;
@ -66,7 +87,12 @@ var TokenIterator = function(session, initialRow, initialColumn) {
return this.$rowTokens[this.$tokenIndex];
};
/**
* Token_Iterator.stepForward() -> String | null
*
* Tokenizes all the items from the current point until the next row in the document. If the current point is at the end of the file, this function returns `null`. Otherwise, it returns the tokenized string.
**/
this.stepForward = function() {
var rowCount = this.$session.getLength();
this.$tokenIndex += 1;
@ -84,15 +110,33 @@ var TokenIterator = function(session, initialRow, initialColumn) {
return this.$rowTokens[this.$tokenIndex];
};
/**
* Token_Iterator.getCurrentToken() -> String
*
* Returns the current tokenized string.
*
**/
this.getCurrentToken = function () {
return this.$rowTokens[this.$tokenIndex];
};
/**
* Token_Iterator.getCurrentTokenRow() -> Number
*
* Returns the current row.
*
**/
this.getCurrentTokenRow = function () {
return this.$row;
};
/**
* Token_Iterator.getCurrentTokenColumn() -> Number
*
* Returns the current column.
*
**/
this.getCurrentTokenColumn = function() {
var rowTokens = this.$rowTokens;
var tokenIndex = this.$tokenIndex;

View file

@ -38,6 +38,21 @@
define(function(require, exports, module) {
"use strict";
/**
* class Tokenizer
*
* This object handles all sorts of tokenizing? TODO
*
**/
/**
* new Tokenizer(rules, flag)
* - rules (String):
* - flag (String):
*
* TODO
*
**/
var Tokenizer = function(rules, flag) {
flag = flag ? "g" + flag : "g";
this.rules = rules;
@ -76,6 +91,11 @@ var Tokenizer = function(rules, flag) {
(function() {
/**
* Tokenizer.getLineTokens() -> Object
*
* TODO. Returns an object containing two properties: `tokens`, all the tokens; and `state`, the current state.
**/
this.getLineTokens = function(line, startState) {
var currentState = startState;
var state = this.rules[currentState];

View file

@ -40,12 +40,30 @@
define(function(require, exports, module) {
"use strict";
/**
* class UndoManager
*
* This object controls all the undoing that needs to be done. TODO
*
**/
/**
* new UndoManager()
*
* Resets the current undo state and creates a new `UndoManager`.
**/
var UndoManager = function() {
this.reset();
};
(function() {
/**
* UndoManager.execute(options) -> Void
* - options (Object):
*
* TODO
**/
this.execute = function(options) {
var deltas = options.args[0];
this.$doc = options.args[1];
@ -53,6 +71,12 @@ var UndoManager = function() {
this.$redoStack = [];
};
/**
* UndoManager.undo(dontSelect) -> Range
* - dontSelect (Boolean): TODO
*
* [Perform an undo operation on the document, reverting the last change. Returns the range of the undo.](~UndoManager.undo)
**/
this.undo = function(dontSelect) {
var deltas = this.$undoStack.pop();
var undoSelectionRange = null;
@ -64,6 +88,12 @@ var UndoManager = function() {
return undoSelectionRange;
};
/**
* UndoManager.redo(dontSelect) -> Void
* - dontSelect (Boolean): TODO
*
* [Perform a redo operation on the document, reimplementing the last change.](~UndoManager.redo)
**/
this.redo = function(dontSelect) {
var deltas = this.$redoStack.pop();
var redoSelectionRange = null;
@ -75,15 +105,30 @@ var UndoManager = function() {
return redoSelectionRange;
};
/**
* UndoManager.reset() -> Void
*
* Destroys the stack of undo and redo redo operations.
**/
this.reset = function() {
this.$undoStack = [];
this.$redoStack = [];
};
/**
* UndoManager.hasUndo() -> Boolean
*
* Returns `true` if there are undo operations left to perform.
**/
this.hasUndo = function() {
return this.$undoStack.length > 0;
};
/**
* UndoManager.hasRedo() -> Boolean
*
* Returns `true` if there are redo operations left to perform.
**/
this.hasRedo = function() {
return this.$redoStack.length > 0;
};

View file

@ -56,6 +56,22 @@ var editorCss = require("ace/requirejs/text!./css/editor.css");
dom.importCssString(editorCss, "ace_editor");
/**
* class Virtual_Renderer
*
* TODO
*
**/
/**
* new Virtual_Renderer(container, theme)
* - container (Editor):
* - theme (String): The starting theme
*
* TODO
*
**/
var VirtualRenderer = function(container, theme) {
var _self = this;
@ -175,6 +191,11 @@ var VirtualRenderer = function(container, theme) {
oop.implement(this, EventEmitter);
/**
* Virtual_Renderer.setSession(session) -> Void
*
* Associates an [[EditSession `EditSession`]].
**/
this.setSession = function(session) {
this.session = session;
this.$cursorLayer.setSession(session);
@ -186,8 +207,12 @@ var VirtualRenderer = function(container, theme) {
};
/**
* Triggers partial update of the text layer
*/
* Virtual_Renderer.updateLines(firstRow, lastRow) -> Void
* - firstRow (Number): The first row to update
* - lastRow (Number): The last row to update
*
* Triggers a partial update of the text, from the range given by the two parameters.
**/
this.updateLines = function(firstRow, lastRow) {
if (lastRow === undefined)
lastRow = Infinity;
@ -210,26 +235,38 @@ var VirtualRenderer = function(container, theme) {
};
/**
* Triggers full update of the text layer
*/
* Virtual_Renderer.updateText() -> Void
*
* Triggers a full update of the text, for all the rows.
**/
this.updateText = function() {
this.$loop.schedule(this.CHANGE_TEXT);
};
/**
* Triggers a full update of all layers
*/
* Virtual_Renderer.updateFull() -> Void
*
* Triggers a full update of all the layers, for all the rows.
**/
this.updateFull = function() {
this.$loop.schedule(this.CHANGE_FULL);
};
/**
* Virtual_Renderer.updateFontSize() -> Void
*
* Updates the font size.
**/
this.updateFontSize = function() {
this.$textLayer.checkForSizeChanges();
};
/**
* Triggers resize of the editor
*/
* Virtual_Renderer.onResize(force) -> Void
* - force (Boolean): TODO
*
* Triggers a resize of the editor.
**/
this.onResize = function(force) {
var changes = this.CHANGE_SIZE;
var size = this.$size;
@ -264,45 +301,99 @@ var VirtualRenderer = function(container, theme) {
this.$loop.schedule(changes);
};
/**
* Virtual_Renderer.adjustWrapLimit() -> Void
*
* Adjusts the wrap limits. TODO.
**/
this.adjustWrapLimit = function() {
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
var limit = Math.floor(availableWidth / this.characterWidth);
return this.session.adjustWrapLimit(limit);
};
/**
* Virtual_Renderer.setShowInvisibles(showInvisibles) -> Void
* - showInvisibles (Boolean): Set to `true` to show invisibles
*
* Identifies whether you want to show invisible characters or not.
*
**/
this.setShowInvisibles = function(showInvisibles) {
if (this.$textLayer.setShowInvisibles(showInvisibles))
this.$loop.schedule(this.CHANGE_TEXT);
};
/**
* Virtual_Renderer.getShowInvisibles() -> Boolean
*
* Returns whether or not invisible characters are being shown or not.
**/
this.getShowInvisibles = function() {
return this.$textLayer.showInvisibles;
};
this.$showPrintMargin = true;
/**
* Virtual_Renderer.setShowPrintMargin(showPrintMargin)
* - showPrintMargin (Boolean): Set to `true` to show the print margin
*
* Identifies whether you want to show the print margin or not.
*
**/
this.setShowPrintMargin = function(showPrintMargin) {
this.$showPrintMargin = showPrintMargin;
this.$updatePrintMargin();
};
/**
* Virtual_Renderer.getShowPrintMargin() -> Boolean
*
* Returns whether or not the print margin is being shown or not.
**/
this.getShowPrintMargin = function() {
return this.$showPrintMargin;
};
this.$printMarginColumn = 80;
/**
* Virtual_Renderer.setPrintMarginColumn(showPrintMargin)
* - showPrintMargin (Boolean): Set to `true` to show the print margin column
*
* Identifies whether you want to show the print margin column or not.
*
**/
this.setPrintMarginColumn = function(showPrintMargin) {
this.$printMarginColumn = showPrintMargin;
this.$updatePrintMargin();
};
/**
* Virtual_Renderer.getPrintMarginColumn() -> Boolean
*
* Returns whether or not the print margin column is being shown or not.
**/
this.getPrintMarginColumn = function() {
return this.$printMarginColumn;
};
/**
* Virtual_Renderer.getShowGutter() -> Boolean
*
* Returns `true` if the gutter is being shown.
**/
this.getShowGutter = function(){
return this.showGutter;
};
/**
* Virtual_Renderer.setShowGutter(show) -> Void
* - show (Boolean): Set to `true` to show the gutter
*
* Identifies whether you want to show the gutter or not.
**/
this.setShowGutter = function(show){
if(this.showGutter === show)
return;
@ -331,18 +422,39 @@ var VirtualRenderer = function(container, theme) {
style.visibility = this.$showPrintMargin ? "visible" : "hidden";
};
/**
* Virtual_Renderer.getContainerElement() -> TODO
*
* TODO
**/
this.getContainerElement = function() {
return this.container;
};
/**
* Virtual_Renderer.getMouseEventTarget() -> TODO
*
* TODO
**/
this.getMouseEventTarget = function() {
return this.content;
};
/**
* Virtual_Renderer.getTextAreaContainer() -> TODO
*
* TODO
**/
this.getTextAreaContainer = function() {
return this.container;
};
/**
* Virtual_Renderer.moveTextAreaToCursor(textarea) -> Void
* - textarea (Element): A text area to work with
*
* Changes the position of `textarea` to where the cursor is pointing.
**/
this.moveTextAreaToCursor = function(textarea) {
// in IE the native cursor always shines through
// this persists in IE9
@ -363,24 +475,52 @@ var VirtualRenderer = function(container, theme) {
textarea.style.top = (bounds.top + pos.top - this.scrollTop + offset) + "px";
};
/**
* Virtual_Renderer.getFirstVisibleRow() -> Number
*
* [Returns the index of the first visible row.](~VirtualRenderer.getFirstVisibleRow)
**/
this.getFirstVisibleRow = function() {
return this.layerConfig.firstRow;
};
/**
* Virtual_Renderer.getFirstFullyVisibleRow() -> Number
*
* Returns the index of the first fully visible row. "Fully" here means TODO
**/
this.getFirstFullyVisibleRow = function() {
return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
};
/**
* Virtual_Renderer.getLastFullyVisibleRow() -> Number
*
* Returns the index of the last fully visible row. "Fully" here means TODO
**/
this.getLastFullyVisibleRow = function() {
var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
return this.layerConfig.firstRow - 1 + flint;
};
/**
* Virtual_Renderer.getLastVisibleRow() -> Number
*
* [Returns the index of the last visible row.](~VirtualRenderer.getLastVisibleRow)
**/
this.getLastVisibleRow = function() {
return this.layerConfig.lastRow;
};
this.$padding = null;
/**
* Virtual_Renderer.setPadding(padding) -> Void
* - padding (Number): A new padding value (in pixels)
*
* Sets the padding for all the layers.
*
**/
this.setPadding = function(padding) {
this.$padding = padding;
this.$textLayer.setPadding(padding);
@ -391,10 +531,21 @@ var VirtualRenderer = function(container, theme) {
this.$updatePrintMargin();
};
/**
* Virtual_Renderer.getHScrollBarAlwaysVisible() -> Boolean
*
* Returns whether or not the horizontal scrollbar is set to be always visible.
**/
this.getHScrollBarAlwaysVisible = function() {
return this.$horizScrollAlwaysVisible;
};
/**
* Virtual_Renderer.setHScrollBarAlwaysVisible(alwaysVisible) -> Void
* - alwaysVisible (Boolean): Set to `true` to make the horizontal scroll bar visible
*
* Identifies whether you want to show the horizontal scrollbar or not.
**/
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
this.$horizScrollAlwaysVisible = alwaysVisible;
@ -588,48 +739,104 @@ var VirtualRenderer = function(container, theme) {
return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
};
/**
* Virtual_Renderer.updateFrontMarkers() -> Void
*
* TODO
**/
this.updateFrontMarkers = function() {
this.$markerFront.setMarkers(this.session.getMarkers(true));
this.$loop.schedule(this.CHANGE_MARKER_FRONT);
};
/**
* Virtual_Renderer.updateBackMarkers() -> Void
*
* TODO
**/
this.updateBackMarkers = function() {
this.$markerBack.setMarkers(this.session.getMarkers());
this.$loop.schedule(this.CHANGE_MARKER_BACK);
};
/**
* Virtual_Renderer.addGutterDecoration(row, className) -> Void
* - row (Number): The row number
* - className (String): The class to add
*
* Adds `className` to the `row`, to be used for CSS stylings and whatnot.
**/
this.addGutterDecoration = function(row, className){
this.$gutterLayer.addGutterDecoration(row, className);
this.$loop.schedule(this.CHANGE_GUTTER);
};
/**
* Virtual_Renderer.removeGutterDecoration(row, className)-> Void
* - row (Number): The row number
* - className (String): The class to add
*
* Removes `className` from the `row`.
**/
this.removeGutterDecoration = function(row, className){
this.$gutterLayer.removeGutterDecoration(row, className);
this.$loop.schedule(this.CHANGE_GUTTER);
};
/**
* Virtual_Renderer.setBreakpoints(rows) -> Void
* - rows (Array): An array containg row numbers
*
* Sets a breakpoint for every row number indicated on `rows`.
**/
this.setBreakpoints = function(rows) {
this.$gutterLayer.setBreakpoints(rows);
this.$loop.schedule(this.CHANGE_GUTTER);
};
/**
* Virtual_Renderer.setAnnotations(annotations) -> Void
* - annotations (Array): An array containing annotation
*
* TODO
**/
this.setAnnotations = function(annotations) {
this.$gutterLayer.setAnnotations(annotations);
this.$loop.schedule(this.CHANGE_GUTTER);
};
/**
* Virtual_Renderer.updateCursor() -> Void
*
* Updates the cursor icon.
**/
this.updateCursor = function() {
this.$loop.schedule(this.CHANGE_CURSOR);
};
/**
* Virtual_Renderer.hideCursor() -> Void
*
* Hides the cursor icon.
**/
this.hideCursor = function() {
this.$cursorLayer.hideCursor();
};
/**
* Virtual_Renderer.showCursor() -> Void
*
* Shows the cursor icon.
**/
this.showCursor = function() {
this.$cursorLayer.showCursor();
};
/**
* Virtual_Renderer.scrollCursorIntoView() -> VOid
*
* TODO
**/
this.scrollCursorIntoView = function() {
// the editor is not visible
if (this.$size.scrollerHeight === 0)
@ -661,26 +868,60 @@ var VirtualRenderer = function(container, theme) {
}
};
/** related to: EditSession.getScrollTop
* Virtual_Renderer.getScrollTop() -> Number
*
* (~EditSession.getScrollTop)
**/
this.getScrollTop = function() {
return this.session.getScrollTop();
};
/** related to: EditSession.getScrollLeft
* Virtual_Renderer.getScrollLeft() -> Number
*
* (~EditSession.getScrollLeft)
**/
this.getScrollLeft = function() {
return this.session.getScrollTop();
};
/**
* Virtual_Renderer.getScrollTopRow() -> Number
*
* Returns the size of the first row, in pixels. TODO
**/
this.getScrollTopRow = function() {
return this.scrollTop / this.lineHeight;
};
/**
* Virtual_Renderer.getScrollBottomRow() -> Number
*
* Returns the size of the last row, in pixels.
**/
this.getScrollBottomRow = function() {
return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
};
/** related to: EditSession.setScrollTop
* Virtual_Renderer.scrollToRow(row) -> Void
* - row (Number): A row id
*
* Sets the top of the editor to the row indicated.
**/
this.scrollToRow = function(row) {
this.session.setScrollTop(row * this.lineHeight);
};
/**
* Virtual_Renderer.scrollToLine(line, center)
* - line (Number): The line to go to
* - center (Boolean): Identifies whether you want the cursor centered or not
*
* Scrolls the editor to the `line` indicated.
*
**/
this.scrollToLine = function(line, center) {
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = pos.top;
@ -690,6 +931,13 @@ var VirtualRenderer = function(container, theme) {
this.session.setScrollTop(offset);
};
/**
* Virtual_Renderer.scrollToY(scrollTop) -> Number
* - scrollTop (Number): The position to scroll to
*
* Scrolls the editor to the y pixel indicated.
*
**/
this.scrollToY = function(scrollTop) {
// after calling scrollBar.setScrollTop
// scrollbar sends us event with same scrollTop. ignore it
@ -699,6 +947,13 @@ var VirtualRenderer = function(container, theme) {
}
};
/**
* Virtual_Renderer.scrollToX(scrollLeft) -> Number
* - scrollLeft (Number): The position to scroll to
*
* Scrolls the editor to the x pixel indicated.
*
**/
this.scrollToX = function(scrollLeft) {
if (scrollLeft <= this.$padding)
scrollLeft = 0;
@ -709,11 +964,25 @@ var VirtualRenderer = function(container, theme) {
}
};
/**
* Virtual_Renderer.scrollBy(deltaX, deltaY) -> Void
* - deltaX (Number): The x value to scroll by
* - deltaY (Number): The y value to scroll by
*
* Scrolls the editor across both x- and y-axes.
**/
this.scrollBy = function(deltaX, deltaY) {
deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
};
/**
* Virtual_Renderer.isScrollableBy(deltaX, deltaY) -> Boolean
* - deltaX (Number): The x value to scroll by
* - deltaY (Number): The y value to scroll by
*
* Returns `true` if you can still scroll by either parameter; in other words, you haven't reached the end of the file or line.
**/
this.isScrollableBy = function(deltaX, deltaY) {
if (deltaY < 0 && this.session.getScrollTop() > 0)
return true;
@ -722,6 +991,11 @@ var VirtualRenderer = function(container, theme) {
// todo: handle horizontal scrolling
};
/**
* Virtual_Renderer.screenToTextCoordinates(pageX, pageY) -> Number
*
* TODO
**/
this.screenToTextCoordinates = function(pageX, pageY) {
var canvasPos = this.scroller.getBoundingClientRect();
@ -735,6 +1009,11 @@ var VirtualRenderer = function(container, theme) {
return this.session.screenToDocumentPosition(row, Math.max(col, 0));
};
/**
* Virtual_Renderer.textToScreenCoordinates(row, column) -> Object
*
* TODO
**/
this.textToScreenCoordinates = function(row, column) {
var canvasPos = this.scroller.getBoundingClientRect();
var pos = this.session.documentToScreenPosition(row, column);
@ -748,14 +1027,29 @@ var VirtualRenderer = function(container, theme) {
};
};
/**
* Virtual_Renderer.visualizeFocus() -> Void
*
* Focuses the current container.
**/
this.visualizeFocus = function() {
dom.addCssClass(this.container, "ace_focus");
};
/**
* Virtual_Renderer.visualizeBlur() -> Void
*
* Blurs the current container.
**/
this.visualizeBlur = function() {
dom.removeCssClass(this.container, "ace_focus");
};
/**
* Virtual_Renderer.showComposition(position) -> Void
*
* TODO
**/
this.showComposition = function(position) {
if (!this.$composition) {
this.$composition = dom.createElement("div");
@ -774,10 +1068,21 @@ var VirtualRenderer = function(container, theme) {
this.hideCursor();
};
/**
* Virtual_Renderer.setCompositionText(text) -> Void
* - text (String): A string of text to use
*
* Sets the inner text of the current composition to `text`.
**/
this.setCompositionText = function(text) {
dom.setInnerText(this.$composition, text);
};
/**
* Virtual_Renderer.hideComposition() -> Void
*
* Hides the current composition.
**/
this.hideComposition = function() {
this.showCursor();
@ -789,6 +1094,12 @@ var VirtualRenderer = function(container, theme) {
style.left = "-10000px";
};
/**
* Virtual_Renderer.setTheme(theme) -> Void
* - theme (String): The path to a theme
*
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.](~VirtualRenderer.setTheme)
**/
this.setTheme = function(theme) {
var _self = this;
@ -830,6 +1141,11 @@ var VirtualRenderer = function(container, theme) {
}
};
/**
* Virtual_Renderer.getTheme() -> String
*
* [Returns the path of the current theme.](~VirtualRenderer.getTheme)
**/
this.getTheme = function() {
return this.$themeValue;
};
@ -838,14 +1154,31 @@ var VirtualRenderer = function(container, theme) {
// This feature can be used by plug-ins to provide a visual indication of
// a certain mode that editor is in.
/**
* Virtual_Renderer.setStyle(style) -> Void
* - style (String): A class name
*
* [Adds a new class, `style`, to the editor.](~VirtualRenderer.setStyle)
**/
this.setStyle = function setStyle(style) {
dom.addCssClass(this.container, style);
};
/**
* Virtual_Renderer.unsetStyle(style) -> Void
* - style (String): A class name
*
* [Removes the class `style` from the editor.](~VirtualRenderer.unsetStyle)
**/
this.unsetStyle = function unsetStyle(style) {
dom.removeCssClass(this.container, style);
};
/**
* Virtual_Renderer.destroy()
*
* TODO
**/
this.destroy = function() {
this.$textLayer.destroy();
this.$cursorLayer.destroy();