search.rs

 1pub use buffer_search::BufferSearchBar;
 2use gpui::{actions, Action, AppContext};
 3pub use project_search::{ProjectSearchBar, ProjectSearchView};
 4
 5pub mod buffer_search;
 6pub mod project_search;
 7
 8pub fn init(cx: &mut AppContext) {
 9    buffer_search::init(cx);
10    project_search::init(cx);
11}
12
13actions!(
14    search,
15    [
16        ToggleWholeWord,
17        ToggleCaseSensitive,
18        ToggleRegex,
19        SelectNextMatch,
20        SelectPrevMatch
21    ]
22);
23
24#[derive(Clone, Copy, PartialEq)]
25pub enum SearchOption {
26    WholeWord,
27    CaseSensitive,
28    Regex,
29}
30
31impl SearchOption {
32    pub fn label(&self) -> &'static str {
33        match self {
34            SearchOption::WholeWord => "Match Whole Word",
35            SearchOption::CaseSensitive => "Match Case",
36            SearchOption::Regex => "Use Regular Expression",
37        }
38    }
39
40    pub fn to_toggle_action(&self) -> Box<dyn Action> {
41        match self {
42            SearchOption::WholeWord => Box::new(ToggleWholeWord),
43            SearchOption::CaseSensitive => Box::new(ToggleCaseSensitive),
44            SearchOption::Regex => Box::new(ToggleRegex),
45        }
46    }
47}