Skip to content

Commit

Permalink
doc: add added: information for readline
Browse files Browse the repository at this point in the history
Got the information from git history, I added the version when Interface
was exported as class (v0.1.104), it was an internal class on previous
versions.

Refs: #6578
PR-URL: #6996
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
julianduque authored and Myles Borins committed Jul 14, 2016
1 parent eec0c63 commit e6d7bfc
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,35 @@ rl.question('What do you think of Node.js? ', (answer) => {
```

## Class: Interface
<!-- YAML
added: v0.1.104
-->

The class that represents a readline interface with an input and output
stream.

### rl.close()
<!-- YAML
added: v0.1.98
-->

Closes the `Interface` instance, relinquishing control on the `input` and
`output` streams. The `'close'` event will also be emitted.

### rl.pause()
<!-- YAML
added: v0.3.4
-->

Pauses the readline `input` stream, allowing it to be resumed later if needed.

Note that this doesn't immediately pause the stream of events. Several events may
be emitted after calling `pause`, including `line`.

### rl.prompt([preserveCursor])
<!-- YAML
added: v0.1.98
-->

Readies readline for input from the user, putting the current `setPrompt`
options on a new line, giving the user a new spot to write. Set `preserveCursor`
Expand All @@ -55,6 +67,9 @@ If `output` is set to `null` or `undefined` when calling `createInterface`, the
prompt is not written.

### rl.question(query, callback)
<!-- YAML
added: v0.3.3
-->

Prepends the prompt with `query` and invokes `callback` with the user's
response. Displays the query to the user, and then invokes `callback`
Expand All @@ -75,15 +90,24 @@ rl.question('What is your favorite food?', (answer) => {
```

### rl.resume()
<!-- YAML
added: v0.3.4
-->

Resumes the readline `input` stream.

### rl.setPrompt(prompt)
<!-- YAML
added: v0.1.98
-->

Sets the prompt, for example when you run `node` on the command line, you see
`> `, which is Node.js's prompt.

### rl.write(data[, key])
<!-- YAML
added: v0.1.98
-->

Writes `data` to `output` stream, unless `output` is set to `null` or
`undefined` when calling `createInterface`. `key` is an object literal to
Expand All @@ -102,6 +126,9 @@ rl.write(null, {ctrl: true, name: 'u'});
## Events

### Event: 'close'
<!-- YAML
added: v0.1.98
-->

`function () {}`

Expand All @@ -115,6 +142,9 @@ This event is also called if there is no `SIGINT` event listener present when
the `input` stream receives a `^C`, respectively known as `SIGINT`.

### Event: 'line'
<!-- YAML
added: v0.1.98
-->

`function (line) {}`

Expand All @@ -131,6 +161,9 @@ rl.on('line', (cmd) => {
```

### Event: 'pause'
<!-- YAML
added: v0.7.5
-->

`function () {}`

Expand All @@ -148,6 +181,9 @@ rl.on('pause', () => {
```

### Event: 'resume'
<!-- YAML
added: v0.7.5
-->

`function () {}`

Expand All @@ -162,6 +198,9 @@ rl.on('resume', () => {
```

### Event: 'SIGCONT'
<!-- YAML
added: v0.7.5
-->

`function () {}`

Expand All @@ -182,6 +221,9 @@ rl.on('SIGCONT', () => {
```

### Event: 'SIGINT'
<!-- YAML
added: v0.3.0
-->

`function () {}`

Expand All @@ -200,6 +242,9 @@ rl.on('SIGINT', () => {
```

### Event: 'SIGTSTP'
<!-- YAML
added: v0.7.5
-->

`function () {}`

Expand Down Expand Up @@ -272,6 +317,9 @@ rl.on('line', (line) => {
```

## readline.clearLine(stream, dir)
<!-- YAML
added: v0.7.7
-->

Clears current line of given TTY stream in a specified direction.
`dir` should have one of following values:
Expand All @@ -281,10 +329,16 @@ Clears current line of given TTY stream in a specified direction.
* `0` - the entire line

## readline.clearScreenDown(stream)
<!-- YAML
added: v0.7.7
-->

Clears the screen from the current position of the cursor down.

## readline.createInterface(options)
<!-- YAML
added: v0.1.98
-->

Creates a readline `Interface` instance. Accepts an `options` Object that takes
the following values:
Expand Down Expand Up @@ -351,17 +405,26 @@ a `'resize'` event on the `output` if/when the columns ever change
([`process.stdout`][] does this automatically when it is a TTY).

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

Move cursor to the specified position in a given TTY stream.

## readline.emitKeypressEvents(stream[, interface])
<!-- YAML
added: v0.7.7
-->

Causes `stream` to begin emitting `'keypress'` events corresponding to its
input.
Optionally, `interface` specifies a `readline.Interface` instance for which
autocompletion is disabled when copy-pasted input is detected.

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

Move cursor relative to it's current position in a given TTY stream.

Expand Down

0 comments on commit e6d7bfc

Please sign in to comment.