From 142f84efb955a9fa59f4205ec3a6db3964c5f433 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Wed, 15 Jul 2020 21:27:32 +0000 Subject: Add support for searching without vi mode This implements search without vi mode by using the selection to track the active search match and advancing it on user input. The keys to go to the next or previous match are not configurable and are bound to enter and shift enter based on Firefox's behavior. Fixes #3937. --- alacritty_terminal/src/grid/mod.rs | 2 +- alacritty_terminal/src/grid/tests.rs | 4 ++-- alacritty_terminal/src/term/mod.rs | 13 +++---------- alacritty_terminal/src/term/search.rs | 8 ++++---- 4 files changed, 10 insertions(+), 17 deletions(-) (limited to 'alacritty_terminal/src') diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs index c1f980e8..5ab25c78 100644 --- a/alacritty_terminal/src/grid/mod.rs +++ b/alacritty_terminal/src/grid/mod.rs @@ -252,7 +252,7 @@ impl Grid { } } - /// Move lines at the bottom towards the top. + /// Move lines at the bottom toward the top. /// /// This is the performance-sensitive part of scrolling. pub fn scroll_up(&mut self, region: &Range, positions: Line, template: T) { diff --git a/alacritty_terminal/src/grid/tests.rs b/alacritty_terminal/src/grid/tests.rs index 1ed279a0..f86c77b5 100644 --- a/alacritty_terminal/src/grid/tests.rs +++ b/alacritty_terminal/src/grid/tests.rs @@ -56,7 +56,7 @@ fn visible_to_buffer() { assert_eq!(point, Point::new(4, Column(3))); } -// Scroll up moves lines upwards. +// Scroll up moves lines upward. #[test] fn scroll_up() { let mut grid = Grid::new(Line(10), Column(1), 0, 0); @@ -88,7 +88,7 @@ fn scroll_up() { assert_eq!(grid[Line(9)].occ, 0); } -// Scroll down moves lines downwards. +// Scroll down moves lines downward. #[test] fn scroll_down() { let mut grid = Grid::new(Line(10), Column(1), 0, 0); diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 5a59b55b..91748359 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -725,7 +725,7 @@ pub struct Term { /// term is set. title_stack: Vec>, - /// Current forwards and backwards buffer search regexes. + /// Current forward and backward buffer search regexes. regex_search: Option, } @@ -1115,13 +1115,6 @@ impl Term { self.dirty = true; } - /// Start vi mode without moving the cursor. - #[inline] - pub fn set_vi_mode(&mut self) { - self.mode.insert(TermMode::VI); - self.dirty = true; - } - /// Move vi mode cursor. #[inline] pub fn vi_motion(&mut self, motion: ViMotion) @@ -1466,8 +1459,8 @@ impl Handler for Term { ptr::copy(src, dst, num_cells); } - // Cells were just moved out towards the end of the line; fill in - // between source and dest with blanks. + // Cells were just moved out toward the end of the line; + // fill in between source and dest with blanks. for c in &mut line[source..destination] { c.reset(&cursor.template); } diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs index b1766b05..a6664054 100644 --- a/alacritty_terminal/src/term/search.rs +++ b/alacritty_terminal/src/term/search.rs @@ -28,7 +28,7 @@ pub struct RegexSearch { } impl RegexSearch { - /// Build the forwards and backwards search DFAs. + /// Build the forward and backward search DFAs. pub fn new(search: &str) -> Result { // Check case info for smart case let has_uppercase = search.chars().any(|c| c.is_uppercase()); @@ -318,7 +318,7 @@ impl Term { let start_char = self.grid[point.line][point.col].c; // Find the matching bracket we're looking for - let (forwards, end_char) = BRACKET_PAIRS.iter().find_map(|(open, close)| { + let (forward, end_char) = BRACKET_PAIRS.iter().find_map(|(open, close)| { if open == &start_char { Some((true, *close)) } else if close == &start_char { @@ -336,7 +336,7 @@ impl Term { loop { // Check the next cell - let cell = if forwards { iter.next() } else { iter.prev() }; + let cell = if forward { iter.next() } else { iter.prev() }; // Break if there are no more cells let c = match cell { @@ -633,7 +633,7 @@ mod tests { fn reverse_search_dead_recovery() { let mut term = mock_term("zooo lense"); - // Make sure the reverse DFA operates the same as a forwards DFA. + // Make sure the reverse DFA operates the same as a forward DFA. term.regex_search = Some(RegexSearch::new("zoo").unwrap()); let start = Point::new(0, Column(9)); let end = Point::new(0, Column(0)); -- cgit