mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: print hints one by one, fix unexpected breakline
This commit is contained in:
1 parent
fc13e9371c
commit
a9a63ea164
2 files changed
+13
-10
No files matched your search
@@ -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,
|
||||
}
|
||||
Reference in new issue
Block a user