Logo (Chafa): accept enum strings instead of numbers

This commit is contained in:
李通洲
2023-11-20 14:27:48 +08:00
parent 6c492882a3
commit 5338583c48
+28 -3
View File
@@ -189,11 +189,36 @@ logoType:
else if(strcasecmp(subKey, "symbols") == 0)
ffOptionParseString(key, value, &options->chafaSymbols);
else if(strcasecmp(subKey, "canvas-mode") == 0)
options->chafaCanvasMode = ffOptionParseUInt32(key, value);
{
options->chafaCanvasMode = (uint32_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "TRUECOLOR", 0 },
{ "INDEXED_256", 1 },
{ "INDEXED_240", 2 },
{ "INDEXED_16", 3 },
{ "FGBG_BGFG", 4 },
{ "FGBG", 5 },
{ "INDEXED_8", 6 },
{ "INDEXED_16_8", 7 },
{},
});
}
else if(strcasecmp(subKey, "color-space") == 0)
options->chafaColorSpace = ffOptionParseUInt32(key, value);
{
options->chafaColorSpace = (uint32_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "RGB", 0 },
{ "DIN99D", 1 },
{},
});
}
else if(strcasecmp(subKey, "dither-mode") == 0)
options->chafaDitherMode = ffOptionParseUInt32(key, value);
{
options->chafaDitherMode = (uint32_t) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
{ "NONE", 0 },
{ "ORDERED", 1 },
{ "DIFFUSION", 2 },
{},
});
}
else
return false;
}