Merge branch 'feat-visual-bell-color' of https://github.com/page-down/kitty
This commit is contained in:
commit
76834c0975
@ -125,6 +125,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
- A new option :opt:`tab_bar_margin_color` to control the color of the tab bar
|
- A new option :opt:`tab_bar_margin_color` to control the color of the tab bar
|
||||||
margins
|
margins
|
||||||
|
|
||||||
|
- A new option :opt:`visual_bell_color` to customize the color of the visual bell
|
||||||
|
(:pull:`4181`)
|
||||||
|
|
||||||
- Add support for OSC 777 based desktop notifications
|
- Add support for OSC 777 based desktop notifications
|
||||||
|
|
||||||
- Wayland: Fix pasting from applications that use a MIME type of "text/plain"
|
- Wayland: Fix pasting from applications that use a MIME type of "text/plain"
|
||||||
|
|||||||
@ -317,6 +317,7 @@ def patch_conf(raw: str, theme_name: str) -> str:
|
|||||||
'tab_bar_background',
|
'tab_bar_background',
|
||||||
'tab_bar_margin_color',
|
'tab_bar_margin_color',
|
||||||
'url_color',
|
'url_color',
|
||||||
|
'visual_bell_color',
|
||||||
'wayland_titlebar_color',
|
'wayland_titlebar_color',
|
||||||
# ALL_COLORS_END
|
# ALL_COLORS_END
|
||||||
) # }}}
|
) # }}}
|
||||||
|
|||||||
@ -170,7 +170,7 @@ patch_color_profiles(PyObject *module UNUSED, PyObject *args) {
|
|||||||
}
|
}
|
||||||
S(foreground, default_fg); S(background, default_bg); S(cursor, cursor_color);
|
S(foreground, default_fg); S(background, default_bg); S(cursor, cursor_color);
|
||||||
S(selection_foreground, highlight_fg); S(selection_background, highlight_bg);
|
S(selection_foreground, highlight_fg); S(selection_background, highlight_bg);
|
||||||
S(cursor_text_color, cursor_text_color);
|
S(cursor_text_color, cursor_text_color); S(visual_bell_color, visual_bell_color);
|
||||||
#undef SI
|
#undef SI
|
||||||
#undef S
|
#undef S
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
@ -195,11 +195,11 @@ colorprofile_to_color(ColorProfile *self, DynamicColor entry, DynamicColor defva
|
|||||||
}
|
}
|
||||||
|
|
||||||
color_type
|
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) {
|
switch(entry.type) {
|
||||||
case COLOR_NOT_SET:
|
case COLOR_NOT_SET:
|
||||||
case COLOR_IS_SPECIAL:
|
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;
|
return defval.rgb;
|
||||||
case COLOR_IS_RGB:
|
case COLOR_IS_RGB:
|
||||||
return entry.rgb;
|
return entry.rgb;
|
||||||
@ -234,7 +234,7 @@ as_dict(ColorProfile *self, PyObject *args UNUSED) {
|
|||||||
}}
|
}}
|
||||||
D(default_fg, foreground); D(default_bg, background);
|
D(default_fg, foreground); D(default_bg, background);
|
||||||
D(cursor_color, cursor); D(cursor_text_color, cursor_text); D(highlight_fg, selection_foreground);
|
D(cursor_color, cursor); D(cursor_text_color, cursor_text); D(highlight_fg, selection_foreground);
|
||||||
D(highlight_bg, selection_background);
|
D(highlight_bg, selection_background); D(visual_bell_color, visual_bell_color);
|
||||||
|
|
||||||
#undef D
|
#undef D
|
||||||
return ans;
|
return ans;
|
||||||
@ -295,13 +295,13 @@ set_color(ColorProfile *self, PyObject *args) {
|
|||||||
static PyObject*
|
static PyObject*
|
||||||
set_configured_colors(ColorProfile *self, PyObject *args) {
|
set_configured_colors(ColorProfile *self, PyObject *args) {
|
||||||
#define set_configured_colors_doc "Set the configured colors"
|
#define set_configured_colors_doc "Set the configured colors"
|
||||||
unsigned int default_fg, default_bg, cursor_color, cursor_text_color, highlight_fg, highlight_bg;
|
unsigned int default_fg, default_bg, cursor_color, cursor_text_color, highlight_fg, highlight_bg, visual_bell_color;
|
||||||
if (!PyArg_ParseTuple(args, "II|IIII", &default_fg, &default_bg,
|
if (!PyArg_ParseTuple(args, "II|IIIII", &default_fg, &default_bg,
|
||||||
&cursor_color, &cursor_text_color, &highlight_fg, &highlight_bg)) return NULL;
|
&cursor_color, &cursor_text_color, &highlight_fg, &highlight_bg, &visual_bell_color)) return NULL;
|
||||||
#define S(which) \
|
#define S(which) \
|
||||||
self->configured.which.rgb = which & 0xffffff; \
|
self->configured.which.rgb = which & 0xffffff; \
|
||||||
self->configured.which.type = (which & 0xff000000) ? COLOR_IS_RGB : COLOR_IS_SPECIAL;
|
self->configured.which.type = (which & 0xff000000) ? COLOR_IS_RGB : COLOR_IS_SPECIAL;
|
||||||
S(default_fg); S(default_bg); S(cursor_color); S(cursor_text_color); S(highlight_fg); S(highlight_bg);
|
S(default_fg); S(default_bg); S(cursor_color); S(cursor_text_color); S(highlight_fg); S(highlight_bg); S(visual_bell_color);
|
||||||
#undef S
|
#undef S
|
||||||
self->dirty = true;
|
self->dirty = true;
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
@ -412,6 +412,7 @@ CGETSET(cursor_color)
|
|||||||
CGETSET(cursor_text_color)
|
CGETSET(cursor_text_color)
|
||||||
CGETSET(highlight_fg)
|
CGETSET(highlight_fg)
|
||||||
CGETSET(highlight_bg)
|
CGETSET(highlight_bg)
|
||||||
|
CGETSET(visual_bell_color)
|
||||||
#undef CGETSET
|
#undef CGETSET
|
||||||
|
|
||||||
static PyGetSetDef cp_getsetters[] = {
|
static PyGetSetDef cp_getsetters[] = {
|
||||||
@ -421,6 +422,7 @@ static PyGetSetDef cp_getsetters[] = {
|
|||||||
GETSET(cursor_text_color)
|
GETSET(cursor_text_color)
|
||||||
GETSET(highlight_fg)
|
GETSET(highlight_fg)
|
||||||
GETSET(highlight_bg)
|
GETSET(highlight_bg)
|
||||||
|
GETSET(visual_bell_color)
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -258,7 +258,7 @@ typedef union DynamicColor {
|
|||||||
} DynamicColor;
|
} DynamicColor;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DynamicColor default_fg, default_bg, cursor_color, cursor_text_color, highlight_fg, highlight_bg;
|
DynamicColor default_fg, default_bg, cursor_color, cursor_text_color, highlight_fg, highlight_bg, visual_bell_color;
|
||||||
} DynamicColors;
|
} DynamicColors;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -701,7 +701,7 @@ class ColorProfile:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def set_configured_colors(
|
def set_configured_colors(
|
||||||
self, fg: int, bg: int, cursor: int = 0, cursor_text: int = 0, highlight_fg: int = 0, highlight_bg: int = 0
|
self, fg: int, bg: int, cursor: int = 0, cursor_text: int = 0, highlight_fg: int = 0, highlight_bg: int = 0, visual_bell_color: int = 0
|
||||||
) -> None:
|
) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -670,6 +670,14 @@ number of seconds. Set to zero to disable.
|
|||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
opt('visual_bell_color', 'none',
|
||||||
|
option_type='to_color_or_none',
|
||||||
|
long_text='''
|
||||||
|
The color used by visual bell. Set to :code:`none` will fall back to selection
|
||||||
|
background color. If you feel that the visual bell is too bright, you can
|
||||||
|
set it to a darker color.
|
||||||
|
''')
|
||||||
|
|
||||||
opt('window_alert_on_bell', 'yes',
|
opt('window_alert_on_bell', 'yes',
|
||||||
option_type='to_bool', ctype='bool',
|
option_type='to_bool', ctype='bool',
|
||||||
long_text='''
|
long_text='''
|
||||||
|
|||||||
3
kitty/options/parse.py
generated
3
kitty/options/parse.py
generated
@ -1248,6 +1248,9 @@ class Parser:
|
|||||||
def url_style(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
def url_style(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
ans['url_style'] = url_style(val)
|
ans['url_style'] = url_style(val)
|
||||||
|
|
||||||
|
def visual_bell_color(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
|
ans['visual_bell_color'] = to_color_or_none(val)
|
||||||
|
|
||||||
def visual_bell_duration(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
def visual_bell_duration(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
ans['visual_bell_duration'] = positive_float(val)
|
ans['visual_bell_duration'] = positive_float(val)
|
||||||
|
|
||||||
|
|||||||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@ -431,6 +431,7 @@ option_names = ( # {{{
|
|||||||
'url_excluded_characters',
|
'url_excluded_characters',
|
||||||
'url_prefixes',
|
'url_prefixes',
|
||||||
'url_style',
|
'url_style',
|
||||||
|
'visual_bell_color',
|
||||||
'visual_bell_duration',
|
'visual_bell_duration',
|
||||||
'watcher',
|
'watcher',
|
||||||
'wayland_titlebar_color',
|
'wayland_titlebar_color',
|
||||||
@ -570,6 +571,7 @@ class Options:
|
|||||||
url_excluded_characters: str = ''
|
url_excluded_characters: str = ''
|
||||||
url_prefixes: typing.Tuple[str, ...] = ('http', 'https', 'file', 'ftp', 'gemini', 'irc', 'gopher', 'mailto', 'news', 'git')
|
url_prefixes: typing.Tuple[str, ...] = ('http', 'https', 'file', 'ftp', 'gemini', 'irc', 'gopher', 'mailto', 'news', 'git')
|
||||||
url_style: int = 3
|
url_style: int = 3
|
||||||
|
visual_bell_color: typing.Optional[kitty.fast_data_types.Color] = None
|
||||||
visual_bell_duration: float = 0
|
visual_bell_duration: float = 0
|
||||||
wayland_titlebar_color: int = 0
|
wayland_titlebar_color: int = 0
|
||||||
wheel_scroll_multiplier: float = 5.0
|
wheel_scroll_multiplier: float = 5.0
|
||||||
|
|||||||
@ -18,6 +18,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
nullable_colors = (
|
nullable_colors = (
|
||||||
|
# generated by gen-config.py DO NOT edit
|
||||||
# NULLABLE_COLORS_START
|
# NULLABLE_COLORS_START
|
||||||
'active_border_color',
|
'active_border_color',
|
||||||
'cursor',
|
'cursor',
|
||||||
@ -26,6 +27,7 @@ nullable_colors = (
|
|||||||
'selection_foreground',
|
'selection_foreground',
|
||||||
'tab_bar_background',
|
'tab_bar_background',
|
||||||
'tab_bar_margin_color',
|
'tab_bar_margin_color',
|
||||||
|
'visual_bell_color',
|
||||||
# NULLABLE_COLORS_END
|
# NULLABLE_COLORS_END
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
|
||||||
bind_program(TINT_PROGRAM);
|
bind_program(TINT_PROGRAM);
|
||||||
GLfloat attenuation = 0.4f;
|
GLfloat attenuation = 0.4f;
|
||||||
const color_type flash = colorprofile_to_color_with_fallback(
|
#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))
|
||||||
screen->color_profile, screen->color_profile->overridden.highlight_bg, screen->color_profile->configured.highlight_bg, screen->color_profile->overridden.default_fg, screen->color_profile->configured.default_fg);
|
#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) )
|
#define C(shift) ((((GLfloat)((flash >> shift) & 0xFF)) / 255.0f) )
|
||||||
const GLfloat r = C(16), g = C(8), b = C(0);
|
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);
|
const GLfloat max_channel = r > g ? (r > b ? r : b) : (g > b ? g : b);
|
||||||
|
|||||||
@ -268,7 +268,8 @@ def setup_colors(screen: Screen, opts: Options) -> None:
|
|||||||
screen.color_profile.set_configured_colors(
|
screen.color_profile.set_configured_colors(
|
||||||
s(opts.foreground), s(opts.background),
|
s(opts.foreground), s(opts.background),
|
||||||
s(opts.cursor), s(opts.cursor_text_color),
|
s(opts.cursor), s(opts.cursor_text_color),
|
||||||
s(opts.selection_foreground), s(opts.selection_background)
|
s(opts.selection_foreground), s(opts.selection_background),
|
||||||
|
s(opts.visual_bell_color)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user