1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
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;
|