zed/crates/search/src/search.rs

48 lines
1.1 KiB
Rust
Raw Normal View History

pub use buffer_search::BufferSearchBar;
use gpui::{actions, Action, AppContext};
pub use project_search::{ProjectSearchBar, ProjectSearchView};
pub mod buffer_search;
pub mod project_search;
pub fn init(cx: &mut AppContext) {
buffer_search::init(cx);
project_search::init(cx);
}
2022-01-28 00:16:51 +00:00
actions!(
search,
[
ToggleWholeWord,
ToggleCaseSensitive,
ToggleRegex,
SelectNextMatch,
SelectPrevMatch
]
);
#[derive(Clone, Copy, PartialEq)]
pub enum SearchOption {
2022-01-28 00:16:51 +00:00
WholeWord,
CaseSensitive,
Regex,
}
impl SearchOption {
pub fn label(&self) -> &'static str {
match self {
SearchOption::WholeWord => "Match Whole Word",
SearchOption::CaseSensitive => "Match Case",
SearchOption::Regex => "Use Regular Expression",
}
}
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),
}
}
}