Skip to content

Commit 8314237

Browse files
Snehil-Shahkgryte
andauthored
feat: add support for auto-closing brackets/quotations in the REPL
PR-URL: #1680 Closes: #1672 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Snehil Shah <[email protected]> Signed-off-by: Snehil Shah <[email protected]>
1 parent 396a40e commit 8314237

File tree

95 files changed

+5625
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+5625
-198
lines changed

lib/node_modules/@stdlib/repl/README.md

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,24 @@ The function accepts the following `options`:
6464

6565
- **input**: input (readable) stream. Default: [`stdin`][@stdlib/streams/node/stdin].
6666
- **output**: output (writable) stream. Default: [`stdout`][@stdlib/streams/node/stdout].
67-
- **sandbox**: `boolean` indicating whether to run a REPL in a sandboxed context. Default: `false`.
67+
- **sandbox**: boolean indicating whether to run a REPL in a sandboxed context. Default: `false`.
6868
- **timeout**: number of milliseconds to execute a command before terminating execution. Default: `4294967295`.
69-
- **isTTY**: `boolean` indicating whether the input and output streams should be treated like a TTY (terminal) and whether the REPL should use ANSI/VT100 escape codes when writing to the output stream.
69+
- **isTTY**: boolean indicating whether the input and output streams should be treated like a TTY (terminal) and whether the REPL should use ANSI/VT100 escape codes when writing to the output stream.
7070
- **inputPrompt**: input prompt. If the input prompt includes the character sequence `%d`, the input prompt includes line numbers. Default: `'In [%d]: '`.
7171
- **outputPrompt**: output prompt. If the output prompt includes the character sequence `%d`, the output prompt includes line numbers. Default: `'Out[%d]: '`.
7272
- **welcome**: welcome message.
7373
- **padding**: number of empty lines between consecutive commands. Default: `1`.
7474
- **load**: file path specifying a JavaScript file to load and evaluate line-by-line (e.g., a previous REPL history file).
7575
- **save**: file path specifying where to save REPL command history.
7676
- **log**: file path specifying where to save REPL commands and printed output.
77-
- **quiet**: `boolean` indicating whether log information, confirmation messages, and other possible REPL diagnostics should be silenced. Default: `false`.
77+
- **quiet**: boolean indicating whether log information, confirmation messages, and other possible REPL diagnostics should be silenced. Default: `false`.
78+
- **settings**: object specifying REPL settings.
79+
80+
The function supports specifying the following settings:
81+
82+
- **autoClosePairs**: boolean indicating whether to automatically insert matching brackets, parentheses, and quotes. Default: `true`.
83+
- **autoDeletePairs**: boolean indicating whether to automatically delete adjacent matching brackets, parentheses, and quotes. Default: `true`.
84+
- **completionPreviews**: boolean indicating whether to display completion previews for auto-completion. When streams are TTY, the default is `true`; otherwise, the default is `false`.
7885

7986
#### REPL.prototype.createContext()
8087

@@ -289,6 +296,71 @@ repl.clearCommand();
289296
repl.close();
290297
```
291298

299+
#### REPL.prototype.settings( \[name\[, value]] )
300+
301+
Returns REPL settings.
302+
303+
```javascript
304+
var debug = require( '@stdlib/streams/node/debug-sink' );
305+
306+
// Create a new REPL:
307+
var repl = new REPL({
308+
'output': debug()
309+
});
310+
311+
// ...
312+
313+
// Retrieve REPL settings:
314+
var o = repl.settings();
315+
316+
// ...
317+
318+
// Close the REPL:
319+
repl.close();
320+
```
321+
322+
To retrieve the current value for a specific setting, provide a `name` argument.
323+
324+
```javascript
325+
var debug = require( '@stdlib/streams/node/debug-sink' );
326+
327+
// Create a new REPL:
328+
var repl = new REPL({
329+
'output': debug()
330+
});
331+
332+
// ...
333+
334+
// Retrieve current setting value:
335+
var v = repl.settings( 'autoClosePairs' );
336+
337+
// ...
338+
339+
// Close the REPL:
340+
repl.close();
341+
```
342+
343+
To update a specific setting, provide a `value` argument.
344+
345+
```javascript
346+
var debug = require( '@stdlib/streams/node/debug-sink' );
347+
348+
// Create a new REPL:
349+
var repl = new REPL({
350+
'output': debug()
351+
});
352+
353+
// ...
354+
355+
// Update setting value:
356+
repl.settings( 'autoClosePairs', false );
357+
358+
// ...
359+
360+
// Close the REPL:
361+
repl.close();
362+
```
363+
292364
#### REPL.prototype.close()
293365

294366
Closes a REPL.
@@ -966,6 +1038,26 @@ Stops saving commands to a file path associated with a specified record identifi
9661038
// TODO
9671039
```
9681040

1041+
#### settings( \[name\[, value]] )
1042+
1043+
Displays REPL settings.
1044+
1045+
```text
1046+
In [1]: settings()
1047+
```
1048+
1049+
To retrieve the current value for a specific setting, provide a `name` argument.
1050+
1051+
```text
1052+
In [1]: settings( 'autoClosePairs' )
1053+
```
1054+
1055+
To update a specific setting, provide a `value` argument.
1056+
1057+
```text
1058+
In [1]: settings( 'autoClosePairs', false )
1059+
```
1060+
9691061
#### tutorial( \[name, \[options]] )
9701062

9711063
Starts a tutorial.

0 commit comments

Comments
 (0)