{ "source": "doc/api/tty.markdown", "modules": [ { "textRaw": "TTY", "name": "tty", "stability": 2, "stabilityText": "Stable", "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.js 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.js is being run\nin a 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",
"classes": [
{
"textRaw": "Class: ReadStream",
"type": "class",
"name": "ReadStream",
"desc": "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.js 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
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
function () {}
\n\n
Emitted by refreshSize()
when either of the columns
or rows
properties\nhas changed.\n\n
process.stdout.on('resize', () => {\n console.log('screen size has changed!');\n console.log(`${process.stdout.columns}x${process.stdout.rows}`);\n});
\n",
"params": []
}
],
"properties": [
{
"textRaw": "ws.columns",
"name": "columns",
"desc": "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
Returns true
or false
depending on if the fd
is associated with a\nterminal.\n\n