Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTY: Document WriteStream.cursorTo and others #22893

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 63 additions & 9 deletions doc/api/tty.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,46 @@ process.stdout.on('resize', () => {
});
```

### writeStream.columns
### writeStream.clearLine(dir)
<!-- YAML
added: v0.7.7
-->

A `number` specifying the number of columns the TTY currently has. This property
is updated whenever the `'resize'` event is emitted.
* `dir` {number}
* `-1` - to the left from cursor
* `1` - to the right from cursor
* `0` - the entire line

### writeStream.isTTY
`writeStream.clearLine()` clears the current line of this `WriteStream` in a
direction identified by `dir`.

### writeStream.clearScreenDown()
<!-- YAML
added: v0.5.8
added: v0.7.7
-->

A `boolean` that is always `true`.
`writeStream.clearScreenDown()` clears this `WriteStream` from the current
cursor down.

### writeStream.rows
### writeStream.columns
<!-- YAML
added: v0.7.7
-->

A `number` specifying the number of rows the TTY currently has. This property
A `number` specifying the number of columns the TTY currently has. This property
is updated whenever the `'resize'` event is emitted.

### writeStream.cursorTo(x, y)
<!-- YAML
added: v0.7.7
-->

* `x` {number}
* `y` {number}

`writeStream.cursorTo()` moves this `WriteStream`'s cursor to the specified
position.

### writeStream.getColorDepth([env])
<!-- YAML
added: v9.9.0
Expand All @@ -147,7 +164,7 @@ to pass in an object with different settings.
Use the `NODE_DISABLE_COLORS` environment variable to enforce this function to
always return 1.

## tty.isatty(fd)
### tty.isatty(fd)
<!-- YAML
added: v0.5.8
-->
Expand All @@ -158,6 +175,43 @@ The `tty.isatty()` method returns `true` if the given `fd` is associated with
a TTY and `false` if it is not, including whenever `fd` is not a non-negative
integer.

### writeStream.getWindowSize()
<!-- YAML
added: v0.7.7
-->
* Returns: {number[]}

`writeStream.getWindowSize()` returns the size of the [TTY](tty.html)
corresponding to this `WriteStream`. The array is of the type
`[numColumns, numRows]` where `numColumns` and `numRows` represent the number
of columns and rows in the corresponding [TTY](tty.html).

### writeStream.isTTY
<!-- YAML
added: v0.5.8
-->

A `boolean` that is always `true`.

### writeStream.moveCursor(dx, dy)
<!-- YAML
added: v0.7.7
-->

* `dx` {number}
* `dy` {number}

`writeStream.moveCursor()` moves this `WriteStream`'s cursor *relative* to its
current position.

### writeStream.rows
<!-- YAML
added: v0.7.7
-->

A `number` specifying the number of rows the TTY currently has. This property
is updated whenever the `'resize'` event is emitted.

[`net.Socket`]: net.html#net_class_net_socket
[`process.stdin`]: process.html#process_process_stdin
[`process.stdout`]: process.html#process_process_stdout
Expand Down