allow multiple lines for box insert/delete lines.
This commit is contained in:
parent
51413c346e
commit
211491409b
|
@ -2168,42 +2168,42 @@ outer:
|
|||
// Maybe _lastPos could be updated on .left, .right, etc setters?
|
||||
|
||||
Box.prototype.insertLine = function(i, line) {
|
||||
//if (typeof line === 'string') line = [line];
|
||||
if (typeof line === 'string') line = [line];
|
||||
|
||||
if (this.screen.cleanSides(this)) {
|
||||
i = Math.max(i, 0);
|
||||
i = Math.min(i, this._lastPos.yl - this._lastPos.yi - (this.border ? 2 : 0) - this.padding * 2);
|
||||
//this.screen.insertLine(line.length
|
||||
this.screen.insertLine(1,
|
||||
this.screen.insertLine(line.length,
|
||||
this._lastPos.yi + (this.border ? 1 : 0) + this.padding + i,
|
||||
this._lastPos.yi,
|
||||
this._lastPos.yl - (this.border ? 1 : 0) - this.padding - 1);
|
||||
}
|
||||
this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i, 0, line);
|
||||
// OR:
|
||||
//line.forEach(function(line, j) {
|
||||
// this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i + j, 0, line);
|
||||
//}, this);
|
||||
|
||||
line.forEach(function(line, j) {
|
||||
this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i + j, 0, line);
|
||||
}, this);
|
||||
|
||||
this.setContent(this._clines.join('\n'), true);
|
||||
};
|
||||
|
||||
Box.prototype.deleteLine = function(i) {
|
||||
//if (typeof line === 'string') line = [line];
|
||||
var reset = true;
|
||||
Box.prototype.deleteLine = function(i, n) {
|
||||
var reset = true
|
||||
, n = n || 1;
|
||||
|
||||
if (this.screen.cleanSides(this)) {
|
||||
i = Math.max(i, 0);
|
||||
i = Math.min(i, this._lastPos.yl - this._lastPos.yi - (this.border ? 2 : 0) - this.padding * 2);
|
||||
//this.screen.deleteLine(line.length,
|
||||
this.screen.deleteLine(1,
|
||||
this.screen.deleteLine(n,
|
||||
this._lastPos.yi + (this.border ? 1 : 0) + this.padding + i,
|
||||
this._lastPos.yi,
|
||||
this._lastPos.yl - (this.border ? 1 : 0) - this.padding - 1);
|
||||
reset = false;
|
||||
}
|
||||
this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i, 1);
|
||||
// OR:
|
||||
//line.forEach(function(line, j) {
|
||||
// this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i, 1);
|
||||
//}, this);
|
||||
|
||||
while (n--) {
|
||||
this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i, 1);
|
||||
}
|
||||
|
||||
this.setContent(this._clines.join('\n'), reset);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue