0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/doc/api/tty.markdown
2011-02-24 16:36:43 -08:00

51 lines
1.1 KiB
Markdown

## TTY
Use `require('tty')` to access this module.
Example:
var tty = require('tty');
tty.setRawMode(true);
process.stdin.resume();
process.stdin.on('keypress', function(char, key) {
if (key && key.ctrl && key.name == 'c') {
console.log('graceful exit');
process.exit()
}
});
### tty.open(path, args=[])
Spawns a new process with the executable pointed to by `path` as the session
leader to a new pseudo terminal.
Returns an array `[slaveFD, childProcess]`. `slaveFD` is the file descriptor
of the slave end of the pseudo terminal. `childProcess` is a child process
object.
### tty.isatty(fd)
Returns `true` or `false` depending on if the `fd` is associated with a
terminal.
### tty.setRawMode(mode)
`mode` should be `true` or `false`. This sets the properties of the current
process's stdin fd to act either as a raw device or default.
### tty.setWindowSize(fd, row, col)
`ioctl`s the window size settings to the file descriptor.
### tty.getWindowSize(fd)
Returns `[row, col]` for the TTY associated with the file descriptor.