From 92b0339178ff860a939f8dbb9eb1fc4e4fde97b6 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 6 May 2010 17:04:21 +0200 Subject: [PATCH] add setValue to the Document --- src/ace/Document.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ace/Document.js b/src/ace/Document.js index d2de45f3..3306eff2 100644 --- a/src/ace/Document.js +++ b/src/ace/Document.js @@ -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) {