mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
gui: simplify some text cursor rendering
Remove special case for blocks where we switched it out for a blank sprite and instead varied the cell background. We now always render a matching cursor sprite as a separate layer over the top of the text background color, but below the text foreground layer. This is preparing for https://github.com/wez/wezterm/issues/1432 Make bar/line cursors use the text foreground color when reverse video cursors are enabled, per @VKondakoff: https://github.com/wez/wezterm/issues/1076#issuecomment-978214136
This commit is contained in:
parent
525739acb3
commit
1c9b9f69e0
@ -31,6 +31,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* Bundled NotoColorEmoji to 2.034 (with Unicode 14 support) Thanks to [@4cm4k1](https://github.com/4cm4k1)! [#1440](https://github.com/wez/wezterm/pull/1440)
|
||||
* macos: removing the titlebar from `window_decorations` now preserves rounded window corners [#1034](https://github.com/wez/wezterm/issues/1034)
|
||||
* Colors can now be specified in the HSL colorspace using syntax like `"hsl:235 100 50"` [#1436](https://github.com/wez/wezterm/issues/1436)
|
||||
* Line/Bar cursors in [force_reverse_video_cursor](config/lua/config/force_reverse_video_cursor.md) mode now use the text foreground color rather than the cursor border color. [#1076](https://github.com/wez/wezterm/issues/1076)
|
||||
|
||||
#### Fixed
|
||||
|
||||
|
@ -2009,41 +2009,9 @@ impl super::TermWindow {
|
||||
// for glyph_idx == 0 based on the whole glyph advance, rather than
|
||||
// for each of the cells.
|
||||
|
||||
if bg_color != style_params.bg_color {
|
||||
// Override the background color
|
||||
if !params.use_pixel_positioning || glyph_idx == 0 {
|
||||
let mut quad = self.filled_rectangle(
|
||||
&mut layers[0],
|
||||
Rect::new(
|
||||
Point::new(
|
||||
(params.left_pixel_x
|
||||
+ if params.use_pixel_positioning {
|
||||
cluster_x_pos
|
||||
+ (glyph.x_offset + glyph.bearing_x).get()
|
||||
as f32
|
||||
} else {
|
||||
cell_idx as f32 * cell_width
|
||||
}) as isize,
|
||||
params.top_pixel_y as isize,
|
||||
),
|
||||
Size::new(
|
||||
(if params.use_pixel_positioning {
|
||||
pixel_width
|
||||
} else {
|
||||
cursor_width * cell_width
|
||||
}) as isize,
|
||||
cell_height as isize,
|
||||
),
|
||||
),
|
||||
bg_color,
|
||||
)?;
|
||||
quad.set_hsv(hsv);
|
||||
}
|
||||
}
|
||||
|
||||
if cursor_shape.is_some() {
|
||||
if !params.use_pixel_positioning || glyph_idx == 0 {
|
||||
let mut quad = layers[2].allocate()?;
|
||||
let mut quad = layers[0].allocate()?;
|
||||
quad.set_position(
|
||||
pos_x,
|
||||
pos_y,
|
||||
@ -2483,10 +2451,6 @@ impl super::TermWindow {
|
||||
) {
|
||||
let (fg_color, bg_color) = if self.config.force_reverse_video_cursor {
|
||||
(params.bg_color, params.fg_color)
|
||||
} else if params.probably_a_ligature {
|
||||
// Preserve normal fg color for a multi-cell ligatured glyph,
|
||||
// in order to avoid the rest of the glyph showing "black"
|
||||
(params.fg_color, params.cursor_bg)
|
||||
} else {
|
||||
(params.cursor_fg, params.cursor_bg)
|
||||
};
|
||||
@ -2584,34 +2548,52 @@ impl super::TermWindow {
|
||||
|
||||
let focused_and_active = self.focused.is_some() && params.is_active_pane;
|
||||
|
||||
let (fg_color, bg_color) = match (selected, focused_and_active, cursor_shape, visibility) {
|
||||
// Selected text overrides colors
|
||||
(true, _, _, CursorVisibility::Hidden) => (params.selection_fg, params.selection_bg),
|
||||
// Cursor cell overrides colors
|
||||
(_, true, CursorShape::BlinkingBlock, CursorVisibility::Visible)
|
||||
| (_, true, CursorShape::SteadyBlock, CursorVisibility::Visible) => {
|
||||
if self.config.force_reverse_video_cursor {
|
||||
(params.bg_color, params.fg_color)
|
||||
} else if params.probably_a_ligature {
|
||||
// Preserve normal fg color for a multi-cell ligatured glyph,
|
||||
// in order to avoid the rest of the glyph showing "black"
|
||||
(params.fg_color, params.cursor_bg)
|
||||
} else {
|
||||
(params.cursor_fg, params.cursor_bg)
|
||||
let (fg_color, bg_color, cursor_bg) =
|
||||
match (selected, focused_and_active, cursor_shape, visibility) {
|
||||
// Selected text overrides colors
|
||||
(true, _, _, CursorVisibility::Hidden) => {
|
||||
(params.selection_fg, params.selection_bg, params.cursor_bg)
|
||||
}
|
||||
}
|
||||
// Normally, render the cell as configured (or if the window is unfocused)
|
||||
_ => (params.fg_color, params.bg_color),
|
||||
};
|
||||
// block Cursor cell overrides colors
|
||||
(
|
||||
_,
|
||||
true,
|
||||
CursorShape::BlinkingBlock | CursorShape::SteadyBlock,
|
||||
CursorVisibility::Visible,
|
||||
) => {
|
||||
if self.config.force_reverse_video_cursor {
|
||||
(params.bg_color, params.fg_color, params.fg_color)
|
||||
} else {
|
||||
(params.cursor_fg, params.cursor_bg, params.cursor_bg)
|
||||
}
|
||||
}
|
||||
(
|
||||
_,
|
||||
true,
|
||||
CursorShape::BlinkingUnderline
|
||||
| CursorShape::SteadyUnderline
|
||||
| CursorShape::BlinkingBar
|
||||
| CursorShape::SteadyBar,
|
||||
CursorVisibility::Visible,
|
||||
) => {
|
||||
if self.config.force_reverse_video_cursor {
|
||||
(params.fg_color, params.bg_color, params.fg_color)
|
||||
} else {
|
||||
(params.fg_color, params.bg_color, params.cursor_bg)
|
||||
}
|
||||
}
|
||||
// Normally, render the cell as configured (or if the window is unfocused)
|
||||
_ => (params.fg_color, params.bg_color, params.cursor_border_color),
|
||||
};
|
||||
|
||||
ComputeCellFgBgResult {
|
||||
fg_color,
|
||||
bg_color,
|
||||
cursor_border_color: params.cursor_border_color,
|
||||
cursor_border_color: cursor_bg,
|
||||
cursor_shape: if visibility == CursorVisibility::Visible {
|
||||
match cursor_shape {
|
||||
CursorShape::BlinkingBlock | CursorShape::SteadyBlock if focused_and_active => {
|
||||
None
|
||||
Some(CursorShape::Default)
|
||||
}
|
||||
// When not focused, convert bar to block to make it more visually
|
||||
// distinct from the focused bar in another pane
|
||||
|
Loading…
Reference in New Issue
Block a user