From 8b92fbdde3e136a62e9b05fca087b655eba3b2bc Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 29 May 2020 09:14:05 -0700 Subject: [PATCH] wezterm: search ctrl-r cycles pattern matching mode When the search overlay is active, pressing ctrl-r cycles through the different pattern matching modes; currently case sensitive and case insensitive, but shortly to add regex. The search ui now also indicates the current mode. --- src/frontend/gui/search.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/frontend/gui/search.rs b/src/frontend/gui/search.rs index b7aa97a77..e0f2a2267 100644 --- a/src/frontend/gui/search.rs +++ b/src/frontend/gui/search.rs @@ -151,6 +151,16 @@ impl Tab for SearchOverlay { r.set_viewport(Some(r.results[next].start_y)); } } + (KeyCode::Char('r'), KeyModifiers::CTRL) => { + // CTRL-r cycles through pattern match types + let mut r = self.renderer.borrow_mut(); + let pattern = match &r.pattern { + Pattern::CaseInSensitiveString(s) => Pattern::CaseSensitiveString(s.clone()), + Pattern::CaseSensitiveString(s) => Pattern::CaseInSensitiveString(s.clone()), + }; + r.pattern = pattern; + r.update_search(); + } (KeyCode::Char(c), KeyModifiers::NONE) | (KeyCode::Char(c), KeyModifiers::SHIFT) => { // Type to add to the pattern let mut r = self.renderer.borrow_mut(); @@ -339,13 +349,18 @@ impl Renderable for SearchRenderable { // Replace with search UI let rev = CellAttributes::default().set_reverse(true).clone(); line.fill_range(0..dims.cols, &Cell::new(' ', rev.clone())); + let mode = &match self.pattern { + Pattern::CaseSensitiveString(_) => "case-sensitive", + Pattern::CaseInSensitiveString(_) => "ignore-case", + }; line.overlay_text_with_attribute( 0, &format!( - "Search: {} ({}/{} matches)", + "Search: {} ({}/{} matches. {})", *self.pattern, self.result_pos.map(|x| x + 1).unwrap_or(0), - self.results.len() + self.results.len(), + mode ), rev, );