rename TextDocument to document

This commit is contained in:
Fabian Jakobs 2010-04-20 17:16:46 +02:00
commit 231d5e78de
12 changed files with 87 additions and 87 deletions

View file

@ -1,6 +1,6 @@
ace.provide("ace.TextDocument");
ace.provide("ace.Document");
ace.TextDocument = function(text, mode) {
ace.Document = function(text, mode) {
this.$initEvents();
this.lines = this._split(text);
@ -13,21 +13,21 @@ ace.TextDocument = function(text, mode) {
}
};
ace.mixin(ace.TextDocument.prototype, ace.MEventEmitter);
ace.mixin(ace.Document.prototype, ace.MEventEmitter);
ace.TextDocument.prototype._split = function(text) {
ace.Document.prototype._split = function(text) {
return text.split(/\r\n|\r|\n/);
};
ace.TextDocument.prototype.toString = function() {
ace.Document.prototype.toString = function() {
return this.lines.join("\n");
};
ace.TextDocument.prototype.getSelection = function() {
ace.Document.prototype.getSelection = function() {
return this.selection;
};
ace.TextDocument.prototype.fireChangeEvent = function(firstRow, lastRow) {
ace.Document.prototype.fireChangeEvent = function(firstRow, lastRow) {
var data = {
firstRow: firstRow,
lastRow: lastRow
@ -35,52 +35,52 @@ ace.TextDocument.prototype.fireChangeEvent = function(firstRow, lastRow) {
this.$dispatchEvent("change", { data: data});
};
ace.TextDocument.prototype.getTabString = function() {
ace.Document.prototype.getTabString = function() {
if (this.getUseSoftTabs()) {
return new Array(this.getTabSize()+1).join(" ");
}
return "\t";
};
ace.TextDocument.prototype._useSoftTabs = true;
ace.TextDocument.prototype.setUseSoftTabs = function(useSoftTabs) {
ace.Document.prototype._useSoftTabs = true;
ace.Document.prototype.setUseSoftTabs = function(useSoftTabs) {
if (this._useSoftTabs === useSoftTabs) return;
this._useSoftTabs = useSoftTabs;
};
ace.TextDocument.prototype.getUseSoftTabs = function() {
ace.Document.prototype.getUseSoftTabs = function() {
return this._useSoftTabs;
};
ace.TextDocument.prototype._tabSize = 4;
ace.TextDocument.prototype.setTabSize = function(tabSize) {
ace.Document.prototype._tabSize = 4;
ace.Document.prototype.setTabSize = function(tabSize) {
if (this._tabSize === tabSize) return;
this._tabSize = tabSize;
this.$dispatchEvent("changeTabSize");
};
ace.TextDocument.prototype.getTabSize = function() {
ace.Document.prototype.getTabSize = function() {
return this._tabSize;
};
ace.TextDocument.prototype._mode = null;
ace.TextDocument.prototype.setMode = function(mode) {
ace.Document.prototype._mode = null;
ace.Document.prototype.setMode = function(mode) {
if (this._mode === mode) return;
this._mode = mode;
this.$dispatchEvent("changeMode");
};
ace.TextDocument.prototype.getMode = function() {
ace.Document.prototype.getMode = function() {
if (!this._mode) {
this._mode = new ace.mode.Text();
}
return this._mode;
};
ace.TextDocument.prototype.getWidth = function() {
ace.Document.prototype.getWidth = function() {
if (this.modified) {
this.modified = false;
@ -94,15 +94,15 @@ ace.TextDocument.prototype.getWidth = function() {
return this.width;
};
ace.TextDocument.prototype.getLine = function(row) {
ace.Document.prototype.getLine = function(row) {
return this.lines[row] || "";
};
ace.TextDocument.prototype.getLength = function() {
ace.Document.prototype.getLength = function() {
return this.lines.length;
};
ace.TextDocument.prototype.getTextRange = function(range) {
ace.Document.prototype.getTextRange = function(range) {
if (range.start.row == range.end.row) {
return this.lines[range.start.row].substring(range.start.column,
range.end.column);
@ -116,11 +116,11 @@ ace.TextDocument.prototype.getTextRange = function(range) {
}
};
ace.TextDocument.prototype.getLines = function(firstRow, lastRow) {
ace.Document.prototype.getLines = function(firstRow, lastRow) {
return this.lines.slice(firstRow, lastRow+1);
};
ace.TextDocument.prototype.findMatchingBracket = function(position) {
ace.Document.prototype.findMatchingBracket = function(position) {
if (position.column == 0) return null;
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
@ -138,7 +138,7 @@ ace.TextDocument.prototype.findMatchingBracket = function(position) {
}
};
ace.TextDocument.prototype._brackets = {
ace.Document.prototype._brackets = {
")": "(",
"(": ")",
"]": "[",
@ -147,7 +147,7 @@ ace.TextDocument.prototype._brackets = {
"}": "{"
};
ace.TextDocument.prototype._findOpeningBracket = function(bracket, position) {
ace.Document.prototype._findOpeningBracket = function(bracket, position) {
var openBracket = this._brackets[bracket];
var column = position.column - 2;
@ -179,7 +179,7 @@ ace.TextDocument.prototype._findOpeningBracket = function(bracket, position) {
return null;
};
ace.TextDocument.prototype._findClosingBracket = function(bracket, position) {
ace.Document.prototype._findClosingBracket = function(bracket, position) {
var closingBracket = this._brackets[bracket];
var column = position.column;
@ -212,20 +212,20 @@ ace.TextDocument.prototype._findClosingBracket = function(bracket, position) {
return null;
};
ace.TextDocument.prototype.insert = function(position, text) {
ace.Document.prototype.insert = function(position, text) {
var end = this._insert(position, text);
this.fireChangeEvent(position.row, position.row == end.row ? position.row
: undefined);
return end;
};
ace.TextDocument.prototype._insertLines = function(row, lines) {
ace.Document.prototype._insertLines = function(row, lines) {
var args = [row, 0];
args.push.apply(args, lines);
this.lines.splice.apply(this.lines, args);
},
ace.TextDocument.prototype._insert = function(position, text) {
ace.Document.prototype._insert = function(position, text) {
this.modified = true;
var newLines = this._split(text);
@ -269,11 +269,11 @@ ace.TextDocument.prototype._insert = function(position, text) {
}
};
ace.TextDocument.prototype._isNewLine = function(text) {
ace.Document.prototype._isNewLine = function(text) {
return (text == "\r\n" || text == "\r" || text == "\n");
};
ace.TextDocument.prototype.remove = function(range) {
ace.Document.prototype.remove = function(range) {
this._remove(range);
this.fireChangeEvent(range.start.row,
@ -282,7 +282,7 @@ ace.TextDocument.prototype.remove = function(range) {
return range.start;
};
ace.TextDocument.prototype._remove = function(range) {
ace.Document.prototype._remove = function(range) {
this.modified = true;
var firstRow = range.start.row;
@ -296,7 +296,7 @@ ace.TextDocument.prototype._remove = function(range) {
return range.start;
};
ace.TextDocument.prototype.replace = function(range, text) {
ace.Document.prototype.replace = function(range, text) {
this._remove(range);
if (text) {
var end = this._insert(range.start, text);
@ -313,7 +313,7 @@ ace.TextDocument.prototype.replace = function(range, text) {
return end;
};
ace.TextDocument.prototype.indentRows = function(range, indentString) {
ace.Document.prototype.indentRows = function(range, indentString) {
for (var i=range.start.row; i<= range.end.row; i++) {
this.lines[i] = indentString + this.getLine(i);
}
@ -321,7 +321,7 @@ ace.TextDocument.prototype.indentRows = function(range, indentString) {
return indentString.length;
};
ace.TextDocument.prototype.outdentRows = function(range, indentString) {
ace.Document.prototype.outdentRows = function(range, indentString) {
outdentLength = indentString.length;
for (var i=range.start.row; i<= range.end.row; i++) {
@ -338,7 +338,7 @@ ace.TextDocument.prototype.outdentRows = function(range, indentString) {
return -outdentLength;
};
ace.TextDocument.prototype.moveLinesUp = function(firstRow, lastRow) {
ace.Document.prototype.moveLinesUp = function(firstRow, lastRow) {
if (firstRow <= 0) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
@ -348,7 +348,7 @@ ace.TextDocument.prototype.moveLinesUp = function(firstRow, lastRow) {
return -1;
};
ace.TextDocument.prototype.moveLinesDown = function(firstRow, lastRow) {
ace.Document.prototype.moveLinesDown = function(firstRow, lastRow) {
if (lastRow >= this.lines.length-1) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
@ -358,7 +358,7 @@ ace.TextDocument.prototype.moveLinesDown = function(firstRow, lastRow) {
return 1;
};
ace.TextDocument.prototype.duplicateLines = function(firstRow, lastRow) {
ace.Document.prototype.duplicateLines = function(firstRow, lastRow) {
var firstRow = this._clipRowToDocument(firstRow);
var lastRow = this._clipRowToDocument(lastRow);
@ -371,7 +371,7 @@ ace.TextDocument.prototype.duplicateLines = function(firstRow, lastRow) {
return addedRows;
};
ace.TextDocument.prototype._clipRowToDocument = function(row) {
ace.Document.prototype._clipRowToDocument = function(row) {
return Math.max(0, Math.min(row, this.lines.length-1));
};

View file

@ -23,7 +23,7 @@ ace.Editor = function(renderer, doc) {
this._highlightLineMarker = null;
this._blockScrolling = false;
this.setDocument(doc || new ace.TextDocument(""));
this.setDocument(doc || new ace.Document(""));
};