Browse Source

tty: throw an Error when getWindowSize() fails

v0.9.1-release
Nathan Rajlich 13 years ago
parent
commit
f1f5de1c8d
  1. 18
      lib/tty.js

18
lib/tty.js

@ -84,8 +84,10 @@ function WriteStream(fd) {
this.writable = true;
var winSize = this._handle.getWindowSize();
this.columns = winSize[0];
this.rows = winSize[1];
if (winSize) {
this.columns = winSize[0];
this.rows = winSize[1];
}
}
inherits(WriteStream, net.Socket);
exports.WriteStream = WriteStream;
@ -98,6 +100,9 @@ WriteStream.prototype._refreshSize = function() {
var oldCols = this.columns;
var oldRows = this.rows;
var winSize = this._handle.getWindowSize();
if (!winSize) {
throw errnoException(errno, 'getWindowSize');
}
var newCols = winSize[0];
var newRows = winSize[1];
if (oldCols !== newCols || oldRows !== newRows) {
@ -124,3 +129,12 @@ WriteStream.prototype.clearScreenDown = function() {
WriteStream.prototype.getWindowSize = function() {
return [this.columns, this.rows];
};
// TODO share with net_uv and others
function errnoException(errorno, syscall) {
var e = new Error(syscall + ' ' + errorno);
e.errno = e.code = errorno;
e.syscall = syscall;
return e;
}

Loading…
Cancel
Save