Skip to main content

par_term/copy_mode/
search.rs

1//! Search state methods for the copy mode state machine.
2
3use super::types::{CopyModeState, SearchDirection};
4
5impl CopyModeState {
6    // ========================================================================
7    // Search
8    // ========================================================================
9
10    /// Start search input mode
11    pub fn start_search(&mut self, direction: SearchDirection) {
12        self.is_searching = true;
13        self.search_direction = direction;
14        self.search_query.clear();
15    }
16
17    /// Add a character to the search query
18    pub fn search_input(&mut self, ch: char) {
19        self.search_query.push(ch);
20    }
21
22    /// Remove the last character from the search query
23    pub fn search_backspace(&mut self) {
24        self.search_query.pop();
25    }
26
27    /// Cancel search mode without executing
28    pub fn cancel_search(&mut self) {
29        self.is_searching = false;
30        self.search_query.clear();
31    }
32}