use APF style class declaration

This commit is contained in:
Fabian Jakobs 2010-04-22 13:25:44 +02:00
commit 2b736e7c8e
20 changed files with 1945 additions and 1867 deletions

View file

@ -41,31 +41,34 @@ ace.BackgroundTokenizer = function(tokenizer) {
this.$initEvents(); this.$initEvents();
}; };
ace.mixin(ace.BackgroundTokenizer.prototype, ace.MEventEmitter);
ace.BackgroundTokenizer.prototype.setTokenizer = function(tokenizer) { (function(){
ace.mixin(this, ace.MEventEmitter);
this.setTokenizer = function(tokenizer) {
this.tokenizer = tokenizer; this.tokenizer = tokenizer;
this.lines = []; this.lines = [];
this.start(0); this.start(0);
}; };
ace.BackgroundTokenizer.prototype.setLines = function(textLines) { this.setLines = function(textLines) {
this.textLines = textLines; this.textLines = textLines;
this.lines = []; this.lines = [];
this.stop(); this.stop();
}; };
ace.BackgroundTokenizer.prototype.fireUpdateEvent = function(firstRow, lastRow) { this.fireUpdateEvent = function(firstRow, lastRow) {
var data = { var data = {
first: firstRow, first: firstRow,
last: lastRow last: lastRow
}; };
this.$dispatchEvent("update", {data: data}); this.$dispatchEvent("update", {data: data});
}; };
ace.BackgroundTokenizer.prototype.start = function(startRow) { this.start = function(startRow) {
this.currentLine = Math.min(startRow || 0, this.currentLine, this.currentLine = Math.min(startRow || 0, this.currentLine,
this.textLines.length); this.textLines.length);
@ -76,21 +79,21 @@ ace.BackgroundTokenizer.prototype.start = function(startRow) {
// pretty long delay to prevent the tokenizer from interfering with the user // pretty long delay to prevent the tokenizer from interfering with the user
this.running = setTimeout(this._worker, 200); this.running = setTimeout(this._worker, 200);
} }
}; };
ace.BackgroundTokenizer.prototype.stop = function() { this.stop = function() {
this.running = false; this.running = false;
}; };
ace.BackgroundTokenizer.prototype.getTokens = function(row) { this.getTokens = function(row) {
return this._tokenizeRow(row).tokens; return this._tokenizeRow(row).tokens;
}; };
ace.BackgroundTokenizer.prototype.getState = function(row) { this.getState = function(row) {
return this._tokenizeRow(row).state; return this._tokenizeRow(row).state;
}; };
ace.BackgroundTokenizer.prototype._tokenizeRow = function(row) { this._tokenizeRow = function(row) {
if (!this.lines[row]) { if (!this.lines[row]) {
var state = "start"; var state = "start";
if (row > 0 && this.lines[row - 1]) { if (row > 0 && this.lines[row - 1]) {
@ -99,4 +102,6 @@ ace.BackgroundTokenizer.prototype._tokenizeRow = function(row) {
this.lines[row] = this.tokenizer.getLineTokens(this.textLines[row] || "", state); this.lines[row] = this.tokenizer.getLineTokens(this.textLines[row] || "", state);
} }
return this.lines[row]; return this.lines[row];
}; };
}).call(ace.BackgroundTokenizer.prototype);

View file

@ -13,86 +13,88 @@ ace.Document = function(text, mode) {
} }
}; };
ace.mixin(ace.Document.prototype, ace.MEventEmitter); (function() {
ace.Document.prototype._split = function(text) { ace.mixin(ace.Document.prototype, ace.MEventEmitter);
this._split = function(text) {
return text.split(/\r\n|\r|\n/); return text.split(/\r\n|\r|\n/);
}; };
ace.Document.prototype.toString = function() { this.toString = function() {
return this.lines.join("\n"); return this.lines.join("\n");
}; };
ace.Document.prototype.getSelection = function() { this.getSelection = function() {
return this.selection; return this.selection;
}; };
ace.Document.prototype.fireChangeEvent = function(firstRow, lastRow) { this.fireChangeEvent = function(firstRow, lastRow) {
var data = { var data = {
firstRow: firstRow, firstRow: firstRow,
lastRow: lastRow lastRow: lastRow
}; };
this.$dispatchEvent("change", { data: data}); this.$dispatchEvent("change", { data: data});
}; };
ace.Document.prototype.getTabString = function() { this.getTabString = function() {
if (this.getUseSoftTabs()) { if (this.getUseSoftTabs()) {
return new Array(this.getTabSize()+1).join(" "); return new Array(this.getTabSize()+1).join(" ");
} }
return "\t"; return "\t";
}; };
ace.Document.prototype._useSoftTabs = true; this._useSoftTabs = false;
ace.Document.prototype.setUseSoftTabs = function(useSoftTabs) { this.setUseSoftTabs = function(useSoftTabs) {
if (this._useSoftTabs === useSoftTabs) return; if (this._useSoftTabs === useSoftTabs) return;
this._useSoftTabs = useSoftTabs; this._useSoftTabs = useSoftTabs;
}; };
ace.Document.prototype.getUseSoftTabs = function() { this.getUseSoftTabs = function() {
return this._useSoftTabs; return this._useSoftTabs;
}; };
ace.Document.prototype._tabSize = 4; this._tabSize = 4;
ace.Document.prototype.setTabSize = function(tabSize) { this.setTabSize = function(tabSize) {
if (this._tabSize === tabSize) return; if (this._tabSize === tabSize) return;
this._tabSize = tabSize; this._tabSize = tabSize;
this.$dispatchEvent("changeTabSize"); this.$dispatchEvent("changeTabSize");
}; };
ace.Document.prototype.getTabSize = function() { this.getTabSize = function() {
return this._tabSize; return this._tabSize;
}; };
ace.Document.prototype._mode = null; this._mode = null;
ace.Document.prototype.setMode = function(mode) { this.setMode = function(mode) {
if (this._mode === mode) return; if (this._mode === mode) return;
this._mode = mode; this._mode = mode;
this.$dispatchEvent("changeMode"); this.$dispatchEvent("changeMode");
}; };
ace.Document.prototype.getMode = function() { this.getMode = function() {
if (!this._mode) { if (!this._mode) {
this._mode = new ace.mode.Text(); this._mode = new ace.mode.Text();
} }
return this._mode; return this._mode;
}; };
ace.Document.prototype._scrollTop = 0; this._scrollTop = 0;
ace.Document.prototype.setScrollTopRow = function(scrollTopRow) { this.setScrollTopRow = function(scrollTopRow) {
if (this._scrollTop === scrollTopRow) return; if (this._scrollTop === scrollTopRow) return;
this._scrollTop = scrollTopRow; this._scrollTop = scrollTopRow;
this.$dispatchEvent("changeScrollTop"); this.$dispatchEvent("changeScrollTop");
}; };
ace.Document.prototype.getScrollTopRow = function() { this.getScrollTopRow = function() {
return this._scrollTop; return this._scrollTop;
}; };
ace.Document.prototype.getWidth = function() { this.getWidth = function() {
if (this.modified) { if (this.modified) {
this.modified = false; this.modified = false;
@ -104,17 +106,17 @@ ace.Document.prototype.getWidth = function() {
this.width = longestLine; this.width = longestLine;
} }
return this.width; return this.width;
}; };
ace.Document.prototype.getLine = function(row) { this.getLine = function(row) {
return this.lines[row] || ""; return this.lines[row] || "";
}; };
ace.Document.prototype.getLength = function() { this.getLength = function() {
return this.lines.length; return this.lines.length;
}; };
ace.Document.prototype.getTextRange = function(range) { this.getTextRange = function(range) {
if (range.start.row == range.end.row) { if (range.start.row == range.end.row) {
return this.lines[range.start.row].substring(range.start.column, return this.lines[range.start.row].substring(range.start.column,
range.end.column); range.end.column);
@ -126,13 +128,13 @@ ace.Document.prototype.getTextRange = function(range) {
lines.push(this.lines[range.end.row].substring(0, range.end.column)); lines.push(this.lines[range.end.row].substring(0, range.end.column));
return lines.join("\n"); return lines.join("\n");
} }
}; };
ace.Document.prototype.getLines = function(firstRow, lastRow) { this.getLines = function(firstRow, lastRow) {
return this.lines.slice(firstRow, lastRow+1); return this.lines.slice(firstRow, lastRow+1);
}; };
ace.Document.prototype.findMatchingBracket = function(position) { this.findMatchingBracket = function(position) {
if (position.column == 0) return null; if (position.column == 0) return null;
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1); var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
@ -148,18 +150,18 @@ ace.Document.prototype.findMatchingBracket = function(position) {
} else { } else {
return this._findOpeningBracket(match[2], position); return this._findOpeningBracket(match[2], position);
} }
}; };
ace.Document.prototype._brackets = { this._brackets = {
")": "(", ")": "(",
"(": ")", "(": ")",
"]": "[", "]": "[",
"[": "]", "[": "]",
"{": "}", "{": "}",
"}": "{" "}": "{"
}; };
ace.Document.prototype._findOpeningBracket = function(bracket, position) { this._findOpeningBracket = function(bracket, position) {
var openBracket = this._brackets[bracket]; var openBracket = this._brackets[bracket];
var column = position.column - 2; var column = position.column - 2;
@ -189,9 +191,9 @@ ace.Document.prototype._findOpeningBracket = function(bracket, position) {
var column = line.length-1; var column = line.length-1;
} }
return null; return null;
}; };
ace.Document.prototype._findClosingBracket = function(bracket, position) { this._findClosingBracket = function(bracket, position) {
var closingBracket = this._brackets[bracket]; var closingBracket = this._brackets[bracket];
var column = position.column; var column = position.column;
@ -222,22 +224,22 @@ ace.Document.prototype._findClosingBracket = function(bracket, position) {
var column = 0; var column = 0;
} }
return null; return null;
}; };
ace.Document.prototype.insert = function(position, text) { this.insert = function(position, text) {
var end = this._insert(position, text); var end = this._insert(position, text);
this.fireChangeEvent(position.row, position.row == end.row ? position.row this.fireChangeEvent(position.row, position.row == end.row ? position.row
: undefined); : undefined);
return end; return end;
}; };
ace.Document.prototype._insertLines = function(row, lines) { this._insertLines = function(row, lines) {
var args = [row, 0]; var args = [row, 0];
args.push.apply(args, lines); args.push.apply(args, lines);
this.lines.splice.apply(this.lines, args); this.lines.splice.apply(this.lines, args);
}, },
ace.Document.prototype._insert = function(position, text) { this._insert = function(position, text) {
this.modified = true; this.modified = true;
var newLines = this._split(text); var newLines = this._split(text);
@ -279,22 +281,22 @@ ace.Document.prototype._insert = function(position, text) {
column : newLines[newLines.length - 1].length column : newLines[newLines.length - 1].length
}; };
} }
}; };
ace.Document.prototype._isNewLine = function(text) { this._isNewLine = function(text) {
return (text == "\r\n" || text == "\r" || text == "\n"); return (text == "\r\n" || text == "\r" || text == "\n");
}; };
ace.Document.prototype.remove = function(range) { this.remove = function(range) {
this._remove(range); this._remove(range);
this.fireChangeEvent(range.start.row, this.fireChangeEvent(range.start.row,
range.end.row == range.start.row ? range.start.row range.end.row == range.start.row ? range.start.row
: undefined); : undefined);
return range.start; return range.start;
}; };
ace.Document.prototype._remove = function(range) { this._remove = function(range) {
this.modified = true; this.modified = true;
var firstRow = range.start.row; var firstRow = range.start.row;
@ -306,9 +308,9 @@ ace.Document.prototype._remove = function(range) {
this.lines.splice(firstRow, lastRow - firstRow + 1, row); this.lines.splice(firstRow, lastRow - firstRow + 1, row);
return range.start; return range.start;
}; };
ace.Document.prototype.replace = function(range, text) { this.replace = function(range, text) {
this._remove(range); this._remove(range);
if (text) { if (text) {
var end = this._insert(range.start, text); var end = this._insert(range.start, text);
@ -323,17 +325,17 @@ ace.Document.prototype.replace = function(range, text) {
: undefined); : undefined);
return end; return end;
}; };
ace.Document.prototype.indentRows = function(range, indentString) { this.indentRows = function(range, indentString) {
for (var i=range.start.row; i<= range.end.row; i++) { for (var i=range.start.row; i<= range.end.row; i++) {
this.lines[i] = indentString + this.getLine(i); this.lines[i] = indentString + this.getLine(i);
} }
this.fireChangeEvent(range.start.row, range.end.row); this.fireChangeEvent(range.start.row, range.end.row);
return indentString.length; return indentString.length;
}; };
ace.Document.prototype.outdentRows = function(range, indentString) { this.outdentRows = function(range, indentString) {
outdentLength = indentString.length; outdentLength = indentString.length;
for (var i=range.start.row; i<= range.end.row; i++) { for (var i=range.start.row; i<= range.end.row; i++) {
@ -348,9 +350,9 @@ ace.Document.prototype.outdentRows = function(range, indentString) {
this.fireChangeEvent(range.start.row, range.end.row); this.fireChangeEvent(range.start.row, range.end.row);
return -outdentLength; return -outdentLength;
}; };
ace.Document.prototype.moveLinesUp = function(firstRow, lastRow) { this.moveLinesUp = function(firstRow, lastRow) {
if (firstRow <= 0) return 0; if (firstRow <= 0) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1); var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
@ -358,9 +360,9 @@ ace.Document.prototype.moveLinesUp = function(firstRow, lastRow) {
this.fireChangeEvent(firstRow-1, lastRow); this.fireChangeEvent(firstRow-1, lastRow);
return -1; return -1;
}; };
ace.Document.prototype.moveLinesDown = function(firstRow, lastRow) { this.moveLinesDown = function(firstRow, lastRow) {
if (lastRow >= this.lines.length-1) return 0; if (lastRow >= this.lines.length-1) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1); var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
@ -368,9 +370,9 @@ ace.Document.prototype.moveLinesDown = function(firstRow, lastRow) {
this.fireChangeEvent(firstRow, lastRow+1); this.fireChangeEvent(firstRow, lastRow+1);
return 1; return 1;
}; };
ace.Document.prototype.duplicateLines = function(firstRow, lastRow) { this.duplicateLines = function(firstRow, lastRow) {
var firstRow = this._clipRowToDocument(firstRow); var firstRow = this._clipRowToDocument(firstRow);
var lastRow = this._clipRowToDocument(lastRow); var lastRow = this._clipRowToDocument(lastRow);
@ -381,9 +383,10 @@ ace.Document.prototype.duplicateLines = function(firstRow, lastRow) {
this.fireChangeEvent(firstRow, lastRow+addedRows); this.fireChangeEvent(firstRow, lastRow+addedRows);
return addedRows; return addedRows;
}; };
ace.Document.prototype._clipRowToDocument = function(row) { this._clipRowToDocument = function(row) {
return Math.max(0, Math.min(row, this.lines.length-1)); return Math.max(0, Math.min(row, this.lines.length-1));
}; };
}).call(ace.Document.prototype);

View file

@ -26,8 +26,9 @@ ace.Editor = function(renderer, doc) {
this.setDocument(doc || new ace.Document("")); this.setDocument(doc || new ace.Document(""));
}; };
(function(){
ace.Editor.prototype.setDocument = function(doc) { this.setDocument = function(doc) {
if (this.doc == doc) return; if (this.doc == doc) return;
if (this.doc) { if (this.doc) {
@ -69,21 +70,21 @@ ace.Editor.prototype.setDocument = function(doc) {
this.onCursorChange(); this.onCursorChange();
this.onSelectionChange(); this.onSelectionChange();
this.renderer.scrollToRow(doc.getScrollTopRow()); this.renderer.scrollToRow(doc.getScrollTopRow());
}; };
ace.Editor.prototype.getDocument = function() { this.getDocument = function() {
return this.doc; return this.doc;
}; };
ace.Editor.prototype.getSelection = function() { this.getSelection = function() {
return this.selection; return this.selection;
}; };
ace.Editor.prototype.resize = function() { this.resize = function() {
this.renderer.onResize(); this.renderer.onResize();
}; };
ace.Editor.prototype._highlightBrackets = function() { this._highlightBrackets = function() {
if (this._bracketHighlight) { if (this._bracketHighlight) {
this.renderer.removeMarker(this._bracketHighlight); this.renderer.removeMarker(this._bracketHighlight);
this._bracketHighlight = null; this._bracketHighlight = null;
@ -111,38 +112,38 @@ ace.Editor.prototype._highlightBrackets = function() {
self._bracketHighlight = self.renderer.addMarker(range, "bracket"); self._bracketHighlight = self.renderer.addMarker(range, "bracket");
} }
}, 10); }, 10);
}; };
ace.Editor.prototype.focus = function() { this.focus = function() {
this.textInput.focus(); this.textInput.focus();
}; };
ace.Editor.prototype.blur = function() { this.blur = function() {
this.textInput.blur(); this.textInput.blur();
}; };
ace.Editor.prototype.onFocus = function() { this.onFocus = function() {
this.renderer.showCursor(); this.renderer.showCursor();
this.renderer.visualizeFocus(); this.renderer.visualizeFocus();
}; };
ace.Editor.prototype.onBlur = function() { this.onBlur = function() {
this.renderer.hideCursor(); this.renderer.hideCursor();
this.renderer.visualizeBlur(); this.renderer.visualizeBlur();
}; };
ace.Editor.prototype.onDocumentChange = function(e) { this.onDocumentChange = function(e) {
var data = e.data; var data = e.data;
this.bgTokenizer.start(data.firstRow); this.bgTokenizer.start(data.firstRow);
this.renderer.updateLines(data.firstRow, data.lastRow); this.renderer.updateLines(data.firstRow, data.lastRow);
}; };
ace.Editor.prototype.onTokenizerUpdate = function(e) { this.onTokenizerUpdate = function(e) {
var rows = e.data; var rows = e.data;
this.renderer.updateLines(rows.first, rows.last); this.renderer.updateLines(rows.first, rows.last);
}; };
ace.Editor.prototype.onCursorChange = function() { this.onCursorChange = function() {
this._highlightBrackets(); this._highlightBrackets();
this.renderer.updateCursor(this.getCursorPosition()); this.renderer.updateCursor(this.getCursorPosition());
@ -150,9 +151,9 @@ ace.Editor.prototype.onCursorChange = function() {
this.renderer.scrollCursorIntoView(); this.renderer.scrollCursorIntoView();
} }
this._updateHighlightActiveLine(); this._updateHighlightActiveLine();
}; };
ace.Editor.prototype._updateHighlightActiveLine = function() { this._updateHighlightActiveLine = function() {
if (this._highlightLineMarker) { if (this._highlightLineMarker) {
this.renderer.removeMarker(this._highlightLineMarker); this.renderer.removeMarker(this._highlightLineMarker);
} }
@ -172,9 +173,9 @@ ace.Editor.prototype._updateHighlightActiveLine = function() {
}; };
this._highlightLineMarker = this.renderer.addMarker(range, "active_line", "line"); this._highlightLineMarker = this.renderer.addMarker(range, "active_line", "line");
} }
}; };
ace.Editor.prototype.onSelectionChange = function() { this.onSelectionChange = function() {
if (this._selectionMarker) { if (this._selectionMarker) {
this.renderer.removeMarker(this._selectionMarker); this.renderer.removeMarker(this._selectionMarker);
} }
@ -187,9 +188,9 @@ ace.Editor.prototype.onSelectionChange = function() {
} }
this.onCursorChange(); this.onCursorChange();
}; };
ace.Editor.prototype.onDocumentModeChange = function() { this.onDocumentModeChange = function() {
var mode = this.doc.getMode(); var mode = this.doc.getMode();
this.mode = mode; this.mode = mode;
@ -205,10 +206,10 @@ ace.Editor.prototype.onDocumentModeChange = function() {
this.renderer.setTokenizer(this.bgTokenizer); this.renderer.setTokenizer(this.bgTokenizer);
this.renderer.draw(); this.renderer.draw();
}; };
ace.Editor.prototype.onMouseDown = function(e) { this.onMouseDown = function(e) {
var pageX = ace.getDocumentX(e); var pageX = ace.getDocumentX(e);
var pageY = ace.getDocumentY(e); var pageY = ace.getDocumentY(e);
@ -244,39 +245,39 @@ ace.Editor.prototype.onMouseDown = function(e) {
var timerId = setInterval(onSelectionInterval, 20); var timerId = setInterval(onSelectionInterval, 20);
return ace.preventDefault(e); return ace.preventDefault(e);
}; };
ace.Editor.prototype.onMouseDoubleClick = function(e) { this.onMouseDoubleClick = function(e) {
this.selection.selectWord(); this.selection.selectWord();
}; };
ace.Editor.prototype.onMouseTripleClick = function(e) { this.onMouseTripleClick = function(e) {
this.selection.selectLine(); this.selection.selectLine();
}; };
ace.Editor.prototype.onMouseWheel = function(e) { this.onMouseWheel = function(e) {
var delta = e.wheel; var delta = e.wheel;
this.renderer.scrollToY(this.renderer.getScrollTop() - (delta * 15)); this.renderer.scrollToY(this.renderer.getScrollTop() - (delta * 15));
return ace.preventDefault(e); return ace.preventDefault(e);
}; };
ace.Editor.prototype.getCopyText = function() { this.getCopyText = function() {
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
return this.doc.getTextRange(this.getSelectionRange()); return this.doc.getTextRange(this.getSelectionRange());
} }
else { else {
return ""; return "";
} }
}; };
ace.Editor.prototype.onCut = function() { this.onCut = function() {
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
this.moveCursorToPosition(this.doc.remove(this.getSelectionRange())); this.moveCursorToPosition(this.doc.remove(this.getSelectionRange()));
this.clearSelection(); this.clearSelection();
} }
}; };
ace.Editor.prototype.onTextInput = function(text) { this.onTextInput = function(text) {
var cursor = this.getCursorPosition(); var cursor = this.getCursorPosition();
if (this.doc.getUseSoftTabs()) { if (this.doc.getUseSoftTabs()) {
@ -311,63 +312,63 @@ ace.Editor.prototype.onTextInput = function(text) {
this.moveCursorToPosition(end); this.moveCursorToPosition(end);
this.renderer.scrollCursorIntoView(); this.renderer.scrollCursorIntoView();
}; };
ace.Editor.prototype._selectionStyle = "line"; this._selectionStyle = "line";
ace.Editor.prototype.setSelectionStyle = function(style) { this.setSelectionStyle = function(style) {
if (this._selectionStyle == style) return; if (this._selectionStyle == style) return;
this._selectionStyle = style; this._selectionStyle = style;
this.onSelectionChange(); this.onSelectionChange();
}; };
ace.Editor.prototype.getSelectionStyle = function() { this.getSelectionStyle = function() {
return this._selectionStyle; return this._selectionStyle;
}; };
ace.Editor.prototype._highlightActiveLine = true; this._highlightActiveLine = true;
ace.Editor.prototype.setHighlightActiveLine = function(shouldHighlight) { this.setHighlightActiveLine = function(shouldHighlight) {
if (this._highlightActiveLine == shouldHighlight) return; if (this._highlightActiveLine == shouldHighlight) return;
this._highlightActiveLine = shouldHighlight; this._highlightActiveLine = shouldHighlight;
this._updateHighlightActiveLine(); this._updateHighlightActiveLine();
}; };
ace.Editor.prototype.getHighlightActiveLine = function() { this.getHighlightActiveLine = function() {
return this._highlightActiveLine; return this._highlightActiveLine;
}; };
ace.Editor.prototype.removeRight = function() { this.removeRight = function() {
if (this.selection.isEmpty()) { if (this.selection.isEmpty()) {
this.selection.selectRight(); this.selection.selectRight();
} }
this.moveCursorToPosition(this.doc.remove(this.getSelectionRange())); this.moveCursorToPosition(this.doc.remove(this.getSelectionRange()));
this.clearSelection(); this.clearSelection();
}; };
ace.Editor.prototype.removeLeft = function() { this.removeLeft = function() {
if (this.selection.isEmpty()) { if (this.selection.isEmpty()) {
this.selection.selectLeft(); this.selection.selectLeft();
} }
this.moveCursorToPosition(this.doc.remove(this.getSelectionRange())); this.moveCursorToPosition(this.doc.remove(this.getSelectionRange()));
this.clearSelection(); this.clearSelection();
}; };
ace.Editor.prototype.blockIndent = function(indentString) { this.blockIndent = function(indentString) {
var indentString = indentString || this.doc.getTabString(); var indentString = indentString || this.doc.getTabString();
var addedColumns = this.doc.indentRows(this.getSelectionRange(), indentString); var addedColumns = this.doc.indentRows(this.getSelectionRange(), indentString);
this.selection.shiftSelection(addedColumns); this.selection.shiftSelection(addedColumns);
}; };
ace.Editor.prototype.blockOutdent = function(indentString) { this.blockOutdent = function(indentString) {
var indentString = indentString || this.doc.getTabString(); var indentString = indentString || this.doc.getTabString();
var addedColumns = this.doc.outdentRows(this.getSelectionRange(), indentString); var addedColumns = this.doc.outdentRows(this.getSelectionRange(), indentString);
this.selection.shiftSelection(addedColumns); this.selection.shiftSelection(addedColumns);
}; };
ace.Editor.prototype.toggleCommentLines = function() { this.toggleCommentLines = function() {
var rows = this._getSelectedRows(); var rows = this._getSelectedRows();
var range = { var range = {
@ -384,44 +385,44 @@ ace.Editor.prototype.toggleCommentLines = function() {
var addedColumns = this.mode.toggleCommentLines(this.doc, range, state); var addedColumns = this.mode.toggleCommentLines(this.doc, range, state);
this.selection.shiftSelection(addedColumns); this.selection.shiftSelection(addedColumns);
}; };
ace.Editor.prototype.removeLines = function() { this.removeLines = function() {
var rows = this._getSelectedRows(); var rows = this._getSelectedRows();
this.selection.setSelectionAnchor(rows.last+1, 0); this.selection.setSelectionAnchor(rows.last+1, 0);
this.selection.selectTo(rows.first, 0); this.selection.selectTo(rows.first, 0);
this.doc.remove(this.getSelectionRange()); this.doc.remove(this.getSelectionRange());
this.clearSelection(); this.clearSelection();
}; };
ace.Editor.prototype.moveLinesDown = function() { this.moveLinesDown = function() {
this._moveLines(function(firstRow, lastRow) { this._moveLines(function(firstRow, lastRow) {
return this.doc.moveLinesDown(firstRow, lastRow); return this.doc.moveLinesDown(firstRow, lastRow);
}); });
}; };
ace.Editor.prototype.moveLinesUp = function() { this.moveLinesUp = function() {
this._moveLines(function(firstRow, lastRow) { this._moveLines(function(firstRow, lastRow) {
return this.doc.moveLinesUp(firstRow, lastRow); return this.doc.moveLinesUp(firstRow, lastRow);
}); });
}; };
ace.Editor.prototype.copyLinesUp = function() { this.copyLinesUp = function() {
this._moveLines(function(firstRow, lastRow) { this._moveLines(function(firstRow, lastRow) {
this.doc.duplicateLines(firstRow, lastRow); this.doc.duplicateLines(firstRow, lastRow);
return 0; return 0;
}); });
}; };
ace.Editor.prototype.copyLinesDown = function() { this.copyLinesDown = function() {
this._moveLines(function(firstRow, lastRow) { this._moveLines(function(firstRow, lastRow) {
return this.doc.duplicateLines(firstRow, lastRow); return this.doc.duplicateLines(firstRow, lastRow);
}); });
}; };
ace.Editor.prototype._moveLines = function(mover) { this._moveLines = function(mover) {
var rows = this._getSelectedRows(); var rows = this._getSelectedRows();
var linesMoved = mover.call(this, rows.first, rows.last); var linesMoved = mover.call(this, rows.first, rows.last);
@ -431,9 +432,9 @@ ace.Editor.prototype._moveLines = function(mover) {
selection._moveSelection(function() { selection._moveSelection(function() {
selection.moveCursorTo(rows.first+linesMoved, 0); selection.moveCursorTo(rows.first+linesMoved, 0);
}); });
}; };
ace.Editor.prototype._getSelectedRows = function() { this._getSelectedRows = function() {
var range = this.getSelectionRange(); var range = this.getSelectionRange();
var firstRow = range.start.row; var firstRow = range.start.row;
var lastRow = range.end.row; var lastRow = range.end.row;
@ -445,86 +446,86 @@ ace.Editor.prototype._getSelectedRows = function() {
first: firstRow, first: firstRow,
last: lastRow last: lastRow
}; };
}; };
ace.Editor.prototype.onCompositionStart = function() { this.onCompositionStart = function() {
this.renderer.showComposition(this.getCursorPosition()); this.renderer.showComposition(this.getCursorPosition());
this.onTextInput(" "); this.onTextInput(" ");
}; };
ace.Editor.prototype.onCompositionUpdate = function(text) { this.onCompositionUpdate = function(text) {
this.renderer.setCompositionText(text); this.renderer.setCompositionText(text);
}; };
ace.Editor.prototype.onCompositionEnd = function() { this.onCompositionEnd = function() {
this.renderer.hideComposition(); this.renderer.hideComposition();
this.removeLeft(); this.removeLeft();
}; };
ace.Editor.prototype.getFirstVisibleRow = function() { this.getFirstVisibleRow = function() {
return this.renderer.getFirstVisibleRow(); return this.renderer.getFirstVisibleRow();
}; };
ace.Editor.prototype.getLastVisibleRow = function() { this.getLastVisibleRow = function() {
return this.renderer.getLastVisibleRow(); return this.renderer.getLastVisibleRow();
}; };
ace.Editor.prototype.isRowVisible = function(row) { this.isRowVisible = function(row) {
return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow()); return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
}; };
ace.Editor.prototype.getVisibleRowCount = function() { this.getVisibleRowCount = function() {
return this.getLastVisibleRow() - this.getFirstVisibleRow() + 1; return this.getLastVisibleRow() - this.getFirstVisibleRow() + 1;
}; };
ace.Editor.prototype.getPageDownRow = function() { this.getPageDownRow = function() {
return this.renderer.getLastVisibleRow() - 1; return this.renderer.getLastVisibleRow() - 1;
}; };
ace.Editor.prototype.getPageUpRow = function() { this.getPageUpRow = function() {
var firstRow = this.renderer.getFirstVisibleRow(); var firstRow = this.renderer.getFirstVisibleRow();
var lastRow = this.renderer.getLastVisibleRow(); var lastRow = this.renderer.getLastVisibleRow();
return firstRow - (lastRow - firstRow) + 1; return firstRow - (lastRow - firstRow) + 1;
}; };
ace.Editor.prototype.scrollPageDown = function() { this.scrollPageDown = function() {
this.scrollToRow(this.getPageDownRow()); this.scrollToRow(this.getPageDownRow());
}; };
ace.Editor.prototype.scrollPageUp = function() { this.scrollPageUp = function() {
this.renderer.scrollToRow(this.getPageUpRow()); this.renderer.scrollToRow(this.getPageUpRow());
}; };
ace.Editor.prototype.scrollToRow = function(row) { this.scrollToRow = function(row) {
this.renderer.scrollToRow(row); this.renderer.scrollToRow(row);
}; };
ace.Editor.prototype.getCursorPosition = function() { this.getCursorPosition = function() {
return this.selection.getCursor(); return this.selection.getCursor();
}; };
ace.Editor.prototype.getSelectionRange = function() { this.getSelectionRange = function() {
return this.selection.getRange(); return this.selection.getRange();
}; };
ace.Editor.prototype.clearSelection = function() { this.clearSelection = function() {
this.selection.clearSelection(); this.selection.clearSelection();
}; };
ace.Editor.prototype.moveCursorTo = function(row, column) { this.moveCursorTo = function(row, column) {
this.selection.moveCursorTo(row, column); this.selection.moveCursorTo(row, column);
}; };
ace.Editor.prototype.moveCursorToPosition = function(pos) { this.moveCursorToPosition = function(pos) {
this.selection.moveCursorToPosition(pos); this.selection.moveCursorToPosition(pos);
}; };
ace.Editor.prototype.gotoLine = function(lineNumber) { this.gotoLine = function(lineNumber) {
this._blockScrolling = true; this._blockScrolling = true;
this.moveCursorTo(lineNumber-1, 0); this.moveCursorTo(lineNumber-1, 0);
this._blockScrolling = false; this._blockScrolling = false;
@ -532,24 +533,24 @@ ace.Editor.prototype.gotoLine = function(lineNumber) {
if (!this.isRowVisible(this.getCursorPosition().row)) { if (!this.isRowVisible(this.getCursorPosition().row)) {
this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2)); this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2));
} }
}, },
ace.Editor.prototype.navigateTo = function(row, column) { this.navigateTo = function(row, column) {
this.clearSelection(); this.clearSelection();
this.moveCursorTo(row, column); this.moveCursorTo(row, column);
}; };
ace.Editor.prototype.navigateUp = function() { this.navigateUp = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorUp(); this.selection.moveCursorUp();
}; };
ace.Editor.prototype.navigateDown = function() { this.navigateDown = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorDown(); this.selection.moveCursorDown();
}; };
ace.Editor.prototype.navigateLeft = function() { this.navigateLeft = function() {
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
var selectionStart = this.getSelectionRange().start; var selectionStart = this.getSelectionRange().start;
this.moveCursorToPosition(selectionStart); this.moveCursorToPosition(selectionStart);
@ -558,9 +559,9 @@ ace.Editor.prototype.navigateLeft = function() {
this.selection.moveCursorLeft(); this.selection.moveCursorLeft();
} }
this.clearSelection(); this.clearSelection();
}; };
ace.Editor.prototype.navigateRight = function() { this.navigateRight = function() {
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
var selectionEnd = this.getSelectionRange().end; var selectionEnd = this.getSelectionRange().end;
this.moveCursorToPosition(selectionEnd); this.moveCursorToPosition(selectionEnd);
@ -569,34 +570,35 @@ ace.Editor.prototype.navigateRight = function() {
this.selection.moveCursorRight(); this.selection.moveCursorRight();
} }
this.clearSelection(); this.clearSelection();
}; };
ace.Editor.prototype.navigateLineStart = function() { this.navigateLineStart = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorLineStart(); this.selection.moveCursorLineStart();
}; };
ace.Editor.prototype.navigateLineEnd = function() { this.navigateLineEnd = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorLineEnd(); this.selection.moveCursorLineEnd();
}; };
ace.Editor.prototype.navigateFileEnd = function() { this.navigateFileEnd = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorFileEnd(); this.selection.moveCursorFileEnd();
}; };
ace.Editor.prototype.navigateFileStart = function() { this.navigateFileStart = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorFileStart(); this.selection.moveCursorFileStart();
}; };
ace.Editor.prototype.navigateWordRight = function() { this.navigateWordRight = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorWordRight(); this.selection.moveCursorWordRight();
}; };
ace.Editor.prototype.navigateWordLeft = function() { this.navigateWordLeft = function() {
this.clearSelection(); this.clearSelection();
this.selection.moveCursorWordLeft(); this.selection.moveCursorWordLeft();
}; };
}).call(ace.Editor.prototype);

