Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow theme colors to be specified as integers #1903

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/config/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,19 @@ find_closest_col(int h, int s, int l)
static int
find_col(const char* col_name, int n)
{
char* endptr;
unsigned long col_value = strtoul(col_name, &endptr, 0);
char name[32] = { 0 };

/*
* When the col_name is a uint8, then we don’t 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
* use strNcasecmp because we could end up matching blue3 with
Expand Down
Loading