render() { if (this.closed) return; if (this.firstRender) this.out.write(cursor.hide); else this.out.write(clear(this.outputText)); super.render(); // Print prompt this.outputText = [ style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []) .join('') ].join(' '); // Print error if (this.error) { this.outputText += this.errorMsg.split('\n').reduce( (a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``); } this.out.write(erase.line + cursor.to(0) + this.outputText); }
render() { if (this.closed) return; if (!this.firstRender) { if (this.outputError) this.out.write(cursor.down(lines(this.outputError) - 1) + clear(this.outputError)); this.out.write(clear(this.outputText)); } super.render(); this.outputError = ''; this.outputText = [ style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.red ? color.red(this.rendered) : this.rendered ].join(` `); if (this.error) { this.outputError += this.errorMsg.split(`\n`) .reduce((a, l, i) => a + `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``); } this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore); }
render() { if (this.closed) return; if (!this.firstRender) { if (this.outputError) this.out.write(cursor.down(lines(this.outputError) - 1) + clear(this.outputError)); this.out.write(clear(this.outputText)); } super.render(); this.outputError = ''; // Print prompt this.outputText = [ style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), !this.done || (!this.done && !this.placeholder) ? color[this.color]().underline(this.rendered) : this.rendered ].join(` `); // Print error if (this.error) { this.outputError += this.errorMsg.split(`\n`) .reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``); } this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore); }