View file

@ -1,26 +1,9 @@
ace.provide("ace.KeyBinding"); ace.provide("ace.KeyBinding");
(function() {
var keys = {
UP : 38,
RIGHT : 39,
DOWN : 40,
LEFT : 37,
PAGEUP : 33,
PAGEDOWN : 34,
POS1 : 36,
END : 35,
DELETE : 46,
BACKSPACE : 8,
TAB : 9,
A : 65,
D: 68,
L: 76,
"7": 55
};
ace.KeyBinding = function(element, editor) { ace.KeyBinding = function(element, editor) {
var keys = this.keys;
ace.addListener(element, "keydown", function(e) { ace.addListener(element, "keydown", function(e) {
var key = e.keyCode; var key = e.keyCode;
var selection = editor.getSelection(); var selection = editor.getSelection();
@ -198,4 +181,22 @@ ace.KeyBinding = function(element, editor) {
}); });
}; };
})(); (function() {
this.keys = {
UP : 38,
RIGHT : 39,
DOWN : 40,
LEFT : 37,
PAGEUP : 33,
PAGEDOWN : 34,
POS1 : 36,
END : 35,
DELETE : 46,
BACKSPACE : 8,
TAB : 9,
A : 65,
D: 68,
L: 76,
"7": 55
};
}).call(ace.KeyBinding.prototype);

View file

@ -17,24 +17,28 @@ ace.ScrollBar = function(parent) {
ace.addListener(this.element, "scroll", ace.bind(this.onScroll, this)); ace.addListener(this.element, "scroll", ace.bind(this.onScroll, this));
}; };
ace.mixin(ace.ScrollBar.prototype, ace.MEventEmitter); (function() {
ace.ScrollBar.prototype.onScroll = function() { ace.mixin(ace.ScrollBar.prototype, ace.MEventEmitter);
this.onScroll = function() {
this.$dispatchEvent("scroll", {data: this.element.scrollTop}); this.$dispatchEvent("scroll", {data: this.element.scrollTop});
}; };
ace.ScrollBar.prototype.getWidth = function() { this.getWidth = function() {
return this.width; return this.width;
}; };
ace.ScrollBar.prototype.setHeight = function(height) { this.setHeight = function(height) {
this.element.style.height = Math.max(0, height - this.width) + "px"; this.element.style.height = Math.max(0, height - this.width) + "px";
}; };
ace.ScrollBar.prototype.setInnerHeight = function(height) { this.setInnerHeight = function(height) {
this.inner.style.height = height + "px"; this.inner.style.height = height + "px";
}; };
ace.ScrollBar.prototype.setScrollTop = function(scrollTop) { this.setScrollTop = function(scrollTop) {
this.element.scrollTop = scrollTop; this.element.scrollTop = scrollTop;
}; };
}).call(ace.ScrollBar.prototype);

