From 1f6764f792887fb36327a5c6f189de655edc35f1 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 5 Feb 2022 16:20:27 -0700 Subject: [PATCH] fixup underlines bd479792927ecfba2eff5c4f29aa3d73a036b0d7 made underlines only as wide as the glyph texture. This commit renders them under the width of the cluster region. --- wezterm-gui/src/termwindow/render.rs | 38 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index f1b71310a..b58862b89 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -1879,6 +1879,29 @@ impl super::TermWindow { quad.set_hsv(hsv); } } + + // Underlines + if item.style.underline_tex_rect != params.white_space { + // Draw one per cell, otherwise curly underlines + // stretch across the whole span + for i in 0..cluster_width { + let mut quad = layers[0].allocate()?; + let x = gl_x + + params.left_pixel_x + + if params.use_pixel_positioning { + item.x_pos + } else { + phys(cluster.first_cell_idx + i, num_cols, direction) as f32 + * cell_width + }; + + quad.set_position(x, pos_y, x + cell_width, pos_y + cell_height); + quad.set_hsv(hsv); + quad.set_has_color(false); + quad.set_texture(item.style.underline_tex_rect); + quad.set_fg_color(item.style.underline_color); + } + } } // Render the selection background color. @@ -2151,21 +2174,6 @@ impl super::TermWindow { continue; } - // Underlines - if style_params.underline_tex_rect != params.white_space { - let mut quad = layers[0].allocate()?; - quad.set_position( - gl_x + range.start, - pos_y, - gl_x + range.end, - pos_y + cell_height, - ); - quad.set_hsv(hsv); - quad.set_has_color(false); - quad.set_texture(style_params.underline_tex_rect); - quad.set_fg_color(style_params.underline_color); - } - let pixel_rect = euclid::rect( texture.coords.origin.x + (range.start - (pos_x + adjust)) as isize, texture.coords.origin.y,