mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Improve color blindness handling
Rename some things and use a swtich instead of if.
This commit is contained in:
parent
2750194279
commit
3258211f27
@ -3,6 +3,7 @@
|
|||||||
* vim: expandtab:ts=4:sts=4:sw=4
|
* vim: expandtab:ts=4:sts=4:sw=4
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 Aurelien Aptel <aurelien.aptel@gmail.com>
|
* Copyright (C) 2019 Aurelien Aptel <aurelien.aptel@gmail.com>
|
||||||
|
* Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
|
||||||
*
|
*
|
||||||
* This file is part of Profanity.
|
* This file is part of Profanity.
|
||||||
*
|
*
|
||||||
@ -401,14 +402,17 @@ static int color_hash(const char *str, color_profile profile)
|
|||||||
|
|
||||||
double h = ((buf[1] << 8) | buf[0]) / 65536. * 360.;
|
double h = ((buf[1] << 8) | buf[0]) / 65536. * 360.;
|
||||||
|
|
||||||
// red/green blindness correction
|
switch(profile)
|
||||||
if (profile == COLOR_PROFILE_REDGREEN) {
|
{
|
||||||
h = fmod(fmod(h + 90., 180) - 90., 360.);
|
case COLOR_PROFILE_REDGREEN_BLINDNESS:
|
||||||
}
|
// red/green blindness correction
|
||||||
|
h = fmod(fmod(h + 90., 180) - 90., 360.);
|
||||||
// blue blindness correction
|
break;
|
||||||
if (profile == COLOR_PROFILE_BLUE) {
|
case COLOR_PROFILE_BLUE_BLINDNESS:
|
||||||
h = fmod(h, 180.);
|
// blue blindness correction
|
||||||
|
h = fmod(h, 180.);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = find_closest_col((int)h, 100, 50);
|
rc = find_closest_col((int)h, 100, 50);
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
COLOR_PROFILE_DEFAULT,
|
COLOR_PROFILE_DEFAULT,
|
||||||
COLOR_PROFILE_REDGREEN,
|
COLOR_PROFILE_REDGREEN_BLINDNESS,
|
||||||
COLOR_PROFILE_BLUE,
|
COLOR_PROFILE_BLUE_BLINDNESS,
|
||||||
} color_profile;
|
} color_profile;
|
||||||
|
|
||||||
struct color_def {
|
struct color_def {
|
||||||
|
@ -677,9 +677,9 @@ theme_hash_attrs(const char *str)
|
|||||||
|
|
||||||
char *color_pref = prefs_get_string(PREF_COLOR_NICK);
|
char *color_pref = prefs_get_string(PREF_COLOR_NICK);
|
||||||
if (strcmp(color_pref, "redgreen") == 0) {
|
if (strcmp(color_pref, "redgreen") == 0) {
|
||||||
profile = COLOR_PROFILE_REDGREEN;
|
profile = COLOR_PROFILE_REDGREEN_BLINDNESS;
|
||||||
} else if (strcmp(color_pref, "blue") == 0) {
|
} else if (strcmp(color_pref, "blue") == 0) {
|
||||||
profile = COLOR_PROFILE_BLUE;
|
profile = COLOR_PROFILE_BLUE_BLINDNESS;
|
||||||
}
|
}
|
||||||
prefs_free_string(color_pref);
|
prefs_free_string(color_pref);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user