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 SelectAllMatches,
22 ]
23);
24
25#[derive(Clone, Copy, PartialEq)]
26pub enum SearchOption {
27 WholeWord,
28 CaseSensitive,
29 Regex,
30}
31
32impl SearchOption {
33 pub fn label(&self) -> &'static str {
34 match self {
35 SearchOption::WholeWord => "Match Whole Word",
36 SearchOption::CaseSensitive => "Match Case",
37 SearchOption::Regex => "Use Regular Expression",
38 }
39 }
40
41 pub fn to_toggle_action(&self) -> Box<dyn Action> {
42 match self {
43 SearchOption::WholeWord => Box::new(ToggleWholeWord),
44 SearchOption::CaseSensitive => Box::new(ToggleCaseSensitive),
45 SearchOption::Regex => Box::new(ToggleRegex),
46 }
47 }
48}