zed/crates/search/src/search.rs
Nathan Sobo de9bf6dfbd Merge MutableAppContext into AppContext
There may have been a good reason for the difference at some point, or I was
still learning Rust. But now it's just &mut AppContext vs &AppContext.
2023-04-06 15:49:03 -06:00

47 lines
1.1 KiB
Rust

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);
}
actions!(
search,
[
ToggleWholeWord,
ToggleCaseSensitive,
ToggleRegex,
SelectNextMatch,
SelectPrevMatch
]
);
#[derive(Clone, Copy, PartialEq)]
pub enum SearchOption {
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),
}
}
}