View file

@ -11,52 +11,55 @@ ace.Selection = function(doc) {
column: 0 column: 0
}; };
}; };
ace.mixin(ace.Selection.prototype, ace.MEventEmitter);
ace.Selection.prototype.updateCursor = function() { (function() {
ace.mixin(ace.Selection.prototype, ace.MEventEmitter);
this.updateCursor = function() {
this.$dispatchEvent("changeCursor", { data: this.getCursor() }); this.$dispatchEvent("changeCursor", { data: this.getCursor() });
}; };
ace.Selection.prototype.updateSelection = function() { this.updateSelection = function() {
this.$dispatchEvent("changeSelection", {}); this.$dispatchEvent("changeSelection", {});
}; };
ace.Selection.prototype.isEmpty = function() { this.isEmpty = function() {
return (this.selectionAnchor == null); return (this.selectionAnchor == null);
}; };
ace.Selection.prototype.isMultiLine = function() { this.isMultiLine = function() {
if (this.isEmpty()) { if (this.isEmpty()) {
return false; return false;
} }
var range = this.getRange(); var range = this.getRange();
return (range.start.row !== range.end.row); return (range.start.row !== range.end.row);
}; };
ace.Selection.prototype.getCursor = function() { this.getCursor = function() {
return this.selectionLead; return this.selectionLead;
}; };
ace.Selection.prototype.setSelectionAnchor = function(row, column) { this.setSelectionAnchor = function(row, column) {
this.clearSelection(); this.clearSelection();
this.selectionAnchor = this._clipPositionToDocument(row, column); this.selectionAnchor = this._clipPositionToDocument(row, column);
}; };
ace.Selection.prototype.getSelectionAnchor = function() { this.getSelectionAnchor = function() {
if (this.selectionAnchor) { if (this.selectionAnchor) {
return this._clone(this.selectionAnchor); return this._clone(this.selectionAnchor);
} else { } else {
return this._clone(this.selectionLead); return this._clone(this.selectionLead);
} }
}; };
ace.Selection.prototype.getSelectionLead = function() { this.getSelectionLead = function() {
return this._clone(this.selectionLead); return this._clone(this.selectionLead);
}; };
ace.Selection.prototype.shiftSelection = function(columns) { this.shiftSelection = function(columns) {
if (this.isEmpty()) { if (this.isEmpty()) {
this.moveCursorTo(this.selectionLead.row, this.selectionLead.column + columns); this.moveCursorTo(this.selectionLead.row, this.selectionLead.column + columns);
return; return;
@ -69,9 +72,9 @@ ace.Selection.prototype.shiftSelection = function(columns) {
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(lead.row, lead.column + columns); this.moveCursorTo(lead.row, lead.column + columns);
}); });
}; };
ace.Selection.prototype.getRange = function() { this.getRange = function() {
var anchor = this.selectionAnchor || this.selectionLead; var anchor = this.selectionAnchor || this.selectionLead;
var lead = this.selectionLead; var lead = this.selectionLead;
@ -88,69 +91,69 @@ ace.Selection.prototype.getRange = function() {
end : lead end : lead
}; };
} }
}; };
ace.Selection.prototype.clearSelection = function() { this.clearSelection = function() {
this.selectionAnchor = null; this.selectionAnchor = null;
this.updateSelection(); this.updateSelection();
}; };
ace.Selection.prototype.selectAll = function() { this.selectAll = function() {
var lastRow = this.doc.getLength() - 1; var lastRow = this.doc.getLength() - 1;
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length); this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(0, 0); this.moveCursorTo(0, 0);
}); });
}; };
ace.Selection.prototype._moveSelection = function(mover) { this._moveSelection = function(mover) {
if (!this.selectionAnchor) { if (!this.selectionAnchor) {
this.selectionAnchor = this._clone(this.selectionLead); this.selectionAnchor = this._clone(this.selectionLead);
} }
mover.call(this); mover.call(this);
this.updateSelection(); this.updateSelection();
}; };
ace.Selection.prototype.selectTo = function(row, column) { this.selectTo = function(row, column) {
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(row, column); this.moveCursorTo(row, column);
}); });
}; };
ace.Selection.prototype.selectToPosition = function(pos) { this.selectToPosition = function(pos) {
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorToPosition(pos); this.moveCursorToPosition(pos);
}); });
}; };
ace.Selection.prototype.selectUp = function() { this.selectUp = function() {
this._moveSelection(this.moveCursorUp); this._moveSelection(this.moveCursorUp);
}; };
ace.Selection.prototype.selectDown = function() { this.selectDown = function() {
this._moveSelection(this.moveCursorDown); this._moveSelection(this.moveCursorDown);
}; };
ace.Selection.prototype.selectRight = function() { this.selectRight = function() {
this._moveSelection(this.moveCursorRight); this._moveSelection(this.moveCursorRight);
}; };
ace.Selection.prototype.selectLeft = function() { this.selectLeft = function() {
this._moveSelection(this.moveCursorLeft); this._moveSelection(this.moveCursorLeft);
}; };
ace.Selection.prototype.selectLineStart = function() { this.selectLineStart = function() {
this._moveSelection(this.moveCursorLineStart); this._moveSelection(this.moveCursorLineStart);
}; };
ace.Selection.prototype.selectLineEnd = function() { this.selectLineEnd = function() {
this._moveSelection(this.moveCursorLineEnd); this._moveSelection(this.moveCursorLineEnd);
}; };
ace.Selection.prototype.selectPageDown = function() { this.selectPageDown = function() {
var row = this.getPageDownRow() + Math.floor(this.getVisibleRowCount() / 2); var row = this.getPageDownRow() + Math.floor(this.getVisibleRowCount() / 2);
this.scrollPageDown(); this.scrollPageDown();
@ -158,9 +161,9 @@ ace.Selection.prototype.selectPageDown = function() {
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(row, this.selectionLead.column); this.moveCursorTo(row, this.selectionLead.column);
}); });
}; };
ace.Selection.prototype.selectPageUp = function() { this.selectPageUp = function() {
var visibleRows = this.getLastVisibleRow() - this.getFirstVisibleRow(); var visibleRows = this.getLastVisibleRow() - this.getFirstVisibleRow();
var row = this.getPageUpRow() + Math.round(visibleRows / 2); var row = this.getPageUpRow() + Math.round(visibleRows / 2);
@ -169,28 +172,28 @@ ace.Selection.prototype.selectPageUp = function() {
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(row, this.selectionLead.column); this.moveCursorTo(row, this.selectionLead.column);
}); });
}; };
ace.Selection.prototype.selectFileEnd = function() { this.selectFileEnd = function() {
this._moveSelection(this.moveCursorFileEnd); this._moveSelection(this.moveCursorFileEnd);
}; };
ace.Selection.prototype.selectFileStart = function() { this.selectFileStart = function() {
this._moveSelection(this.moveCursorFileStart); this._moveSelection(this.moveCursorFileStart);
}; };
ace.Selection.prototype.tokenRe = /^[\w\d]+/g; this.tokenRe = /^[\w\d]+/g;
ace.Selection.prototype.nonTokenRe = /^[^\w\d]+/g; this.nonTokenRe = /^[^\w\d]+/g;
ace.Selection.prototype.selectWordRight = function() { this.selectWordRight = function() {
this._moveSelection(this.moveCursorWordRight); this._moveSelection(this.moveCursorWordRight);
}; };
ace.Selection.prototype.selectWordLeft = function() { this.selectWordLeft = function() {
this._moveSelection(this.moveCursorWordLeft); this._moveSelection(this.moveCursorWordLeft);
}; };
ace.Selection.prototype.selectWord = function() { this.selectWord = function() {
var cursor = this.selectionLead; var cursor = this.selectionLead;
var line = this.doc.getLine(cursor.row); var line = this.doc.getLine(cursor.row);
@ -225,24 +228,24 @@ ace.Selection.prototype.selectWord = function() {
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(cursor.row, end); this.moveCursorTo(cursor.row, end);
}); });
}; };
ace.Selection.prototype.selectLine = function() { this.selectLine = function() {
this.setSelectionAnchor(this.selectionLead.row, 0); this.setSelectionAnchor(this.selectionLead.row, 0);
this._moveSelection(function() { this._moveSelection(function() {
this.moveCursorTo(this.selectionLead.row + 1, 0); this.moveCursorTo(this.selectionLead.row + 1, 0);
}); });
}; };
ace.Selection.prototype.moveCursorUp = function() { this.moveCursorUp = function() {
this.moveCursorBy(-1, 0); this.moveCursorBy(-1, 0);
}; };
ace.Selection.prototype.moveCursorDown = function() { this.moveCursorDown = function() {
this.moveCursorBy(1, 0); this.moveCursorBy(1, 0);
}; };
ace.Selection.prototype.moveCursorLeft = function() { this.moveCursorLeft = function() {
if (this.selectionLead.column == 0) { if (this.selectionLead.column == 0) {
if (this.selectionLead.row > 0) { if (this.selectionLead.row > 0) {
this.moveCursorTo(this.selectionLead.row - 1, this.doc this.moveCursorTo(this.selectionLead.row - 1, this.doc
@ -252,9 +255,9 @@ ace.Selection.prototype.moveCursorLeft = function() {
else { else {
this.moveCursorBy(0, -1); this.moveCursorBy(0, -1);
} }
}; };
ace.Selection.prototype.moveCursorRight = function() { this.moveCursorRight = function() {
if (this.selectionLead.column == this.doc.getLine(this.selectionLead.row).length) { if (this.selectionLead.column == this.doc.getLine(this.selectionLead.row).length) {
if (this.selectionLead.row < this.doc.getLength() - 1) { if (this.selectionLead.row < this.doc.getLength() - 1) {
this.moveCursorTo(this.selectionLead.row + 1, 0); this.moveCursorTo(this.selectionLead.row + 1, 0);
@ -263,28 +266,28 @@ ace.Selection.prototype.moveCursorRight = function() {
else { else {
this.moveCursorBy(0, 1); this.moveCursorBy(0, 1);
} }
}; };
ace.Selection.prototype.moveCursorLineStart = function() { this.moveCursorLineStart = function() {
this.moveCursorTo(this.selectionLead.row, 0); this.moveCursorTo(this.selectionLead.row, 0);
}; };
ace.Selection.prototype.moveCursorLineEnd = function() { this.moveCursorLineEnd = function() {
this.moveCursorTo(this.selectionLead.row, this.moveCursorTo(this.selectionLead.row,
this.doc.getLine(this.selectionLead.row).length); this.doc.getLine(this.selectionLead.row).length);
}; };
ace.Selection.prototype.moveCursorFileEnd = function() { this.moveCursorFileEnd = function() {
var row = this.doc.getLength() - 1; var row = this.doc.getLength() - 1;
var column = this.doc.getLine(row).length; var column = this.doc.getLine(row).length;
this.moveCursorTo(row, column); this.moveCursorTo(row, column);
}; };
ace.Selection.prototype.moveCursorFileStart = function() { this.moveCursorFileStart = function() {
this.moveCursorTo(0, 0); this.moveCursorTo(0, 0);
}; };
ace.Selection.prototype.moveCursorWordRight = function() { this.moveCursorWordRight = function() {
var row = this.selectionLead.row; var row = this.selectionLead.row;
var column = this.selectionLead.column; var column = this.selectionLead.column;
var line = this.doc.getLine(row); var line = this.doc.getLine(row);
@ -308,9 +311,9 @@ ace.Selection.prototype.moveCursorWordRight = function() {
} }
this.moveCursorTo(row, column); this.moveCursorTo(row, column);
}; };
ace.Selection.prototype.moveCursorWordLeft = function() { this.moveCursorWordLeft = function() {
var row = this.selectionLead.row; var row = this.selectionLead.row;
var column = this.selectionLead.column; var column = this.selectionLead.column;
var line = this.doc.getLine(row); var line = this.doc.getLine(row);
@ -334,27 +337,27 @@ ace.Selection.prototype.moveCursorWordLeft = function() {
} }
this.moveCursorTo(row, column); this.moveCursorTo(row, column);
}; };
ace.Selection.prototype.moveCursorBy = function(rows, chars) { this.moveCursorBy = function(rows, chars) {
this.moveCursorTo(this.selectionLead.row + rows, this.selectionLead.column + chars); this.moveCursorTo(this.selectionLead.row + rows, this.selectionLead.column + chars);
}; };
ace.Selection.prototype.moveCursorToPosition = function(position) { this.moveCursorToPosition = function(position) {
this.moveCursorTo(position.row, position.column); this.moveCursorTo(position.row, position.column);
}; };
ace.Selection.prototype.moveCursorTo = function(row, column) { this.moveCursorTo = function(row, column) {
this.selectionLead = this._clipPositionToDocument(row, column); this.selectionLead = this._clipPositionToDocument(row, column);
this.updateCursor(); this.updateCursor();
}; };
ace.Selection.prototype.moveCursorUp = function() { this.moveCursorUp = function() {
this.moveCursorBy(-1, 0); this.moveCursorBy(-1, 0);
}; };
ace.Selection.prototype._clipPositionToDocument = function(row, column) { this._clipPositionToDocument = function(row, column) {
var pos = {}; var pos = {};
if (row >= this.doc.getLength()) { if (row >= this.doc.getLength()) {
@ -371,11 +374,13 @@ ace.Selection.prototype._clipPositionToDocument = function(row, column) {
Math.max(0, column)); Math.max(0, column));
} }
return pos; return pos;
}; };
ace.Selection.prototype._clone = function(pos) { this._clone = function(pos) {
return { return {
row: pos.row, row: pos.row,
column: pos.column column: pos.column
}; };
}; };
}).call(ace.Selection.prototype);

View file

@ -17,7 +17,9 @@ ace.Tokenizer = function(rules) {
} }
}; };
ace.Tokenizer.prototype.getLineTokens = function(line, startState) { (function() {
this.getLineTokens = function(line, startState) {
var currentState = startState; var currentState = startState;
var state = this.rules[currentState]; var state = this.rules[currentState];
var re = this.regExps[currentState]; var re = this.regExps[currentState];
@ -85,4 +87,6 @@ ace.Tokenizer.prototype.getLineTokens = function(line, startState) {
tokens : tokens, tokens : tokens,
state : currentState state : currentState
}; };
}; };
}).call(ace.Tokenizer.prototype);

View file

@ -38,35 +38,37 @@ ace.VirtualRenderer = function(container) {
this.onResize(); this.onResize();
}; };
ace.VirtualRenderer.prototype.setDocument = function(doc) { (function() {
this.setDocument = function(doc) {
this.lines = doc.lines; this.lines = doc.lines;
this.doc = doc; this.doc = doc;
this.markerLayer.setDocument(doc); this.markerLayer.setDocument(doc);
this.textLayer.setTabSize(doc.getTabSize()); this.textLayer.setTabSize(doc.getTabSize());
}; };
ace.VirtualRenderer.prototype.setTokenizer = function(tokenizer) { this.setTokenizer = function(tokenizer) {
this.textLayer.setTokenizer(tokenizer); this.textLayer.setTokenizer(tokenizer);
}; };
ace.VirtualRenderer.prototype.getContainerElement = function() { this.getContainerElement = function() {
return this.container; return this.container;
}; };
ace.VirtualRenderer.prototype.getMouseEventTarget = function() { this.getMouseEventTarget = function() {
return this.scroller; return this.scroller;
}; };
ace.VirtualRenderer.prototype.getFirstVisibleRow = function() { this.getFirstVisibleRow = function() {
return this.layerConfig.firstRow || 0; return this.layerConfig.firstRow || 0;
}; };
ace.VirtualRenderer.prototype.getLastVisibleRow = function() { this.getLastVisibleRow = function() {
return this.layerConfig.lastRow || 0; return this.layerConfig.lastRow || 0;
}; };
ace.VirtualRenderer.prototype.onResize = function() this.onResize = function()
{ {
var height = ace.getInnerHeight(this.container); var height = ace.getInnerHeight(this.container);
this.gutter.style.height = height + "px"; this.gutter.style.height = height + "px";
this.scroller.style.height = height + "px"; this.scroller.style.height = height + "px";
@ -82,18 +84,18 @@ ace.VirtualRenderer.prototype.onResize = function()
this.scrollToY(this.getScrollTop()); this.scrollToY(this.getScrollTop());
this.draw(); this.draw();
} }
}; };
ace.VirtualRenderer.prototype.onScroll = function(e) { this.onScroll = function(e) {
this.scrollToY(e.data); this.scrollToY(e.data);
}; };
ace.VirtualRenderer.prototype._updateScrollBar = function() { this._updateScrollBar = function() {
this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight); this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight);
this.scrollBar.setScrollTop(this.scrollTop); this.scrollBar.setScrollTop(this.scrollTop);
}; };
ace.VirtualRenderer.prototype.updateLines = function(firstRow, lastRow) { this.updateLines = function(firstRow, lastRow) {
var layerConfig = this.layerConfig; var layerConfig = this.layerConfig;
if (firstRow > layerConfig.lastRow + 1) { return; } if (firstRow > layerConfig.lastRow + 1) { return; }
@ -107,9 +109,9 @@ ace.VirtualRenderer.prototype.updateLines = function(firstRow, lastRow) {
// else update only the changed rows // else update only the changed rows
this.textLayer.updateLines(layerConfig, firstRow, lastRow); this.textLayer.updateLines(layerConfig, firstRow, lastRow);
}; };
ace.VirtualRenderer.prototype.draw = function() { this.draw = function() {
var lines = this.lines; var lines = this.lines;
var offset = this.scrollTop % this.lineHeight; var offset = this.scrollTop % this.lineHeight;
@ -145,30 +147,30 @@ ace.VirtualRenderer.prototype.draw = function() {
this.gutterLayer.update(layerConfig); this.gutterLayer.update(layerConfig);
this._updateScrollBar(); this._updateScrollBar();
}; };
ace.VirtualRenderer.prototype.addMarker = function(range, clazz, type) { this.addMarker = function(range, clazz, type) {
return this.markerLayer.addMarker(range, clazz, type); return this.markerLayer.addMarker(range, clazz, type);
}; };
ace.VirtualRenderer.prototype.removeMarker = function(markerId) { this.removeMarker = function(markerId) {
this.markerLayer.removeMarker(markerId); this.markerLayer.removeMarker(markerId);
}; };
ace.VirtualRenderer.prototype.updateCursor = function(position) { this.updateCursor = function(position) {
this.cursorLayer.setCursor(position); this.cursorLayer.setCursor(position);
this.cursorLayer.update(this.layerConfig); this.cursorLayer.update(this.layerConfig);
}; };
ace.VirtualRenderer.prototype.hideCursor = function() { this.hideCursor = function() {
this.cursorLayer.hideCursor(); this.cursorLayer.hideCursor();
}; };
ace.VirtualRenderer.prototype.showCursor = function() { this.showCursor = function() {
this.cursorLayer.showCursor(); this.cursorLayer.showCursor();
}; };
ace.VirtualRenderer.prototype.scrollCursorIntoView = function() { this.scrollCursorIntoView = function() {
var pos = this.cursorLayer.getPixelPosition(); var pos = this.cursorLayer.getPixelPosition();
var left = pos.left; var left = pos.left;
@ -192,21 +194,21 @@ ace.VirtualRenderer.prototype.scrollCursorIntoView = function() {
this.scroller.scrollLeft = Math.round(left + this.characterWidth this.scroller.scrollLeft = Math.round(left + this.characterWidth
- this.scroller.clientWidth); - this.scroller.clientWidth);
} }
}, },
ace.VirtualRenderer.prototype.getScrollTop = function() { this.getScrollTop = function() {
return this.scrollTop; return this.scrollTop;
}; };
ace.VirtualRenderer.prototype.getScrollTopRow = function() { this.getScrollTopRow = function() {
return this.scrollTop / this.lineHeight; return this.scrollTop / this.lineHeight;
}; };
ace.VirtualRenderer.prototype.scrollToRow = function(row) { this.scrollToRow = function(row) {
this.scrollToY(row * this.lineHeight); this.scrollToY(row * this.lineHeight);
}; };
ace.VirtualRenderer.prototype.scrollToY = function(scrollTop) { this.scrollToY = function(scrollTop) {
var maxHeight = this.lines.length * this.lineHeight var maxHeight = this.lines.length * this.lineHeight
- this.scroller.clientHeight; - this.scroller.clientHeight;
var scrollTop = Math.max(0, Math.min(maxHeight, scrollTop)); var scrollTop = Math.max(0, Math.min(maxHeight, scrollTop));
@ -216,9 +218,9 @@ ace.VirtualRenderer.prototype.scrollToY = function(scrollTop) {
this._updateScrollBar(); this._updateScrollBar();
this.draw(); this.draw();
} }
}; };
ace.VirtualRenderer.prototype.screenToTextCoordinates = function(pageX, pageY) { this.screenToTextCoordinates = function(pageX, pageY) {
var canvasPos = this.scroller.getBoundingClientRect(); var canvasPos = this.scroller.getBoundingClientRect();
var col = Math.floor((pageX + this.scroller.scrollLeft - canvasPos.left) var col = Math.floor((pageX + this.scroller.scrollLeft - canvasPos.left)
@ -230,21 +232,23 @@ ace.VirtualRenderer.prototype.screenToTextCoordinates = function(pageX, pageY) {
row : row, row : row,
column : col column : col
}; };
}; };
ace.VirtualRenderer.prototype.visualizeFocus = function() { this.visualizeFocus = function() {
ace.addCssClass(this.container, "focus"); ace.addCssClass(this.container, "focus");
}; };
ace.VirtualRenderer.prototype.visualizeBlur = function() { this.visualizeBlur = function() {
ace.removeCssClass(this.container, "focus"); ace.removeCssClass(this.container, "focus");
}; };
ace.VirtualRenderer.prototype.showComposition = function(position) { this.showComposition = function(position) {
}; };
ace.VirtualRenderer.prototype.setCompositionText = function(text) { this.setCompositionText = function(text) {
}; };
ace.VirtualRenderer.prototype.hideComposition = function() { this.hideComposition = function() {
}; };
}).call(ace.VirtualRenderer.prototype);

