summaryrefslogtreecommitdiff
path: root/Library/SDK/Modules/Strawberry.MenuBar.js
diff options
context:
space:
mode:
Diffstat (limited to 'Library/SDK/Modules/Strawberry.MenuBar.js')
-rw-r--r--Library/SDK/Modules/Strawberry.MenuBar.js143
1 files changed, 143 insertions, 0 deletions
diff --git a/Library/SDK/Modules/Strawberry.MenuBar.js b/Library/SDK/Modules/Strawberry.MenuBar.js
new file mode 100644
index 0000000..957dcf1
--- /dev/null
+++ b/Library/SDK/Modules/Strawberry.MenuBar.js
@@ -0,0 +1,143 @@
+// 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);
+ 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: () => {
+ 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; \ No newline at end of file