mirror of
https://github.com/chjj/blessed.git
synced 2026-02-06 11:22:09 +00:00
helpers to potentially support node <=0.6.0.
This commit is contained in:
parent
b0d0063b1c
commit
103ce24787
@ -156,3 +156,40 @@ helpers.__defineGetter__('Element', function() {
|
||||
}
|
||||
return helpers._element;
|
||||
});
|
||||
|
||||
// NOTE: Leave these here for now if we
|
||||
// want to potentially support node <=v0.6.0.
|
||||
|
||||
helpers.isTTY = function(stream) {
|
||||
if (stream.setRawMode || stream.isTTY) {
|
||||
return true;
|
||||
}
|
||||
if (stream === process.stdin) {
|
||||
return true;
|
||||
}
|
||||
// if (stream.fd != null) {
|
||||
// return require('tty').isatty(stream.fd);
|
||||
// }
|
||||
return false;
|
||||
};
|
||||
|
||||
helpers.setRawMode = function(stream, value) {
|
||||
if (stream.setRawMode) {
|
||||
return stream.setRawMode(value);
|
||||
}
|
||||
if (stream === process.stdin) {
|
||||
helpers._isRaw = value;
|
||||
return require('tty').setRawMode(value);
|
||||
}
|
||||
throw new Error('Could not set raw mode.');
|
||||
};
|
||||
|
||||
helpers.isRaw = function(stream) {
|
||||
if (stream.isRaw != null) {
|
||||
return stream.isRaw;
|
||||
}
|
||||
if (stream === process.stdin) {
|
||||
return !!helpers._isRaw;
|
||||
}
|
||||
throw new Error('Could not check raw mode.');
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user