DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Find/Change: Change and Change/Find (PR #1498's own change on main's Find/Change)
aionggb9f884f002c7
diff --git a/ROADMAP.md b/ROADMAP.mdindex ed98bb2f1..4c925cd23 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -464,6 +464,7 @@ Newest first.- **2026-10-21** · Paragraph rules have InDesign's Type (solid, thick/thin stripes, dashed, dotted, straight hash, wavy, or a stroke style of the document), Gap Color and Gap Tint, and Keep In Frame (rule above); the Paragraph Rules page is laid out as InDesign's (Weight and Type, Color and Tint, Gap Color and Gap Tint, Width and Offset, Left and Right Indent). IDML reads and writes them (`RuleAboveType`, `RuleBelowGapColor`, `KeepRuleAboveInFrame`…). Found in the Learn Skills Daily course, chapter 20. No readiness percentage change.- **2026-10-21** · New Character Style with text selected starts from what the text has of its own over its paragraph style, as InDesign's ("[None] + Bold + color"), and Apply Style to Selection gives the text the new style, with no override left. A new style's dialog is titled New Paragraph Style / New Character Style. `type.selectionAttrs` reports the text's own character attributes (`ownChars`). Found in the Learn Skills Daily course, chapter 22. No readiness percentage change.- **2026-10-21** · New Paragraph Style with text selected starts from it, as InDesign's (Based On [No Paragraph Style], every setting of the text that differs) and Apply Style to Selection gives the paragraph the new style; General has Next Style and Reset To Base; Basic Character Formats is in two columns (Size | Leading, Kerning | Tracking, Case | Position). `style.paragraph.edit` honours `nextStyle` (it was ignored) and takes `resetToBase`. Found in the Learn Skills Daily course, chapter 20. No readiness percentage change.+- **2026-10-21** · Find/Change has InDesign's Change and Change/Find: Change changes the text Find Next found and keeps it selected, Change/Find also finds the next match, and the search keeps its domain (a selection or story) across them. The Search list reads Document, Story and Selection. `find.change` takes `found`. Found in the Learn Skills Daily course, chapter 22. No readiness percentage change.- **2026-10-21** · Find/Change has InDesign's Find Format: Specify Attributes opens Find Format Settings (the same Style Options and character sections as Change Format Settings), and only text with the format is found. With nothing in Find what, each stretch of text with the format is found, so Change All can restyle every word in a character style. `find.find`, `find.next` and `find.change` take `findFormat {charStyle?, paraStyle?, chars?}`. Found in the Learn Skills Daily course, chapter 22. No readiness percentage change.- **2026-10-21** · Find/Change has InDesign's Change Format. Specify Attributes opens Change Format Settings: Style Options (the character and paragraph style to apply, [Any Style] for none), then Basic and Advanced Character Formats, Character Color, OpenType Features, Underline and Strikethrough Options. The box shows the format ("Character Style: eggs"), and Change All gives it to the changed text. With a Change Format and nothing in Change to, the found text stays and is only formatted, as InDesign's (an ⓘ beside Change to says so). `find.change` takes `charStyle` and `paraStyle`. Found in the Learn Skills Daily course, chapter 22. No readiness percentage change.- **2026-10-21** · Preferences › Interface follows InDesign's: Appearance has a Color Theme swatch per interface theme (a click shows it at once, Cancel goes back) and Panels sets the Tools panel to a single or double column; UI Size moves to a UI Scaling section of its own. Interface held only UI Size, and the theme could be changed only from the Window menu. Found in the Learn Skills Daily course, chapter 26. No readiness percentage change.diff --git a/crates/compose/src/grep.rs b/crates/compose/src/grep.rsindex 6f9e8f9e3..61546d162 100644--- a/crates/compose/src/grep.rs+++ b/crates/compose/src/grep.rs@@ -385,6 +385,16 @@ impl Grep {self.re.find_iter(text).take(limit).map(|m| m.map(|m| m.range()).map_err(run_err)).collect()}+ /// The first match starting at or after byte `start`, with its replacement: `template`+ /// expanded as [`Self::replacements`] does.+ pub fn replacement_at(&self, text: &str, start: usize, template: &str) -> Result<Option<(Range<usize>, String)>, GrepError> {+ if start > text.len() || !text.is_char_boundary(start) {+ return Ok(None);+ }+ let Some(caps) = self.re.captures_from_pos(text, start).map_err(run_err)? else { return Ok(None) };+ Ok(caps.get(0).map(|m| (m.range(), fancy_regex::Expander::default().expansion(template, &caps))))+ }+/// Non-empty matches in `text`, at most `limit` of them: an empty match styles nothing, so it/// doesn't count toward a GREP style's cap.pub fn find_nonempty(&self, text: &str, limit: usize) -> Result<Vec<Range<usize>>, GrepError> {diff --git a/crates/engine/src/cmd/find.rs b/crates/engine/src/cmd/find.rsindex 6c0be2cd9..4ac02d928 100644--- a/crates/engine/src/cmd/find.rs+++ b/crates/engine/src/cmd/find.rs@@ -61,18 +61,18 @@ pub fn specs() -> Vec<CommandSpec> {}),cmd!(query "find.find", "Find", ["Edit", "Find/Change"], None,- "{find, grep?: bool, caseSensitive?: bool, wholeWord?: bool, scope?: document|story|selection, story?, findFormat?: {charStyle?, paraStyle?, chars?: resolved character attributes} (Find Format: only text with it all through; with an empty find, each stretch of text with it), change?|first?|attrs?|charStyle?|paraStyle?: ignored (find.change takes them; one request serves all three Find/Change commands)} → matches [{story, start, end, text, cell?: {table, row, col}}] (document scope also searches table cells; start/end then index the cell's text)",+ "{find, grep?: bool, caseSensitive?: bool, wholeWord?: bool, scope?: document|story|selection, story?, findFormat?: {charStyle?, paraStyle?, chars?: resolved character attributes} (Find Format: only text with it all through; with an empty find, each stretch of text with it), change?|first?|found?|attrs?|charStyle?|paraStyle?: ignored (find.change takes them; one request serves all three Find/Change commands)} → matches [{story, start, end, text, cell?: {table, row, col}}] (document scope also searches table cells; start/end then index the cell's text)",has_doc, find),cmd!("find.change","Change All",["Edit", "Find/Change"],None,- "{find, change, grep?, caseSensitive?, wholeWord?, scope?, story?, findFormat?: {charStyle?, paraStyle?, chars?: resolved character attributes} (Find Format: only text with it all through; with an empty find, each stretch of text with it), first?: bool (change only the first match), attrs?: {character attributes applied to changed text}, charStyle?: a character style applied to it, paraStyle?: a paragraph style applied to its paragraphs} → {count} — attrs, charStyle and paraStyle are the Change Format: with one and an empty change, the found text stays and is only formatted; with no find, change is literal text",+ "{find, change, grep?, caseSensitive?, wholeWord?, scope?, story?, findFormat?: {charStyle?, paraStyle?, chars?: resolved character attributes} (Find Format: only text with it all through; with an empty find, each stretch of text with it), first?: bool (change only the first match), found?: bool (Change: only the text Find Next found, while it is selected and still a match; it stays selected, and Find Next goes on after it in the same domain), attrs?: {character attributes applied to changed text}, charStyle?: a character style applied to it, paraStyle?: a paragraph style applied to its paragraphs} → {count} — attrs, charStyle and paraStyle are the Change Format: with one and an empty change, the found text stays and is only formatted; with no find, change is literal text",has_doc,change),- cmd!(noundo "find.next", "Find Next", ["Edit"], Some("Cmd+Alt+F"), "{find, grep?, caseSensitive?, wholeWord?, scope?: document|story|selection, story?, findFormat?: {charStyle?, paraStyle?, chars?: resolved character attributes} (Find Format: only text with it all through; with an empty find, each stretch of text with it), change?|first?|attrs?|charStyle?|paraStyle?: ignored (find.change takes them; one request serves all three Find/Change commands)} — Selection starts at its original beginning; later calls advance within the scope", has_doc, find_next),+ cmd!(noundo "find.next", "Find Next", ["Edit"], Some("Cmd+Alt+F"), "{find, grep?, caseSensitive?, wholeWord?, scope?: document|story|selection, story?, findFormat?: {charStyle?, paraStyle?, chars?: resolved character attributes} (Find Format: only text with it all through; with an empty find, each stretch of text with it), change?|first?|found?|attrs?|charStyle?|paraStyle?: ignored (find.change takes them; one request serves all three Find/Change commands)} — Selection starts at its original beginning; later calls advance within the scope", has_doc, find_next),]}@@ -272,6 +272,34 @@ impl Search {}}+ /// The edit Change makes when the selection `range` (offsets in `text`, target `r` of story+ /// `sid`) is what Find Next found there, so the two commands agree on what a match is. With+ /// no pattern: a selection inside one stretch with the Find Format (Find Next selects the rest+ /// of a stretch from inside it). With a pattern: the match it makes from the selection's start+ /// must be the selection, overlapping matches Find Next can select included.+ #[allow(clippy::too_many_arguments)]+ fn found_edit(+ &self,+ d: &Document,+ sid: StoryId,+ cell: Option<CellAddr>,+ r: &Range<usize>,+ text: &str,+ range: &Range<usize>,+ rep: &str,+ grep: bool,+ ) -> Result<Option<(Range<usize>, String)>> {+ let spans = self.spans(d, sid, cell, r);+ let Some(re) = &self.re else {+ let inside = !range.is_empty() && spans.unwrap_or_default().iter().any(|s| s.start <= range.start && range.end <= s.end);+ return Ok(inside.then(|| (range.clone(), rep.to_string())));+ };+ let found =+ if grep { re.replacement_at(text, range.start, rep) } else { re.find_at(text, range.start).map(|m| m.map(|m| (m, rep.to_string()))) };+ let found = found.map_err(|e| bad("find.change", e))?;+ Ok(found.filter(|(m, _)| m == range && spans.as_ref().is_none_or(|s| within(s, m))))+ }+/// The edits Change All makes in `text` (target `r` of story `sid`): `rep` expanded for each/// GREP match, else `rep` itself.#[allow(clippy::too_many_arguments)]@@ -378,6 +406,29 @@ impl FindContext {self.selection = st.selection.clone();}+ /// After Change put `new_len` bytes in place of `old` in story `sid`: the domain keeps the+ /// changed text and the search goes on after it.+ fn after_change(&mut self, st: &DocState, sid: StoryId, cell: Option<CellAddr>, old: &Range<usize>, new_len: usize) {+ let moved = |x: usize| if x >= old.end { x - old.len() + new_len } else { x };+ for (tid, tcell, r) in &mut self.targets {+ if *tid == sid && *tcell == cell {+ *r = moved(r.start)..moved(r.end);+ }+ }+ self.offset = old.start + new_len;+ self.last_match_end = Some(self.offset);+ let at = self.offset;+ if let Some(i) = self+ .order+ .iter()+ .position(|i| self.targets.get(*i).is_some_and(|(tid, tcell, r)| *tid == sid && *tcell == cell && r.start <= at && at <= r.end))+ {+ self.target = i;+ }+ self.document = Arc::downgrade(&st.doc);+ self.acknowledge(st);+ }+fn restart(&mut self, st: &DocState) -> Result<()> {self.target = 0;self.last_match_end = None;@@ -570,21 +621,58 @@ fn change(s: &mut Session, p: &Value) -> Result<Value> {return Err(bad("find.change", format!("no paragraph style `{n}`")));}// InDesign: with a Change Format and nothing in Change to, the found text is only formatted.- let format_only =- str_param(p, "change").unwrap_or("").is_empty() && (char_style.is_some() || para_style.is_some() || !over.is_empty() || !cleared.is_empty());- let targets = scope(s, p)?.targets;- s.edit(|d, sel| {+ let format_only = str_param(p, "change").unwrap_or("").is_empty() && (char_style.is_some() || para_style.is_some() || !over.is_empty() || !cleared.is_empty());+ let context = scope(s, p)?;+ let targets = context.targets.clone();+ // Change: only the text Find Next found, the selection, while it is still a match (as Find+ // Next defines one), with its replacement.+ let (found, found_out) = if bool_or(p, "found", false) {+ let st = s.doc()?;+ let selected = st.selection.text.filter(|t| st.selection.cells.is_none() && !t.is_caret()).map(|t| (t.story, t.cell, t.range()));+ let hit = selected.and_then(|(sid, cell, range)| {+ targets.iter().find_map(|(tid, tcell, r)| {+ if *tid != sid || *tcell != cell || range.start < r.start || r.end < range.end {+ return None;+ }+ let text = target_text(&st.doc, *tid, cell, r).ok()?;+ let local = range.start - r.start..range.end - r.start;+ let (m, out) = re.found_edit(&st.doc, *tid, cell, r, text, &local, &rep, grep).ok()??;+ Some(((sid, cell, r.start + m.start..r.start + m.end), out))+ })+ });+ match hit {+ Some((hit, out)) => (Some(hit), Some(out)),+ None => return Ok(json!({"count": 0})),+ }+ } else {+ (None, None)+ };+ let (count, changed) = s.edit(|d, sel| {let styles = d.styles.clone();let mut count = 0usize;+ let mut changed = None;for (sid, cell, r) in targets {+ if found.as_ref().is_some_and(|(at, in_cell, _)| *at != sid || *in_cell != cell) {+ continue;+ }let Some(story) = d.text_story(sid, cell) else { continue };// Collect matches first (positions refer to the original text), apply back to front.let text = story.text.get(r.clone()).ok_or_else(|| bad("find", "invalid selection bounds or UTF-8 boundary"))?;- let edits: Vec<(std::ops::Range<usize>, String)> = re- .replacements(d, sid, cell, &r, text, &rep, grep, first_only)?- .into_iter()- .map(|(m, out)| (r.start + m.start..r.start + m.end, out))- .collect();+ let edits: Vec<(std::ops::Range<usize>, String)> = match (&found, &found_out) {+ // Change: the found text alone, in the target it lies in.+ (Some((_, _, range)), Some(out)) => {+ if r.start <= range.start && range.end <= r.end {+ vec![(range.clone(), out.clone())]+ } else {+ Vec::new()+ }+ }+ _ => re+ .replacements(d, sid, cell, &r, text, &rep, grep, first_only)?+ .into_iter()+ .map(|(m, out)| (r.start + m.start..r.start + m.end, out))+ .collect(),+ };let Some(st) = d.text_story_mut(sid, cell) else { continue };for (range, new) in edits.iter().rev() {let changed = if format_only {@@ -616,13 +704,29 @@ fn change(s: &mut Session, p: &Value) -> Result<Value> {if let Some(t) = sel.text.as_mut().filter(|t| t.story == sid && t.cell == cell) {repair_selection(t, st);}+ // Change leaves the changed text selected.+ if let Some((_, _, range)) = &found+ && let Some((_, new)) = edits.first()+ && let Some(t) = sel.text.as_mut()+ {+ let len = if format_only { range.len() } else { new.len() };+ (t.anchor, t.focus) = (range.start, range.start + len);+ changed = Some(len);+ }// `first` is the first match of the whole search, not of each story.if first_only && count > 0 {break;}}- Ok(json!({"count": count}))- })+ Ok((count, changed))+ })?;+ // Change: Find Next goes on after the changed text, in the search's domain.+ if let (Some((sid, cell, old)), Some(len)) = (&found, changed) {+ let mut context = context;+ context.after_change(s.doc()?, *sid, *cell, old, len);+ s.find_context = Some(context);+ }+ Ok(json!({"count": count}))}fn find_next(s: &mut Session, p: &Value) -> Result<Value> {diff --git a/crates/engine/src/cmd/find/tests.rs b/crates/engine/src/cmd/find/tests.rsindex 7de29f8ea..65dad887b 100644--- a/crates/engine/src/cmd/find/tests.rs+++ b/crates/engine/src/cmd/find/tests.rs@@ -621,6 +621,27 @@ fn document_scope_searches_and_changes_table_cells() {assert_eq!(s.execute("find.find", &json!({"find": "13.00", "scope": "document"})).unwrap().as_array().unwrap().len(), 2);}+/// Change (`found`) on text Find Next found in a table cell changes it there, leaves the+/// same text in the story alone, and Find Next goes on after it.+#[test]+fn change_changes_the_text_find_next_found_in_a_cell() {+ let (mut s, sid) = scope_session("red here");+ scope_select(&mut s, sid, 0, 0);+ let table = s.execute("table.insert", &json!({"rows": 1, "cols": 2})).unwrap()["table"].as_u64().unwrap();+ s.execute("table.setCell", &json!({"row": 0, "col": 1, "text": "red"})).unwrap();+ let p = json!({"find": "red", "change": "blue", "scope": "document"});+ let hit = s.execute("find.next", &p).unwrap();+ assert_eq!(hit["cell"], json!({"table": table, "row": 0, "col": 1}), "{hit}");+ let mut change = p.clone();+ change["found"] = json!(true);+ assert_eq!(s.execute("find.change", &change).unwrap()["count"], 1);+ let t = s.execute("table.get", &json!({"table": table})).unwrap();+ assert_eq!(t["cells"][1]["text"], "blue");+ assert!(s.doc().unwrap().doc.story(sid).unwrap().text.contains("red here"), "the story's red stays");+ let next = s.execute("find.next", &p).unwrap();+ assert!(next.get("cell").is_none() && next.get("start").is_some(), "on to the story: {next}");+}+fn child_scope_session(note: bool, child: &str) -> (Session, designcraft_doc::StoryId, designcraft_doc::TextSel) {let (mut s, sid) = scope_session("red");scope_select(&mut s, sid, 3, 3);@@ -862,3 +883,73 @@ fn a_find_format_finds_only_text_with_it() {}assert!(s.execute("find.find", &json!({"find": ""})).is_err());}++/// Change and Change/Find: only the text Find Next found changes; it stays selected and the+/// search goes on after it in its domain (here the original selection). A selection that+/// isn't a match changes nothing and makes no undo step.+#[test]+fn change_changes_the_found_text_and_the_search_goes_on() {+ let (mut s, sid) = scope_session("red red | red");+ scope_select(&mut s, sid, 0, 7);+ let p = json!({"find": "red", "change": "blue", "scope": "selection"});+ let mut change = p.clone();+ change["found"] = json!(true);+ scope_hit(&mut s, &p, sid, 0, 3);+ assert_eq!(s.execute("find.change", &change).unwrap()["count"], 1);+ let text = |s: &Session| s.doc().unwrap().doc.story(sid).unwrap().text.clone();+ assert_eq!(text(&s), "blue red | red");+ assert_eq!(s.doc().unwrap().selection.text.unwrap().range(), 0..4, "the changed text stays selected");+ scope_hit(&mut s, &p, sid, 5, 8);+ s.execute("find.change", &change).unwrap();+ assert_eq!(text(&s), "blue blue | red");+ assert_eq!(s.execute("find.next", &p).unwrap(), serde_json::Value::Null, "the last red is outside the selection searched");+ // Not a match: nothing changes, no undo step.+ scope_select(&mut s, sid, 0, 4);+ let history = s.doc().unwrap().history.undo.len();+ assert_eq!(s.execute("find.change", &json!({"find": "red", "change": "blue", "found": true})).unwrap()["count"], 0);+ assert_eq!(s.doc().unwrap().history.undo.len(), history);+ // A Change Format with nothing in Change to formats the found text only.+ scope_select(&mut s, sid, 0, 0);+ let fmt = json!({"find": "red", "change": "", "attrs": {"underline": true}});+ let hit = s.execute("find.next", &fmt).unwrap();+ assert_eq!(hit["start"], 12);+ let mut found = fmt.clone();+ found["found"] = json!(true);+ s.execute("find.change", &found).unwrap();+ assert_eq!(text(&s), "blue blue | red");+ assert_eq!(s.doc().unwrap().doc.story(sid).unwrap().format_after(12).over.underline, Some(true));+ assert_eq!(s.doc().unwrap().selection.text.unwrap().range(), 12..15);+}++/// Change accepts what Find Next selected even when Change All wouldn't match there: the+/// rest of a Find Format stretch from a caret inside it, and an overlapping match.+#[test]+fn change_takes_any_selection_find_next_made() {+ // A caret inside a bold stretch: Find Next with only a Find Format selects the rest of it.+ let (mut s, sid) = scope_session("plain bold text");+ s.execute("style.character.create", &json!({"name": "Strong", "chars": {"fontStyle": "Bold"}})).unwrap();+ scope_select(&mut s, sid, 6, 10);+ s.execute("style.character.apply", &json!({"name": "Strong"})).unwrap();+ scope_select(&mut s, sid, 8, 8);+ let p = json!({"find": "", "change": "", "findFormat": {"charStyle": "Strong"}, "attrs": {"underline": true}, "scope": "story"});+ let hit = s.execute("find.next", &p).unwrap();+ assert_eq!((hit["start"].as_u64(), hit["end"].as_u64()), (Some(8), Some(10)));+ let mut change = p.clone();+ change["found"] = json!(true);+ assert_eq!(s.execute("find.change", &change).unwrap()["count"], 1);+ let st = s.doc().unwrap().doc.story(sid).unwrap().clone();+ assert_eq!((st.format_after(7).over.underline, st.format_after(8).over.underline), (None, Some(true)), "only the selected rest");+ // "aa" in "aaa" from the second a: Find Next selects 1..3, which Change All never finds.+ for grep in [false, true] {+ let (mut s, sid) = scope_session("aaa");+ scope_select(&mut s, sid, 1, 1);+ let (find, change) = if grep { ("(a)a", "<$1>") } else { ("aa", "b") };+ let p = json!({"find": find, "change": change, "grep": grep, "scope": "story"});+ let hit = s.execute("find.next", &p).unwrap();+ assert_eq!((hit["start"].as_u64(), hit["end"].as_u64()), (Some(1), Some(3)));+ let mut found = p.clone();+ found["found"] = json!(true);+ assert_eq!(s.execute("find.change", &found).unwrap()["count"], 1, "grep: {grep}");+ assert_eq!(s.doc().unwrap().doc.story(sid).unwrap().text, if grep { "a<a>" } else { "ab" });+ }+}diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rsindex 642f0d1cd..bd99d9222 100644--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@ -2676,13 +2676,21 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {});text_field_named(ui, &mut d, "change", 260.0, crate::i18n::tr(&app.ui.language, "Change to:"));ui.end_row();- let scope_name = crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Search:"));+ let search_label = crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Search:"));let cur = d.s("scope");+ // InDesign's names for the scopes.+ let scope_name = |v: &str| match v {+ "story" => "Story",+ "selection" => "Selection",+ _ => "Document",+ };craft_ui::ComboBox::from_id_salt("fcscope")- .selected_text(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, &cur)))+ .selected_text(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, scope_name(&cur)))).show_ui(ui, |ui| {for v in ["document", "story", "selection"] {- if ui.selectable_label(cur == v, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, v))).clicked()+ if ui+ .selectable_label(cur == v, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, scope_name(v))))+ .clicked()&& d.set_field("scope", json!(v)){app.session.reset_find_scope();@@ -2690,7 +2698,7 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {}}).response- .labelled_by(scope_name.id);+ .labelled_by(search_label.id);ui.end_row();});ui.horizontal(|ui| {@@ -2702,11 +2710,27 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {ui.horizontal(|ui| {let params0 = find_change_params(&d);let params = || params0.clone();+ // Change and Change/Find act on the text Find Next found.+ let mut found = params0.clone();+ found["found"] = json!(true);+ let selected = app.session.active().and_then(|st| st.selection.text).is_some_and(|t| !t.is_caret());+ let next_status = |app: &mut DesignApp, r: Result<Value, String>| match r {+ Ok(Value::Null) => crate::i18n::tr(&app.ui.language, "No matches").to_string(),+ Ok(_) => crate::i18n::tr(&app.ui.language, "Found").to_string(),+ Err(e) => e,+ };if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Find Next"))).clicked() {let r = app.run("find.next", params());- let msg = match r {- Ok(Value::Null) => crate::i18n::tr(&app.ui.language, "No matches").to_string(),- Ok(_) => crate::i18n::tr(&app.ui.language, "Found").to_string(),+ let msg = next_status(app, r);+ d.fields.insert("status".into(), json!(msg));+ }+ if ui+ .add_enabled(selected, egui::Button::new(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Change"))))+ .clicked()+ {+ let msg = match app.run("find.change", found.clone()) {+ Ok(v) => crate::i18n::tr(&app.ui.language, "{count} replacement(s) made")+ .replace("{count}", &v["count"].to_string()),Err(e) => e,};d.fields.insert("status".into(), json!(msg));@@ -2719,6 +2743,17 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {};d.fields.insert("status".into(), json!(msg));}+ if ui+ .add_enabled(+ selected,+ egui::Button::new(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Change/Find"))),+ )+ .clicked()+ {+ let r = app.run("find.change", found.clone()).and_then(|_| app.run("find.next", params()));+ let msg = next_status(app, r);+ d.fields.insert("status".into(), json!(msg));+ }if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Count"))).clicked() {let msg = match app.run("find.find", params()) {Ok(v) => crate::i18n::tr(&app.ui.language, "{count} match(es)")diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rsindex d3f99b14e..e3e271a7e 100644--- a/crates/ui-egui/src/dialogs/tests.rs+++ b/crates/ui-egui/src/dialogs/tests.rs@@ -1647,6 +1647,15 @@ fn dialog_frame(app: &mut DesignApp, ctx: &egui::Context, screen: egui::Rect, evlabels}+/// What Find/Change's Search list shows for a scope.+fn scope_label(scope: &str) -> &'static str {+ match scope {+ "story" => "Story",+ "selection" => "Selection",+ _ => "Document",+ }+}+fn visible_label(labels: &[(String, egui::Rect, egui::Rect)], screen: egui::Rect, expected: &str) -> egui::Rect {let (_, rect, clip) = labels.iter().find(|(text, _, _)| text.trim() == expected).unwrap_or_else(|| panic!("{expected} is painted"));assert!(screen.contains_rect(*rect), "{expected} must stay on screen: {rect:?}");@@ -1730,8 +1739,8 @@ fn scope_dialog_with_tool(text: &str, end: usize, tool: Option<&str>) -> (Designfor _ in 0..3 {dialog_frame(&mut app, &ctx, screen, vec![]);}- scope_click(&mut app, &ctx, screen, "document");- scope_click(&mut app, &ctx, screen, "selection");+ scope_click(&mut app, &ctx, screen, "Document");+ scope_click(&mut app, &ctx, screen, "Selection");assert_eq!(app.ui.dialog.as_ref().unwrap().s("scope"), "selection");(app, ctx, screen, sid)}@@ -1806,8 +1815,8 @@ fn find_scope_dialog_explicit_story_ignored_scope_preserves_grep_cursor() {let cur = app.ui.dialog.as_ref().unwrap().s("scope");let next = if cur == "selection" { "document" } else { "selection" };if physical {- scope_click(&mut app, &ctx, screen, &cur);- scope_click(&mut app, &ctx, screen, next);+ scope_click(&mut app, &ctx, screen, scope_label(&cur));+ scope_click(&mut app, &ctx, screen, scope_label(next));} else {scope_control(&mut app, &ctx, "ui.dialog.set", json!({"field": "scope", "value": next}));}@@ -1824,8 +1833,8 @@ fn find_scope_dialog_explicit_story_ignored_scope_preserves_grep_cursor() {let cur = app.ui.dialog.as_ref().unwrap().s("scope");let next = if cur == "selection" { "document" } else { "selection" };if physical {- scope_click(&mut app, &ctx, screen, &cur);- scope_click(&mut app, &ctx, screen, next);+ scope_click(&mut app, &ctx, screen, scope_label(&cur));+ scope_click(&mut app, &ctx, screen, scope_label(next));} else {scope_control(&mut app, &ctx, "ui.dialog.set", json!({"field": "scope", "value": next}));}@@ -4400,3 +4409,49 @@ fn on_a_page_without_a_section_the_window_is_new_section() {visible_label(&labels, screen, "Numbering & Section Options");assert!(!labels.iter().any(|(t, _, _)| t == "New Section"));}++/// Find/Change's Change and Change/Find, as InDesign's: Find Next selects a match, Change/Find+/// changes it and selects the next, Change changes that one and keeps it selected. With no+/// text selected they're off.+#[test]+fn change_and_change_find_change_the_found_text() {+ use egui_kittest::Harness;+ use egui_kittest::kittest::{NodeT, Queryable};+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let f = app.run("frame.create", json!({"rect": [36, 36, 400, 300], "content": "text", "text": "red red | red"})).unwrap();+ let sid = designcraft_doc::StoryId(f["story"].as_u64().unwrap());+ app.run("text.select", json!({"story": sid.0, "anchor": 0, "focus": 0})).unwrap();+ app.run("app.findChange", json!({})).unwrap();+ if let Some(d) = app.ui.dialog.as_mut() {+ d.fields.insert("find".into(), json!("red"));+ d.fields.insert("change".into(), json!("blue"));+ }+ let mut h = Harness::builder().with_size(egui::vec2(1200.0, 900.0)).build_ui_state(+ |ui, app: &mut DesignApp| {+ let key = egui::Id::unique("change_find_test_fonts");+ if ui.data(|d| d.get_temp::<bool>(key)).is_none() {+ crate::theme::install_fonts(ui.ctx(), "");+ ui.data_mut(|d| d.insert_temp(key, true));+ return;+ }+ show(app, ui.ctx());+ },+ app,+ );+ h.run_steps(4);+ assert!(h.query_by_value("Document").is_some(), "the Search choices are InDesign's");+ assert!(h.get_by_label("Change").accesskit_node().is_disabled(), "nothing found yet");+ let text = |h: &Harness<'_, DesignApp>| h.state().session.doc().unwrap().doc.story(sid).unwrap().text.clone();+ let selected = |h: &Harness<'_, DesignApp>| h.state().session.doc().unwrap().selection.text.unwrap().range();+ h.get_by_label("Find Next").click();+ h.run_steps(3);+ assert_eq!(selected(&h), 0..3);+ h.get_by_label("Change/Find").click();+ h.run_steps(3);+ assert_eq!((text(&h), selected(&h)), ("blue red | red".to_string(), 5..8));+ h.get_by_label("Change").click();+ h.run_steps(3);+ assert_eq!((text(&h), selected(&h)), ("blue blue | red".to_string(), 5..9));+ assert_eq!(h.state().ui.dialog.as_ref().unwrap().fields["status"], json!("1 replacement(s) made"));+}diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rsindex 79f28509f..b507d292c 100644--- a/crates/ui-egui/src/i18n/ar.rs+++ b/crates/ui-egui/src/i18n/ar.rs@@ -39,6 +39,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[النمط نفسه]"),("Reset To Base", "إعادة التعيين إلى الأساس"),("Apply Style to Selection", "تطبيق النمط على التحديد"),+ ("Change/Find", "تغيير/بحث"),("Find Format:", "البحث عن تنسيق:"),("Find Format Settings", "إعدادات البحث عن تنسيق"),("Specify attributes to find", "تحديد السمات المراد البحث عنها"),diff --git a/crates/ui-egui/src/i18n/cs.rs b/crates/ui-egui/src/i18n/cs.rsindex e9023b369..c2c977876 100644--- a/crates/ui-egui/src/i18n/cs.rs+++ b/crates/ui-egui/src/i18n/cs.rs@@ -41,6 +41,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[Stejný styl]"),("Reset To Base", "Obnovit podle základu"),("Apply Style to Selection", "Použít styl na výběr"),+ ("Change/Find", "Změnit/Najít"),("Find Format:", "Hledat formát:"),("Find Format Settings", "Nastavení hledání formátu"),("Specify attributes to find", "Určit atributy k hledání"),diff --git a/crates/ui-egui/src/i18n/fr.rs b/crates/ui-egui/src/i18n/fr.rsindex 2dd2e1bfc..993d2722c 100644--- a/crates/ui-egui/src/i18n/fr.rs+++ b/crates/ui-egui/src/i18n/fr.rs@@ -319,7 +319,6 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Select Sentence", "Sélectionner la phrase"),("Select Story", "Sélectionner l'article"),("Select Text Unit", "Sélectionner une unité de texte"),- ("Selection", "Sélection"),("Selection Tool", "Outil Sélection"),("Sent {count} page(s) to {printer}", "{count} page(s) envoyée(s) à {printer}"),("Sentence case", "Majuscule en début de phrase"),diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rsindex 180524863..2976a4df3 100644--- a/crates/ui-egui/src/i18n/it.rs+++ b/crates/ui-egui/src/i18n/it.rs@@ -37,6 +37,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[Stesso stile]"),("Reset To Base", "Ripristina base"),("Apply Style to Selection", "Applica stile alla selezione"),+ ("Change/Find", "Sostituisci/Trova"),("Find Format:", "Trova formato:"),("Find Format Settings", "Impostazioni di ricerca formato"),("Specify attributes to find", "Specifica gli attributi da trovare"),diff --git a/crates/ui-egui/src/i18n/ka.rs b/crates/ui-egui/src/i18n/ka.rsindex 2344a666c..a22fe780f 100644--- a/crates/ui-egui/src/i18n/ka.rs+++ b/crates/ui-egui/src/i18n/ka.rs@@ -40,6 +40,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[იგივე სტილი]"),("Reset To Base", "საბაზოზე დაბრუნება"),("Apply Style to Selection", "სტილის გამოყენება მონიშნულზე"),+ ("Change/Find", "ჩანაცვლება/ძიება"),("Find Format:", "ფორმატის ძიება:"),("Find Format Settings", "ფორმატის ძიების პარამეტრები"),("Specify attributes to find", "საძიებო ატრიბუტების მითითება"),diff --git a/crates/ui-egui/src/i18n/pl.rs b/crates/ui-egui/src/i18n/pl.rsindex 252f82f74..de5360fbd 100644--- a/crates/ui-egui/src/i18n/pl.rs+++ b/crates/ui-egui/src/i18n/pl.rs@@ -39,6 +39,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[Ten sam styl]"),("Reset To Base", "Przywróć bazowy"),("Apply Style to Selection", "Zastosuj styl do zaznaczenia"),+ ("Change/Find", "Zmień/Znajdź"),("Find Format:", "Znajdź format:"),("Find Format Settings", "Ustawienia wyszukiwania formatu"),("Specify attributes to find", "Określ atrybuty do znalezienia"),diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rsindex ccd3117e1..ac0c1dd43 100644--- a/crates/ui-egui/src/i18n/pt_br.rs+++ b/crates/ui-egui/src/i18n/pt_br.rs@@ -40,6 +40,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[Mesmo estilo]"),("Reset To Base", "Redefinir para base"),("Apply Style to Selection", "Aplicar estilo à seleção"),+ ("Change/Find", "Alterar/Localizar"),("Find Format:", "Localizar formato:"),("Find Format Settings", "Configurações de localização de formato"),("Specify attributes to find", "Especificar atributos a localizar"),diff --git a/crates/ui-egui/src/i18n/ru.rs b/crates/ui-egui/src/i18n/ru.rsindex a3271593e..c87d33f25 100644--- a/crates/ui-egui/src/i18n/ru.rs+++ b/crates/ui-egui/src/i18n/ru.rs@@ -43,6 +43,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[Тот же стиль]"),("Reset To Base", "Сбросить до основы"),("Apply Style to Selection", "Применить стиль к выделенному"),+ ("Change/Find", "Заменить/Найти"),("Find Format:", "Найти формат:"),("Find Format Settings", "Параметры поиска формата"),("Specify attributes to find", "Задать атрибуты для поиска"),diff --git a/crates/ui-egui/src/i18n/table.rs b/crates/ui-egui/src/i18n/table.rsindex ffc78fdfc..c879a2424 100644--- a/crates/ui-egui/src/i18n/table.rs+++ b/crates/ui-egui/src/i18n/table.rs@@ -988,6 +988,7 @@ pub(super) const TABLE: &[(&str, [&str; 5])] = &[("Change All", ["Change All", "Tout remplacer", "Change All", "Change All", "全部更改"]),("Change to:", ["Change to:", "Remplacer par :", "Change to:", "Change to:", "更改为:"]),("Change Format:", ["Format ersetzen:", "Remplacer le format :", "Cambiar formato:", "置換形式 :", "更改格式:"]),+ ("Change/Find", ["Ersetzen/Suchen", "Remplacer/Rechercher", "Cambiar/Buscar", "置換して検索", "更改/查找"]),("Find Format:", ["Format suchen:", "Rechercher le format :", "Buscar formato:", "検索形式 :", "查找格式:"]),("Find Format Settings",@@ -1227,6 +1228,7 @@ pub(super) const TABLE: &[(&str, [&str; 5])] = &[("Load Styles", ["Formate laden", "Charger les styles", "Cargar estilos", "スタイルを読み込み", "加载样式"]),("New Section", ["Neuer Abschnitt", "Nouvelle section", "Nueva sección", "新規セクション", "新建章节"]),("Cannot be edited", ["Nicht bearbeitbar", "Non modifiable", "No editable", "編集不可", "不可编辑"]),+ ("Selection", ["Auswahl", "Sélection", "Selección", "選択範囲", "选区"]),("Restart Numbering", ["Nummerierung neu beginnen", "Recommencer la numérotation", "Reiniciar numeración", "番号の振り直し", "重新开始编号"]),("Continue Numbering", ["Nummerierung fortführen", "Poursuivre la numérotation", "Continuar numeración", "番号の継続", "继续编号"]),("Keep Options…", ["Umbruchoptionen …", "Options d'enchaînement…", "Opciones de separación…", "段落分離禁止オプション…", "保持选项…"]),diff --git a/crates/ui-egui/src/i18n/uk.rs b/crates/ui-egui/src/i18n/uk.rsindex 87b9ec847..8706ec6be 100644--- a/crates/ui-egui/src/i18n/uk.rs+++ b/crates/ui-egui/src/i18n/uk.rs@@ -38,6 +38,7 @@ pub(super) const TABLE: &[(&str, &str)] = &[("[Same style]", "[Той самий стиль]"),("Reset To Base", "Скинути до основи"),("Apply Style to Selection", "Застосувати стиль до виділеного"),+ ("Change/Find", "Замінити/Знайти"),("Find Format:", "Знайти формат:"),("Find Format Settings", "Параметри пошуку формату"),("Specify attributes to find", "Задати атрибути для пошуку"),diff --git a/docs/target-app-parity.md b/docs/target-app-parity.mdindex 7e65a1833..3506695d4 100644--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@ -276,7 +276,7 @@ It is evidence of breadth: each item exists. It is not a claim of InDesign-level- FID2: IDML underline/strikethrough Text Color resets survive style inheritance and roundtrip. Raster and PDF paint underlines behind glyphs, retain strikethrough above, and center rules on their offsets; synthetic overlap tests cover both backends.- Rendering: vello_cpu (SIMD, multithreaded) — pages, items, images with mip levels, gradients, composed text.- UI (egui): application bar + menus, Control panel (object and text modes), Tools panel with flyouts and the Fill/Stroke proxy (D, X, Shift+X, / as `color.*` commands), document tabs, rulers, pasteboard, guides (margins, columns, bleed, baseline grid), document grid (View ▸ Grids & Guides, ⌘', on the snap positions, behind or in front of items), Lock Guides (⌥⌘;) and Lock Column Guides (View ▸ Grids & Guides; Lock Column Guides is saved with the document and in IDML), frame edges, selection handles, text ports and threads, Properties / Pages / Layers dock, Swatches (InDesign's header: Fill/Stroke proxy, Formatting Affects Container/Text, Tint, which reads 100 with nothing selected; a swatch goes to the fill or stroke in front; rows show InDesign's type columns: the crossed pencil on swatches that can't be edited, process or spot, and the colour mode; New Color Group / New Swatch / Delete Swatch row), Styles, Character, Paragraph, Stroke, Text Wrap panels, New Document and Preferences dialogs, Quick Apply (⌘Return), 4 brightness themes.-- Pen tool, Direct Selection anchor/handle editing, rotate from corners, Rotate/Scale/Shear tools, Eyedropper, snapping & smart guides, Align/Distribute, Find/Change (text + GREP, with Find Format: text that has a character or paragraph style or character attributes), Story Editor, Paragraph Style Options, Effects panel, hidden characters, native macOS menu bar, measured InDesign 2026 look (Medium Dark): Properties sections per selection state, 21 pt spinner fields with arithmetic, Contextual Task Bar, inverse (black) text selection, Pages panel with drag-and-drop reorder / parent apply, Layers panel with per-object rows, expandable groups and drag-and-drop reorder of layers and objects (the selection square moves the selection to another layer).+- Pen tool, Direct Selection anchor/handle editing, rotate from corners, Rotate/Scale/Shear tools, Eyedropper, snapping & smart guides, Align/Distribute, Find/Change (text + GREP, with Find Format: text that has a character or paragraph style or character attributes; Change and Change/Find on the text Find Next found), Story Editor, Paragraph Style Options, Effects panel, hidden characters, native macOS menu bar, measured InDesign 2026 look (Medium Dark): Properties sections per selection state, 21 pt spinner fields with arithmetic, Contextual Task Bar, inverse (black) text selection, Pages panel with drag-and-drop reorder / parent apply, Layers panel with per-object rows, expandable groups and drag-and-drop reorder of layers and objects (the selection square moves the selection to another layer).- Tools: Selection (click, marquee, move, Alt-duplicate, resize handles), Direct Selection, Type (draw frame, click caret, select, type; Option/Alt+Left/Right kerns at the caret or tracks a selection by the Kerning/Tracking increment, ×5 with Cmd/Ctrl; words move with Cmd+Left/Right on macOS and Ctrl+Left/Right elsewhere), Rectangle/Ellipse/Polygon (+ frame variants), Line, Hand, Zoom.- PDF export (krilla): real selectable text with embedded font subsets, DeviceCMYK/RGB + spot Separations, bleed boxes, crop/bleed marks + page info, pages or spreads, PDF/A-2b (PDF/X-4 output intent pending) — `file.exportPdf`, File › Export PDF…, `designcraft-cli run --export out.pdf`. File › Export PDF… now opens an "Export PDF" options dialog (General / Compression / Marks and Bleeds / Advanced) and remembers the last-used settings across exports and sessions.- IDML interchange (`designcraft-idml`): export and import of swatches, styles, fonts, preferences, parent spreads, spreads/pages, frames, groups, images (embedded or linked), formatted threaded stories; attributes a file leaves unset take InDesign's defaults (Keep Lines Together at start/end of paragraph, 12 pt corners, paragraph rules in Text Color, auto-sizing from the centre, numbered lists restarting in each story, alternating table fills Black 20 % / None; a tint of −1 is the colour's own; frames take the fill, stroke, corners and Text Frame Options they don't write from their object style chain, then [None]) — opens in InDesign 2026 and round-trips InDesign-exported files (`file.exportIdml`, `file.openIdml`, File → Export IDML…, CLI `--in x.idml` / `--export x.idml`).