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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// noinspection JSValidateTypes,JSUnresolvedVariable
process.stdout.cursorTo(0, 0);
let name;
let menus = "";
let menusText = "";
self = {
Initialize: () => {
menus = "";
menusText = "";
if (Strawberry.System) {
name = color.bgCyan.black(" " + Strawberry.App + " ")
} else {
name = color.bgGreen.black(" " + Strawberry.App + " ")
}
for (let item of Strawberry.Menus) {
menus += color.bgBlue(" " + color.bgWhite.black(" " + item + " "));
menusText += " " + item + " ";
}
if (!Strawberry.Tick.Events.includes(self.UpdateClock)) {
Strawberry.Tick.Events.push(self.UpdateClock)
}
},
Reset: () => {
process.stdout.cursorTo(0, 0);
if (global._STRAWBERRY_DEBUG_MODE) {
process.stdout.write(color.reset(color.bgBlue(" " + color.black.bgYellowBright(" O ") + " " + menus + " ".repeat(process.stdout.columns - (15 + Strawberry.App.length + menusText.length + 4)) + new Date().toTimeString().substring(0, 5) + " " + name + " " + color.bgRed.black(" D ") + " ")))
process.stdout.cursorTo(0, process.stdout.rows);
} else {
process.stdout.write(color.reset(color.bgBlue(" " + color.black.bgYellowBright(" O ") + " " + menus + " ".repeat(process.stdout.columns - (15 + Strawberry.App.length + menusText.length)) + new Date().toTimeString().substring(0, 5) + " " + name + " ")))
process.stdout.cursorTo(0, process.stdout.rows);
}
},
Active: (item) => {
let a = Strawberry.Menus.filter((_, i) => {
return i < item;
}).map((e) => {
return e.length + 3;
});
let b;
if (a.length === 0) {
b = 0
} else {
b = a.reduce((a, b) => {
return a + b;
})
}
process.stdout.cursorTo(6 + b, 0);
process.stdout.write(color.bgGray.white(" " + Strawberry.Menus[item] + " "));
},
Inactive: (item) => {
let a = Strawberry.Menus.filter((_, i) => {
return i < item;
}).map((e) => {
return e.length + 3;
});
let b;
if (a.length === 0) {
b = 0
} else {
b = a.reduce((a, b) => {
return a + b;
})
}
process.stdout.cursorTo(6 + b, 0);
process.stdout.write(color.bgWhite.black(" " + Strawberry.Menus[item] + " "));
},
Blink: (item) => {
process.stdout.cursorTo(0, 0);
process.stdout.write(color.reset(color.bgBlue(" " + color.black.bgYellowBright(" O ") + " " + menus + " ".repeat(process.stdout.columns - (15 + Strawberry.App.length + menusText.length)) + new Date().toTimeString().substring(0, 5) + " " + name + " ")))
process.stdout.cursorTo(0, process.stdout.rows);
setTimeout(() => {
self.Active(item);
setTimeout(() => {
self.Inactive(item);
setTimeout(() => {
self.Active(item);
setTimeout(() => {
self.Inactive(item);
setTimeout(() => {
self.Active(item);
setTimeout(() => {
self.Inactive(item);
}, 30);
}, 30);
}, 30);
}, 30);
}, 30);
}, 30);
},
BlinkAndQuit: () => {
load("Strawberry.AppManager");
setTimeout(() => {
self.QuitActive();
setTimeout(() => {
self.QuitInactive();
setTimeout(() => {
self.QuitActive();
setTimeout(() => {
self.QuitInactive();
setTimeout(() => {
self.QuitActive();
setTimeout(() => {
self.QuitInactive();
setTimeout(() => {
Strawberry.AppManager.Quit();
}, 30);
}, 30);
}, 30);
}, 30);
}, 30);
}, 30);
}, 30);
},
QuitActive: () => {
process.stdout.cursorTo(1, 0);
process.stdout.write(chalk.bgYellow.black(" O "));
},
QuitInactive: () => {
process.stdout.cursorTo(1, 0);
process.stdout.write(chalk.bgYellowBright.black(" O "));
},
UpdateClock: () => {
if (global._STRAWBERRY_DEBUG_MODE) {
process.stdout.cursorTo(process.stdout.columns - (10 + Strawberry.App.length + 4), 0);
} else {
process.stdout.cursorTo(process.stdout.columns - (10 + Strawberry.App.length), 0);
}
process.stdout.write(color.bgBlue(new Date().toTimeString().substring(0, 5)));
process.stdout.cursorTo(0, process.stdout.rows);
}
}
self.Initialize();
self.Reset();
Strawberry.Tick.Events.push(self.UpdateClock)
module.exports = self;
|