// 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;