From 48ea59e96ff88af9070d832142bf423d850030be Mon Sep 17 00:00:00 2001 From: y4my4my4m <8145020+y4my4my4m@users.noreply.github.com> Date: Sat, 18 Nov 2023 20:48:22 -0500 Subject: [PATCH] fontbook --- src/Home/FontBook/CurrentFont.TXT | Bin 0 -> 9 bytes src/Home/FontBook/FontCycle.ZC | 75 ++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 src/Home/FontBook/CurrentFont.TXT create mode 100755 src/Home/FontBook/FontCycle.ZC diff --git a/src/Home/FontBook/CurrentFont.TXT b/src/Home/FontBook/CurrentFont.TXT new file mode 100755 index 0000000000000000000000000000000000000000..4829304696ddcd59e29b8aa3bce77afcad930c9f GIT binary patch literal 9 Qcmaz_P0Vr1&q-kb01%u54gdfE literal 0 HcmV?d00001 diff --git a/src/Home/FontBook/FontCycle.ZC b/src/Home/FontBook/FontCycle.ZC new file mode 100755 index 00000000..6ae85b3f --- /dev/null +++ b/src/Home/FontBook/FontCycle.ZC @@ -0,0 +1,75 @@ +U0 FontCycle(I8 direction) +{ + CDirEntry *tmpde1, *previous = NULL, *selected = NULL; + U8 selected_font; + + I64 current_font = FileRead("~/FontBook/CurrentFont.TXT"); + if (!current_font) + { + FileWrite("~/FontBook/CurrentFont.TXT", "Zeal", 4); + } + + //I64 current_font = "Zeal"; + //"$$LTBLUE$$current_font:\t%s$$FG$$\n", current_font; + + if (direction == 0) + { + selected_font = current_font; + goto load_current; + } + + tmpde1 = FilesFind("~/FontBook/Fonts/*.BIN", 1); + if (!tmpde1) return; + + do { + FileExtRemove(tmpde1->name); + //"found:\t\t\t%s\n", tmpde1->name; + // Check if this is the current font + if (StrCompare(current_font, tmpde1->name) == 0) { + if (direction == 1) { + if (tmpde1->next) { + selected = tmpde1->next; + } else { + selected = FilesFind("~/FontBook/Fonts/*.BIN", 1); // Start from the first font if at the end + } + } else { + if (previous) { + selected = previous; + } else { + // Find the last font for the case where direction is -1 and we're at the start + CDirEntry *temp = tmpde1; + while (temp->next) { + temp = temp->next; + } + selected = temp; + } + } + break; // Exit loop once the current font is found. + } + + previous = tmpde1; + tmpde1 = tmpde1->next; + } while (tmpde1); + + if (selected) { + FileExtRemove(selected->name); + + selected_font = selected->name; + "\n$$YELLOW$$selected:\t\t%s$$FG$$\n", selected_font; + FileWrite("~/FontBook/CurrentFont.TXT", selected_font, StrLen(selected_font)+1); + +load_current: + U8 selected_path[0]; + StrPrint(selected_path, "~/FontBook/Fonts/%s.BIN", selected_font); + //"%s\n", selected_path; + + U64 *new_font = FileRead(selected_path); + if (new_font) { + + text.font = new_font; + Free(new_font); + } + } +} + +//FontCycle(1);