Add an option to control the underline style for highlighting URLs on mouse over

This commit is contained in:
Kovid Goyal 2017-12-05 12:28:10 +05:30
parent e8441ce697
commit ed9b332da5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
7 changed files with 18 additions and 5 deletions

View File

@ -37,6 +37,7 @@ version 0.6.0 [future]
- Allow drag and drop of files into kitty. On drop kitty will paste the
file path to the running program.
- Add an option to control the underline style for URL highlighting on hover
version 0.5.1 [2017-12-01]
---------------------------

View File

@ -6,7 +6,7 @@
layout(std140) uniform CellRenderData {
float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity;
uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color;
uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color, url_style;
int color1, color2;
@ -160,7 +160,7 @@ void main() {
// Underline and strike through (rendered via sprites)
float in_url = in_range(c, r);
decoration_fg = choose_color(in_url, color_to_vec(url_color), to_color(colors[2], resolved_fg));
underline_pos = choose_color(in_url, to_sprite_pos(pos, THREE, ZERO, ZERO), to_sprite_pos(pos, (text_attrs >> 2) & DECORATION_MASK, ZERO, ZERO));
underline_pos = choose_color(in_url, to_sprite_pos(pos, url_style, ZERO, ZERO), to_sprite_pos(pos, (text_attrs >> 2) & DECORATION_MASK, ZERO, ZERO));
strike_pos = to_sprite_pos(pos, ((text_attrs >> 7) & STRIKE_MASK) * FOUR, ZERO, ZERO);
// Cursor

View File

@ -248,6 +248,13 @@ def tab_font_style(x):
return {'bold-italic': (True, True), 'bold': (True, False), 'italic': (False, True)}.get(x.lower().replace('_', '-'), (False, False))
def url_style(x):
return url_style.map.get(x, url_style.map['curly'])
url_style.map = dict(((v, i) for i, v in enumerate('none single double curly'.split())))
type_map = {
'adjust_line_height': adjust_line_height,
'scrollback_lines': positive_int,
@ -283,6 +290,7 @@ type_map = {
'tab_separator': tab_separator,
'active_tab_font_style': tab_font_style,
'inactive_tab_font_style': tab_font_style,
'url_style': url_style,
}
for name in (

View File

@ -61,8 +61,10 @@ selection_foreground #000000
# The background for selections
selection_background #FFFACD
# The color for highlighting URLs on mouse-over
# The color and style for highlighting URLs on mouse-over. url_style can be one of:
# none, single, double, curly
url_color #0087BD
url_style curly
# The cursor color
cursor #cccccc

View File

@ -202,7 +202,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G
struct CellRenderData {
GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity;
GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color;
GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, url_color, url_style;
GLint color1, color2;
@ -236,7 +236,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G
#define COLOR(name) colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name)
rd->default_fg = COLOR(default_fg); rd->default_bg = COLOR(default_bg); rd->highlight_fg = COLOR(highlight_fg); rd->highlight_bg = COLOR(highlight_bg);
#undef COLOR
rd->cursor_color = cursor->color; rd->url_color = OPT(url_color);
rd->cursor_color = cursor->color; rd->url_color = OPT(url_color); rd->url_style = OPT(url_style);
unmap_vao_buffer(vao_idx, uniform_buffer); rd = NULL;
}

View File

@ -310,6 +310,7 @@ PYWRAP1(set_options) {
S(cursor_stop_blinking_after, PyFloat_AsDouble);
S(background_opacity, PyFloat_AsDouble);
S(cursor_shape, PyLong_AsLong);
S(url_style, PyLong_AsUnsignedLong);
S(x11_bell_volume, PyLong_AsLong);
S(mouse_hide_wait, PyFloat_AsDouble);
S(wheel_scroll_multiplier, PyFloat_AsDouble);

View File

@ -15,6 +15,7 @@ typedef struct {
bool enable_audio_bell;
CursorShape cursor_shape;
unsigned int open_url_modifiers;
unsigned int url_style;
char_type select_by_word_characters[256]; size_t select_by_word_characters_count;
color_type url_color, background;
double repaint_delay, input_delay;