View file

@ -11,31 +11,33 @@ ace.layer.Cursor = function(parentEl) {
this.isVisible = false; this.isVisible = false;
}; };
ace.layer.Cursor.prototype.setCursor = function(position) { (function() {
this.setCursor = function(position) {
this.position = { this.position = {
row : position.row, row : position.row,
column : position.column column : position.column
}; };
}; };
ace.layer.Cursor.prototype.hideCursor = function() { this.hideCursor = function() {
this.isVisible = false; this.isVisible = false;
if (this.cursor.parentNode) { if (this.cursor.parentNode) {
this.cursor.parentNode.removeChild(this.cursor); this.cursor.parentNode.removeChild(this.cursor);
} }
clearInterval(this.blinkId); clearInterval(this.blinkId);
}; };
ace.layer.Cursor.prototype.showCursor = function() { this.showCursor = function() {
this.isVisible = true; this.isVisible = true;
this.element.appendChild(this.cursor); this.element.appendChild(this.cursor);
var cursor = this.cursor; var cursor = this.cursor;
cursor.style.visibility = "visible"; cursor.style.visibility = "visible";
this.restartTimer(); this.restartTimer();
}; };
ace.layer.Cursor.prototype.restartTimer = function() { this.restartTimer = function() {
clearInterval(this.blinkId); clearInterval(this.blinkId);
if (!this.isVisible) { if (!this.isVisible) {
return; return;
@ -48,16 +50,16 @@ ace.layer.Cursor.prototype.restartTimer = function() {
cursor.style.visibility = "visible"; cursor.style.visibility = "visible";
}, 400); }, 400);
}, 1000); }, 1000);
}; };
ace.layer.Cursor.prototype.getPixelPosition = function() { this.getPixelPosition = function() {
return this.pixelPos || { return this.pixelPos || {
left : 0, left : 0,
top : 0 top : 0
}; };
}; };
ace.layer.Cursor.prototype.update = function(config) { this.update = function(config) {
if (!this.position) if (!this.position)
return; return;
@ -78,4 +80,6 @@ ace.layer.Cursor.prototype.update = function(config) {
this.element.appendChild(this.cursor); this.element.appendChild(this.cursor);
} }
this.restartTimer(); this.restartTimer();
}; };
}).call(ace.layer.Cursor.prototype);

