Skip to main content

par_term/search/
types.rs

1//! Types for terminal search functionality.
2
3/// A single search match in the terminal scrollback.
4#[derive(Clone, Debug, PartialEq, Eq)]
5pub struct SearchMatch {
6    /// Line index in scrollback (0 = oldest line)
7    pub line: usize,
8    /// Column position in the line (0-indexed)
9    pub column: usize,
10    /// Length of the match in characters
11    pub length: usize,
12}
13
14impl SearchMatch {
15    /// Create a new search match.
16    pub fn new(line: usize, column: usize, length: usize) -> Self {
17        Self {
18            line,
19            column,
20            length,
21        }
22    }
23}
24
25/// Configuration options for search behavior.
26#[derive(Clone, Debug)]
27pub struct SearchConfig {
28    /// Whether search is case-sensitive.
29    pub case_sensitive: bool,
30    /// Whether to use regex pattern matching.
31    pub use_regex: bool,
32    /// Whether to match whole words only.
33    pub whole_word: bool,
34    /// Whether to wrap around when navigating matches.
35    pub wrap_around: bool,
36}
37
38impl Default for SearchConfig {
39    fn default() -> Self {
40        Self {
41            case_sensitive: false,
42            use_regex: false,
43            whole_word: false,
44            wrap_around: true,
45        }
46    }
47}
48
49/// Actions that can result from search UI interaction.
50#[derive(Debug, Clone)]
51pub enum SearchAction {
52    /// No action needed.
53    None,
54    /// Scroll to make a match visible at the given scroll offset.
55    ScrollToMatch(usize),
56    /// Close the search UI.
57    Close,
58}