let self = { Basic: (message, col) => { console.clear(); process.stdout.cursorTo(0, 0); global.vertical = Math.round(process.stdout.rows / 2 + 1) - 3; let horizontal = Math.round(process.stdout.columns / 2 - (1 + ((message.length + 8) / 2))); for (let n = 0; n < vertical; n++) { process.stdout.write("\n"); } console.log(" ".repeat(horizontal) + color.bgWhite[col]("┏━━━" + "━".repeat(message.length) + "━━━┓")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(message.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite.black(color[col]("┃") + " " + message + " " + color[col]("┃"))); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(message.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┗━━━" + "─".repeat(message.length) + "━━━┛")); for (let n = 0; n < (vertical - 3); n++) { process.stdout.write("\n"); } }, ConfirmLines: (lines, confirm, col) => { process.stdout.cursorTo(0, 1); let longest = lines.reduce(function(a, b) { return a.length > b.length ? a : b }, ''); global.vertical = Math.round(process.stdout.rows / 2 + 1) - 5 - (lines.length / 2); let horizontal = Math.round(process.stdout.columns / 2 - (1 + ((longest.length + 8) / 2))); for (let n = 0; n < vertical; n++) { process.stdout.write("\n"); } console.log(" ".repeat(horizontal) + color.bgWhite[col]("┏━━━" + "━".repeat(longest.length) + "━━━┓")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(longest.length) + " ┃")); let index = 0; for (let line of lines) { if (index === 0) { console.log(" ".repeat(horizontal) + color.bgWhite.black(color[col]("┃") + " " + chalk.underline(line) + " ".repeat(longest.length - line.length) + " " + color[col]("┃"))); } else { console.log(" ".repeat(horizontal) + color.bgWhite.black(color[col]("┃") + " " + line + " ".repeat(longest.length - line.length) + " " + color[col]("┃"))); } index++; } console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(longest.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(longest.length - (confirm.length + 2)) + chalk.bgBlack.white(" " + confirm + " ") + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(longest.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┗━━━" + "━".repeat(longest.length) + "━━━┛")); for (let n = 0; n < (vertical - 3 - lines.length); n++) { process.stdout.write("\n"); } Strawberry.KeyboardEvents.push(Strawberry.Dialog._KeyboardHandler); }, Confirm: (message, confirm, col) => { process.stdout.cursorTo(0, 1); global.vertical = Math.round(process.stdout.rows / 2 + 1) - 5; let horizontal = Math.round(process.stdout.columns / 2 - (1 + ((message.length + 8) / 2))); for (let n = 0; n < vertical; n++) { process.stdout.write("\n"); } console.log(" ".repeat(horizontal) + color.bgWhite[col]("┏━━━" + "━".repeat(message.length) + "━━━┓")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(message.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite.black(color[col]("┃") + " " + message + " " + color[col]("┃"))); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(message.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(message.length - (confirm.length + 2)) + chalk.bgBlack.white(" " + confirm + " ") + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┃ " + " ".repeat(message.length) + " ┃")); console.log(" ".repeat(horizontal) + color.bgWhite[col]("┗━━━" + "━".repeat(message.length) + "━━━┛")); for (let n = 0; n < (vertical - 3); n++) { process.stdout.write("\n"); } Strawberry.KeyboardEvents.push(Strawberry.Dialog._KeyboardHandler); }, WhenConfirmed: () => {}, _KeyboardHandler: (sequence) => { if (sequence === "\r") { Strawberry.Audio.SystemSound("Strawberry.UI.Button"); Strawberry.KeyboardEvents.splice(Strawberry.KeyboardEvents.indexOf(Strawberry.Dialog._KeyboardHandler), 1); Strawberry.Dialog.WhenConfirmed(); } } } module.exports = self;