Compare commits

...
Author SHA1 Message Date
FredApps a4b7d6795c parity: headless column from the engine registry (RFC-0052) 2026-11-28 04:41:46 +07:00
Dylan M. TaylorandFredApps 72ca96a27c ci: notify artcraft-services on release state changes (#7923)
* ci: notify artcraft-services on release state changes

* ci: pass only the dispatch token to the notify-services workflow

secrets: inherit hands the called workflow every repository secret, including
the signing credentials. The reusable workflow only reads
ARTCRAFT_SERVICES_DISPATCH_TOKEN, so map just that one.

---------

Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-27 09:17:48 -05:00
f83d554322 Pictures: an inserted or pasted picture fits the table cell, column or section it goes in (#5428) (#6903)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: D13GOOOO <106814760+D13GOOOO@users.noreply.github.com>
2026-11-27 10:07:07 +00:00
Martin BallandClaude Opus 5.5 0f4e80aedd #7165: Symbol drop-down has compact cells, and hover names the character (#7173)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 10:07:01 +00:00
Martin BallandClaude Opus 5.5 bab08b77e1 #7841: dark-mode interface text gets the lighter Gamma(0.8) curve again (#7867)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 10:06:54 +00:00
Martin BallandClaude Opus 5.5 2b407facd0 #7824: a disabled table menu button keeps its menu shut under read-only protection (#7871)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 10:02:47 +00:00
17 changed files with 602 additions and 105 deletions
+20
View File
@@ -0,0 +1,20 @@
name: Notify Services on Release Change
on:
release:
types:
- published
- unpublished
- created
- edited
- deleted
- prereleased
- released
permissions: {}
jobs:
notify:
uses: storytold/craft-common-actions/.github/workflows/notify-services.yml@main
secrets:
ARTCRAFT_SERVICES_DISPATCH_TOKEN: ${{ secrets.ARTCRAFT_SERVICES_DISPATCH_TOKEN }}
+1
View File
@@ -74,5 +74,6 @@ WordCraft is a Rust word processor targeting Microsoft Word parity, for macOS, W
- Attribution: `ATTRIBUTION.md`, a row per asset file, checked by `cargo xtask assets`. Icons are our own SVG set in `crates/ui-egui/icons/` (draw new icons there); sample content is in `crates/engine/src/sample.rs` and `cmd/design.rs`.
- Fonts and language data come from other repositories as optional build inputs: craft-fonts through `CRAFT_FONTS_DIR`, and craft-i18n's `language-data/` through `CRAFT_I18N_DIR` (pinned by `craft-i18n.rev`; CI checks it out). Without craft-i18n the app builds with fallback spelling and no pattern hyphenation, so proofing tests need it. Proprietary font requests use installed fonts or the open substitutes in `crates/fonts/src/word.rs`. Layout tests use the fixed fonts in `assets/fonts/` ([docs/testing.md](docs/testing.md)).
- Run: `cargo run --release -p wordcraft -- --sample --control 7981` starts the app with a sample document and the control channel. It takes JSON lines on `127.0.0.1:7981`: authenticate once per connection with the token from `~/.config/wordcraft/control-key.local-7981` (macOS: `~/Library/Application Support/WordCraft/`), `{"id":1,"method":"auth","params":{"token":"…"}}`, then send requests without a token; methods are in `crates/ui-egui/src/control.rs`, docs in `docs/control-protocol.md` (Token). Headless screenshots: `cargo run --release -p wordcraft-ui-egui --example ui_shot -- script.jsonl`. CLI: `wordcraft-cli convert|run|commands|parity`. MCP: `wordcraft-cli mcp --automation-read-root DIR --automation-write-root DIR` (both required; `--connect` is refused until the app confines its control channel, #3695), see `docs/mcp.md`.
- Headless column ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): `cargo xtask parity` marks a catalog feature `headless: yes` only when its command is in the engine registry that `wordcraft-cli` and the MCP server load (never a `ui.*` id). A missing feature takes its `no`/`partial` value and `reach:` (`window`, `os` or `engine-gap`) from `HEADLESS` in `crates/engine/src/catalog.rs`, or reads `unknown`. When a command lands, delete its mark; `headless_marks_are_current` fails on a stale one.
- Notes and progress: `plan/` is an optional gitignored notebook. Committed: `ROADMAP.md` (progress log), `docs/gaps.md`, `docs/roadmap.md`, `docs/target-app-parity.md`, `docs/architecture.md` and the parity checklists.
- Contributor credits: `docs/contributors.md`.
+2
View File
@@ -172,6 +172,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm
- 2026-11-15: Get the Missing Fonts. A document opened from a file that is missing fonts their publisher gives away (Microsoft's Aptos family, the default in recent Word documents; Cascadia Code and Mono) brings up a box naming each font, the font drawn instead, the publisher's download page and how to install the download, with Don't show this again. `font.missing` reports the same page, so agents get it without the box. WordCraft links to the page only; it downloads and bundles nothing.
- 2026-10-30: Track Changes: a list item deleted whole, text and paragraph mark, shows its number as deleted text, in the deletion's colour and with its mark (struck through by default, or caret, #, bold, italic, underline), and hides it with No Markup or when Track Changes Options hide deletions (#4828). Readiness unchanged.
- 2026-11-03: A picture inserted or pasted in a table cell fits the cell, as in Word, instead of running out of it; in text columns it fits the column, in a section with other margins that section's width (#5428).
- 2026-11-09: Touchpad and mouse-wheel scroll speed settings (#6146): scales Wayland touchpad point input by default (4×) so two-finger scrolling matches desktop speed rather than crawling 1:1, and scales mouse wheel line distance; File › Options › Advanced › Scrolling; commands ui.scrollSpeed and ui.touchpadScrollSpeed.
- 2026-11-15: Layout: from Word 2013's layout (compatibility mode 15), balancing the columns before a continuous break keeps the last two, three or five lines of a paragraph that began on the page before together, keeps a two- or three-line paragraph that begins the last page whole, and holds a paragraph with keep lines together (or keep with next) whole in the first column when the strict rules fit. Synthetic tests also cover a footnote and a float (#6821); mode 14 splits them as before. Readiness estimates unchanged.
@@ -993,6 +994,7 @@ MATH glyphs that reference the same construction now share its immutable variant
| 2026-11-12 | trivial | Validator: exclude every glossary-typed part from main traversal and fallback assignment; multiple content-type fallback candidates are ambiguous, with no selected anchor (#5875). Synthetic controls; no parity estimate changed. |
| 2026-11-12 | trivial | Validator: mixed Transitional/Strict entry points to the same target skip document checks with coverage in either order (#5875); distinct competing roots retain ambiguity treatment without evaluating the profile gate. No parity estimate changed. |
| 2026-11-12 | trivial | Validator: competing official role targets produce coverage and suppress dependent findings; both-order, repeated-target, malformed-source and owner-isolation controls (#5875). No parity estimate changed. |
| 2026-11-03 | trivial | Progress log: a picture inserted or pasted in a table cell fits the cell (#5428) |
| 2026-11-10 | trivial | Save As on Linux: the desktop portal's Save dialog reports the file type picked, updating the extension so saving as PDF writes a .pdf (#6180) |
| 2026-11-08 | trivial | Progress log: freestanding custom.dic dictionary file support in File › Options › Proofing (#5840) |
| 2026-11-08 | trivial | Progress log: XML line ends in text normalised (#5897) |
+11
View File
@@ -889,6 +889,17 @@ fn parity_markdown(p: &Value) -> String {
for t in p["tabs"].as_array().cloned().unwrap_or_default() {
s += &format!("| {} | {} | {} |\n", t["tab"].as_str().unwrap_or(""), t["live"], t["total"]);
}
let h = &p["headless"];
s += &format!(
"\n**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): {} yes, {} no (window {}, os {}, engine-gap {}), {} partial, {} unknown.** A feature is `headless: yes` when its command is in the engine registry that `wordcraft-cli` and the MCP server load, so every live feature above is `yes`; the missing ones carry the hand mark from `HEADLESS` in `crates/engine/src/catalog.rs`, or `unknown`.\n",
h["yes"],
h["no"]["window"].as_u64().unwrap_or(0) + h["no"]["os"].as_u64().unwrap_or(0) + h["no"]["engine-gap"].as_u64().unwrap_or(0),
h["no"]["window"],
h["no"]["os"],
h["no"]["engine-gap"],
h["partial"],
h["unknown"]
);
s += "\n## Missing\n\n";
for t in p["tabs"].as_array().cloned().unwrap_or_default() {
let m = t["missing"].as_array().cloned().unwrap_or_default();
+137 -1
View File
@@ -532,6 +532,98 @@ Tools|Templates|Templates and Add-ins|tools.templates
Tools|Views|Full Screen View|view.fullScreenView
";
/// RFC-0052 hand marks for catalog features with no engine command: `id|headless|reach|why`.
///
/// `headless` is `no` or `partial`, `reach` is `window` (needs a desktop window, dialog or
/// pointer), `os` (needs an OS or online service the engine doesn't wrap) or `engine-gap` (could
/// be an engine command, isn't one yet). `yes` is never written here: a feature is `yes` only when
/// its id is in the engine registry that `wordcraft-cli` and the MCP server load, and a mark on such
/// an id is stale (`headless_errors`). A missing feature with no mark is `unknown`.
pub const HEADLESS: &str = "\
tools.dictate|no|os|speech recognition service
insert.onlinePicture|no|os|online image search service
insert.model3d|no|engine-gap|3-D model files could be inserted by a command
insert.screenshot|no|os|screen capture of other windows
addins.get|no|os|add-in store service
insert.video|no|os|online video service
insert.inkEquation|no|window|drawn with a pen or pointer
draw.inkToMath|no|os|handwriting recognition service
review.translate|no|os|online translation service
review.blockAuthors|no|os|co-authoring service
view.readLayout|no|window|Read Mode window layout
";
/// One feature's RFC-0052 `headless:` value and, for `no`/`partial`, its `reach:` and reason.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Headless {
pub value: &'static str,
pub reach: Option<&'static str>,
pub why: &'static str,
}
const REACHES: [&str; 3] = ["window", "os", "engine-gap"];
/// Parsed `HEADLESS`-format marks: (id, value, reach, why). A malformed line is an error.
pub fn headless_marks(src: &'static str) -> Result<Vec<(&'static str, Headless)>, String> {
let mut out = Vec::new();
for line in src.lines().filter(|l| !l.trim().is_empty()) {
let f: Vec<&'static str> = line.splitn(4, '|').collect();
let [id, value, reach, why] = f[..] else {
return Err(format!("headless mark `{line}`: want `id|headless|reach|why`"));
};
if !matches!(value, "no" | "partial") {
return Err(format!("headless mark `{id}`: `{value}` is not `no` or `partial` (`yes` comes from the registry)"));
}
if !REACHES.contains(&reach) {
return Err(format!("headless mark `{id}`: reach `{reach}` is not window, os or engine-gap"));
}
if out.iter().any(|(m, _)| *m == id) {
return Err(format!("headless mark `{id}` is written twice"));
}
out.push((id, Headless { value, reach: Some(reach), why }));
}
Ok(out)
}
/// The `headless:` value of a catalog feature: `yes` when the engine registry has its id, else its
/// hand mark, else `unknown`.
pub fn headless_of(id: &str, live: bool, marks: &[(&'static str, Headless)]) -> Headless {
if live {
return Headless { value: "yes", reach: None, why: "" };
}
marks.iter().find(|(m, _)| *m == id).map(|(_, h)| *h).unwrap_or(Headless { value: "unknown", reach: None, why: "" })
}
/// Problems with the marks against the catalog and the registry's ids: unknown ids, and marks on
/// ids the engine registry has (they would hide a `yes`).
pub fn headless_errors(src: &'static str, catalog: &[(&str, &str, &str, &str)], live: impl Fn(&str) -> bool) -> Vec<String> {
let marks = match headless_marks(src) {
Ok(m) => m,
Err(e) => return vec![e],
};
let mut errs = Vec::new();
for (id, _) in &marks {
if !catalog.iter().any(|e| e.3 == *id) {
errs.push(format!("headless mark `{id}` is not a catalog id"));
} else if live(id) {
errs.push(format!("headless mark `{id}` is stale: the engine registry has it, so it is `yes`"));
}
}
errs
}
/// Headless counts in the RFC-0052 summary shape.
fn headless_summary(values: &[Headless]) -> Value {
let count = |v: &str| values.iter().filter(|h| h.value == v).count();
let no = |r: &str| values.iter().filter(|h| h.value == "no" && h.reach == Some(r)).count();
json!({
"yes": count("yes"),
"no": {"window": no("window"), "os": no("os"), "engine-gap": no("engine-gap")},
"partial": count("partial"),
"unknown": count("unknown"),
})
}
/// Catalog entries: (tab, group, feature, id).
pub fn entries() -> Vec<(&'static str, &'static str, &'static str, &'static str)> {
CATALOG
@@ -546,9 +638,13 @@ pub fn entries() -> Vec<(&'static str, &'static str, &'static str, &'static str)
/// Parity summary: per tab and overall, with the missing features.
pub fn parity(reg: &Registry) -> Value {
let e = entries();
let marks = headless_marks(HEADLESS).unwrap_or_default();
let mut values = Vec::with_capacity(e.len());
let mut tabs: Vec<(&str, usize, usize, Vec<String>)> = Vec::new();
for (tab, group, label, id) in &e {
let have = reg.get(id).is_some();
let h = headless_of(id, have, &marks);
values.push(h);
let t = match tabs.iter_mut().find(|t| t.0 == *tab) {
Some(t) => t,
None => {
@@ -564,7 +660,8 @@ pub fn parity(reg: &Registry) -> Value {
if have {
t.1 += 1;
} else {
t.3.push(format!("{group} › {label} (`{id}`)"));
let reach = h.reach.map(|r| format!(", reach: {r} ({})", h.why)).unwrap_or_default();
t.3.push(format!("{group} › {label} (`{id}`): headless: {}{reach}", h.value));
}
}
let live = tabs.iter().map(|t| t.1).sum::<usize>();
@@ -573,6 +670,7 @@ pub fn parity(reg: &Registry) -> Value {
"live": live,
"total": total,
"percent": if total == 0 { 0.0 } else { (live as f64 * 1000.0 / total as f64).round() / 10.0 },
"headless": headless_summary(&values),
"tabs": tabs.iter().map(|t| json!({"tab": t.0, "live": t.1, "total": t.2, "missing": t.3})).collect::<Vec<_>>(),
})
}
@@ -597,6 +695,44 @@ mod tests {
assert!(pct >= 90.4, "parity {pct}%");
}
#[test]
fn headless_marks_are_current() {
let reg = crate::cmd::registry();
let errs = headless_errors(HEADLESS, &entries(), |id| reg.get(id).is_some());
assert!(errs.is_empty(), "{errs:?}");
}
#[test]
fn headless_yes_comes_only_from_the_registry() {
let marks = headless_marks("a.b|no|window|pointer\n").unwrap();
assert_eq!(headless_of("a.b", true, &marks).value, "yes", "a live id is yes whatever the mark says");
assert_eq!(headless_of("a.b", false, &marks).reach, Some("window"));
assert_eq!(headless_of("c.d", false, &marks).value, "unknown");
assert!(headless_marks("a.b|yes|window|x\n").is_err(), "a hand-written yes is refused");
assert!(headless_marks("a.b|no|desk|x\n").is_err(), "reach must be window, os or engine-gap");
assert!(headless_marks("a.b|no\n").is_err());
assert!(headless_marks("a.b|no|os|x\na.b|partial|os|y\n").is_err(), "one mark per id");
}
#[test]
fn headless_errors_flag_stale_and_unknown_marks() {
let cat = [("T", "G", "F", "a.b"), ("T", "G", "H", "c.d")];
let errs = headless_errors("a.b|no|os|x\nz.z|no|os|y\n", &cat, |id| id == "a.b");
assert!(errs.iter().any(|e| e.contains("`a.b` is stale")), "{errs:?}");
assert!(errs.iter().any(|e| e.contains("`z.z` is not a catalog id")), "{errs:?}");
assert!(headless_errors("bad\n", &cat, |_| false).len() == 1);
}
#[test]
fn parity_counts_every_feature_once_in_the_headless_summary() {
let p = parity(&crate::cmd::registry());
let h = &p["headless"];
let n = |v: &Value| v.as_u64().unwrap_or(0);
let no = n(&h["no"]["window"]) + n(&h["no"]["os"]) + n(&h["no"]["engine-gap"]);
assert_eq!(n(&h["yes"]) + no + n(&h["partial"]) + n(&h["unknown"]), n(&p["total"]));
assert_eq!(n(&h["yes"]), n(&p["live"]), "every live feature is an engine command here");
}
#[test]
fn read_mode_view_menu_is_catalogued() {
let e = entries();
+2 -2
View File
@@ -117,9 +117,9 @@ fn place_picture(s: &mut Session, bytes: Vec<u8>, width: Option<f32>, alt: &str)
None => return Err(CmdError::Failed("not a supported image (PNG, JPEG, GIF, WebP, BMP, TIFF, WMF, EMF)".into())),
},
};
// Fitted to the room where it goes: the table cell, the column, its own section (#5428).
let max_w = s.room_at(&s.sel.ordered().0);
let key = s.doc.add_media(bytes, ext);
// Fitted to the text width.
let max_w = s.doc.sections().first().map(|(_, sp)| sp.text_width()).unwrap_or(468.0);
let (mut w, mut h) = (natural_w, natural_h);
if let Some(want) = width {
// At most 22 inches, as for icons: a huge width made the height of a tall picture infinite.
+16 -3
View File
@@ -499,10 +499,23 @@ pub(crate) fn unlink_sections(blocks: &mut [Block]) {
/// lists and styles it refers to (renumbered so they can't collide with ours).
fn adopt(s: &mut Session, src: Document) -> Fragment {
let mut frag = s.doc.adopt(src);
// Pasted pictures fit our text width, like Insert › Pictures (layout keeps their size).
let max_w = crate::io::text_width(&s.doc);
// Pasted pictures fit the room where they go, like Insert › Pictures: the table cell, the
// column, its own section (#5428; layout keeps their size). Measured (a layout) only when
// the fragment holds an inline picture.
let mut has_picture = false;
for b in &mut frag.blocks {
crate::io::fit_block_pictures(b, max_w);
each_para(b, 0, &mut |p| {
has_picture |= p
.objects
.iter()
.any(|o| matches!(o, wordcraft_doc::InlineObject::Image { float, .. } if float.wrap == wordcraft_doc::para::Wrap::Inline));
});
}
if has_picture {
let max_w = s.room_at(&s.sel.ordered().0);
for b in &mut frag.blocks {
crate::io::fit_block_pictures(b, max_w);
}
}
unlink_sections(&mut frag.blocks);
frag
+37
View File
@@ -204,6 +204,43 @@ impl Session {
Arc::new(wordcraft_layout::layout(doc, &mut LayoutCache::new(), &opts))
}
/// How wide a picture put in at `pos` may be, as Word fits an inserted or pasted picture
/// (#5428): the room its paragraph's lines have (the width available to its widest laid-out line,
/// so the paragraph's indents are already taken out; inside a table cell, the innermost cell's
/// text area, nested tables included; a turned cell isn't measured and falls back to the
/// column width), never wider than the column it is in, of its own section. The narrowest
/// section's text width ([`crate::io::text_width`]) when `pos` isn't laid out. It is measured on the pages, whatever the view: Web Layout and Read Mode reflow the
/// text to the window, and a picture put in there keeps the size it gets in the document.
pub(crate) fn room_at(&mut self, pos: &wordcraft_doc::Pos) -> f32 {
let first = crate::io::text_width(&self.doc);
let l =
if !self.view.read_mode && self.view.mode == ViewMode::Print { self.layout() } else { self.output_layout_of(&self.doc, false, false) };
let Some((caret, page)) = l.caret_on(pos, self.page_hint).and_then(|c| Some((c, l.pages.get(c.page)?))) else { return first };
// A page can hold several continuous sections: the body's own comes from the position.
let at = match (pos.story, pos.path.0.first()) {
(StoryRef::Body, Some(b)) => self.doc.section_index_of(*b as usize),
_ => page.section,
};
let section = self.doc.sections().get(at).map(|(_, sp)| (*sp).clone());
let column = match (&section, pos.story) {
(Some(sp), StoryRef::Body) => {
let boxes = sp.column_boxes();
let x = caret.x - page.body.x;
boxes.iter().find(|(cx, w)| x >= cx - 0.5 && x <= cx + w + 0.5).map_or_else(|| sp.text_width(), |(_, w)| *w)
}
(Some(sp), StoryRef::Part(_)) => sp.text_width(),
(None, _) => first,
};
let lines = wordcraft_layout::hit::page_lines(page, pos.story)
.iter()
.filter(|h| *h.path == pos.path)
.map(|h| h.right - h.left)
.filter(|w| w.is_finite())
.fold(0.0f32, f32::max);
let room = if lines >= 1.0 { lines.min(column) } else { column };
if room.is_finite() && room >= 1.0 { room } else { first }
}
/// Invalidate the cached layout (fonts changed etc.).
pub fn relayout(&mut self) {
self.layout = Default::default();
+137
View File
@@ -14943,6 +14943,143 @@ fn page_down_extends_a_selection_that_ends_in_collapsed_outline_text() {
assert!(s.layout().caret(&s.sel.focus).is_some(), "to a place the outline shows");
}
/// #5428: an inserted or pasted picture fits where it goes, as in Word: a table cell's width
/// (a nested cell's too), a column's, not the whole page's text width.
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn an_inserted_or_pasted_picture_fits_where_it_goes() {
let png = |w: u32, h: u32| {
let mut b = Vec::new();
image::RgbaImage::from_pixel(w, h, image::Rgba([30, 90, 200, 255]))
.write_to(&mut std::io::Cursor::new(&mut b), image::ImageFormat::Png)
.unwrap();
cmd::insert::base64_encode(&b)
};
let widths = |s: &Session| {
let mut v = Vec::new();
for b in s.doc.body.iter() {
let mut b = (**b).clone();
cmd::paste::each_para(&mut b, 0, &mut |p| {
for o in &p.objects {
if let wordcraft_doc::InlineObject::Image { w, h, .. } = o {
v.push((*w, *h));
}
}
});
}
v
};
let text_w = crate::io::text_width(&Session::new(wordcraft_doc::Document::new()).doc);
let in_cell = |cols: u32| {
let mut s = Session::new(wordcraft_doc::Document::new());
run(&mut s, "insert.table", json!({"rows": 1, "cols": cols}));
assert!(s.sel.focus.path.depth() > 0, "the caret is in the first cell");
s
};
// Insert › Pictures and Paste in a cell of a three-column table.
let cell = text_w / 3.0;
let mut s = in_cell(3);
run(&mut s, "insert.picture", json!({"data": png(1000, 200)}));
let mut p = in_cell(3);
let html = format!("<p><img src=\"data:image/png;base64,{}\"></p>", png(1000, 200));
run(&mut p, "edit.pasteSpecial", json!({"as": "html", "html": html}));
for (how, s) in [("inserted", &s), ("pasted", &p)] {
let got = widths(s);
let [(w, h)] = got.as_slice() else { panic!("{how}: {got:?}") };
assert!(*w <= cell && *w > cell - 20.0, "{how}: {w} fits the cell's text area ({cell} less its margins)");
assert!((h * 5.0 - w).abs() < 0.1, "{how}: proportions kept: {w} × {h}");
}
// A table in that cell: its own narrower cell.
let mut s = in_cell(2);
let outer = s.room_at(&s.sel.focus.clone());
// (A table inserted in a cell takes the page's text width for its columns, so four columns
// make its cells narrower than the outer one.)
run(&mut s, "insert.table", json!({"rows": 1, "cols": 4}));
assert!(s.sel.focus.path.depth() > 1, "the caret is in the nested cell");
let nested = s.room_at(&s.sel.focus.clone());
assert!(nested < outer - 50.0, "the nested cell ({nested}) is narrower than the outer one ({outer})");
run(&mut s, "insert.picture", json!({"data": png(1000, 200)}));
let w = widths(&s)[0].0;
assert!((w - nested).abs() < 0.5 && w <= text_w / 4.0, "{w} fits the nested cell ({nested})");
// Two text columns: one column's width.
let mut s = Session::new(wordcraft_doc::Document::new());
run(&mut s, "layout.columns", json!({"count": 2}));
let column = s.doc.sections()[0].1.column_boxes()[0].1;
run(&mut s, "insert.picture", json!({"data": png(1000, 200)}));
let w = widths(&s)[0].0;
assert!((w - column).abs() < 0.5, "{w} fits the column ({column})");
// Body text keeps the full text width.
let mut s = Session::new(wordcraft_doc::Document::new());
run(&mut s, "insert.picture", json!({"data": png(1000, 200)}));
assert!((widths(&s)[0].0 - text_w).abs() < 0.5);
}
/// #5428 review: a page can hold several continuous sections; a picture goes by the section of the
/// position, not of the page's first one (two columns, then a continuous single-column section).
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn a_picture_after_a_continuous_break_fits_its_own_section() {
let sect = |cols: &str, kind: &str| format!(r#"<w:sectPr>{kind}<w:pgSz w:w="11906" w:h="16838"/><w:cols {cols} w:space="708"/></w:sectPr>"#);
let body = [
"<w:p><w:r><w:t>one</w:t></w:r></w:p>".to_string(),
format!("<w:p><w:pPr>{}</w:pPr></w:p>", sect(r#"w:num="2""#, "")),
"<w:p><w:r><w:t>two</w:t></w:r></w:p>".to_string(),
sect("", r#"<w:type w:val="continuous"/>"#),
]
.concat();
let mut s = Session::new(wordcraft_docx::read(&docx_with_styles(&body, "")).unwrap());
let last = s.doc.body.len() - 1;
s.sel = crate::Selection::caret(Pos::body(last, 0));
let room = s.room_at(&s.sel.focus.clone());
let column = s.doc.sections()[0].1.column_boxes()[0].1;
assert!(room > column + 50.0, "{room} is the single column's width, not the earlier two columns' ({column})");
}
/// #5428 review: Web Layout and Read Mode reflow the text to the window, but a picture put in
/// there is fitted to the page's text width, as in Print Layout: the size stays in the document.
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn a_picture_put_in_in_web_layout_fits_the_page_not_the_window() {
let png = |w: u32, h: u32| {
let mut b = Vec::new();
image::RgbaImage::from_pixel(w, h, image::Rgba([30, 90, 200, 255]))
.write_to(&mut std::io::Cursor::new(&mut b), image::ImageFormat::Png)
.unwrap();
cmd::insert::base64_encode(&b)
};
let width = |s: &Session| {
s.doc.body.iter().filter_map(|b| b.as_para()).flat_map(|p| p.objects.iter()).find_map(|o| match o {
wordcraft_doc::InlineObject::Image { w, .. } => Some(*w),
_ => None,
})
};
let text_w = crate::io::text_width(&Session::new(wordcraft_doc::Document::new()).doc);
let web = || {
let mut s = Session::new(wordcraft_doc::Document::new());
run(&mut s, "view.webLayout", json!({}));
// A narrow window, or a high zoom.
s.view.web_width = 350.0;
assert!(s.layout().pages[0].w < text_w, "the window is narrower than the page's text");
s
};
let mut s = web();
run(&mut s, "insert.picture", json!({"data": png(1000, 200)}));
let mut p = web();
let html = format!("<p><img src=\"data:image/png;base64,{}\"></p>", png(1000, 200));
run(&mut p, "edit.pasteSpecial", json!({"as": "html", "html": html}));
for (how, s) in [("inserted", &s), ("pasted", &p)] {
let w = width(s).unwrap();
assert!((w - text_w).abs() < 0.5, "{how}: {w} fits the page's text width ({text_w})");
}
// Read Mode's narrow pages don't set it either.
let mut s = Session::new(wordcraft_doc::Document::new());
run(&mut s, "text.insert", json!({"text": "Read"}));
run(&mut s, "view.readMode", json!({}));
s.view.read_width = 240.0;
let room = s.room_at(&s.sel.focus.clone());
assert!((room - text_w).abs() < 0.5, "Read Mode: {room} is the page's text width ({text_w})");
}
/// A picture an OpenDocument file gives no size is shown at its own, fitted to the text as other
/// formats' are; one with a stated size keeps it, in line too.
#[test]
+1
View File
@@ -319,6 +319,7 @@ impl WordApp {
pub fn logic(&mut self, ctx: &egui::Context) {
let lang = i18n::Lang::from_pref(&self.ui.language);
if self.ctx.is_none() {
theme::set_dark_text_curve(ctx);
self.ctx = Some(ctx.clone());
}
updates_ui::tick(self, ctx);
+64 -12
View File
@@ -8,7 +8,7 @@ use craft::ui::buttons::{Arrangement, Button, IconButton};
use craft::ui::contract::{ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _};
use craft::ui::display::Divider;
use craft::ui::layout_components::Stack;
use craft::ui::list::ThumbAspect;
use craft::ui::list::{ThumbAspect, ThumbSize};
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::primitives::{HAlign, TextRun};
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
@@ -286,17 +286,69 @@ pub(super) fn insert(row: &mut RibbonRow<'_>, app: &mut WordApp) {
});
}
/// The recent and common characters as a grid of six per row; a click inserts the character, remembers it and closes
/// The characters the grid offers after the recent ones, with their Unicode names (UnicodeData.txt). No Unicode-names
/// crate is installed, and the one on crates.io is under Unicode-DFS-2016, which the licence allowlist lacks.
const DEFAULT_SYMBOLS: &[(char, &str)] = &[
('\u{A9}', "COPYRIGHT SIGN"),
('\u{AE}', "REGISTERED SIGN"),
('\u{2122}', "TRADE MARK SIGN"),
('\u{A7}', "SECTION SIGN"),
('\u{B6}', "PILCROW SIGN"),
('\u{20AC}', "EURO SIGN"),
('\u{A3}', "POUND SIGN"),
('\u{A5}', "YEN SIGN"),
('\u{B0}', "DEGREE SIGN"),
('\u{B1}', "PLUS-MINUS SIGN"),
('\u{2260}', "NOT EQUAL TO"),
('\u{2264}', "LESS-THAN OR EQUAL TO"),
('\u{2265}', "GREATER-THAN OR EQUAL TO"),
('\u{F7}', "DIVISION SIGN"),
('\u{D7}', "MULTIPLICATION SIGN"),
('\u{221E}', "INFINITY"),
('\u{B5}', "MICRO SIGN"),
('\u{3B1}', "GREEK SMALL LETTER ALPHA"),
('\u{3B2}', "GREEK SMALL LETTER BETA"),
('\u{3C0}', "GREEK SMALL LETTER PI"),
('\u{3A9}', "GREEK CAPITAL LETTER OMEGA"),
('\u{2211}', "N-ARY SUMMATION"),
('\u{221A}', "SQUARE ROOT"),
('\u{2192}', "RIGHTWARDS ARROW"),
('\u{2190}', "LEFTWARDS ARROW"),
('\u{2713}', "CHECK MARK"),
('\u{2605}', "BLACK STAR"),
('\u{2665}', "BLACK HEART SUIT"),
('\u{2014}', "EM DASH"),
('\u{2026}', "HORIZONTAL ELLIPSIS"),
];
/// A symbol's hover text: its Unicode name and code point (the code point alone, with its block, for a character
/// not named above), then its font when it has one.
pub(super) fn symbol_tip(glyph: &str, font: &str) -> String {
let mut chars = glyph.chars();
let tip = match (chars.next(), chars.next()) {
(Some(c), None) => {
let name = DEFAULT_SYMBOLS.iter().find(|(n, _)| *n == c).map(|(_, name)| *name);
let block = crate::dialogs_insert::subset_of(c);
match (name, block) {
(Some(name), _) => format!("{name} (U+{:04X})", c as u32),
(None, Some(block)) => format!("U+{:04X} ({block})", c as u32),
(None, None) => format!("U+{:04X}", c as u32),
}
}
_ => glyph.to_string(),
};
if font.is_empty() { tip } else { format!("{tip}, {font}") }
}
/// The recent and common characters as a compact grid; a click inserts the character, remembers it and closes
/// the menu.
fn symbol_grid(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
// Recently used symbols first (their font on hover), then common ones.
let mut items: Vec<(String, String)> = app.ui.recent_symbols.iter().map(|r| (r.ch.clone(), r.font.clone())).collect();
for c in [
"©", "®", "™", "§", "", "€", "£", "¥", "°", "±", "≠", "≤", "≥", "÷", "×", "∞", "µ", "α", "β", "π", "Ω", "∑", "√", "→", "←", "✓", "★", "♥",
"—", "…",
] {
if !items.iter().any(|(ch, f)| ch == c && f.is_empty()) {
items.push((c.to_string(), String::new()));
for (c, _) in DEFAULT_SYMBOLS {
let c = c.to_string();
if !items.iter().any(|(ch, f)| *ch == c && f.is_empty()) {
items.push((c, String::new()));
}
}
items.truncate(30);
@@ -304,20 +356,20 @@ fn symbol_grid(ui: &mut Ui, cx: &mut BodyCx<'_>, app: &mut WordApp) {
.select(SelectMode::None)
.activate(ActivateOn::Click)
.caption(CaptionPlace::None)
.card_columns(6)
.content_cells()
// Small cells (#7165): a glyph needs no more room than the small thumbnail step.
.thumb_size(ThumbSize::Small)
// At most thirty symbols, all shown; the menu's body is the one scroll.
.natural_height(true)
.show_items(ui, &SymbolCells(items.len()), &mut |key, _| {
let (c, font) = items.get(*key).cloned().unwrap_or_default();
let glyph = c.clone();
let (glyph, tip) = (c.clone(), symbol_tip(&c, &font));
let tile = Tile::new(c).thumb(ThumbAspect::SQUARE, move |cx, rect| {
let run = TextRun::new(glyph.as_str()).align(HAlign::Center);
cx.with_draw(|d| {
d.text_on_centre_line(rect, &run);
});
});
if font.is_empty() { tile } else { tile.tooltip(font) }
tile.tooltip(tip)
});
for event in &out.response.events {
if let CollectionEvent::Activate(key) = event
+124 -73
View File
@@ -959,92 +959,109 @@ fn unimplemented_stub_ribbon_buttons_are_disabled() {
}
}
/// #7324, #7457: Table ribbon menu buttons (Styles, Borders, Select, Delete, AutoFit) bind their command IDs
/// so they disable when editing is protected or when no table is active.
#[test]
fn table_ribbon_menu_buttons_disable_when_unselected_or_protected() {
/// Is the ribbon button `name` disabled? (helpers for the table ribbon gate tests below.)
fn table_button_disabled(h: &Harness, name: &str) -> bool {
use egui::accesskit::Role;
h.query_all(By::new().role(Role::Button).label(name)).next().unwrap_or_else(|| panic!("button {name} not found")).accesskit_node().is_disabled()
}
let is_disabled = |h: &Harness, name: &str| {
h.query_all(By::new().role(Role::Button).label(name))
.next()
.unwrap_or_else(|| panic!("button {name} not found"))
.accesskit_node()
.is_disabled()
};
fn table_button_hint(h: &Harness, name: &str) -> String {
use egui::accesskit::Role;
h.query_all(By::new().role(Role::Button).label(name))
.next()
.unwrap_or_else(|| panic!("button {name} not found"))
.accesskit_node()
.description()
.map(|s| s.to_string())
.unwrap_or_default()
}
let description = |h: &Harness, name: &str| {
h.query_all(By::new().role(Role::Button).label(name))
.next()
.unwrap_or_else(|| panic!("button {name} not found"))
.accesskit_node()
.description()
.map(|s| s.to_string())
};
/// A 2x2 table app on `tab`; `protected` sets read-only protection.
fn table_tab_harness(tab: &str, protected: bool) -> Harness {
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
if protected {
app.session.doc.settings.protection = Some("readOnly".into());
}
tab_harness(app, tab)
}
// Configure Table Design & Table Layout as explicit ribbon tabs so they can be
// displayed even when the cursor is outside a table.
let make_table_tabs_app = |mut app: WordApp| {
/// #7324, #7457: without an active table the Table ribbon menu buttons disable. The Table tabs are
/// configured explicitly so they show with the cursor outside a table.
#[test]
fn table_ribbon_menu_buttons_disable_when_unselected() {
for tab in ["Table Design", "Table Layout"] {
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default());
app.session.ribbon.tabs = vec![
wordcraft_engine::ribbon::TabEntry { name: "Table Design".to_string(), custom: false, hidden: false, groups: Vec::new() },
wordcraft_engine::ribbon::TabEntry { name: "Table Layout".to_string(), custom: false, hidden: false, groups: Vec::new() },
];
app
};
let h = tab_harness(app, tab);
if tab == "Table Design" {
assert!(table_button_disabled(&h, "Styles"), "Styles button should be disabled when not in table");
assert!(table_button_disabled(&h, "Borders"), "Borders button should be disabled when not in table");
} else {
assert!(table_button_disabled(&h, "Select"), "Select button should be disabled when not in table");
assert!(table_button_disabled(&h, "Delete"), "Delete button should be disabled when not in table");
assert!(table_button_disabled(&h, "AutoFit"), "AutoFit button should be disabled when not in table");
assert!(
table_button_hint(&h, "Select").to_ascii_lowercase().contains("the cursor isn't in a table"),
"Select should indicate outside table in disabled hint"
);
}
}
}
// 1. Without a table active:
let app_no_table = make_table_tabs_app(WordApp::new(Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default()));
let h_design_empty = tab_harness(app_no_table, "Table Design");
assert!(is_disabled(&h_design_empty, "Styles"), "Styles button should be disabled when not in table");
assert!(is_disabled(&h_design_empty, "Borders"), "Borders button should be disabled when not in table");
/// With an active, unprotected table the Table Design buttons are enabled.
#[test]
fn table_design_menu_buttons_enabled_in_table() {
let h = table_tab_harness("Table Design", false);
assert!(!table_button_disabled(&h, "Styles"), "Styles button should be enabled in table");
assert!(!table_button_disabled(&h, "Borders"), "Borders button should be enabled in table");
}
let app_no_table2 = make_table_tabs_app(WordApp::new(Session::new(wordcraft_doc::Document::from_text("Hello")), crate::Services::default()));
let h_layout_empty = tab_harness(app_no_table2, "Table Layout");
assert!(is_disabled(&h_layout_empty, "Select"), "Select button should be disabled when not in table");
assert!(is_disabled(&h_layout_empty, "Delete"), "Delete button should be disabled when not in table");
assert!(is_disabled(&h_layout_empty, "AutoFit"), "AutoFit button should be disabled when not in table");
assert!(
description(&h_layout_empty, "Select").as_deref().unwrap_or("").to_ascii_lowercase().contains("the cursor isn't in a table"),
"Select should indicate outside table in disabled hint"
);
/// With an active, unprotected table the Table Layout buttons are enabled and open their menus
/// (the controls for the shut-menu checks under protection).
#[test]
fn table_layout_menu_buttons_enabled_in_table() {
let mut h = table_tab_harness("Table Layout", false);
assert!(!table_button_disabled(&h, "Select"), "Select button should be enabled in table");
assert!(!table_button_disabled(&h, "Delete"), "Delete button should be enabled in table");
assert!(!table_button_disabled(&h, "AutoFit"), "AutoFit button should be enabled in table");
click_button(&mut h, "Delete");
assert!(h.query_all(menu_row("Delete Rows")).next().is_some(), "an enabled Delete opens its menu");
}
// 2. With an active table and no protection: buttons are enabled:
let mut app_table = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app_table.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
let h_design = tab_harness(app_table, "Table Design");
assert!(!is_disabled(&h_design, "Styles"), "Styles button should be enabled in table");
assert!(!is_disabled(&h_design, "Borders"), "Borders button should be enabled in table");
/// Positive control for the AutoFit shut-menu check under protection: an enabled AutoFit opens its menu.
#[test]
fn table_layout_autofit_opens_menu_in_table() {
let mut h = table_tab_harness("Table Layout", false);
click_button(&mut h, "AutoFit");
assert!(h.query_all(menu_row("AutoFit Window")).next().is_some(), "an enabled AutoFit opens its menu");
}
let mut app_table2 = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app_table2.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
let h_layout = tab_harness(app_table2, "Table Layout");
assert!(!is_disabled(&h_layout, "Select"), "Select button should be enabled in table");
assert!(!is_disabled(&h_layout, "Delete"), "Delete button should be enabled in table");
assert!(!is_disabled(&h_layout, "AutoFit"), "AutoFit button should be enabled in table");
/// Under read-only protection the Table Design buttons disable and say why.
#[test]
fn table_design_menu_buttons_disable_when_protected() {
let h = table_tab_harness("Table Design", true);
assert!(table_button_disabled(&h, "Styles"), "Styles button should be disabled under protection");
assert!(table_button_disabled(&h, "Borders"), "Borders button should be disabled under protection");
assert!(table_button_hint(&h, "Styles").contains("protected"), "Styles should indicate protection in disabled hint");
}
// 3. With an active table under document protection (read-only): mutating buttons are disabled:
let mut app_protected_design = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app_protected_design.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
app_protected_design.session.doc.settings.protection = Some("readOnly".into());
let h_prot_design = tab_harness(app_protected_design, "Table Design");
assert!(is_disabled(&h_prot_design, "Styles"), "Styles button should be disabled under protection");
assert!(is_disabled(&h_prot_design, "Borders"), "Borders button should be disabled under protection");
assert!(
description(&h_prot_design, "Styles").as_deref().unwrap_or("").contains("protected"),
"Styles should indicate protection in disabled hint"
);
let mut app_protected_layout = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app_protected_layout.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
app_protected_layout.session.doc.settings.protection = Some("readOnly".into());
let h_prot_layout = tab_harness(app_protected_layout, "Table Layout");
assert!(!is_disabled(&h_prot_layout, "Select"), "Select button should remain enabled under protection");
assert!(is_disabled(&h_prot_layout, "Delete"), "Delete button should be disabled under protection");
assert!(is_disabled(&h_prot_layout, "AutoFit"), "AutoFit button should be disabled under protection");
assert!(
description(&h_prot_layout, "Delete").as_deref().unwrap_or("").contains("protected"),
"Delete should indicate protection in disabled hint"
);
/// Under read-only protection the mutating Table Layout buttons disable, say why, and stay shut
/// when clicked (C2-5, #7824).
#[test]
fn table_layout_menu_buttons_disable_when_protected() {
let mut h = table_tab_harness("Table Layout", true);
assert!(!table_button_disabled(&h, "Select"), "Select button should remain enabled under protection");
assert!(table_button_disabled(&h, "Delete"), "Delete button should be disabled under protection");
assert!(table_button_disabled(&h, "AutoFit"), "AutoFit button should be disabled under protection");
assert!(table_button_hint(&h, "Delete").contains("protected"), "Delete should indicate protection in disabled hint");
click_button(&mut h, "Delete");
assert!(h.query_all(menu_row("Delete Rows")).next().is_none(), "a disabled Delete opens no menu");
click_button(&mut h, "AutoFit");
assert!(h.query_all(menu_row("AutoFit Window")).next().is_none(), "a disabled AutoFit opens no menu");
}
/// #7374: the Decorative Text / WordArt Styles dropdown menu renders compact tiles (~40×36 pt)
@@ -1322,3 +1339,37 @@ fn a_combo_field_reached_with_tab_shows_its_hint_after_a_delay() {
}
assert!(h.query_all_by_label("Font Size").count() >= 2, "hint must show after tooltip delay");
}
/// #7165: the Symbol drop-down's cells are compact (a thumbnail-small step, not a card) and the hover text names
/// the character, not just the glyph.
#[test]
fn symbol_menu_cells_are_compact_and_the_tooltip_names_the_character() {
let app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Text")), crate::Services::default());
let mut h = tab_harness(app, "Insert");
click_button(&mut h, "Symbol");
let cell_y = |h: &Harness| h.get_by_label("\u{A9}").rect().min.y;
let cell = h.get_by_label("\u{A9}").rect();
assert!(cell.width() <= 80.0 && cell.height() <= 80.0, "a symbol cell is compact, got {:?}", cell.size());
// Eight symbols fit one row, so the menu does not cover the page.
assert_eq!(h.get_by_label("\u{A5}").rect().min.y, cell_y(&h), "the eighth symbol is on the first row");
h.get_by_label("\u{A9}").hover();
crate::test_harness::frames(&mut h, 40);
assert!(h.query_by_label_contains("COPYRIGHT SIGN (U+00A9)").is_some(), "the tooltip names the character");
// A screen reader gets the name without hovering: the tile's label is the glyph, its description the name.
let desc = h.get_by_label("\u{A9}").accesskit_node().description().map(|d| d.to_string()).unwrap_or_default();
assert!(desc.contains("COPYRIGHT SIGN"), "the tile's accessible description names the character, got {desc:?}");
}
/// Characters outside the common list still say what they are: code point and block.
#[test]
fn symbol_tip_names_known_characters_and_falls_back_to_the_code_point() {
use super::insert::symbol_tip;
let named = symbol_tip("\u{A9}", "");
assert!(named.contains("COPYRIGHT SIGN") && named.contains("00A9"), "named character: {named}");
let with_font = symbol_tip("\u{3B1}", "Symbol");
assert!(with_font.contains("GREEK SMALL LETTER ALPHA") && with_font.contains("03B1") && with_font.contains("Symbol"), "{with_font}");
assert!(!named.contains("Symbol"), "no font, none named");
let unnamed = symbol_tip("\u{2602}", "");
assert!(unnamed.contains("2602") && unnamed.contains("Miscellaneous Symbols"), "unnamed character: {unnamed}");
assert_eq!(symbol_tip("", ""), "");
}
+22
View File
@@ -3393,6 +3393,28 @@ fn check_spelling_off_in_a_second_window_stays_off_in_every_window() {
assert!(!b.session.view.proofing && !b.session.prefs.check_spelling, "saved off, whichever window was drawn");
}
/// #7841: in dark mode the app draws its interface text with its own lighter curve, not egui's dark default, and
/// light mode keeps egui's light one.
#[test]
#[cfg(all(unix, not(target_os = "macos")))]
fn dark_interface_text_uses_the_app_s_lighter_curve() {
let ctx = crate::test_harness::context();
let mut a = app();
let curve = |a: &mut WordApp, theme: theme::Appearance| {
a.ui.theme = theme;
for _ in 0..2 {
crate::test_harness::pass(&ctx, a, egui::RawInput::default());
}
ctx.global_style().visuals.text_options.color_transfer_function
};
let dark = curve(&mut a, theme::Appearance::Dark);
let light = curve(&mut a, theme::Appearance::Light);
let lighter = egui::epaint::FontColorTransferFunction::Gamma(0.8);
assert_eq!(dark, lighter, "dark mode draws with the app's curve");
assert_eq!(light, egui::Visuals::light().text_options.color_transfer_function, "light mode keeps egui's");
assert_eq!(curve(&mut a, theme::Appearance::Dark), lighter, "back to dark gets the app's curve again");
}
/// #1861: the registered Interface Theme command drives the same setting as Options:
/// searchable in the registry, settable, toggling without a value, and surviving a restart.
#[test]
+10
View File
@@ -712,6 +712,16 @@ pub fn apply_animations(ctx: &egui::Context, on: bool) {
/// Coverage exponent for light-on-dark interface text on Linux and the BSDs (see [`visuals`]).
const DARK_TEXT_GAMMA: f32 = 0.8;
/// Gives egui's dark style our lighter light-on-dark text curve on Linux and the BSDs (see [`visuals`]). The craft
/// runtime's mode sync keeps an app's own curve for each mode (craft-libs#3589), so setting it once is enough (#7841).
pub fn set_dark_text_curve(ctx: &egui::Context) {
if cfg!(all(unix, not(target_os = "macos"))) {
ctx.style_mut_of(egui::Theme::Dark, |s| {
s.visuals.text_options.color_transfer_function = egui::epaint::FontColorTransferFunction::Gamma(DARK_TEXT_GAMMA);
});
}
}
/// egui's visuals for one of our palettes.
fn visuals(t: &Tokens) -> Visuals {
let mut v = if t.dark { Visuals::dark() } else { Visuals::light() };
+2 -1
View File
File diff suppressed because one or more lines are too long
+14 -12
View File
@@ -32,35 +32,37 @@ Generated by `cargo xtask parity` (`wordcraft-cli parity --markdown`): the word-
| Editing | 41 | 41 |
| Tools | 7 | 7 |
**Headless ([RFC-0052](https://github.com/storytold/craft-contrib/blob/main/rfcs/0052-headless-reach.md)): 510 yes, 12 no (window 3, os 8, engine-gap 1), 0 partial, 0 unknown.** A feature is `headless: yes` when its command is in the engine registry that `wordcraft-cli` and the MCP server load, so every live feature above is `yes`; the missing ones carry the hand mark from `HEADLESS` in `crates/engine/src/catalog.rs`, or `unknown`.
## Missing
### Home
- Voice › Dictate (`tools.dictate`)
- Voice › Dictate (`tools.dictate`): headless: no, reach: os (speech recognition service)
### Insert
- Illustrations › Online Pictures (`insert.onlinePicture`)
- Illustrations › 3D Models (`insert.model3d`)
- Illustrations › Screenshot (`insert.screenshot`)
- Add-ins › Get Add-ins (`addins.get`)
- Media › Online Video (`insert.video`)
- Symbols › Ink Equation (`insert.inkEquation`)
- Illustrations › Online Pictures (`insert.onlinePicture`): headless: no, reach: os (online image search service)
- Illustrations › 3D Models (`insert.model3d`): headless: no, reach: engine-gap (3-D model files could be inserted by a command)
- Illustrations › Screenshot (`insert.screenshot`): headless: no, reach: os (screen capture of other windows)
- Add-ins › Get Add-ins (`addins.get`): headless: no, reach: os (add-in store service)
- Media › Online Video (`insert.video`): headless: no, reach: os (online video service)
- Symbols › Ink Equation (`insert.inkEquation`): headless: no, reach: window (drawn with a pen or pointer)
### Draw
- Convert › Ink to Math (`draw.inkToMath`)
- Convert › Ink to Math (`draw.inkToMath`): headless: no, reach: os (handwriting recognition service)
### Review
- Language › Translate (`review.translate`)
- Protect › Block Authors (`review.blockAuthors`)
- Language › Translate (`review.translate`): headless: no, reach: os (online translation service)
- Protect › Block Authors (`review.blockAuthors`): headless: no, reach: os (co-authoring service)
### Read Mode
- View › Layout (`view.readLayout`)
- View › Layout (`view.readLayout`): headless: no, reach: window (Read Mode window layout)
### Equation
- Tools › Ink Equation (`insert.inkEquation`)
- Tools › Ink Equation (`insert.inkEquation`): headless: no, reach: window (drawn with a pen or pointer)
+2 -1
View File
File diff suppressed because one or more lines are too long