Skip to content

Commit

Permalink
Add toggle to search with regex
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Jul 1, 2024
1 parent 6b6b7d6 commit 7e92b41
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions egui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ struct UiState {

query: String,
search_highlighted_id: Option<u64>,
search_with_regex: bool,

was_focused: bool,
skipped_first_focus: bool,
Expand Down Expand Up @@ -573,7 +574,11 @@ fn search_ui(
) {
let response = ui.add(
TextEdit::singleline(&mut state.query)
.hint_text("Search")
.hint_text(if state.search_with_regex {
"Search with RegEx"
} else {
"Search"
})
.desired_width(f32::INFINITY)
.cursor_at_end(true),
);
Expand All @@ -593,6 +598,9 @@ fn search_ui(
ui.memory_mut(egui::Memory::close_popup);
response.request_focus();
}
if ui.input(|i| i.modifiers.alt && i.key_pressed(Key::X)) {
state.search_with_regex ^= true;
}

if !response.changed() {
return;
Expand All @@ -604,7 +612,7 @@ fn search_ui(

let _ = requests.send(Command::Search {
query: state.query.clone(),
regex: false,
regex: state.search_with_regex,
});
}

Expand Down

0 comments on commit 7e92b41

Please sign in to comment.