add screen.realloc() method.

This commit is contained in:
Christopher Jeffrey 2015-08-09 17:35:34 -07:00
parent 364a56f4dc
commit b7c5f0f2f2
3 changed files with 8 additions and 4 deletions

View File

@ -390,6 +390,7 @@ The screen on which every other node renders.
`debug` option was set.
- __alloc()__ - Allocate a new pending screen buffer and a new output screen
buffer.
- __realloc()__ - Reallocate the screen buffers and clear the screen.
- __draw(start, end)__ - Draw the screen based on the contents of the screen
buffer.
- __render()__ - Render all child elements, writing all data to the screen

View File

@ -31,8 +31,7 @@ var server = telnet.createServer(function(client) {
screen.terminal = data.value;
} else {
// Clear the screen since they may have used `env send [var]`.
screen.alloc();
screen.clearRegion(0, screen.width, 0, screen.height, true);
screen.realloc();
}
screen.render();
}

View File

@ -691,7 +691,7 @@ Screen.prototype.__defineGetter__('height', function() {
return this.program.rows;
});
Screen.prototype.alloc = function() {
Screen.prototype.alloc = function(dirty) {
var x, y;
this.lines = [];
@ -700,7 +700,7 @@ Screen.prototype.alloc = function() {
for (x = 0; x < this.cols; x++) {
this.lines[y][x] = [this.dattr, ' '];
}
this.lines[y].dirty = false;
this.lines[y].dirty = !!dirty;
}
this.olines = [];
@ -714,6 +714,10 @@ Screen.prototype.alloc = function() {
this.program.clear();
};
Screen.prototype.realloc = function() {
return this.alloc(true);
};
Screen.prototype.render = function() {
var self = this;