Use cell colors for focused match CellRgb
Fixes #5022. Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
parent
e2a853b1a7
commit
e3818a226c
|
@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
### Changed
|
||||
|
||||
- The vi mode cursor is now created in the top-left if the terminal cursor is invisible
|
||||
- Focused search match will use cell instead of match colors for CellForeground/CellBackground
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -221,8 +221,8 @@
|
|||
# foreground: '#000000'
|
||||
# background: '#ffffff'
|
||||
#focused_match:
|
||||
# foreground: CellBackground
|
||||
# background: CellForeground
|
||||
# foreground: '#ffffff'
|
||||
# background: '#000000'
|
||||
|
||||
#bar:
|
||||
# background: '#c5c8c6'
|
||||
|
|
|
@ -122,11 +122,26 @@ impl Default for InvertedCellColors {
|
|||
|
||||
#[derive(ConfigDeserialize, Debug, Copy, Clone, Default, PartialEq, Eq)]
|
||||
pub struct SearchColors {
|
||||
pub focused_match: InvertedCellColors,
|
||||
pub focused_match: FocusedMatchColors,
|
||||
pub matches: MatchColors,
|
||||
bar: BarColors,
|
||||
}
|
||||
|
||||
#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct FocusedMatchColors {
|
||||
pub foreground: CellRgb,
|
||||
pub background: CellRgb,
|
||||
}
|
||||
|
||||
impl Default for FocusedMatchColors {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
background: CellRgb::Rgb(Rgb { r: 0x00, g: 0x00, b: 0x00 }),
|
||||
foreground: CellRgb::Rgb(Rgb { r: 0xff, g: 0xff, b: 0xff }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct MatchColors {
|
||||
pub foreground: CellRgb,
|
||||
|
|
|
@ -234,17 +234,13 @@ impl RenderableCell {
|
|||
bg_alpha = 1.0;
|
||||
}
|
||||
} else if content.search.advance(cell.point) {
|
||||
// Highlight the cell if it is part of a search match.
|
||||
let config_fg = colors.search.matches.foreground;
|
||||
let config_bg = colors.search.matches.background;
|
||||
let focused = content.focused_match.map_or(false, |fm| fm.contains(&cell.point));
|
||||
let (config_fg, config_bg) = if focused {
|
||||
(colors.search.focused_match.foreground, colors.search.focused_match.background)
|
||||
} else {
|
||||
(colors.search.matches.foreground, colors.search.matches.background)
|
||||
};
|
||||
Self::compute_cell_rgb(&mut fg, &mut bg, &mut bg_alpha, config_fg, config_bg);
|
||||
|
||||
// Apply the focused match colors, using the normal match colors as base reference.
|
||||
if content.focused_match.map_or(false, |fm| fm.contains(&cell.point)) {
|
||||
let config_fg = colors.search.focused_match.foreground;
|
||||
let config_bg = colors.search.focused_match.background;
|
||||
Self::compute_cell_rgb(&mut fg, &mut bg, &mut bg_alpha, config_fg, config_bg);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert cell point to viewport position.
|
||||
|
|
Loading…
Reference in New Issue