feat(find): add find and replace

Closes #583
This commit is contained in:
Hakan Seven committed 2026-07-30 17:56:54 +03:00
1 parent 4af141ebec
commit c9aab122f0
10 files changed
+814 -7

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
use crate::app::Message;
use iced::widget::{button, column, row, text, text_input, Space};
use iced::{Element, Fill};
pub const FIND_INPUT_ID: &str = "find-replace-search";
pub fn view_window<'a>(
search: &'a str,
replacement: &'a str,
status: &'a str,
) -> Element<'a, Message> {
let find_input = text_input("Text to find", search)
.id(iced::widget::Id::new(FIND_INPUT_ID))
.on_input(Message::FindReplaceSearchChanged)
.on_submit(Message::FindReplaceNext)
.padding([6, 8])
.size(13);
let replacement_input = text_input("Replacement text", replacement)
.on_input(Message::FindReplaceReplacementChanged)
.padding([6, 8])
.size(13);
let enabled = !search.trim().is_empty();
let action = |label: &'static str, message: Message| {
let button = button(text(label).size(12)).padding([6, 12]);
if enabled {
button.on_press(message)
} else {
button
}
};
column![
row![
text("Find:").size(12).width(90),
find_input.width(Fill),
]
.spacing(8)
.align_y(iced::Center),
row![
text("Replace with:").size(12).width(90),
replacement_input.width(Fill),
]
.spacing(8)
.align_y(iced::Center),
text("Searches Text, MText, Attribute Definitions, and block attribute values.")
.size(11),
text(status).size(11),
row![
Space::new().width(Fill),
button(text("Close").size(12))
.on_press(Message::CloseModal)
.padding([6, 12])
.style(button::secondary),
action("Replace", Message::FindReplaceOne).style(button::secondary),
action("Replace All", Message::FindReplaceAll).style(button::danger),
action("Find Next", Message::FindReplaceNext).style(button::primary),
]
.spacing(8)
.align_y(iced::Center),
]
.spacing(10)
.padding(12)
.width(Fill)
.into()
}
+1
View File
@@ -10,3 +10,4 @@ pub mod open_progress;
pub mod options;
pub mod attribute_editor;
pub mod alias_editor;
pub mod find_replace;
+1
View File
@@ -109,6 +109,7 @@ pub fn view_window<'a>(
shortcut_row(format!("{MOD}+Shift+S"), "Save As"),
shortcut_row(format!("{MOD}+Z"), "Undo"),
shortcut_row(format!("{MOD}+Shift+Z / {MOD}+Y"), "Redo"),
shortcut_row(format!("{MOD}+F / {MOD}+H"), "Find and Replace"),
shortcut_row(format!("{MOD}+C"), "Copy to Clipboard"),
shortcut_row(format!("{MOD}+X"), "Cut to Clipboard"),
shortcut_row(format!("{MOD}+V"), "Paste from Clipboard"),