add setValue to the Document

This commit is contained in:
Fabian Jakobs 2010-05-06 17:04:21 +02:00
commit 92b0339178

View file

@ -1,8 +1,8 @@
ace.provide("ace.Document");
ace.Document = function(text, mode) {
this.lines = [];
this.modified = true;
this.lines = [];
this.selection = new ace.Selection(this);
this.listeners = [];
@ -27,6 +27,13 @@ ace.Document = function(text, mode) {
return text.split(/\r\n|\r|\n/);
};
this.setValue = function(text) {
var args = [0, this.lines.length];
args.push.apply(args, this.$split(text));
this.lines.splice.apply(this.lines, args);
this.fireChangeEvent(0);
};
this.toString = function() {
return this.lines.join(this.$getNewLineCharacter());
};
@ -323,7 +330,7 @@ ace.Document = function(text, mode) {
this.$insert = function(position, text, fromUndo) {
if (text.length == 0)
return;
return position;
this.modified = true;
if (this.lines.length <= 1) {