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?
|
// Maybe _lastPos could be updated on .left, .right, etc setters?
|
||||||
|
|
||||||
Box.prototype.insertLine = function(i, line) {
|
Box.prototype.insertLine = function(i, line) {
|
||||||
//if (typeof line === 'string') line = [line];
|
if (typeof line === 'string') line = [line];
|
||||||
|
|
||||||
if (this.screen.cleanSides(this)) {
|
if (this.screen.cleanSides(this)) {
|
||||||
i = Math.max(i, 0);
|
i = Math.max(i, 0);
|
||||||
i = Math.min(i, this._lastPos.yl - this._lastPos.yi - (this.border ? 2 : 0) - this.padding * 2);
|
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(line.length,
|
||||||
this.screen.insertLine(1,
|
|
||||||
this._lastPos.yi + (this.border ? 1 : 0) + this.padding + i,
|
this._lastPos.yi + (this.border ? 1 : 0) + this.padding + i,
|
||||||
this._lastPos.yi,
|
this._lastPos.yi,
|
||||||
this._lastPos.yl - (this.border ? 1 : 0) - this.padding - 1);
|
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) {
|
||||||
//line.forEach(function(line, j) {
|
this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i + j, 0, line);
|
||||||
// this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i + j, 0, line);
|
}, this);
|
||||||
//}, this);
|
|
||||||
this.setContent(this._clines.join('\n'), true);
|
this.setContent(this._clines.join('\n'), true);
|
||||||
};
|
};
|
||||||
|
|
||||||
Box.prototype.deleteLine = function(i) {
|
Box.prototype.deleteLine = function(i, n) {
|
||||||
//if (typeof line === 'string') line = [line];
|
var reset = true
|
||||||
var reset = true;
|
, n = n || 1;
|
||||||
|
|
||||||
if (this.screen.cleanSides(this)) {
|
if (this.screen.cleanSides(this)) {
|
||||||
i = Math.max(i, 0);
|
i = Math.max(i, 0);
|
||||||
i = Math.min(i, this._lastPos.yl - this._lastPos.yi - (this.border ? 2 : 0) - this.padding * 2);
|
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(n,
|
||||||
this.screen.deleteLine(1,
|
|
||||||
this._lastPos.yi + (this.border ? 1 : 0) + this.padding + i,
|
this._lastPos.yi + (this.border ? 1 : 0) + this.padding + i,
|
||||||
this._lastPos.yi,
|
this._lastPos.yi,
|
||||||
this._lastPos.yl - (this.border ? 1 : 0) - this.padding - 1);
|
this._lastPos.yl - (this.border ? 1 : 0) - this.padding - 1);
|
||||||
reset = false;
|
reset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (n--) {
|
||||||
this._clines.splice((this.childBase || 0) + (this.border ? 1 : 0) + this.padding + i, 1);
|
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);
|
|
||||||
this.setContent(this._clines.join('\n'), reset);
|
this.setContent(this._clines.join('\n'), reset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue