2022-03-29 15:04:39 +00:00
|
|
|
pub use buffer_search::BufferSearchBar;
|
2023-04-06 21:49:03 +00:00
|
|
|
use gpui::{actions, Action, AppContext};
|
2022-03-31 16:36:39 +00:00
|
|
|
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
2022-02-28 09:34:11 +00:00
|
|
|
|
2022-03-29 15:04:39 +00:00
|
|
|
pub mod buffer_search;
|
|
|
|
pub mod project_search;
|
2022-01-28 22:00:00 +00:00
|
|
|
|
2023-04-06 21:49:03 +00:00
|
|
|
pub fn init(cx: &mut AppContext) {
|
2022-02-27 15:15:38 +00:00
|
|
|
buffer_search::init(cx);
|
|
|
|
project_search::init(cx);
|
2022-01-28 22:00:00 +00:00
|
|
|
}
|
2022-01-28 00:16:51 +00:00
|
|
|
|
2022-06-16 12:28:37 +00:00
|
|
|
actions!(
|
|
|
|
search,
|
|
|
|
[
|
|
|
|
ToggleWholeWord,
|
|
|
|
ToggleCaseSensitive,
|
|
|
|
ToggleRegex,
|
|
|
|
SelectNextMatch,
|
|
|
|
SelectPrevMatch
|
|
|
|
]
|
|
|
|
);
|
2022-02-27 21:18:04 +00:00
|
|
|
|
2022-06-16 12:28:37 +00:00
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
2022-02-24 18:07:00 +00:00
|
|
|
pub enum SearchOption {
|
2022-01-28 00:16:51 +00:00
|
|
|
WholeWord,
|
|
|
|
CaseSensitive,
|
|
|
|
Regex,
|
|
|
|
}
|
2022-02-27 21:18:04 +00:00
|
|
|
|
2022-06-16 11:44:00 +00:00
|
|
|
impl SearchOption {
|
|
|
|
pub fn label(&self) -> &'static str {
|
|
|
|
match self {
|
|
|
|
SearchOption::WholeWord => "Match Whole Word",
|
|
|
|
SearchOption::CaseSensitive => "Match Case",
|
|
|
|
SearchOption::Regex => "Use Regular Expression",
|
|
|
|
}
|
|
|
|
}
|
2022-06-16 12:28:37 +00:00
|
|
|
|
|
|
|
pub fn to_toggle_action(&self) -> Box<dyn Action> {
|
|
|
|
match self {
|
|
|
|
SearchOption::WholeWord => Box::new(ToggleWholeWord),
|
|
|
|
SearchOption::CaseSensitive => Box::new(ToggleCaseSensitive),
|
|
|
|
SearchOption::Regex => Box::new(ToggleRegex),
|
|
|
|
}
|
|
|
|
}
|
2022-06-16 11:44:00 +00:00
|
|
|
}
|