feat: print hints one by one, fix unexpected breakline

This commit is contained in:
Lin, Hung-Shin committed 2023-11-23 21:56:01 +08:00
1 parent fc13e9371c
commit a9a63ea164
2 files changed
+13 -10

No files matched your search

+10 -5
View File
@@ -52,6 +52,7 @@ function printLine(content, delay, color) {
waitForEnter().then(() => {
clearInterval(timer)
if (i >= printContent.length) return
process.stdout.write(printContent.slice(i))
process.stdout.write('\n')
resolve()
@@ -68,22 +69,26 @@ async function printResponses(responses, delay = 100) {
for (const line of content) {
await printLine(line, delay, color || 'cyan')
}
console.log(colorize('------------------------------', 'green'))
console.log()
}
if (type === 'dialogue') {
console.log(colorize(`${speaker}:`, 'green'))
for (const line of content) {
await printLine(` ${line}`, delay, color || 'cyan')
}
console.log(colorize('------------------------------', 'green'))
console.log()
}
console.log(colorize('------------------------------', 'green'))
console.log()
}
}
async function printHints(hints, delay = 100) {
for (const hint of hints) {
await printLine(hint, delay, 'yellow')
}
rl.close()
}
module.exports = {
printResponses,
printHints,
colorize,
}