Visible bell color falls back to default fg when selection bg is none

This commit is contained in:
pagedown 2021-11-03 10:07:57 +08:00
parent b4a6ed8d8f
commit ce36b09593
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
2 changed files with 8 additions and 5 deletions

View File

@ -195,11 +195,11 @@ colorprofile_to_color(ColorProfile *self, DynamicColor entry, DynamicColor defva
}
color_type
colorprofile_to_color_with_fallback(ColorProfile *self, DynamicColor entry, DynamicColor defval, DynamicColor fallback, DynamicColor falback_defval) {
colorprofile_to_color_with_fallback(ColorProfile *self, DynamicColor entry, DynamicColor defval, DynamicColor fallback, DynamicColor fallback_defval) {
switch(entry.type) {
case COLOR_NOT_SET:
case COLOR_IS_SPECIAL:
if (defval.type == COLOR_IS_SPECIAL) return colorprofile_to_color(self, fallback, falback_defval).rgb;
if (defval.type == COLOR_IS_SPECIAL) return colorprofile_to_color(self, fallback, fallback_defval).rgb;
return defval.rgb;
case COLOR_IS_RGB:
return entry.rgb;
@ -297,7 +297,7 @@ set_configured_colors(ColorProfile *self, PyObject *args) {
#define set_configured_colors_doc "Set the configured colors"
unsigned int default_fg, default_bg, cursor_color, cursor_text_color, highlight_fg, highlight_bg, visual_bell_color;
if (!PyArg_ParseTuple(args, "II|IIIII", &default_fg, &default_bg,
&cursor_color, &cursor_text_color, &highlight_fg, &highlight_bg, &visual_bell_color)) return NULL;
&cursor_color, &cursor_text_color, &highlight_fg, &highlight_bg, &visual_bell_color)) return NULL;
#define S(which) \
self->configured.which.rgb = which & 0xffffff; \
self->configured.which.type = (which & 0xff000000) ? COLOR_IS_RGB : COLOR_IS_SPECIAL;

View File

@ -635,8 +635,11 @@ draw_visual_bell_flash(GLfloat intensity, GLfloat xstart, GLfloat ystart, GLfloa
glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
bind_program(TINT_PROGRAM);
GLfloat attenuation = 0.4f;
const color_type flash = colorprofile_to_color_with_fallback(
screen->color_profile, screen->color_profile->overridden.visual_bell_color, screen->color_profile->configured.visual_bell_color, screen->color_profile->overridden.highlight_bg, screen->color_profile->configured.highlight_bg);
#define IS_SPECIAL_COLOR(name) (screen->color_profile->overridden.name.type == COLOR_IS_SPECIAL || (screen->color_profile->overridden.name.type == COLOR_NOT_SET && screen->color_profile->configured.name.type == COLOR_IS_SPECIAL))
#define COLOR(name, fallback) colorprofile_to_color_with_fallback(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name, screen->color_profile->overridden.fallback, screen->color_profile->configured.fallback)
const color_type flash = !IS_SPECIAL_COLOR(highlight_bg) ? COLOR(visual_bell_color, highlight_bg) : COLOR(visual_bell_color, default_fg);
#undef IS_SPECIAL_COLOR
#undef COLOR
#define C(shift) ((((GLfloat)((flash >> shift) & 0xFF)) / 255.0f) )
const GLfloat r = C(16), g = C(8), b = C(0);
const GLfloat max_channel = r > g ? (r > b ? r : b) : (g > b ? g : b);