terminal search

This commit is contained in:
Dongdong Zhou 2021-10-21 22:33:21 +01:00
parent a3a637c27e
commit 196d7240a4
1 changed files with 21 additions and 1 deletions

View File

@ -587,9 +587,29 @@ pub fn run(&mut self, receiver: Receiver<TerminalEvent>) -> Result<()> {
}
TerminalEvent::SearchNext(search_string, direction) => {
if let Ok(dfas) = RegexSearch::new(&search_string) {
let mut point = self.term.renderable_content().cursor.point;
if direction == Direction::Right {
if point.column.0 < self.term.last_column() {
point.column.0 += 1;
} else {
if point.line.0 < self.term.bottommost_line() {
point.column.0 = 0;
point.line.0 += 1;
}
}
} else {
if point.column.0 > 0 {
point.column.0 -= 1;
} else {
if point.line.0 > self.term.topmost_line() {
point.column.0 = self.term.last_column().0;
point.line.0 -= 1;
}
}
}
if let Some(m) = self.term.search_next(
&dfas,
self.term.renderable_content().cursor.point,
point,
direction,
Side::Left,
None,