|
1 |
| -// module Node.ReadLine |
| 1 | +// module Node.rl |
2 | 2 |
|
3 |
| -import { createInterface } from "readline"; |
| 3 | +import readline from "node:readline"; |
4 | 4 |
|
5 |
| -export const createInterfaceImpl = (options) => createInterface({ |
| 5 | +export const createInterfaceImpl = (options) => readline.createInterface({ |
6 | 6 | input: options.input,
|
7 | 7 | output: options.output,
|
8 | 8 | completer: options.completer && (line => {
|
9 | 9 | const res = options.completer(line)();
|
10 | 10 | return [res.completions, res.matched];
|
11 | 11 | }),
|
12 | 12 | terminal: options.terminal,
|
| 13 | + history: options.history, |
13 | 14 | historySize: options.historySize,
|
| 15 | + removeHistoryDuplicates: options.removeHistoryDuplicates, |
| 16 | + prompt: options.prompt, |
| 17 | + crlDelay: options.crlDelay, |
| 18 | + escapeCodeTimeout: options.escapeCodeTimeout, |
| 19 | + tabSize: options.tabSize, |
| 20 | + signal: options.signal |
14 | 21 | });
|
15 | 22 |
|
16 |
| -export const closeImpl = (readline) => readline.close(); |
17 |
| -export const promptImpl = (readline) => readline.prompt(); |
18 |
| -export const questionImpl = (readline, text, cb) => readline.question(text, cb); |
19 |
| -export const setPromptImpl = (readline, prompt) => readline.setPrompt(prompt); |
20 |
| -export const setLineHandlerImpl = (readline, cb) => { |
21 |
| - readline.removeAllListeners("line"); |
22 |
| - readline.on("line", cb); |
23 |
| -}; |
| 23 | +export const closeImpl = (rl) => rl.close(); |
| 24 | +export const pauseImpl = (rl) => rl.pause(); |
| 25 | +export const promptImpl = (rl) => rl.prompt(); |
| 26 | +export const promptOptsImpl = (rl, cursor) => rl.prompt(cursor); |
| 27 | +export const questionImpl = (rl, text, cb) => rl.question(text, cb); |
| 28 | +export const resumeImpl = (rl) => rl.resume(); |
| 29 | +export const setPromptImpl = (rl, prompt) => rl.setPrompt(prompt); |
| 30 | +export const getPromptImpl = (rl) => rl.getPrompt(); |
| 31 | +export const writeDataImpl = (rl, dataStr) => rl.write(dataStr); |
| 32 | +export const writeKeyImpl = (rl, keySeqObj) => rl.write(null, keySeqObj); |
| 33 | +export const lineImpl = (rl) => rl.line; |
| 34 | +export const cursorImpl = (rl) => rl.cursor; |
| 35 | +export const getCursorPosImpl = (rl) => rl.getCursorPos(); |
| 36 | + |
| 37 | +export const clearLineLeftImpl = (w) => readline.clearLine(w, -1); |
| 38 | +export const clearLineLeftCbImpl = (w, cb) => readline.clearLine(w, -1, cb); |
| 39 | +export const clearLineRightImpl = (w) => readline.clearLine(w, 1); |
| 40 | +export const clearLineRightCbImpl = (w, cb) => readline.clearLine(w, 1, cb); |
| 41 | +export const clearEntireLineImpl = (w) => readline.clearLine(w, 0); |
| 42 | +export const clearEntireLineCbImpl = (w, cb) => readline.clearLine(w, 0, cb); |
| 43 | +export const clearScreenDownImpl = (w) => readline.clearScreenDown(w); |
| 44 | +export const clearScreenDownCbImpl = (w, cb) => readline.clearScreenDown(w, cb); |
| 45 | +export const cursorToXImpl = (w, x) => readline.cursorTo(w, x); |
| 46 | +export const cursorToXCbImpl = (w, x, cb) => readline.cursorTo(w, x, cb); |
| 47 | +export const cursorToXYImpl = (w, x, y) => readline.cursorTo(w, x, y); |
| 48 | +export const cursorToXYCbImpl = (w, x, y, cb) => readline.cursorTo(w, x, y, cb); |
| 49 | +export const emitKeyPressEventsImpl = (r) => readline.emitKeypressEvents(r); |
| 50 | +export const emitKeyPressEventsIfaceImpl = (r, iface) => readline.emitKeypressEvents(r, iface); |
| 51 | +export const moveCursorXYImpl = (w, x, y) => readline.moveCursor(w, x, y); |
| 52 | +export const moveCursorXYCbImpl = (w, x, y, cb) => readline.moveCursor(w, x, y, cb); |
0 commit comments