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

@ -53,7 +53,7 @@
<script src="../src/mode/XmlHighlightRules.js" type="text/javascript" charset="utf-8"></script> <script src="../src/mode/XmlHighlightRules.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/MEventEmitter.js" type="text/javascript" charset="utf-8"></script> <script src="../src/MEventEmitter.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/Selection.js" type="text/javascript" charset="utf-8"></script> <script src="../src/Selection.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/TextDocument.js" type="text/javascript" charset="utf-8"></script> <script src="../src/Document.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/Tokenizer.js" type="text/javascript" charset="utf-8"></script> <script src="../src/Tokenizer.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/BackgroundTokenizer.js" type="text/javascript" charset="utf-8"></script> <script src="../src/BackgroundTokenizer.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/layer/Cursor.js" type="text/javascript" charset="utf-8"></script> <script src="../src/layer/Cursor.js" type="text/javascript" charset="utf-8"></script>
@ -140,11 +140,11 @@
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
var docs = {} var docs = {}
docs.js = new ace.TextDocument(document.getElementById("jstext").innerHTML); docs.js = new ace.Document(document.getElementById("jstext").innerHTML);
docs.js.setMode(new ace.mode.JavaScript()); docs.js.setMode(new ace.mode.JavaScript());
docs.css = new ace.TextDocument(document.getElementById("csstext").innerHTML); docs.css = new ace.Document(document.getElementById("csstext").innerHTML);
docs.css.setMode(new ace.mode.Css()); docs.css.setMode(new ace.mode.Css());
docs.html = new ace.TextDocument(document.getElementById("htmltext").innerHTML); docs.html = new ace.Document(document.getElementById("htmltext").innerHTML);
docs.html.setMode(new ace.mode.Html()); docs.html.setMode(new ace.mode.Html());
var docEl = document.getElementById("doc"); var docEl = document.getElementById("doc");

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.$initEvents();
this.lines = this._split(text); 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/); return text.split(/\r\n|\r|\n/);
}; };
ace.TextDocument.prototype.toString = function() { ace.Document.prototype.toString = function() {
return this.lines.join("\n"); return this.lines.join("\n");
}; };
ace.TextDocument.prototype.getSelection = function() { ace.Document.prototype.getSelection = function() {
return this.selection; return this.selection;
}; };
ace.TextDocument.prototype.fireChangeEvent = function(firstRow, lastRow) { ace.Document.prototype.fireChangeEvent = function(firstRow, lastRow) {
var data = { var data = {
firstRow: firstRow, firstRow: firstRow,
lastRow: lastRow lastRow: lastRow
@ -35,52 +35,52 @@ ace.TextDocument.prototype.fireChangeEvent = function(firstRow, lastRow) {
this.$dispatchEvent("change", { data: data}); this.$dispatchEvent("change", { data: data});
}; };
ace.TextDocument.prototype.getTabString = function() { ace.Document.prototype.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.TextDocument.prototype._useSoftTabs = true; ace.Document.prototype._useSoftTabs = true;
ace.TextDocument.prototype.setUseSoftTabs = function(useSoftTabs) { ace.Document.prototype.setUseSoftTabs = function(useSoftTabs) {
if (this._useSoftTabs === useSoftTabs) return; if (this._useSoftTabs === useSoftTabs) return;
this._useSoftTabs = useSoftTabs; this._useSoftTabs = useSoftTabs;
}; };
ace.TextDocument.prototype.getUseSoftTabs = function() { ace.Document.prototype.getUseSoftTabs = function() {
return this._useSoftTabs; return this._useSoftTabs;
}; };
ace.TextDocument.prototype._tabSize = 4; ace.Document.prototype._tabSize = 4;
ace.TextDocument.prototype.setTabSize = function(tabSize) { ace.Document.prototype.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.TextDocument.prototype.getTabSize = function() { ace.Document.prototype.getTabSize = function() {
return this._tabSize; return this._tabSize;
}; };
ace.TextDocument.prototype._mode = null; ace.Document.prototype._mode = null;
ace.TextDocument.prototype.setMode = function(mode) { ace.Document.prototype.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.TextDocument.prototype.getMode = function() { ace.Document.prototype.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.TextDocument.prototype.getWidth = function() { ace.Document.prototype.getWidth = function() {
if (this.modified) { if (this.modified) {
this.modified = false; this.modified = false;
@ -94,15 +94,15 @@ ace.TextDocument.prototype.getWidth = function() {
return this.width; return this.width;
}; };
ace.TextDocument.prototype.getLine = function(row) { ace.Document.prototype.getLine = function(row) {
return this.lines[row] || ""; return this.lines[row] || "";
}; };
ace.TextDocument.prototype.getLength = function() { ace.Document.prototype.getLength = function() {
return this.lines.length; return this.lines.length;
}; };
ace.TextDocument.prototype.getTextRange = function(range) { ace.Document.prototype.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);
@ -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); 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; 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);
@ -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 openBracket = this._brackets[bracket];
var column = position.column - 2; var column = position.column - 2;
@ -179,7 +179,7 @@ ace.TextDocument.prototype._findOpeningBracket = function(bracket, position) {
return null; return null;
}; };
ace.TextDocument.prototype._findClosingBracket = function(bracket, position) { ace.Document.prototype._findClosingBracket = function(bracket, position) {
var closingBracket = this._brackets[bracket]; var closingBracket = this._brackets[bracket];
var column = position.column; var column = position.column;
@ -212,20 +212,20 @@ ace.TextDocument.prototype._findClosingBracket = function(bracket, position) {
return null; return null;
}; };
ace.TextDocument.prototype.insert = function(position, text) { ace.Document.prototype.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.TextDocument.prototype._insertLines = function(row, lines) { ace.Document.prototype._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.TextDocument.prototype._insert = function(position, text) { ace.Document.prototype._insert = function(position, text) {
this.modified = true; this.modified = true;
var newLines = this._split(text); 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"); return (text == "\r\n" || text == "\r" || text == "\n");
}; };
ace.TextDocument.prototype.remove = function(range) { ace.Document.prototype.remove = function(range) {
this._remove(range); this._remove(range);
this.fireChangeEvent(range.start.row, this.fireChangeEvent(range.start.row,
@ -282,7 +282,7 @@ ace.TextDocument.prototype.remove = function(range) {
return range.start; return range.start;
}; };
ace.TextDocument.prototype._remove = function(range) { ace.Document.prototype._remove = function(range) {
this.modified = true; this.modified = true;
var firstRow = range.start.row; var firstRow = range.start.row;
@ -296,7 +296,7 @@ ace.TextDocument.prototype._remove = function(range) {
return range.start; return range.start;
}; };
ace.TextDocument.prototype.replace = function(range, text) { ace.Document.prototype.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);
@ -313,7 +313,7 @@ ace.TextDocument.prototype.replace = function(range, text) {
return end; 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++) { 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);
} }
@ -321,7 +321,7 @@ ace.TextDocument.prototype.indentRows = function(range, indentString) {
return indentString.length; return indentString.length;
}; };
ace.TextDocument.prototype.outdentRows = function(range, indentString) { ace.Document.prototype.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++) {
@ -338,7 +338,7 @@ ace.TextDocument.prototype.outdentRows = function(range, indentString) {
return -outdentLength; return -outdentLength;
}; };
ace.TextDocument.prototype.moveLinesUp = function(firstRow, lastRow) { ace.Document.prototype.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);
@ -348,7 +348,7 @@ ace.TextDocument.prototype.moveLinesUp = function(firstRow, lastRow) {
return -1; return -1;
}; };
ace.TextDocument.prototype.moveLinesDown = function(firstRow, lastRow) { ace.Document.prototype.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);
@ -358,7 +358,7 @@ ace.TextDocument.prototype.moveLinesDown = function(firstRow, lastRow) {
return 1; return 1;
}; };
ace.TextDocument.prototype.duplicateLines = function(firstRow, lastRow) { ace.Document.prototype.duplicateLines = function(firstRow, lastRow) {
var firstRow = this._clipRowToDocument(firstRow); var firstRow = this._clipRowToDocument(firstRow);
var lastRow = this._clipRowToDocument(lastRow); var lastRow = this._clipRowToDocument(lastRow);
@ -371,7 +371,7 @@ ace.TextDocument.prototype.duplicateLines = function(firstRow, lastRow) {
return addedRows; 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)); 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._highlightLineMarker = null;
this._blockScrolling = false; this._blockScrolling = false;
this.setDocument(doc || new ace.TextDocument("")); this.setDocument(doc || new ace.Document(""));
}; };

View file

@ -1,8 +1,8 @@
var ChangeDocumentTest = new TestCase("ChangeDocumentTest", { var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
setUp : function() { setUp : function() {
this.doc1 = new ace.TextDocument(["abc", "def"].join("\n")); this.doc1 = new ace.Document(["abc", "def"].join("\n"));
this.doc2 = new ace.TextDocument(["ghi", "jkl"].join("\n")); this.doc2 = new ace.Document(["ghi", "jkl"].join("\n"));
this.editor = new ace.Editor(new MockRenderer()); this.editor = new ace.Editor(new MockRenderer());
}, },

View file

@ -3,7 +3,7 @@ var NavigationTest = TestCase("NavigationTest",
createTextDocument : function(rows, cols) { createTextDocument : function(rows, cols) {
var line = new Array(cols + 1).join("a"); var line = new Array(cols + 1).join("a");
var text = new Array(rows).join(line + "\n") + line; var text = new Array(rows).join(line + "\n") + line;
return new ace.TextDocument(text); return new ace.Document(text);
}, },
"test: navigate to end of file should scroll the last line into view" : function() { "test: navigate to end of file should scroll the last line into view" : function() {

View file

@ -3,7 +3,7 @@ var SelectionTest = TestCase("SelectionTest",
createTextDocument : function(rows, cols) { createTextDocument : function(rows, cols) {
var line = new Array(cols + 1).join("a"); var line = new Array(cols + 1).join("a");
var text = new Array(rows).join(line + "\n") + line; var text = new Array(rows).join(line + "\n") + line;
return new ace.TextDocument(text); return new ace.Document(text);
}, },
"test: move cursor to end of file should place the cursor on last row and column" : function() { "test: move cursor to end of file should place the cursor on last row and column" : function() {
@ -49,7 +49,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: move cursor word right" : function() { "test: move cursor word right" : function() {
var doc = new ace.TextDocument( ["ab", var doc = new ace.Document( ["ab",
" Juhu Kinners (abc, 12)", " cde"].join("\n")); " Juhu Kinners (abc, 12)", " cde"].join("\n"));
var selection = doc.getSelection(); var selection = doc.getSelection();
@ -89,7 +89,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word right if cursor in word" : function() { "test: select word right if cursor in word" : function() {
var doc = new ace.TextDocument("Juhu Kinners"); var doc = new ace.Document("Juhu Kinners");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 2); selection.moveCursorTo(0, 2);
@ -99,7 +99,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: moveCursor word left" : function() { "test: moveCursor word left" : function() {
var doc = new ace.TextDocument( ["ab", var doc = new ace.Document( ["ab",
" Juhu Kinners (abc, 12)", " cde"].join("\n")); " Juhu Kinners (abc, 12)", " cde"].join("\n"));
var selection = doc.getSelection(); var selection = doc.getSelection();
@ -140,7 +140,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word left if cursor in word" : function() { "test: select word left if cursor in word" : function() {
var doc = new ace.TextDocument("Juhu Kinners"); var doc = new ace.Document("Juhu Kinners");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 8); selection.moveCursorTo(0, 8);
@ -150,7 +150,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word right and select" : function() { "test: select word right and select" : function() {
var doc = new ace.TextDocument("Juhu Kinners"); var doc = new ace.Document("Juhu Kinners");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 0); selection.moveCursorTo(0, 0);
@ -163,7 +163,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word left and select" : function() { "test: select word left and select" : function() {
var doc = new ace.TextDocument("Juhu Kinners"); var doc = new ace.Document("Juhu Kinners");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 3); selection.moveCursorTo(0, 3);
@ -176,7 +176,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word with cursor in word should select the word" : function() { "test: select word with cursor in word should select the word" : function() {
var doc = new ace.TextDocument("Juhu Kinners 123"); var doc = new ace.Document("Juhu Kinners 123");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 8); selection.moveCursorTo(0, 8);
@ -188,7 +188,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word with cursor betwen white space and word should select the word" : function() { "test: select word with cursor betwen white space and word should select the word" : function() {
var doc = new ace.TextDocument("Juhu Kinners"); var doc = new ace.Document("Juhu Kinners");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 4); selection.moveCursorTo(0, 4);
@ -207,7 +207,7 @@ var SelectionTest = TestCase("SelectionTest",
}, },
"test: select word with cursor in white space should select white space" : function() { "test: select word with cursor in white space should select white space" : function() {
var doc = new ace.TextDocument("Juhu Kinners"); var doc = new ace.Document("Juhu Kinners");
var selection = doc.getSelection(); var selection = doc.getSelection();
selection.moveCursorTo(0, 5); selection.moveCursorTo(0, 5);

View file

@ -1,7 +1,7 @@
var TextDocumentTest = new TestCase("TextDocumentTest", { var TextDocumentTest = new TestCase("TextDocumentTest", {
"test: find matching opening bracket" : function() { "test: find matching opening bracket" : function() {
var doc = new ace.TextDocument(["(()(", "())))"].join("\n")); var doc = new ace.Document(["(()(", "())))"].join("\n"));
assertPosition(0, 1, doc.findMatchingBracket({row: 0, column: 3})); assertPosition(0, 1, doc.findMatchingBracket({row: 0, column: 3}));
assertPosition(1, 0, doc.findMatchingBracket({row: 1, column: 2})); assertPosition(1, 0, doc.findMatchingBracket({row: 1, column: 2}));
@ -11,7 +11,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
}, },
"test: find matching closing bracket" : function() { "test: find matching closing bracket" : function() {
var doc = new ace.TextDocument(["(()(", "())))"].join("\n")); var doc = new ace.Document(["(()(", "())))"].join("\n"));
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1})); assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1})); assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
@ -22,7 +22,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
}, },
"test: match different bracket types" : function() { "test: match different bracket types" : function() {
var doc = new ace.TextDocument(["({[", ")]}"].join("\n")); var doc = new ace.Document(["({[", ")]}"].join("\n"));
assertPosition(1, 0, doc.findMatchingBracket({row: 0, column: 1})); assertPosition(1, 0, doc.findMatchingBracket({row: 0, column: 1}));
assertPosition(1, 2, doc.findMatchingBracket({row: 0, column: 2})); assertPosition(1, 2, doc.findMatchingBracket({row: 0, column: 2}));
@ -34,7 +34,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
}, },
"test: move lines down" : function() { "test: move lines down" : function() {
var doc = new ace.TextDocument(["1", "2", "3", "4"].join("\n")); var doc = new ace.Document(["1", "2", "3", "4"].join("\n"));
doc.moveLinesDown(0, 1); doc.moveLinesDown(0, 1);
assertEquals(["3", "1", "2", "4"].join("\n"), doc.toString()); assertEquals(["3", "1", "2", "4"].join("\n"), doc.toString());
@ -50,7 +50,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
}, },
"test: move lines up" : function() { "test: move lines up" : function() {
var doc = new ace.TextDocument(["1", "2", "3", "4"].join("\n")); var doc = new ace.Document(["1", "2", "3", "4"].join("\n"));
doc.moveLinesUp(2, 3); doc.moveLinesUp(2, 3);
assertEquals(["1", "3", "4", "2"].join("\n"), doc.toString()); assertEquals(["1", "3", "4", "2"].join("\n"), doc.toString());
@ -66,21 +66,21 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
}, },
"test: duplicate lines" : function() { "test: duplicate lines" : function() {
var doc = new ace.TextDocument(["1", "2", "3", "4"].join("\n")); var doc = new ace.Document(["1", "2", "3", "4"].join("\n"));
doc.duplicateLines(1, 2); doc.duplicateLines(1, 2);
assertEquals(["1", "2", "3", "2", "3", "4"].join("\n"), doc.toString()); assertEquals(["1", "2", "3", "2", "3", "4"].join("\n"), doc.toString());
}, },
"test: duplicate last line" : function() { "test: duplicate last line" : function() {
var doc = new ace.TextDocument(["1", "2", "3"].join("\n")); var doc = new ace.Document(["1", "2", "3"].join("\n"));
doc.duplicateLines(2, 2); doc.duplicateLines(2, 2);
assertEquals(["1", "2", "3", "3"].join("\n"), doc.toString()); assertEquals(["1", "2", "3", "3"].join("\n"), doc.toString());
}, },
"test: duplicate first line" : function() { "test: duplicate first line" : function() {
var doc = new ace.TextDocument(["1", "2", "3"].join("\n")); var doc = new ace.Document(["1", "2", "3"].join("\n"));
doc.duplicateLines(0, 0); doc.duplicateLines(0, 0);
assertEquals(["1", "1", "2", "3"].join("\n"), doc.toString()); assertEquals(["1", "1", "2", "3"].join("\n"), doc.toString());

View file

@ -1,7 +1,7 @@
var TextEditTest = TestCase("TextEditTest", var TextEditTest = TestCase("TextEditTest",
{ {
"test: delete line from the middle" : function() { "test: delete line from the middle" : function() {
var doc = new ace.TextDocument(["a", "b", "c", "d"].join("\n")); var doc = new ace.Document(["a", "b", "c", "d"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(1, 1); editor.moveCursorTo(1, 1);
@ -27,7 +27,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: delete multiple selected lines" : function() { "test: delete multiple selected lines" : function() {
var doc = new ace.TextDocument(["a", "b", "c", "d"].join("\n")); var doc = new ace.Document(["a", "b", "c", "d"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(1, 1); editor.moveCursorTo(1, 1);
@ -39,7 +39,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: delete first line" : function() { "test: delete first line" : function() {
var doc = new ace.TextDocument(["a", "b", "c"].join("\n")); var doc = new ace.Document(["a", "b", "c"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.removeLines(); editor.removeLines();
@ -49,7 +49,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: delete last" : function() { "test: delete last" : function() {
var doc = new ace.TextDocument(["a", "b", "c"].join("\n")); var doc = new ace.Document(["a", "b", "c"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(2, 1); editor.moveCursorTo(2, 1);
@ -60,7 +60,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: indent block" : function() { "test: indent block" : function() {
var doc = new ace.TextDocument(["a12345", "b12345", "c12345"].join("\n")); var doc = new ace.Document(["a12345", "b12345", "c12345"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(1, 3); editor.moveCursorTo(1, 3);
@ -79,7 +79,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: outdent block" : function() { "test: outdent block" : function() {
var doc = new ace.TextDocument([" a12345", " b12345", " c12345"].join("\n")); var doc = new ace.Document([" a12345", " b12345", " c12345"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 3); editor.moveCursorTo(0, 3);
@ -107,7 +107,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: outent without a selection should update cursor" : function() { "test: outent without a selection should update cursor" : function() {
var doc = new ace.TextDocument(" 12"); var doc = new ace.Document(" 12");
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 3); editor.moveCursorTo(0, 3);
@ -118,7 +118,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: comment lines should perserve selection" : function() { "test: comment lines should perserve selection" : function() {
var doc = new ace.TextDocument([" abc", "cde"].join("\n"), new ace.mode.JavaScript()); var doc = new ace.Document([" abc", "cde"].join("\n"), new ace.mode.JavaScript());
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 2); editor.moveCursorTo(0, 2);
@ -134,7 +134,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: uncomment lines should perserve selection" : function() { "test: uncomment lines should perserve selection" : function() {
var doc = new ace.TextDocument(["// abc", "//cde"].join("\n"), new ace.mode.JavaScript()); var doc = new ace.Document(["// abc", "//cde"].join("\n"), new ace.mode.JavaScript());
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 1); editor.moveCursorTo(0, 1);
@ -152,7 +152,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: move lines down should select moved lines" : function() { "test: move lines down should select moved lines" : function() {
var doc = new ace.TextDocument(["11", "22", "33", "44"].join("\n")); var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 1); editor.moveCursorTo(0, 1);
@ -179,7 +179,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: move lines up should select moved lines" : function() { "test: move lines up should select moved lines" : function() {
var doc = new ace.TextDocument(["11", "22", "33", "44"].join("\n")); var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(2, 1); editor.moveCursorTo(2, 1);
@ -200,7 +200,7 @@ var TextEditTest = TestCase("TextEditTest",
"test: move line without active selection should move cursor to start of the moved line" : function() "test: move line without active selection should move cursor to start of the moved line" : function()
{ {
var doc = new ace.TextDocument(["11", "22", "33", "44"].join("\n")); var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(1, 1); editor.moveCursorTo(1, 1);
@ -218,7 +218,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: copy lines down should select lines and place cursor at the selection start" : function() { "test: copy lines down should select lines and place cursor at the selection start" : function() {
var doc = new ace.TextDocument(["11", "22", "33", "44"].join("\n")); var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(1, 1); editor.moveCursorTo(1, 1);
@ -233,7 +233,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: copy lines up should select lines and place cursor at the selection start" : function() { "test: copy lines up should select lines and place cursor at the selection start" : function() {
var doc = new ace.TextDocument(["11", "22", "33", "44"].join("\n")); var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
editor.moveCursorTo(1, 1); editor.moveCursorTo(1, 1);
@ -248,7 +248,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: input a tab with soft tab should convert it to spaces" : function() { "test: input a tab with soft tab should convert it to spaces" : function() {
var doc = new ace.TextDocument(""); var doc = new ace.Document("");
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
doc.setTabSize(2); doc.setTabSize(2);
@ -263,7 +263,7 @@ var TextEditTest = TestCase("TextEditTest",
}, },
"test: input tab without soft tabs should keep the tab character" : function() { "test: input tab without soft tabs should keep the tab character" : function() {
var doc = new ace.TextDocument(""); var doc = new ace.Document("");
var editor = new ace.Editor(new MockRenderer(), doc); var editor = new ace.Editor(new MockRenderer(), doc);
doc.setUseSoftTabs(false); doc.setUseSoftTabs(false);

View file

@ -5,7 +5,7 @@ var CssTest = new TestCase("mode.CssTest", {
}, },
"test: toggle comment lines should not do anything" : function() { "test: toggle comment lines should not do anything" : function() {
var doc = new ace.TextDocument([" abc", "cde", "fg"].join("\n")); var doc = new ace.Document([" abc", "cde", "fg"].join("\n"));
var range = { var range = {
start: {row: 0, column: 3}, start: {row: 0, column: 3},

View file

@ -14,7 +14,7 @@ var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
}, },
"test: toggle comment lines should prepend '//' to each line" : function() { "test: toggle comment lines should prepend '//' to each line" : function() {
var doc = new ace.TextDocument([" abc", "cde", "fg"].join("\n")); var doc = new ace.Document([" abc", "cde", "fg"].join("\n"));
var range = { var range = {
start: {row: 0, column: 3}, start: {row: 0, column: 3},
@ -26,7 +26,7 @@ var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
}, },
"test: toggle comment on commented lines should remove leading '//' chars" : function() { "test: toggle comment on commented lines should remove leading '//' chars" : function() {
var doc = new ace.TextDocument(["// abc", "//cde", "fg"].join("\n")); var doc = new ace.Document(["// abc", "//cde", "fg"].join("\n"));
var range = { var range = {
start: {row: 0, column: 3}, start: {row: 0, column: 3},
@ -38,7 +38,7 @@ var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
}, },
"test: toggle comment on multiple lines with one commented line prepend '//' to each line" : function() { "test: toggle comment on multiple lines with one commented line prepend '//' to each line" : function() {
var doc = new ace.TextDocument(["// abc", "//cde", "fg"].join("\n")); var doc = new ace.Document(["// abc", "//cde", "fg"].join("\n"));
var range = { var range = {
start: {row: 0, column: 3}, start: {row: 0, column: 3},

View file

@ -5,7 +5,7 @@ var TextTest = new TestCase("mode.TextTest", {
}, },
"test: toggle comment lines should not do anything" : function() { "test: toggle comment lines should not do anything" : function() {
var doc = new ace.TextDocument([" abc", "cde", "fg"].join("\n")); var doc = new ace.Document([" abc", "cde", "fg"].join("\n"));
var range = { var range = {
start: {row: 0, column: 3}, start: {row: 0, column: 3},

View file

@ -14,7 +14,7 @@ var XmlTest = new TestCase("mode.XmlTest", {
}, },
"test: toggle comment lines should not do anything" : function() { "test: toggle comment lines should not do anything" : function() {
var doc = new ace.TextDocument([" abc", "cde", "fg"].join("\n")); var doc = new ace.Document([" abc", "cde", "fg"].join("\n"));
var range = { var range = {
start: {row: 0, column: 3}, start: {row: 0, column: 3},