1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Vetter
0c3dbbd9cd
Merge bccfad3de2 into c6cf27e4e1 2024-03-10 11:19:19 -06:00
toastal
bccfad3de2 Add support for int colors in themes
Allow theme colors to be specified as integers.

Works with both decimal & hex. Given the XXX warning, it seems
reasonable to allow users to specify their theme’s colors as the base
integers since the names are pretty arbitrary.

We changed the variable name `ul` to `col_value` per @H3rnand3zzz
suggestion.
2023-11-20 12:48:44 +01:00

View File

@ -361,8 +361,19 @@ find_closest_col(int h, int s, int l)
static int static int
find_col(const char* col_name, int n) find_col(const char* col_name, int n)
{ {
char* endptr;
unsigned long col_value = strtoul(col_name, &endptr, 0);
char name[32] = { 0 }; char name[32] = { 0 };
/*
* When the col_name is a uint8, then we dont need to look up by
* color name (which is problematic given the duplicate names)
*/
if ((*endptr == '\0' || *endptr == '\n') && col_value <= UINT8_MAX) {
return (int)col_value;
}
/* /*
* make a null terminated version of col_name. we don't want to * make a null terminated version of col_name. we don't want to
* use strNcasecmp because we could end up matching blue3 with * use strNcasecmp because we could end up matching blue3 with