insert and delete line functions utilizing csr.

This commit is contained in:
Christopher Jeffrey 2013-06-13 01:33:10 -05:00
parent 9963df5343
commit 761e2a2aaf
2 changed files with 61 additions and 0 deletions

View File

@ -2031,6 +2031,7 @@ Program.prototype.setMouse = function(opt) {
// dow) (DECSTBM).
// CSI ? Pm r
Program.prototype.decstbm =
Program.prototype.csr =
Program.prototype.setScrollRegion = function(top, bottom) {
this.scrollTop = (top || 1) - 1;
this.scrollBottom = (bottom || this.rows) - 1;

View File

@ -270,6 +270,66 @@ Screen.prototype.render = function() {
this.emit('draw');
};
Screen.prototype.blankLine = function(ch, dirty) {
var out = [];
for (var y = 0; y < this.rows; y++) {
out[y] = [];
for (var x = 0; x < this.cols; x++) {
out[y][x] = [this.dattr, ch || ' '];
}
out[y].dirty = dirty;
}
return out;
};
Screen.prototype.insertLine = function(n, y, top, bottom) {
this.program.csr(top + 1, bottom + 1);
this.program.cup(y + 1, 1);
this.program.il(1);
this.program.csr(1, this.height - 1 + 1);
this.program.cup(y + 1, 1);
if (n < 1) n = 1;
var j = this.rows - 1 - bottom;
j = this.rows - 1 - j + 1;
while (n--) {
this.lines.splice(y, 0, this.blankLine());
this.lines.splice(j, 1);
this.olines.splice(y, 0, this.blankLine());
this.olines.splice(j, 1);
}
};
Screen.prototype.deleteLine = function(n, y, top, bottom) {
this.program.csr(top + 1, bottom + 1);
this.program.cup(y + 1, 1);
this.program.dl(1);
this.program.csr(1, this.height - 1 + 1);
this.program.cup(y + 1, 1);
if (n < 1) n = 1;
var j = this.rows - 1 - bottom;
j = this.rows - 1 - j + 1;
while (n--) {
this.lines.splice(j, 0, this.blankLine());
this.lines.splice(y, 1);
this.olines.splice(j, 0, this.blankLine());
this.olines.splice(y, 1);
}
};
Screen.prototype.insertBottom = function(top, bottom) {
return this.deleteLine(1, top, top, bottom);
};
Screen.prototype.insertTop = function(top, bottom) {
return this.insertLine(1, top, top, bottom);
};
Screen.prototype.draw = function(start, end) {
var x
, y