@@ -26,23 +26,35 @@ rl.question('What do you think of Node.js? ', (answer) => {
26
26
```
27
27
28
28
## Class: Interface
29
+ <!-- YAML
30
+ added: v0.1.104
31
+ -->
29
32
30
33
The class that represents a readline interface with an input and output
31
34
stream.
32
35
33
36
### rl.close()
37
+ <!-- YAML
38
+ added: v0.1.98
39
+ -->
34
40
35
41
Closes the ` Interface ` instance, relinquishing control on the ` input ` and
36
42
` output ` streams. The ` 'close' ` event will also be emitted.
37
43
38
44
### rl.pause()
45
+ <!-- YAML
46
+ added: v0.3.4
47
+ -->
39
48
40
49
Pauses the readline ` input ` stream, allowing it to be resumed later if needed.
41
50
42
51
Note that this doesn't immediately pause the stream of events. Several events may
43
52
be emitted after calling ` pause ` , including ` line ` .
44
53
45
54
### rl.prompt([ preserveCursor] )
55
+ <!-- YAML
56
+ added: v0.1.98
57
+ -->
46
58
47
59
Readies readline for input from the user, putting the current ` setPrompt `
48
60
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
55
67
prompt is not written.
56
68
57
69
### rl.question(query, callback)
70
+ <!-- YAML
71
+ added: v0.3.3
72
+ -->
58
73
59
74
Prepends the prompt with ` query ` and invokes ` callback ` with the user's
60
75
response. Displays the query to the user, and then invokes ` callback `
@@ -75,15 +90,24 @@ rl.question('What is your favorite food?', (answer) => {
75
90
```
76
91
77
92
### rl.resume()
93
+ <!-- YAML
94
+ added: v0.3.4
95
+ -->
78
96
79
97
Resumes the readline ` input ` stream.
80
98
81
99
### rl.setPrompt(prompt)
100
+ <!-- YAML
101
+ added: v0.1.98
102
+ -->
82
103
83
104
Sets the prompt, for example when you run ` node ` on the command line, you see
84
105
` > ` , which is Node.js's prompt.
85
106
86
107
### rl.write(data[ , key] )
108
+ <!-- YAML
109
+ added: v0.1.98
110
+ -->
87
111
88
112
Writes ` data ` to ` output ` stream, unless ` output ` is set to ` null ` or
89
113
` undefined ` when calling ` createInterface ` . ` key ` is an object literal to
@@ -102,6 +126,9 @@ rl.write(null, {ctrl: true, name: 'u'});
102
126
## Events
103
127
104
128
### Event: 'close'
129
+ <!-- YAML
130
+ added: v0.1.98
131
+ -->
105
132
106
133
` function () {} `
107
134
@@ -115,6 +142,9 @@ This event is also called if there is no `SIGINT` event listener present when
115
142
the ` input ` stream receives a ` ^C ` , respectively known as ` SIGINT ` .
116
143
117
144
### Event: 'line'
145
+ <!-- YAML
146
+ added: v0.1.98
147
+ -->
118
148
119
149
` function (line) {} `
120
150
@@ -131,6 +161,9 @@ rl.on('line', (cmd) => {
131
161
```
132
162
133
163
### Event: 'pause'
164
+ <!-- YAML
165
+ added: v0.7.5
166
+ -->
134
167
135
168
` function () {} `
136
169
@@ -148,6 +181,9 @@ rl.on('pause', () => {
148
181
```
149
182
150
183
### Event: 'resume'
184
+ <!-- YAML
185
+ added: v0.7.5
186
+ -->
151
187
152
188
` function () {} `
153
189
@@ -162,6 +198,9 @@ rl.on('resume', () => {
162
198
```
163
199
164
200
### Event: 'SIGCONT'
201
+ <!-- YAML
202
+ added: v0.7.5
203
+ -->
165
204
166
205
` function () {} `
167
206
@@ -182,6 +221,9 @@ rl.on('SIGCONT', () => {
182
221
```
183
222
184
223
### Event: 'SIGINT'
224
+ <!-- YAML
225
+ added: v0.3.0
226
+ -->
185
227
186
228
` function () {} `
187
229
@@ -200,6 +242,9 @@ rl.on('SIGINT', () => {
200
242
```
201
243
202
244
### Event: 'SIGTSTP'
245
+ <!-- YAML
246
+ added: v0.7.5
247
+ -->
203
248
204
249
` function () {} `
205
250
@@ -272,6 +317,9 @@ rl.on('line', (line) => {
272
317
```
273
318
274
319
## readline.clearLine(stream, dir)
320
+ <!-- YAML
321
+ added: v0.7.7
322
+ -->
275
323
276
324
Clears current line of given TTY stream in a specified direction.
277
325
` dir ` should have one of following values:
@@ -281,10 +329,16 @@ Clears current line of given TTY stream in a specified direction.
281
329
* ` 0 ` - the entire line
282
330
283
331
## readline.clearScreenDown(stream)
332
+ <!-- YAML
333
+ added: v0.7.7
334
+ -->
284
335
285
336
Clears the screen from the current position of the cursor down.
286
337
287
338
## readline.createInterface(options)
339
+ <!-- YAML
340
+ added: v0.1.98
341
+ -->
288
342
289
343
Creates a readline ` Interface ` instance. Accepts an ` options ` Object that takes
290
344
the following values:
@@ -351,17 +405,26 @@ a `'resize'` event on the `output` if/when the columns ever change
351
405
([ ` process.stdout ` ] [ ] does this automatically when it is a TTY).
352
406
353
407
## readline.cursorTo(stream, x, y)
408
+ <!-- YAML
409
+ added: v0.7.7
410
+ -->
354
411
355
412
Move cursor to the specified position in a given TTY stream.
356
413
357
414
## readline.emitKeypressEvents(stream[ , interface] )
415
+ <!-- YAML
416
+ added: v0.7.7
417
+ -->
358
418
359
419
Causes ` stream ` to begin emitting ` 'keypress' ` events corresponding to its
360
420
input.
361
421
Optionally, ` interface ` specifies a ` readline.Interface ` instance for which
362
422
autocompletion is disabled when copy-pasted input is detected.
363
423
364
424
## readline.moveCursor(stream, dx, dy)
425
+ <!-- YAML
426
+ added: v0.7.7
427
+ -->
365
428
366
429
Move cursor relative to it's current position in a given TTY stream.
367
430
0 commit comments