View file

@ -6,7 +6,9 @@ ace.layer.Gutter = function(parentEl) {
parentEl.appendChild(this.element); parentEl.appendChild(this.element);
}; };
ace.layer.Gutter.prototype.update = function(config) { (function() {
this.update = function(config) {
var html = []; var html = [];
for ( var i = config.firstRow; i <= config.lastRow; i++) { for ( var i = config.firstRow; i <= config.lastRow; i++) {
html.push("<div class='gutter-cell' style='height:" + config.lineHeight html.push("<div class='gutter-cell' style='height:" + config.lineHeight
@ -15,4 +17,6 @@ ace.layer.Gutter.prototype.update = function(config) {
} }
this.element.innerHTML = html.join(""); this.element.innerHTML = html.join("");
}; };
}).call(ace.layer.Gutter.prototype);

View file

@ -9,11 +9,13 @@ ace.layer.Marker = function(parentEl) {
this._markerId = 1; this._markerId = 1;
}; };
ace.layer.Marker.prototype.setDocument = function(doc) { (function() {
this.doc = doc;
};
ace.layer.Marker.prototype.addMarker = function(range, clazz, type) { this.setDocument = function(doc) {
this.doc = doc;
};
this.addMarker = function(range, clazz, type) {
var id = this._markerId++; var id = this._markerId++;
this.markers[id] = { this.markers[id] = {
range : range, range : range,
@ -23,17 +25,17 @@ ace.layer.Marker.prototype.addMarker = function(range, clazz, type) {
this.update(); this.update();
return id; return id;
}; };
ace.layer.Marker.prototype.removeMarker = function(markerId) { this.removeMarker = function(markerId) {
var marker = this.markers[markerId]; var marker = this.markers[markerId];
if (marker) { if (marker) {
delete (this.markers[markerId]); delete (this.markers[markerId]);
this.update(); this.update();
} }
}; };
ace.layer.Marker.prototype.update = function(config) { this.update = function(config) {
var config = config || this.config; var config = config || this.config;
if (!config) if (!config)
return; return;
@ -78,9 +80,9 @@ ace.layer.Marker.prototype.update = function(config) {
} }
} }
this.element.innerHTML = html.join(""); this.element.innerHTML = html.join("");
}; };
ace.layer.Marker.prototype.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) { this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
// selection start // selection start
var row = range.start.row; var row = range.start.row;
@ -106,9 +108,9 @@ ace.layer.Marker.prototype.drawTextMarker = function(stringBuilder, range, clazz
lineRange.end.column = this.doc.getLine(row).length; lineRange.end.column = this.doc.getLine(row).length;
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig); this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig);
} }
}; };
ace.layer.Marker.prototype.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig) { this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig) {
var height = layerConfig.lineHeight; var height = layerConfig.lineHeight;
var width = Math.round(layerConfig.width - (range.start.column * layerConfig.characterWidth)); var width = Math.round(layerConfig.width - (range.start.column * layerConfig.characterWidth));
@ -142,9 +144,9 @@ ace.layer.Marker.prototype.drawMultiLineMarker = function(stringBuilder, range,
"top:", top, "px;'></div>" "top:", top, "px;'></div>"
); );
} }
}; };
ace.layer.Marker.prototype.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig) { this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig) {
var height = layerConfig.lineHeight; var height = layerConfig.lineHeight;
var width = Math.round((range.end.column - range.start.column) * layerConfig.characterWidth); var width = Math.round((range.end.column - range.start.column) * layerConfig.characterWidth);
@ -158,4 +160,6 @@ ace.layer.Marker.prototype.drawSingleLineMarker = function(stringBuilder, range,
"top:", top, "px;", "top:", top, "px;",
"left:", left,"px;'></div>" "left:", left,"px;'></div>"
); );
}; };
}).call(ace.layer.Marker.prototype);

