mirror of
https://github.com/wez/wezterm.git
synced 2024-12-18 02:42:05 +03:00
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.
This commit is contained in:
parent
7f83d2172c
commit
8b92fbdde3
@ -151,6 +151,16 @@ impl Tab for SearchOverlay {
|
|||||||
r.set_viewport(Some(r.results[next].start_y));
|
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) => {
|
(KeyCode::Char(c), KeyModifiers::NONE) | (KeyCode::Char(c), KeyModifiers::SHIFT) => {
|
||||||
// Type to add to the pattern
|
// Type to add to the pattern
|
||||||
let mut r = self.renderer.borrow_mut();
|
let mut r = self.renderer.borrow_mut();
|
||||||
@ -339,13 +349,18 @@ impl Renderable for SearchRenderable {
|
|||||||
// Replace with search UI
|
// Replace with search UI
|
||||||
let rev = CellAttributes::default().set_reverse(true).clone();
|
let rev = CellAttributes::default().set_reverse(true).clone();
|
||||||
line.fill_range(0..dims.cols, &Cell::new(' ', rev.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(
|
line.overlay_text_with_attribute(
|
||||||
0,
|
0,
|
||||||
&format!(
|
&format!(
|
||||||
"Search: {} ({}/{} matches)",
|
"Search: {} ({}/{} matches. {})",
|
||||||
*self.pattern,
|
*self.pattern,
|
||||||
self.result_pos.map(|x| x + 1).unwrap_or(0),
|
self.result_pos.map(|x| x + 1).unwrap_or(0),
|
||||||
self.results.len()
|
self.results.len(),
|
||||||
|
mode
|
||||||
),
|
),
|
||||||
rev,
|
rev,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user