Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
, render: function () {
let prompt = [
ui.symbol(this.done, this.aborted),
this.msg,
ui.delimiter(this.completing),
this.done && this.suggestions[this.cursor]
? this.suggestions[this.cursor].title
: this.transform(this.input)
].join(' ')
if (!this.done) {
prompt += esc.cursorSavePosition
for (let i = 0; i < this.suggestions.length; i++) {
const s = this.suggestions[i]
prompt += '\n' + (i === this.cursor ? chalk.cyan(s.title) : s.title)
}
prompt += esc.cursorRestorePosition
}
this.out.write(ui.clear(this.lastRendered) + prompt)
this.lastRendered = prompt
}
}
var red = AnsiStyles.red;
var yellow = AnsiStyles.yellow;
var green = AnsiStyles.green;
var blue = AnsiStyles.blue;
var magenta = AnsiStyles.magenta;
var bgRed = AnsiStyles.bgRed;
var bgYellow = AnsiStyles.bgYellow;
var bgGreen = AnsiStyles.bgGreen;
var bgBlue = AnsiStyles.bgBlue;
var cursorUp = AnsiEscapes.cursorUp;
var cursorDown = AnsiEscapes.cursorDown;
var eraseEndLine = AnsiEscapes.eraseEndLine;
var cursorSavePosition = AnsiEscapes.cursorSavePosition;
var cursorRestorePosition = AnsiEscapes.cursorRestorePosition;
var width = 50;
var stdoutLineCount = 0;
var nyanTemplate = {
ascii: [
' ,--------, ',
' │▗▝ ▞ ▝ ˄---˄ ',
'~│ ▞ ▞ ❬.◕‿‿◕.❭',
' `w-w---- w w '
],
colors: [
' ggggggggggg ',
' gMMMMMMMggggg ',
'ggMMMMMMgwwwwwwg',
readline.emitKeypressEvents(rl.input);
if (stdin.isTTY) stdin.setRawMode(true);
const close = () => {
rl.close();
let result = session.renderResult();
update.clear(1);
if (options.onClose) {
setImmediate(() => {
options.onClose.call(session, colors.unstyle(result), session);
});
}
};
rl.write(escapes.cursorSavePosition);
session.on('alert', () => {
session.alert = false;
rl.write('\u0007');
});
rl.on('SIGINT', close);
rl.on('line', close);
rl.input.on('keypress', (input, event) => {
if (!session.focused) return;
let action = keypress.action(input, event);
let item = session.focused;
let type = item.type;
item.input = colors.unstyle(item.input || '');