You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/repl/README.md
+265-1Lines changed: 265 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,7 @@ The function accepts the following `options`:
71
71
-**outputPrompt**: output prompt. If the output prompt includes the character sequence `%d`, the output prompt includes line numbers. Default: `'Out[%d]: '`.
72
72
-**welcome**: welcome message.
73
73
-**padding**: number of empty lines between consecutive commands. Default: `1`.
74
+
-**themes**: table containing color themes for syntax highlighting.
74
75
-**load**: file path specifying a JavaScript file to load and evaluate line-by-line (e.g., a previous REPL history file).
75
76
-**save**: file path specifying where to save REPL command history.
76
77
-**log**: file path specifying where to save REPL commands and printed output.
@@ -83,6 +84,27 @@ The function supports specifying the following settings:
83
84
-**autoDeletePairs**: boolean indicating whether to automatically delete adjacent matching brackets, parentheses, and quotes. Default: `true`.
84
85
-**autoPage**: boolean indicating whether to automatically page return values having a display size exceeding the visible screen. When streams are TTY, the default is `true`; otherwise, the default is `false`.
85
86
-**completionPreviews**: boolean indicating whether to display completion previews for auto-completion. When streams are TTY, the default is `true`; otherwise, the default is `false`.
87
+
-**syntaxHighlighting**: boolean indicating whether to enable syntax highlighting of entered input expressions. When streams are TTY, the default is `true`; otherwise, the default is `false`.
88
+
-**theme**: initial color theme for syntax highlighting. Default: `stdlib-ansi-basic`.
89
+
90
+
#### REPL.prototype.viewport()
91
+
92
+
Returns the REPL viewport.
93
+
94
+
```javascript
95
+
var debug =require( '@stdlib/streams/node/debug-sink' );
96
+
97
+
// Create a new REPL:
98
+
var repl =newREPL({
99
+
'output':debug()
100
+
});
101
+
102
+
// Query the REPL viewport:
103
+
var v =repl.viewport();
104
+
105
+
// Close the REPL:
106
+
repl.close();
107
+
```
86
108
87
109
#### REPL.prototype.createContext()
88
110
@@ -153,7 +175,7 @@ repl.clearHistory();
153
175
repl.close();
154
176
```
155
177
156
-
#### Repl.prototype.clearUserDocs()
178
+
#### REPL.prototype.clearUserDocs()
157
179
158
180
Clears user-defined documentation.
159
181
@@ -176,6 +198,167 @@ repl.clearUserDocs();
176
198
repl.close();
177
199
```
178
200
201
+
#### REPL.prototype.themes()
202
+
203
+
Returns a list of all available themes for syntax highlighting.
204
+
205
+
```javascript
206
+
var debug =require( '@stdlib/streams/node/debug-sink' );
207
+
208
+
// Create a new REPL:
209
+
var repl =newREPL({
210
+
'output':debug()
211
+
});
212
+
213
+
// ...
214
+
215
+
// Fetch all available themes:
216
+
var themes =repl.themes();
217
+
// returns [...]
218
+
219
+
// ...
220
+
221
+
// Close the REPL:
222
+
repl.close();
223
+
```
224
+
225
+
#### REPL.prototype.getTheme( name )
226
+
227
+
Returns a theme's color palette for syntax highlighting.
228
+
229
+
```javascript
230
+
var debug =require( '@stdlib/streams/node/debug-sink' );
231
+
232
+
// Create a new REPL:
233
+
var repl =newREPL({
234
+
'output':debug()
235
+
});
236
+
237
+
// ...
238
+
239
+
// Add a user-defined theme:
240
+
repl.addTheme( 'myTheme', {
241
+
'keyword':'red'
242
+
});
243
+
244
+
// Get a theme's color palette:
245
+
var theme =repl.getTheme( 'myTheme' );
246
+
// returns { 'keyword': 'red' }
247
+
248
+
// ...
249
+
250
+
// Close the REPL:
251
+
repl.close();
252
+
```
253
+
254
+
#### REPL.prototype.addTheme( name, theme )
255
+
256
+
Adds a syntax highlighting theme.
257
+
258
+
```javascript
259
+
var debug =require( '@stdlib/streams/node/debug-sink' );
260
+
261
+
// Create a new REPL:
262
+
var repl =newREPL({
263
+
'output':debug()
264
+
});
265
+
266
+
// ...
267
+
268
+
// Add a user-defined theme:
269
+
repl.addTheme( 'myTheme', {
270
+
'keyword':'red',
271
+
'variable':'green'
272
+
273
+
// ...
274
+
});
275
+
276
+
// ...
277
+
278
+
// Close the REPL:
279
+
repl.close();
280
+
```
281
+
282
+
The syntax-highlighter supports the following tokens and associated theme fields:
283
+
284
+
-**keyword**: keywords (e.g., `var`, `function`, `let`, `const`, `in`, and `class`).
285
+
-**control**: control flow keywords (e.g., `if`, `else`, `try`, `catch`, and `return`).
286
+
-**specialIdentifier**: special identifiers (e.g., `this` and `super`).
287
+
-**string**: string and template literals.
288
+
-**number**: numeric literals.
289
+
-**literal**: reserved literals (e.g., `true`, `false`, `null`, and `undefined`).
290
+
-**regexp**: regular expressions.
291
+
-**command**: built-in REPL commands.
292
+
-**function**: function identifiers.
293
+
-**object**: object identifiers.
294
+
-**variable**: literal identifiers.
295
+
-**name**: variable names.
296
+
-**comment**: line comments.
297
+
-**punctuation**: punctuation symbols (e.g., `;`, `[`, `{`, `,`, and `?`).
0 commit comments