mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
tty: document WriteStream.cursorTo() and others
Adds documentation for the following `WriteStream` instance methods: - `WriteStream.clearLine()` - `WriteStream.clearScreenDown()` - `WriteStream.cursorTo()` - `WriteStream.getWindowSize()` - `WriteStream.moveCursor()` PR-URL: https://github.com/nodejs/node/pull/22893 Fixes: https://github.com/nodejs/node/issues/9853 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
This commit is contained in:
1 parent
26928a8afe
commit
6b9965abaa
1 file changed
+64
-10
+64
-10
@@ -99,6 +99,27 @@ process.stdout.on('resize', () => {
|
||||
});
|
||||
```
|
||||
|
||||
### writeStream.clearLine(dir)
|
||||
<!-- YAML
|
||||
added: v0.7.7
|
||||
-->
|
||||
|
||||
* `dir` {number}
|
||||
* `-1` - to the left from cursor
|
||||
* `1` - to the right from cursor
|
||||
* `0` - the entire line
|
||||
|
||||
`writeStream.clearLine()` clears the current line of this `WriteStream` in a
|
||||
direction identified by `dir`.
|
||||
|
||||
### writeStream.clearScreenDown()
|
||||
<!-- YAML
|
||||
added: v0.7.7
|
||||
-->
|
||||
|
||||
`writeStream.clearScreenDown()` clears this `WriteStream` from the current
|
||||
cursor down.
|
||||
|
||||
### writeStream.columns
|
||||
<!-- YAML
|
||||
added: v0.7.7
|
||||
@@ -107,20 +128,16 @@ 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.
|
||||
|
||||
### writeStream.isTTY
|
||||
<!-- YAML
|
||||
added: v0.5.8
|
||||
-->
|
||||
|
||||
A `boolean` that is always `true`.
|
||||
|
||||
### writeStream.rows
|
||||
### writeStream.cursorTo(x, y)
|
||||
<!-- 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.
|
||||
* `x` {number}
|
||||
* `y` {number}
|
||||
|
||||
`writeStream.cursorTo()` moves this `WriteStream`'s cursor to the specified
|
||||
position.
|
||||
|
||||
### writeStream.getColorDepth([env])
|
||||
<!-- YAML
|
||||
@@ -148,6 +165,43 @@ to pass in an object with different settings.
|
||||
Use the `NODE_DISABLE_COLORS` environment variable to enforce this function to
|
||||
always return 1.
|
||||
|
||||
### 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.
|
||||
|
||||
## tty.isatty(fd)
|
||||
<!-- YAML
|
||||
added: v0.5.8
|
||||
|
||||
Reference in new issue
Block a user