2012-02-28 03:09:35 +08:00
|
|
|
# TTY
|
2010-11-26 11:09:28 +08:00
|
|
|
|
|
|
|
Use `require('tty')` to access this module.
|
|
|
|
|
2011-02-21 05:53:40 +08:00
|
|
|
Example:
|
|
|
|
|
|
|
|
var tty = require('tty');
|
|
|
|
process.stdin.resume();
|
2011-10-29 02:07:06 +08:00
|
|
|
tty.setRawMode(true);
|
2011-02-21 05:53:40 +08:00
|
|
|
process.stdin.on('keypress', function(char, key) {
|
|
|
|
if (key && key.ctrl && key.name == 'c') {
|
|
|
|
console.log('graceful exit');
|
|
|
|
process.exit()
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2012-02-28 03:09:35 +08:00
|
|
|
## tty.isatty(fd)
|
2010-11-26 11:09:28 +08:00
|
|
|
|
|
|
|
Returns `true` or `false` depending on if the `fd` is associated with a
|
|
|
|
terminal.
|
|
|
|
|
|
|
|
|
2012-02-28 03:09:35 +08:00
|
|
|
## tty.setRawMode(mode)
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2011-02-25 08:36:43 +08:00
|
|
|
`mode` should be `true` or `false`. This sets the properties of the current
|
2010-11-26 11:09:28 +08:00
|
|
|
process's stdin fd to act either as a raw device or default.
|
|
|
|
|
|
|
|
|
2012-02-28 03:09:35 +08:00
|
|
|
## tty.setWindowSize(fd, row, col)
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2011-11-23 02:22:53 +08:00
|
|
|
This function was removed in v0.6.0.
|
2010-11-26 11:09:28 +08:00
|
|
|
|
2012-02-28 03:09:35 +08:00
|
|
|
## tty.getWindowSize(fd)
|
2011-02-08 05:46:15 +08:00
|
|
|
|
2011-11-23 02:22:53 +08:00
|
|
|
This function was removed in v0.6.0. Use `process.stdout.getWindowSize()`
|
|
|
|
instead.
|
2010-11-26 11:09:28 +08:00
|
|
|
|
|
|
|
|