mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-28 08:45:52 -06:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5796c665b9 | ||
|
|
e74e627a38 |
@@ -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`.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -147,12 +147,6 @@ const LINKED_EDIT: [craft::ui::runtime::commands::EditCommands; 5] = {
|
||||
[Cut, Copy, Paste, Undo, Redo]
|
||||
};
|
||||
|
||||
/// The English parts of a registry `location` (`Home › Font`, split as `i18n::location` does); `None` for no place.
|
||||
pub(crate) fn location_path(location: &str) -> Option<Vec<&str>> {
|
||||
let path: Vec<&str> = location.split(" › ").filter(|part| !part.is_empty()).collect();
|
||||
(!path.is_empty()).then_some(path)
|
||||
}
|
||||
|
||||
impl WordApp {
|
||||
/// The app's commands as the keymap knows them: every engine command with its default
|
||||
/// chords, then the interface commands. The interface commands come last because a tie in the
|
||||
@@ -189,11 +183,6 @@ impl WordApp {
|
||||
// warned about), so their chords go in as the set's replaced defaults (the `LINKED_EDIT` fold below).
|
||||
for spec in registry.all().iter().filter(|spec| seen.insert(spec.id) && !LINKED_EDIT.iter().any(|c| c.id() == spec.id)) {
|
||||
let mut def = CommandDef::new(CommandRef::new(spec.id), tl!(spec.label), Scope::app());
|
||||
// Its ribbon place is its menu path, in English: Customize Keyboard files it under the tab by name,
|
||||
// and the framework translates each segment where it shows it.
|
||||
if let Some(path) = location_path(spec.location) {
|
||||
def = def.with_path(path.into_iter().map(str::to_owned).collect());
|
||||
}
|
||||
for binding in default_bindings(spec.shortcut) {
|
||||
def = def.with_default(binding);
|
||||
}
|
||||
|
||||
@@ -25,11 +25,7 @@ pub(crate) fn help_entries(app: &WordApp) -> Vec<HelpEntry> {
|
||||
.map(|c| {
|
||||
let command =
|
||||
if c.id == "view.paperColor" { CommandRef::with_params("file.options", json!({"pane": "general"})) } else { CommandRef::new(c.id) };
|
||||
let entry = HelpEntry::new(command, tl!(c.label).to_string()).with_english(c.label.to_string());
|
||||
match crate::app::command_board::location_path(c.location) {
|
||||
Some(path) => entry.with_path(path.into_iter().map(|part| tl!(part).to_string())),
|
||||
None => entry,
|
||||
}
|
||||
HelpEntry::new(command, tl!(c.label).to_string()).with_english(c.label.to_string())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -85,17 +81,3 @@ pub(super) fn show(app: &mut WordApp, ui: &mut Ui, compact: bool) -> egui::Rect
|
||||
}
|
||||
rect
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{Services, WordApp};
|
||||
|
||||
/// #7983: a search result names the ribbon place of its command.
|
||||
#[test]
|
||||
fn search_entries_show_the_ribbon_location() {
|
||||
let app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Services::default());
|
||||
let entries = super::help_entries(&app);
|
||||
let bold = entries.iter().find(|e| e.command().id == "format.bold").expect("format.bold is searchable");
|
||||
assert!(!bold.path().is_empty(), "the entry has a path");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
//! through `tools.customizeKeyboard`, so agents get the same result without the dialog.
|
||||
|
||||
use craft::keymap::{Binding, CommandDef, Keymap, Overrides};
|
||||
use craft::menu::shortcuts::{Area, DialogState, Layout, Options, Outcome, ShortcutsDialog};
|
||||
use craft::menu::shortcuts::{DialogState, Layout, Options, Outcome, ShortcutsDialog};
|
||||
use craft::ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id};
|
||||
use egui::{Context, Ui};
|
||||
use serde_json::{Value, json};
|
||||
use wordcraft_engine::ribbon::{CONTEXTUAL_TABS, TABS};
|
||||
|
||||
use super::host::{DialogHooks, Settle, open_with};
|
||||
use crate::WordApp;
|
||||
@@ -50,61 +49,11 @@ fn assignable(binding: &Binding) -> bool {
|
||||
chord.mods.cmd || chord.mods.ctrl || chord.mods.alt || chord.is_function_key()
|
||||
}
|
||||
|
||||
/// The ribbon tab a command lives on, in English (the first part of its path).
|
||||
fn tab(def: &CommandDef) -> &str {
|
||||
def.paths.first().and_then(|path| path.first()).map_or("", String::as_str)
|
||||
}
|
||||
|
||||
/// Tabs that come up with the selection or a view, besides the engine's contextual ones; they share one Categories entry.
|
||||
const EXTRA_CONTEXT_TABS: [&str; 3] = ["Header & Footer", "Outlining", "Reading"];
|
||||
|
||||
fn in_tab<const N: usize>(def: &CommandDef) -> bool {
|
||||
tab(def) == TABS[N]
|
||||
}
|
||||
|
||||
fn in_context_tab(def: &CommandDef) -> bool {
|
||||
CONTEXTUAL_TABS.contains(&tab(def)) || EXTRA_CONTEXT_TABS.contains(&tab(def))
|
||||
}
|
||||
|
||||
fn in_no_tab(def: &CommandDef) -> bool {
|
||||
!TABS.contains(&tab(def)) && !in_context_tab(def)
|
||||
}
|
||||
|
||||
/// One filter per entry of `TABS` (the array's length makes the compiler check it).
|
||||
const TAB_FILTERS: [fn(&CommandDef) -> bool; TABS.len()] = [
|
||||
in_tab::<0>,
|
||||
in_tab::<1>,
|
||||
in_tab::<2>,
|
||||
in_tab::<3>,
|
||||
in_tab::<4>,
|
||||
in_tab::<5>,
|
||||
in_tab::<6>,
|
||||
in_tab::<7>,
|
||||
in_tab::<8>,
|
||||
in_tab::<9>,
|
||||
in_tab::<10>,
|
||||
in_tab::<11>,
|
||||
in_tab::<12>,
|
||||
];
|
||||
|
||||
/// Categories as Word lists them: the ribbon tabs (not the framework's menu and panel ids), the contextual tabs, the
|
||||
/// rest, then All Commands.
|
||||
fn areas() -> Vec<Area> {
|
||||
let mut areas: Vec<Area> = TABS.iter().copied().zip(TAB_FILTERS).map(|(name, rows)| Area::new(name, tl!(name), rows)).collect();
|
||||
areas.push(Area::new("Contextual Tabs", tl!("Contextual Tabs"), in_context_tab));
|
||||
areas.push(Area::new("Other", tl!("Other"), in_no_tab));
|
||||
areas.push(Area::new("All Commands", tl!("All Commands"), |_| true));
|
||||
areas
|
||||
}
|
||||
|
||||
/// The framework dialog's options: the command-list layout, sorted by label, with the assign rule above.
|
||||
fn options() -> Options {
|
||||
Options::default().with(|o| {
|
||||
o.layout = Layout::CommandLists;
|
||||
o.sort_by_label = true;
|
||||
o.own_areas = true;
|
||||
o.size = Some(egui::vec2(720.0, 700.0));
|
||||
o.areas = areas();
|
||||
o.title = Some(tl!("Customize Keyboard").to_string());
|
||||
o.accept = Some(Box::new(|_: &CommandDef, binding: &Binding| {
|
||||
if assignable(binding) { Ok(()) } else { Err(tl!("Use a key combination with Ctrl, Alt or a function key.").to_string()) }
|
||||
@@ -298,53 +247,4 @@ mod tests {
|
||||
let unbound_labels = keys_list_labels(&h);
|
||||
assert!(unbound_labels.iter().any(|t| t == "None"), "empty keys list says None: {unbound_labels:?}");
|
||||
}
|
||||
|
||||
/// #7971: Categories are the ribbon tabs a command is on, not menu or panel ids; a command with no tab is under Other,
|
||||
/// and every command is under All Commands.
|
||||
#[test]
|
||||
fn categories_are_ribbon_tabs() {
|
||||
use craft::keymap::{CommandDef, Scope};
|
||||
let on = |path: &[&str]| {
|
||||
let mut def = CommandDef::new(CommandRef::new("x"), "X", Scope::app());
|
||||
if !path.is_empty() {
|
||||
def = def.with_path(path.iter().map(|part| part.to_string()).collect());
|
||||
}
|
||||
def
|
||||
};
|
||||
let areas = super::areas();
|
||||
let listing = |def: &CommandDef| areas.iter().filter(|a| (a.rows)(def)).map(|a| a.id).collect::<Vec<_>>();
|
||||
assert_eq!(listing(&on(&["Home", "Font"])), ["Home", "All Commands"]);
|
||||
assert_eq!(listing(&on(&["Help", "Support"])), ["Help", "All Commands"], "every ribbon tab has its entry");
|
||||
assert_eq!(listing(&on(&["Table Design", "Styles"])), ["Contextual Tabs", "All Commands"]);
|
||||
assert_eq!(listing(&on(&[])), ["Other", "All Commands"]);
|
||||
assert_eq!(areas.last().map(|a| a.id), Some("All Commands"), "All Commands comes last");
|
||||
}
|
||||
|
||||
/// #7971: under another language, and for the SmartArt tab that shows as "Diagram Design", commands still land
|
||||
/// under their tab (the catalog keeps English paths; only the display is translated).
|
||||
#[test]
|
||||
fn commands_stay_under_their_tab_in_another_language() {
|
||||
let ctx = egui::Context::default();
|
||||
crate::i18n::fixture_host(&ctx, "x-fixture", "\tHome\tHome-FX\n\tFont\tFont-FX\n\tDiagram Design\tDiagram-FX\n");
|
||||
let mut a = app();
|
||||
let catalog = a.catalog().expect("catalog");
|
||||
let areas = super::areas();
|
||||
let under = |id: &str, area: &str| {
|
||||
let def = catalog.defs().iter().find(|def| def.command == CommandRef::new(id)).unwrap_or_else(|| panic!("{id} in catalog"));
|
||||
areas.iter().any(|a| a.id == area && (a.rows)(def))
|
||||
};
|
||||
assert!(under("format.bold", "Home"), "Bold is under Home in a translated interface");
|
||||
assert!(!under("format.bold", "Other"));
|
||||
let smart = a.session.registry.all().iter().find(|spec| spec.location.starts_with("SmartArt Design")).expect("a SmartArt command");
|
||||
assert!(under(smart.id, "Contextual Tabs") && !under(smart.id, "Other"), "{} is under the contextual tabs", smart.id);
|
||||
}
|
||||
|
||||
/// #7971: the board's catalog files each engine command under its ribbon tab.
|
||||
#[test]
|
||||
fn catalog_paths_follow_the_ribbon_location() {
|
||||
let mut a = app();
|
||||
let catalog = a.catalog().expect("catalog");
|
||||
let bold = catalog.defs().iter().find(|def| def.command == CommandRef::new("format.bold")).expect("format.bold");
|
||||
assert_eq!(bold.paths.first().and_then(|p| p.first()).map(String::as_str), Some("Home"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ use craft::ui::contract::{
|
||||
};
|
||||
use craft::ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, PromptChoice, StackDialog, StandardPrompt, dialog_id};
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::layout_components::{Grid, Row, Stack};
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::list::{List, ListRow, ToggleCell, ToggleState};
|
||||
use craft::ui::notices::Notice;
|
||||
use craft::ui::runtime::env::Label;
|
||||
@@ -51,8 +51,6 @@ pub struct TreeItem {
|
||||
pub command: Option<String>,
|
||||
}
|
||||
|
||||
/// The body's panes: the command pickers, the Add and Remove buttons, then the ribbon or toolbar list.
|
||||
const PANES: [ColumnWidth; 3] = [ColumnWidth::fill(1.0), ColumnWidth::Content, ColumnWidth::fill(1.0)];
|
||||
/// The column of show boxes in the ribbon tree.
|
||||
const SHOWN: ColumnKey = ColumnKey::new("shown");
|
||||
|
||||
@@ -145,10 +143,10 @@ impl RibbonDialog {
|
||||
fn body(&mut self, ui: &mut Ui) {
|
||||
self.page_tabs(ui);
|
||||
search(ui, &mut self.filter);
|
||||
Grid::new(&PANES).fill_width().show(ui, |ui, _| {
|
||||
Stack::new().fill_width().show(ui, |ui, _| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
Text::new(word("Choose a command")).show(ui);
|
||||
Row::new().fill_width().show(ui, |ui, _| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
if let Some(category) = pick(ui, "rb_categories", "Categories:", &self.categories, &self.category) {
|
||||
self.category = category;
|
||||
self.filter.clear();
|
||||
@@ -221,9 +219,9 @@ impl RibbonDialog {
|
||||
self.file("remove", Value::Object(address(&sel)));
|
||||
}
|
||||
});
|
||||
Stack::new().fill_width().show(ui, |ui, _| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
Text::new(word("Ribbon tabs")).show(ui);
|
||||
Row::new().fill_width().show(ui, |ui, _| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
self.tree(ui);
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
for (text, by) in [("Up", -1), ("Down", 1)] {
|
||||
@@ -311,9 +309,9 @@ impl RibbonDialog {
|
||||
self.file("qatRemove", json!(self.qat_selected));
|
||||
}
|
||||
});
|
||||
Stack::new().fill_width().show(ui, |ui, _| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
Text::new(word("Quick Access Toolbar")).show(ui);
|
||||
Row::new().fill_width().show(ui, |ui, _| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
if let Some(id) = pick(ui, "rb_qat", "Quick Access Toolbar", &self.qat, &self.qat_selected) {
|
||||
self.qat_selected = id;
|
||||
}
|
||||
|
||||
+14
-12
@@ -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)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ sonar.python.coverage.reportPaths=python-coverage.xml
|
||||
# S4790 (weak hash): SHA-1 is a start-key and "SHA1/1K" checksum algorithm that ODF package
|
||||
# encryption (ODF 1.3 Part 2 §4.16) names, and older office suites wrote it. It is needed to open
|
||||
# those files, not chosen for new security: WordCraft writes a SHA-256 start key and checksum.
|
||||
sonar.issue.ignore.multicriteria=odt_sha1
|
||||
sonar.issue.ignore.multicriteria=odt_sha1,validate_py_paths
|
||||
sonar.issue.ignore.multicriteria.odt_sha1.ruleKey=rust:S4790
|
||||
sonar.issue.ignore.multicriteria.odt_sha1.resourceKey=crates/formats/src/odt/crypt.rs
|
||||
|
||||
@@ -22,3 +22,9 @@ sonar.issue.ignore.multicriteria.odt_sha1.resourceKey=crates/formats/src/odt/cry
|
||||
# os_window, control-key). process_identity.rs is Windows-only (the taskbar AUMID) and cannot run
|
||||
# on the Linux runner either.
|
||||
sonar.coverage.exclusions=packaging/**,apps/wordcraft/src/main.rs,apps/wordcraft-cli/src/main.rs,apps/wordcraft/src/process_identity.rs
|
||||
|
||||
# S8707 (path traversal): the crates/validate *.py scripts are developer tools run by hand to
|
||||
# regenerate checked-in files; reading and writing the paths given on their command line is
|
||||
# their purpose, and nothing passes them untrusted input.
|
||||
sonar.issue.ignore.multicriteria.validate_py_paths.ruleKey=pythonsecurity:S8707
|
||||
sonar.issue.ignore.multicriteria.validate_py_paths.resourceKey=crates/validate/**/*.py
|
||||
|
||||
Reference in New Issue
Block a user