aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/display.rs')
-rw-r--r--alacritty/src/display.rs28
1 files changed, 24 insertions, 4 deletions
diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs
index 6d683336..af21001e 100644
--- a/alacritty/src/display.rs
+++ b/alacritty/src/display.rs
@@ -27,7 +27,7 @@ use crossfont::{self, Rasterize, Rasterizer};
use alacritty_terminal::event::{EventListener, OnResize};
use alacritty_terminal::index::{Column, Direction, Point};
use alacritty_terminal::selection::Selection;
-use alacritty_terminal::term::{RenderableCell, SizeInfo, Term, TermMode};
+use alacritty_terminal::term::{SizeInfo, Term, TermMode};
use alacritty_terminal::term::{MIN_COLS, MIN_SCREEN_LINES};
use crate::config::font::Font;
@@ -437,7 +437,13 @@ impl Display {
mods: ModifiersState,
search_state: &SearchState,
) {
- let grid_cells: Vec<RenderableCell> = terminal.renderable_cells(config).collect();
+ // Convert search match from viewport to absolute indexing.
+ let search_active = search_state.regex().is_some();
+ let viewport_match = search_state
+ .focused_match()
+ .and_then(|focused_match| terminal.grid().clamp_buffer_range_to_visible(focused_match));
+
+ let grid_cells = terminal.renderable_cells(config, !search_active).collect::<Vec<_>>();
let visual_bell_intensity = terminal.visual_bell.intensity();
let background_color = terminal.background_color();
let cursor_point = terminal.grid().cursor.point;
@@ -471,7 +477,21 @@ impl Display {
self.renderer.with_api(&config.ui_config, config.cursor, &size_info, |mut api| {
// Iterate over all non-empty cells in the grid.
- for cell in grid_cells {
+ for mut cell in grid_cells {
+ // Invert the active match in vi-less search.
+ let cell_point = Point::new(cell.line, cell.column);
+ if cell.is_match
+ && viewport_match
+ .as_ref()
+ .map_or(false, |viewport_match| viewport_match.contains(&cell_point))
+ {
+ let colors = config.colors.search.focused_match;
+ let match_fg = colors.foreground().color(cell.fg, cell.bg);
+ cell.bg = colors.background().color(cell.fg, cell.bg);
+ cell.fg = match_fg;
+ cell.bg_alpha = 1.0;
+ }
+
// Update URL underlines.
urls.update(size_info.cols(), &cell);
@@ -525,7 +545,7 @@ impl Display {
}
if let Some(message) = message_buffer.message() {
- let search_offset = if search_state.regex().is_some() { 1 } else { 0 };
+ let search_offset = if search_active { 1 } else { 0 };
let text = message.text(&size_info);
// Create a new rectangle for the background.