diff --git a/README.md b/README.md index 62f0eac..cbb64da 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/example/blessed-telnet.js b/example/blessed-telnet.js index 69fa8a1..1de93e0 100755 --- a/example/blessed-telnet.js +++ b/example/blessed-telnet.js @@ -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(); } diff --git a/lib/widgets/screen.js b/lib/widgets/screen.js index 20f8db1..e0f2c04 100644 --- a/lib/widgets/screen.js +++ b/lib/widgets/screen.js @@ -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;