{ "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

\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

\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

\n", "signatures": [ { "params": [ { "name": "fd" } ] } ] }, { "textRaw": "tty.setRawMode(mode)", "type": "method", "name": "setRawMode", "desc": "

Deprecated. Use tty.ReadStream#setRawMode()\n(i.e. process.stdin.setRawMode()) instead.\n\n\n

\n", "signatures": [ { "params": [ { "name": "mode" } ] } ] } ], "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 program (only when isatty(0) is true).\n\n

\n", "properties": [ { "textRaw": "rs.isRaw", "name": "isRaw", "desc": "

A Boolean that is initialized to false. It represents the current "raw" state\nof the tty.ReadStream instance.\n\n

\n" } ], "methods": [ { "textRaw": "rs.setRawMode(mode)", "type": "method", "name": "setRawMode", "desc": "

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

\n", "signatures": [ { "params": [ { "name": "mode" } ] } ] } ] } ], "modules": [ { "textRaw": "Class WriteStream", "name": "class_writestream", "desc": "

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

\n", "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

\n" }, { "textRaw": "ws.rows", "name": "rows", "desc": "

A Number that gives the number of rows the TTY currently has. This property\ngets updated on "resize" events.\n\n

\n" } ], "events": [ { "textRaw": "Event: 'resize'", "type": "event", "name": "resize", "desc": "

function () {}\n\n

\n

Emitted by refreshSize() when either of the columns or rows properties\nhas changed.\n\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": "Class WriteStream" } ], "type": "module", "displayName": "TTY" } ] }