View file

@ -9,19 +9,21 @@ ace.layer.Text = function(parentEl) {
this._tabString = " "; this._tabString = " ";
}; };
ace.layer.Text.prototype.setTokenizer = function(tokenizer) { (function() {
this.setTokenizer = function(tokenizer) {
this.tokenizer = tokenizer; this.tokenizer = tokenizer;
}; };
ace.layer.Text.prototype.getLineHeight = function() { this.getLineHeight = function() {
return this.lineHeight; return this.lineHeight;
}; };
ace.layer.Text.prototype.getCharacterWidth = function() { this.getCharacterWidth = function() {
return this.characterWidth; return this.characterWidth;
}; };
ace.layer.Text.prototype._measureSizes = function() { this._measureSizes = function() {
var measureNode = document.createElement("div"); var measureNode = document.createElement("div");
var style = measureNode.style; var style = measureNode.style;
style.width = style.height = "auto"; style.width = style.height = "auto";
@ -40,13 +42,13 @@ ace.layer.Text.prototype._measureSizes = function() {
this.characterWidth = measureNode.offsetWidth / 2000; this.characterWidth = measureNode.offsetWidth / 2000;
this.element.removeChild(measureNode); this.element.removeChild(measureNode);
}; };
ace.layer.Text.prototype.setTabSize = function(tabSize) { this.setTabSize = function(tabSize) {
this._tabString = new Array(tabSize+1).join("&nbsp;"); this._tabString = new Array(tabSize+1).join("&nbsp;");
}; };
ace.layer.Text.prototype.updateLines = function(layerConfig, firstRow, lastRow) { this.updateLines = function(layerConfig, firstRow, lastRow) {
var first = Math.max(firstRow, layerConfig.firstRow); var first = Math.max(firstRow, layerConfig.firstRow);
var last = Math.min(lastRow, layerConfig.lastRow); var last = Math.min(lastRow, layerConfig.lastRow);
@ -59,9 +61,9 @@ ace.layer.Text.prototype.updateLines = function(layerConfig, firstRow, lastRow)
var lineElement = lineElements[i - layerConfig.firstRow]; var lineElement = lineElements[i - layerConfig.firstRow];
lineElement.innerHTML = html.join(""); lineElement.innerHTML = html.join("");
}; };
}; };
ace.layer.Text.prototype.update = function(config) { this.update = function(config) {
var html = []; var html = [];
for ( var i = config.firstRow; i <= config.lastRow; i++) { for ( var i = config.firstRow; i <= config.lastRow; i++) {
html.push("<div class='line' style='height:" + this.lineHeight + "px;", "width:", html.push("<div class='line' style='height:" + this.lineHeight + "px;", "width:",
@ -70,9 +72,9 @@ ace.layer.Text.prototype.update = function(config) {
} }
this.element.innerHTML = html.join(""); this.element.innerHTML = html.join("");
}; };
ace.layer.Text.prototype.renderLine = function(stringBuilder, row) { this.renderLine = function(stringBuilder, row) {
var tokens = this.tokenizer.getTokens(row); var tokens = this.tokenizer.getTokens(row);
for ( var i = 0; i < tokens.length; i++) { for ( var i = 0; i < tokens.length; i++) {
var token = tokens[i]; var token = tokens[i];
@ -80,6 +82,7 @@ ace.layer.Text.prototype.renderLine = function(stringBuilder, row) {
var output = token.value var output = token.value
.replace(/&/g, "&amp;") .replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
//.replace(/\t/g, "&#x2023; ")
.replace(/\t/g, this._tabString) .replace(/\t/g, this._tabString)
.replace(/\s/g, "&nbsp;"); .replace(/\s/g, "&nbsp;");
@ -91,4 +94,8 @@ ace.layer.Text.prototype.renderLine = function(stringBuilder, row) {
stringBuilder.push(output); stringBuilder.push(output);
} }
}; };
}; // TODO: show invisibles
//stringBuilder.push("&para;");
};
}).call(ace.layer.Text.prototype);

View file

@ -5,7 +5,9 @@ ace.mode.Css = function() {
}; };
ace.inherits(ace.mode.Css, ace.mode.Text); ace.inherits(ace.mode.Css, ace.mode.Text);
ace.mode.Css.prototype.getNextLineIndent = function(line, state, tab) { (function() {
this.getNextLineIndent = function(line, state, tab) {
var indent = this.$getIndent(line); var indent = this.$getIndent(line);
// ignore braces in comments // ignore braces in comments
@ -20,4 +22,6 @@ ace.mode.Css.prototype.getNextLineIndent = function(line, state, tab) {
} }
return indent; return indent;
}; };
}).call(ace.mode.Css.prototype);

