* Not much

This commit is contained in:
Bryan Ashby 2015-05-31 21:50:49 -06:00
parent c8c7566fd3
commit 40f38d8682
2 changed files with 11 additions and 7 deletions

View File

@ -53,5 +53,5 @@ MultiLineEditTextView2.prototype.redraw = function() {
MultiLineEditTextView2.prototype.setText = function(text) {
this.textBuffer.insertText(0, text);
console.log(this.textBuffer.getArray());
console.log(this.textBuffer.getArray())
};

View File

@ -103,9 +103,12 @@ TextBuffer.prototype.insertFragment = function(index, fragment) {
throw new RangeError('Index must be >= 0');
}
/*
if(index > this.length) {
console.log(this.gapStart)
console.log(this.gapEnd)
throw new RangeError('Index must be <= length');
}
}*/
if(this.gapStart === this.gapEnd) {
this.spliceArgs[0] = index;
@ -137,7 +140,7 @@ TextBuffer.prototype.insertText = function(index, text) {
return;
}
var re = /\s+|\r\n|\n|\r/g;
var re = /\r\n|\n|\r|\t|\s+/g;
var m;
var i = index;
var from;
@ -153,7 +156,7 @@ TextBuffer.prototype.insertText = function(index, text) {
switch(m[0].charAt(0)) {
case '\t' :
for(var j = 0; j < m[0].length; ++j) {
this.insertFragment(i++, new TextBuffer({
this.insertFragment(i++, new TextBuferFragment({
text : m[0].charAt(j)
}));
}
@ -163,22 +166,23 @@ TextBuffer.prototype.insertText = function(index, text) {
case '\n' :
var count = m[0].split(/\r\n|\n|\r/g).length;
for(var j = 0; j < count; ++j) {
this.insertFragment(i++, new TextBuffer({
this.insertFragment(i++, new TextBuferFragment({
text : '\n' // always normalized
}));
}
break;
case ' ' :
this.insertFragment(i++, new TextBuffer({
this.insertFragment(i++, new TextBuferFragment({
text : m[0],
}));
break;
}
}
}
} while(0 !== re.lastIndex);
};
// :TODO: getArray() should take range
TextBuffer.prototype.getArray = function() {
return this.buffer.slice(0, this.gapStart).concat(this.buffer.slice(this.gapEnd));
};