()
| 171 | } |
| 172 | |
| 173 | render() { |
| 174 | if (this.closed) return; |
| 175 | if (this.firstRender) this.out.write(cursor.hide); |
| 176 | else this.out.write(clear(this.outputText, this.out.columns)); |
| 177 | super.render(); |
| 178 | |
| 179 | let outputText = [ |
| 180 | "\n", |
| 181 | this.label, |
| 182 | " ", |
| 183 | this.msg, |
| 184 | this.done |
| 185 | ? "" |
| 186 | : this.hint |
| 187 | ? (this.out.columns < 80 ? "\n" + " ".repeat(8) : "") + |
| 188 | color.dim(` (${this.hint})`) |
| 189 | : "", |
| 190 | "\n", |
| 191 | ]; |
| 192 | |
| 193 | let prefix = " ".repeat(strip(this.label).length); |
| 194 | |
| 195 | if (this.done) { |
| 196 | outputText.push( |
| 197 | `${prefix} `, |
| 198 | color.dim(`${this.choices[this.cursor]?.label}`), |
| 199 | ); |
| 200 | } else { |
| 201 | outputText.push( |
| 202 | this.choices |
| 203 | .map((choice, i) => |
| 204 | i === this.cursor |
| 205 | ? `${prefix} ${color.green( |
| 206 | shouldUseAscii() ? ">" : "●", |
| 207 | )} ${this.highlight(choice.label)} ${ |
| 208 | choice.hint ? color.dim(choice.hint) : "" |
| 209 | }` |
| 210 | : color.dim( |
| 211 | `${prefix} ${shouldUseAscii() ? "—" : "○"} ${choice.label} `, |
| 212 | ), |
| 213 | ) |
| 214 | .join("\n"), |
| 215 | ); |
| 216 | } |
| 217 | this.outputText = outputText.join(""); |
| 218 | |
| 219 | this.out.write(erase.line + cursor.to(0) + this.outputText); |
| 220 | } |
| 221 | } |
no test coverage detected