View file

@ -175,6 +175,10 @@ ace.mode.CssHighlightRules = function() {
}; };
}; };
ace.mode.CssHighlightRules.prototype.getRules = function() { (function() {
this.getRules = function() {
return this._rules; return this._rules;
}; };
}).call(ace.mode.CssHighlightRules.prototype);

View file

@ -8,7 +8,9 @@ ace.mode.Html = function() {
}; };
ace.inherits(ace.mode.Html, ace.mode.Text); ace.inherits(ace.mode.Html, ace.mode.Text);
ace.mode.Html.prototype.toggleCommentLines = function(doc, range, state) { (function() {
this.toggleCommentLines = function(doc, range, state) {
var split = state.split("js-"); var split = state.split("js-");
if (!split[0] && split[1]) { if (!split[0] && split[1]) {
return this._js.toggleCommentLines(doc, range, state); return this._js.toggleCommentLines(doc, range, state);
@ -20,9 +22,9 @@ ace.mode.Html.prototype.toggleCommentLines = function(doc, range, state) {
} }
return 0; return 0;
}; };
ace.mode.Html.prototype.getNextLineIndent = function(line, state, tab) { this.getNextLineIndent = function(line, state, tab) {
var split = state.split("js-"); var split = state.split("js-");
if (!split[0] && split[1]) { if (!split[0] && split[1]) {
return this._js.getNextLineIndent(line, split[1], tab); return this._js.getNextLineIndent(line, split[1], tab);
@ -34,4 +36,6 @@ ace.mode.Html.prototype.getNextLineIndent = function(line, state, tab) {
} }
return ""; return "";
}; };
}).call(ace.mode.Html.prototype);

View file

@ -130,8 +130,9 @@ ace.mode.HtmlHighlightRules = function() {
}); });
}; };
(function() {
ace.mode.HtmlHighlightRules.prototype._addRules = function(rules, prefix) { this._addRules = function(rules, prefix) {
for (var key in rules) { for (var key in rules) {
var state = rules[key]; var state = rules[key];
for (var i=0; i<state.length; i++) { for (var i=0; i<state.length; i++) {
@ -142,8 +143,10 @@ ace.mode.HtmlHighlightRules.prototype._addRules = function(rules, prefix) {
} }
this._rules[prefix + key] = state; this._rules[prefix + key] = state;
} }
}; };
ace.mode.HtmlHighlightRules.prototype.getRules = function() { this.getRules = function() {
return this._rules; return this._rules;
}; };
}).call(ace.mode.HtmlHighlightRules.prototype);

View file

@ -5,15 +5,17 @@ ace.mode.JavaScript = function() {
}; };
ace.inherits(ace.mode.JavaScript, ace.mode.Text); ace.inherits(ace.mode.JavaScript, ace.mode.Text);
ace.mode.JavaScript.prototype.toggleCommentLines = function(doc, range, state) { (function() {
this.toggleCommentLines = function(doc, range, state) {
var addedRows = doc.outdentRows(range, "//"); var addedRows = doc.outdentRows(range, "//");
if (addedRows == 0) { if (addedRows == 0) {
var addedRows = doc.indentRows(range, "//"); var addedRows = doc.indentRows(range, "//");
}; };
return addedRows; return addedRows;
}; };
ace.mode.JavaScript.prototype.getNextLineIndent = function(line, state, tab) { this.getNextLineIndent = function(line, state, tab) {
var indent = this.$getIndent(line); var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state); var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
@ -43,4 +45,6 @@ ace.mode.JavaScript.prototype.getNextLineIndent = function(line, state, tab) {
} }
return indent; return indent;
}; };
}).call(ace.mode.JavaScript.prototype);

