{ "source": "doc/api/tty.markdown", "modules": [ { "textRaw": "TTY", "name": "tty", "stability": 2, "stabilityText": "Unstable", "desc": "
The tty
module houses the tty.ReadStream
and tty.WriteStream
classes. In\nmost cases, you will not need to use this module directly.\n\n
When node detects that it is being run inside a TTY context, then process.stdin
\nwill be a tty.ReadStream
instance and process.stdout
will be\na tty.WriteStream
instance. The preferred way to check if node is being run in\na TTY context is to check process.stdout.isTTY
:\n\n
$ node -p -e "Boolean(process.stdout.isTTY)"\ntrue\n$ node -p -e "Boolean(process.stdout.isTTY)" | cat\nfalse
\n",
"methods": [
{
"textRaw": "tty.isatty(fd)",
"type": "method",
"name": "isatty",
"desc": "Returns true
or false
depending on if the fd
is associated with a\nterminal.\n\n\n
Deprecated. Use tty.ReadStream#setRawMode()
\n(i.e. process.stdin.setRawMode()
) instead.\n\n\n
A net.Socket
subclass that represents the readable portion of a tty. In normal\ncircumstances, process.stdin
will be the only tty.ReadStream
instance in any\nnode program (only when isatty(0)
is true).\n\n
A Boolean
that is initialized to false
. It represents the current "raw" state\nof the tty.ReadStream
instance.\n\n
mode
should be true
or false
. This sets the properties of the\ntty.ReadStream
to act either as a raw device or default. isRaw
will be set\nto the resulting mode.\n\n\n
A net.Socket
subclass that represents the writable portion of a tty. In normal\ncircumstances, process.stdout
will be the only tty.WriteStream
instance\never created (and only when isatty(1)
is true).\n\n
A Number
that gives the number of columns the TTY currently has. This property\ngets updated on "resize" events.\n\n
A Number
that gives the number of rows the TTY currently has. This property\ngets updated on "resize" events.\n\n
function () {}
\n\n
Emitted by refreshSize()
when either of the columns
or rows
properties\nhas changed.\n\n
process.stdout.on('resize', function() {\n console.log('screen size has changed!');\n console.log(process.stdout.columns + 'x' + process.stdout.rows);\n});
\n",
"params": []
}
]
}
],
"type": "module",
"displayName": "TTY"
}
]
}