// From here: http://stackoverflow.com/a/24519813/3296811 const fixedPrint = function (type, args) { const indent = Math.ceil((REPL.line.length + 3) / process.stdout.columns); const text = util.format.apply(console, args); REPL.output.write('\n\x1B[' + indent + 'A\x1B[0J'); // No idea at all.... REPL.output.write(text + '\n'); REPL.output.write(Array(indent).join('\n\x1B[E')); REPL._refreshLine(); }
rl.history.find((h) => h.includes(rl.line))
rl.on('SIGINT', () => { if (MODE === 'REVERSE') { MODE = 'NORMAL'; process.stdout.moveCursor(0, -1); process.stdout.cursorTo(0); rl._refreshLine(); } else if (rl.line.length) { rl.line = ''; rl.cursor = 0; rl._refreshLine(); } else if (nextCtrlCKills) { process.exit(); } else { nextCtrlCKills = true; process.stdout.write(`\n(To exit, press ^C again)\n${PROMPT}`); } });
Promise.all([ completeLine(inspectedLine, true), getPreview(inspectedLine), ]) .then(([completion, preview]) => { if (rl.line !== inspectedLine) { return; } if (completion && completion.completions.length > 0) { if (completion.fillable) { ([completionCache] = completion.completions); } process.stdout.cursorTo(PROMPT.length + rl.line.length); process.stdout.write(chalk.grey(completion.completions[0])); } if (preview) { process.stdout.write(`\n${chalk.grey(preview.slice(0, process.stdout.columns - 1))}`); process.stdout.moveCursor(0, -1); } if (completion || preview) { process.stdout.cursorTo(PROMPT.length + rl.cursor); } }) .catch(() => {});
function hidden (query, cb) { const stdin = process.openStdin() const hidden = readline.createInterface({ input: stdin, output: process.stdout }) function onData (char) { char = char.toString() switch (char) { case '\n': case '\r': case '\u0004': stdin.removeListener('data', onData) break default: process.stdout.write('\u001b[2K\u001b[200D' + query + Array(hidden.line.length + 1).join('*')) break } } stdin.on('data', onData) hidden.question(query, value => { hidden.history = hidden.history.slice(1) hidden.close() cb(value) }) }
message += this.rl.line;
this.rl.line = _.trim(this.rl.line); if (this.rl.line === this.lastQuery) { return; sourcePromise = this.opt.source(this.answers, this.rl.line); } else { sourcePromise = this.opt.source(this.answers, null); this.lastQuery = this.rl.line; this.lastSourcePromise = sourcePromise; this.searching = true;
var fu = function (type, args) { var t = Math.ceil((rl.line.length + 3) / process.stdout.columns); var text = util.format.apply(console, args); rl.output.write("\n\x1B[" + t + "A\x1B[0J"); rl.output.write(text + "\n"); rl.output.write(Array(t).join("\n\x1B[E")); rl._refreshLine(); }