From e6d7bfcbe78a0a0bf4488ea63cad3a5cca503977 Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Thu, 26 May 2016 11:39:07 -0400 Subject: [PATCH] doc: add `added:` information for readline 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: https://github.com/nodejs/node/issues/6578 PR-URL: https://github.com/nodejs/node/pull/6996 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/readline.md | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/doc/api/readline.md b/doc/api/readline.md index e48865ac04a40a..eddebccc9d31d1 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -26,16 +26,25 @@ rl.question('What do you think of Node.js? ', (answer) => { ``` ## Class: Interface + The class that represents a readline interface with an input and output stream. ### rl.close() + Closes the `Interface` instance, relinquishing control on the `input` and `output` streams. The `'close'` event will also be emitted. ### rl.pause() + Pauses the readline `input` stream, allowing it to be resumed later if needed. @@ -43,6 +52,9 @@ Note that this doesn't immediately pause the stream of events. Several events ma be emitted after calling `pause`, including `line`. ### rl.prompt([preserveCursor]) + 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` @@ -55,6 +67,9 @@ If `output` is set to `null` or `undefined` when calling `createInterface`, the prompt is not written. ### rl.question(query, callback) + Prepends the prompt with `query` and invokes `callback` with the user's response. Displays the query to the user, and then invokes `callback` @@ -75,15 +90,24 @@ rl.question('What is your favorite food?', (answer) => { ``` ### rl.resume() + Resumes the readline `input` stream. ### rl.setPrompt(prompt) + 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]) + Writes `data` to `output` stream, unless `output` is set to `null` or `undefined` when calling `createInterface`. `key` is an object literal to @@ -102,6 +126,9 @@ rl.write(null, {ctrl: true, name: 'u'}); ## Events ### Event: 'close' + `function () {}` @@ -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' + `function (line) {}` @@ -131,6 +161,9 @@ rl.on('line', (cmd) => { ``` ### Event: 'pause' + `function () {}` @@ -148,6 +181,9 @@ rl.on('pause', () => { ``` ### Event: 'resume' + `function () {}` @@ -162,6 +198,9 @@ rl.on('resume', () => { ``` ### Event: 'SIGCONT' + `function () {}` @@ -182,6 +221,9 @@ rl.on('SIGCONT', () => { ``` ### Event: 'SIGINT' + `function () {}` @@ -200,6 +242,9 @@ rl.on('SIGINT', () => { ``` ### Event: 'SIGTSTP' + `function () {}` @@ -272,6 +317,9 @@ rl.on('line', (line) => { ``` ## readline.clearLine(stream, dir) + Clears current line of given TTY stream in a specified direction. `dir` should have one of following values: @@ -281,10 +329,16 @@ Clears current line of given TTY stream in a specified direction. * `0` - the entire line ## readline.clearScreenDown(stream) + Clears the screen from the current position of the cursor down. ## readline.createInterface(options) + Creates a readline `Interface` instance. Accepts an `options` Object that takes the following values: @@ -351,10 +405,16 @@ 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) + Move cursor to the specified position in a given TTY stream. ## readline.emitKeypressEvents(stream[, interface]) + Causes `stream` to begin emitting `'keypress'` events corresponding to its input. @@ -362,6 +422,9 @@ Optionally, `interface` specifies a `readline.Interface` instance for which autocompletion is disabled when copy-pasted input is detected. ## readline.moveCursor(stream, dx, dy) + Move cursor relative to it's current position in a given TTY stream.