=> aac0bc8a49d06fffcaca7a1fd3c35de035ac3e7c
[1mdiff --git a/src/app.c b/src/app.c[m [1mindex 749d998e..3a1ee101 100644[m [1m--- a/src/app.c[m [1m+++ b/src/app.c[m [36m@@ -761,6 +761,7 @@[m [mstatic void init_App_(iApp *d, int argc, char **argv) {[m setupApplication_iOS();[m #endif[m init_Keys();[m [32m+[m[32m loadPalette_Color(dataDir_App_());[m setThemePalette_Color(d->prefs.theme); /* default UI colors */[m loadPrefs_App_(d);[m load_Keys(dataDir_App_());[m [1mdiff --git a/src/ui/color.c b/src/ui/color.c[m [1mindex 6c51bc06..05ec1f6f 100644[m [1m--- a/src/ui/color.c[m [1m+++ b/src/ui/color.c[m [36m@@ -24,11 +24,13 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m #include "root.h"[m #include "app.h"[m [m [32m+[m[32m#include[m [32m+[m[32m#include [m #include [m [m static const iColor transparent_;[m [m [31m-static const iColor darkPalette_[] = {[m [32m+[m[32mstatic iColor darkPalette_[] = {[m { 0, 0, 0, 255 },[m { 40, 40, 40, 255 },[m { 80, 80, 80, 255 },[m [36m@@ -47,7 +49,7 @@[m [mstatic const iColor darkPalette_[] = {[m { 0, 200, 0, 255 },[m };[m [m [31m-static const iColor lightPalette_[] = {[m [32m+[m[32mstatic iColor lightPalette_[] = {[m { 0, 0, 0, 255 },[m { 75, 75, 75, 255 },[m { 150, 150, 150, 255 },[m [36m@@ -804,3 +806,77 @@[m [miColor ansiForeground_Color(iRangecc escapeSequence, int fallback) {[m }[m return clr;[m }[m [32m+[m [32m+[m[32miBool loadPalette_Color(const char *path) {[m [32m+[m[32m iBool wasLoaded = iFalse;[m [32m+[m[32m iFile *f = newCStr_File(concatPath_CStr(path, "palette.txt"));[m [32m+[m[32m if (open_File(f, text_FileMode | readOnly_FileMode)) {[m [32m+[m[32m iColor *dstPal = darkPalette_;[m [32m+[m[32m iRangecc srcLine = iNullRange;[m [32m+[m[32m const iBlock *src = collect_Block(readAll_File(f));[m [32m+[m[32m while (nextSplit_Rangecc(range_Block(src), "\n", &srcLine)) {[m [32m+[m[32m iRangecc line = srcLine;[m [32m+[m[32m trim_Rangecc(&line);[m [32m+[m[32m if (isEmpty_Range(&line)) {[m [32m+[m[32m continue;[m [32m+[m[32m }[m [32m+[m[32m if (*line.start == '#') {[m [32m+[m[32m /* Control directive. */[m [32m+[m[32m line.start++;[m [32m+[m[32m trim_Rangecc(&line);[m [32m+[m[32m if (equalCase_Rangecc(line, "dark")) {[m [32m+[m[32m dstPal = darkPalette_;[m [32m+[m[32m }[m [32m+[m[32m else if (equalCase_Rangecc(line, "light")) {[m [32m+[m[32m dstPal = lightPalette_;[m [32m+[m[32m }[m [32m+[m[32m continue;[m [32m+[m[32m }[m [32m+[m[32m static const struct {[m [32m+[m[32m const char *label;[m [32m+[m[32m int paletteIndex;[m [32m+[m[32m } colors_[] = {[m [32m+[m[32m { "black:", 0 }, { "gray25:", 1 }, { "gray50:", 2 }, { "gray75:", 3 },[m [32m+[m[32m { "white:", 4 }, { "brown:", 5 }, { "orange:", 6 }, { "teal:", 7 },[m [32m+[m[32m { "cyan:", 8 }, { "yellow:", 9 }, { "red:", 10 }, { "magenta:", 11 },[m [32m+[m[32m { "blue:", 12 }, { "green:", 13 },[m [32m+[m[32m };[m [32m+[m[32m iForIndices(i, colors_) {[m [32m+[m[32m if (startsWithCase_Rangecc(line, colors_[i].label)) {[m [32m+[m[32m iColor *dst = &dstPal[colors_[i].paletteIndex];[m [32m+[m[32m line.start += strlen(colors_[i].label);[m [32m+[m[32m trim_Rangecc(&line);[m [32m+[m[32m if (!isEmpty_Range(&line)) {[m [32m+[m[32m if (*line.start == '#') {[m [32m+[m[32m /* Hexadecimal color. */[m [32m+[m[32m line.start++;[m [32m+[m[32m if (size_Range(&line) == 6) {[m [32m+[m[32m iBlock *vals = hexDecode_Rangecc(line);[m [32m+[m[32m iAssert(size_Block(vals) == 3);[m [32m+[m[32m const uint8_t *rgb = constData_Block(vals);[m [32m+[m[32m *dst = (iColor){ rgb[0], rgb[1], rgb[2], 255 };[m [32m+[m[32m delete_Block(vals);[m [32m+[m[32m }[m [32m+[m[32m else {[m [32m+[m[32m fprintf(stderr, "[Color] invalid custom color: %s\n",[m [32m+[m[32m cstr_Rangecc(line));[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m else {[m [32m+[m[32m unsigned int red = 0, green = 0, blue = 0;[m [32m+[m[32m sscanf(line.start, "%u %u %u", &red, &green, &blue);[m [32m+[m[32m if (red > 255 || green > 255 || blue > 255) {[m [32m+[m[32m fprintf(stderr, "[Color] RGB value(s) out of range: %s\n",[m [32m+[m[32m cstr_Rangecc(line));[m [32m+[m[32m }[m [32m+[m[32m *dst = (iColor){ red, green, blue, 255 };[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m }[m [32m+[m[32m wasLoaded = iTrue;[m [32m+[m[32m }[m [32m+[m[32m iRelease(f);[m [32m+[m[32m return wasLoaded;[m [32m+[m[32m}[m [1mdiff --git a/src/ui/color.h b/src/ui/color.h[m [1mindex aafc1794..37ec49eb 100644[m [1m--- a/src/ui/color.h[m [1m+++ b/src/ui/color.h[m [36m@@ -244,7 +244,9 @@[m [miLocalDef void setHsl_Color(int color, iHSLColor hsl) {[m set_Color(color, rgb_HSLColor(hsl));[m }[m [m [32m+[m[32miBool loadPalette_Color (const char *path);[m void setThemePalette_Color (enum iColorTheme theme);[m [m iColor ansiForeground_Color (iRangecc escapeSequence, int fallback);[m const char * escape_Color (int color);[m [41m+[m
text/gemini; charset=utf-8
This content has been proxied by September (3851b).