()
| 230 | } |
| 231 | |
| 232 | render() { |
| 233 | if (this.closed) return; |
| 234 | if (!this.firstRender) { |
| 235 | if (this.outputError) |
| 236 | this.out.write( |
| 237 | cursor.down(lines(this.outputError, this.out.columns) - 1) + |
| 238 | clear(this.outputError, this.out.columns), |
| 239 | ); |
| 240 | this.out.write(clear(this.outputText, this.out.columns)); |
| 241 | } |
| 242 | super.render(); |
| 243 | this.outputError = ""; |
| 244 | |
| 245 | let prefix = " ".repeat(strip(this.label).length); |
| 246 | |
| 247 | this.outputText = [ |
| 248 | "\n", |
| 249 | this.label, |
| 250 | " ", |
| 251 | this.msg, |
| 252 | this.done |
| 253 | ? "" |
| 254 | : this.hint |
| 255 | ? (this.out.columns < 80 ? "\n" + " ".repeat(8) : "") + |
| 256 | color.dim(` (${this.hint})`) |
| 257 | : "", |
| 258 | "\n" + prefix, |
| 259 | " ", |
| 260 | this.done ? color.dim(this.rendered) : this.rendered, |
| 261 | ].join(""); |
| 262 | |
| 263 | if (this.error) { |
| 264 | this.outputError += ` ${color.redBright( |
| 265 | (shouldUseAscii() ? "> " : "▶ ") + this.errorMsg, |
| 266 | )}`; |
| 267 | } |
| 268 | |
| 269 | this.out.write( |
| 270 | erase.line + |
| 271 | cursor.to(0) + |
| 272 | this.outputText + |
| 273 | cursor.save + |
| 274 | this.outputError + |
| 275 | cursor.restore + |
| 276 | cursor.move( |
| 277 | this.placeholder |
| 278 | ? (this.rendered.length - 9) * -1 |
| 279 | : this.cursorOffset, |
| 280 | 0, |
| 281 | ), |
| 282 | ); |
| 283 | } |
| 284 | } |
no test coverage detected