View file

@ -127,6 +127,10 @@ ace.mode.JavaScriptHighlightRules = function() {
}; };
}; };
ace.mode.JavaScriptHighlightRules.prototype.getRules = function() { (function() {
this.getRules = function() {
return this._rules; return this._rules;
}; };
}).call(ace.mode.JavaScriptHighlightRules.prototype);

View file

@ -10,23 +10,27 @@ ace.mode.Text = function() {
this.$tokenizer = new ace.Tokenizer(rules); this.$tokenizer = new ace.Tokenizer(rules);
}; };
ace.mode.Text.prototype.getTokenizer = function() { (function() {
this.getTokenizer = function() {
return this.$tokenizer; return this.$tokenizer;
}; };
ace.mode.Text.prototype.toggleCommentLines = function(doc, range, state) { this.toggleCommentLines = function(doc, range, state) {
return 0; return 0;
}; };
ace.mode.Text.prototype.getNextLineIndent = function(line, state, tab) { this.getNextLineIndent = function(line, state, tab) {
return ""; return "";
}; };
ace.mode.Text.prototype.$getIndent = function(line) { this.$getIndent = function(line) {
var match = line.match(/^(\s+)/); var match = line.match(/^(\s+)/);
if (match) { if (match) {
return match[1]; return match[1];
} }
return ""; return "";
}; };
}).call(ace.mode.Text.prototype);

View file

@ -70,6 +70,10 @@ ace.mode.XmlHighlightRules = function() {
}; };
}; };
ace.mode.XmlHighlightRules.prototype.getRules = function() { (function() {
this.getRules = function() {
return this._rules; return this._rules;
}; };
}).call(ace.mode.XmlHighlightRules.prototype);