Compare commits

..
Author SHA1 Message Date
Martin Ball 8f627faed0 Merge remote-tracking branch 'origin/fix/8811-status-ink' into test/overnight-5dec 2026-12-05 08:48:48 +00:00
Martin Ball 8cc1912dc0 test: trial repin to craft-libs test/overnight-5dec (18499ec3) 2026-12-05 08:48:48 +00:00
Martin BallandClaude Opus 5.5 0eda97fe8c #8811: the status bar's muted-ink override returns nothing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCXNomWeGUu3duixKdm
2026-12-05 08:48:41 +00:00
Martin Ball db301eb1ba Merge remote-tracking branch 'origin/fix/8980-vertical-ime-preedit' into test/overnight-5dec
; Conflicts:
;	crates/ui-egui/src/canvas/tests.rs
2026-12-05 08:41:38 +00:00
Martin Ball ab05f3f6d4 Merge remote-tracking branch 'origin/fix/8855-touchpad-glide' into test/overnight-5dec
; Conflicts:
;	crates/ui-egui/src/canvas.rs
2026-12-05 08:41:28 +00:00
Martin Ball 440243e3d7 Merge remote-tracking branch 'origin/fix/8969-flatpak-kde-clipboard' into test/overnight-5dec 2026-12-05 08:41:20 +00:00
Martin Ball 18369a756e Merge remote-tracking branch 'origin/fix/8811-status-ink' into test/overnight-5dec 2026-12-05 08:41:20 +00:00
Martin Ball e8b2c87781 Merge remote-tracking branch 'origin/fix/8853-interface-scale' into test/overnight-5dec 2026-12-05 08:41:18 +00:00
Martin Ball bf556a1cd6 Merge remote-tracking branch 'origin/fix/9111-print-preview-sheet-edge' into test/overnight-5dec 2026-12-05 08:41:18 +00:00
Martin Ball 0bcb856280 Merge remote-tracking branch 'origin/fix/8872-vmerge-page-split' into test/overnight-5dec 2026-12-05 08:41:16 +00:00
Martin BallandClaude Sonnet 5.5 241bf8c94d #8853: interface size uses the document window's display scale, not the hidden root's
Cause: the zoom is context-wide and divided the display scale read from the root viewport; the windowless root (v0.20.0) has no window, so it reported none (1.0) and a chosen size drew at size x the window's real scale (too large on a scaled display, wrong on mixed DPI). Now read from the active document viewport.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCXNomWeGUu3duixKdm
2026-12-05 06:15:17 +00:00
Martin BallandClaude Sonnet 5.5 f086af023f #8980: IME composition in vertical text runs down the line at the text size
The composition was drawn horizontally in the interface font whenever the
caret lay in turned text (typing_style and the caret were horizontal-only).
Caret now carries the line's direction and typing_style serves turned text;
the canvas stacks the composition's characters upright down (tbRl) or up
(btLr) the line at the run's size, and reports the column it fills as the
candidate window rect.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCXNomWeGUu3duixKdm
2026-12-05 04:35:45 +00:00
Martin BallandClaude Sonnet 5.5 f9ff36d67c #8811: status bar page, word count and language read in the muted ink again
Cause: the craft-ui port drew the readouts in full ink; v0.19.1 used text_dim.
Fix: set AfterInk::Muted around the readouts; craft-libs now honours it on ghost buttons
(depends on the craft-libs PR, builds after the repin).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCXNomWeGUu3duixKdm
2026-12-05 04:26:00 +00:00
Martin BallandClaude Sonnet 5.5 0739eb7379 #8969: Flatpak on KDE Plasma Wayland can paste again
Cause: KWin has no data-control protocol, arboard falls back to X11, but fallback-x11 gives the sandbox no X11 under Wayland.
Fix: grant --socket=x11 beside wayland so the XWayland clipboard bridge is reachable. Interim: a real wl_data_device clipboard belongs in craft-libs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCXNomWeGUu3duixKdm
2026-12-05 02:33:00 +00:00
52 changed files with 468 additions and 1955 deletions
Generated
+98 -97
View File
@@ -1173,7 +1173,7 @@ dependencies = [
[[package]]
name = "craft"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-automation",
"craft-behavior",
@@ -1224,7 +1224,7 @@ dependencies = [
[[package]]
name = "craft-appkit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"block2 0.6.2",
"objc2 0.6.5",
@@ -1236,7 +1236,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"rustix 1.1.6",
]
@@ -1244,7 +1244,7 @@ dependencies = [
[[package]]
name = "craft-automation"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"base64 0.23.1",
"craft-behavior",
@@ -1269,11 +1269,12 @@ dependencies = [
[[package]]
name = "craft-behavior"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"accesskit",
"bitflags 2.13.2",
"craft-host",
"craft-i18n",
"craft-keymap",
"craft-theme",
"craft-tracked",
@@ -1287,7 +1288,7 @@ dependencies = [
[[package]]
name = "craft-browse"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-docpath",
@@ -1305,12 +1306,12 @@ dependencies = [
[[package]]
name = "craft-cfb"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
[[package]]
name = "craft-cloud-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"egui",
]
@@ -1318,7 +1319,7 @@ dependencies = [
[[package]]
name = "craft-cms"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"md-5",
"rayon",
@@ -1327,12 +1328,12 @@ dependencies = [
[[package]]
name = "craft-codepage"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
[[package]]
name = "craft-color"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"serde",
]
@@ -1340,7 +1341,7 @@ dependencies = [
[[package]]
name = "craft-color-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-cms",
@@ -1360,7 +1361,7 @@ dependencies = [
[[package]]
name = "craft-control"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-ai-agents",
"craft-atomic",
@@ -1376,7 +1377,7 @@ dependencies = [
[[package]]
name = "craft-control-protocol"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"getrandom 0.3.4",
"serde_json",
@@ -1386,7 +1387,7 @@ dependencies = [
[[package]]
name = "craft-dds"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"rayon",
]
@@ -1394,7 +1395,7 @@ dependencies = [
[[package]]
name = "craft-dialogs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"block2 0.6.2",
"craft-appkit",
@@ -1420,7 +1421,7 @@ dependencies = [
[[package]]
name = "craft-doc-binary"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"chrono",
"craft-cfb",
@@ -1437,7 +1438,7 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"serde",
]
@@ -1445,7 +1446,7 @@ dependencies = [
[[package]]
name = "craft-docx"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"base64 0.23.1",
"chrono",
@@ -1465,7 +1466,7 @@ dependencies = [
[[package]]
name = "craft-draw"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1484,7 +1485,7 @@ dependencies = [
[[package]]
name = "craft-drawingml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"chrono",
"craft-xml",
@@ -1496,7 +1497,7 @@ dependencies = [
[[package]]
name = "craft-flags"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-atomic",
"dirs",
@@ -1506,7 +1507,7 @@ dependencies = [
[[package]]
name = "craft-flow"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-wordmodel",
"image",
@@ -1516,7 +1517,7 @@ dependencies = [
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"fontique",
"harfrust 0.13.3",
@@ -1531,7 +1532,7 @@ dependencies = [
[[package]]
name = "craft-font-manager"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -1550,7 +1551,7 @@ dependencies = [
[[package]]
name = "craft-font-os-windows"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"windows-registry",
"windows-sys 0.61.2",
@@ -1559,7 +1560,7 @@ dependencies = [
[[package]]
name = "craft-font-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"cap-primitives",
"craft-atomic",
@@ -1582,7 +1583,7 @@ dependencies = [
[[package]]
name = "craft-font-subset"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"brotli 9.1.3",
"harfbuzz-subset-sys",
@@ -1595,7 +1596,7 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-font-subset",
]
@@ -1603,7 +1604,7 @@ dependencies = [
[[package]]
name = "craft-gpu"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"egui-wgpu",
"log",
@@ -1615,7 +1616,7 @@ dependencies = [
[[package]]
name = "craft-host"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"bitflags 2.13.2",
"craft-i18n",
@@ -1628,7 +1629,7 @@ dependencies = [
[[package]]
name = "craft-html"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-codepage",
"craft-flow",
@@ -1641,7 +1642,7 @@ dependencies = [
[[package]]
name = "craft-i18n"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"brotli 9.1.3",
"brotli-decompressor 6.3.1",
@@ -1671,7 +1672,7 @@ dependencies = [
[[package]]
name = "craft-image-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-dds",
"craft-jpeg",
@@ -1698,7 +1699,7 @@ dependencies = [
[[package]]
name = "craft-imaging"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1716,7 +1717,7 @@ dependencies = [
[[package]]
name = "craft-jpeg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"thiserror 2.0.21",
]
@@ -1724,7 +1725,7 @@ dependencies = [
[[package]]
name = "craft-keymap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-host",
"craft-i18n",
@@ -1739,7 +1740,7 @@ dependencies = [
[[package]]
name = "craft-latex"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-flow",
"craft-math",
@@ -1750,7 +1751,7 @@ dependencies = [
[[package]]
name = "craft-markdown"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-flow",
"craft-html",
@@ -1760,7 +1761,7 @@ dependencies = [
[[package]]
name = "craft-math"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-xml",
"roxmltree",
@@ -1770,7 +1771,7 @@ dependencies = [
[[package]]
name = "craft-mcp-server"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"serde_json",
]
@@ -1778,7 +1779,7 @@ dependencies = [
[[package]]
name = "craft-menu"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -1796,7 +1797,7 @@ dependencies = [
[[package]]
name = "craft-metadata"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"brotli-decompressor 6.3.1",
"chrono",
@@ -1808,7 +1809,7 @@ dependencies = [
[[package]]
name = "craft-metafile"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"encoding_rs",
"image",
@@ -1819,7 +1820,7 @@ dependencies = [
[[package]]
name = "craft-mime"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"chardetng",
"chrono",
@@ -1830,7 +1831,7 @@ dependencies = [
[[package]]
name = "craft-nightly"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"uds_windows",
"winsafe",
@@ -1839,7 +1840,7 @@ dependencies = [
[[package]]
name = "craft-odf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"aes",
"base64 0.23.1",
@@ -1865,7 +1866,7 @@ dependencies = [
[[package]]
name = "craft-ods"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-odf",
"craft-sheet",
@@ -1876,7 +1877,7 @@ dependencies = [
[[package]]
name = "craft-offcrypto"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"aes",
"base64 0.23.1",
@@ -1893,7 +1894,7 @@ dependencies = [
[[package]]
name = "craft-opc"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1904,7 +1905,7 @@ dependencies = [
[[package]]
name = "craft-pages"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -1920,7 +1921,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"krilla",
"serde",
@@ -1930,7 +1931,7 @@ dependencies = [
[[package]]
name = "craft-platform"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"arboard",
"async-channel",
@@ -1968,7 +1969,7 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -1992,7 +1993,7 @@ dependencies = [
[[package]]
name = "craft-proof"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"log",
"miniz_oxide 0.9.1",
@@ -2003,7 +2004,7 @@ dependencies = [
[[package]]
name = "craft-quit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"dispatch2",
"egui",
@@ -2016,7 +2017,7 @@ dependencies = [
[[package]]
name = "craft-review"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"base64 0.23.1",
"craft-behavior",
@@ -2035,7 +2036,7 @@ dependencies = [
[[package]]
name = "craft-rtf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-codepage",
"craft-flow",
@@ -2048,7 +2049,7 @@ dependencies = [
[[package]]
name = "craft-settings"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-atomic",
"craft-host",
@@ -2065,17 +2066,17 @@ dependencies = [
[[package]]
name = "craft-sheet"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
[[package]]
name = "craft-ssip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
[[package]]
name = "craft-svg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-xml",
"flate2",
@@ -2092,7 +2093,7 @@ dependencies = [
[[package]]
name = "craft-table"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2104,7 +2105,7 @@ dependencies = [
[[package]]
name = "craft-text"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2128,7 +2129,7 @@ dependencies = [
[[package]]
name = "craft-theme"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"bitflags 2.13.2",
"craft-tracked",
@@ -2143,7 +2144,7 @@ dependencies = [
[[package]]
name = "craft-theme-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-atomic",
"craft-behavior",
@@ -2158,7 +2159,7 @@ dependencies = [
[[package]]
name = "craft-tiff"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2168,7 +2169,7 @@ dependencies = [
[[package]]
name = "craft-time"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2177,7 +2178,7 @@ dependencies = [
[[package]]
name = "craft-timeline"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2192,12 +2193,12 @@ dependencies = [
[[package]]
name = "craft-tracked"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
[[package]]
name = "craft-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-cloud-ui",
"craft-ui-canvas",
@@ -2211,7 +2212,7 @@ dependencies = [
[[package]]
name = "craft-ui-canvas"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -2228,7 +2229,7 @@ dependencies = [
[[package]]
name = "craft-ui-contract"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"accesskit",
"craft-behavior",
@@ -2266,7 +2267,7 @@ dependencies = [
[[package]]
name = "craft-ui-macros"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -2277,7 +2278,7 @@ dependencies = [
[[package]]
name = "craft-ui-panels"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2295,7 +2296,7 @@ dependencies = [
[[package]]
name = "craft-ui-patterns"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2316,7 +2317,7 @@ dependencies = [
[[package]]
name = "craft-ui-shell"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2337,7 +2338,7 @@ dependencies = [
[[package]]
name = "craft-ui-test-kit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2348,7 +2349,7 @@ dependencies = [
[[package]]
name = "craft-ui-widgets"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2367,7 +2368,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"base64 0.22.1",
"chrono",
@@ -2399,7 +2400,7 @@ dependencies = [
[[package]]
name = "craft-web-api"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"js-sys",
"serde_json",
@@ -2410,7 +2411,7 @@ dependencies = [
[[package]]
name = "craft-web-host"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-host",
"craft-platform",
@@ -2422,7 +2423,7 @@ dependencies = [
[[package]]
name = "craft-win32"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"winsafe",
]
@@ -2430,7 +2431,7 @@ dependencies = [
[[package]]
name = "craft-window"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-appkit",
"craft-atomic",
@@ -2462,7 +2463,7 @@ dependencies = [
[[package]]
name = "craft-wordmodel"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"base64 0.23.1",
"craft-math",
@@ -2476,7 +2477,7 @@ dependencies = [
[[package]]
name = "craft-xls"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-cfb",
"craft-sheet",
@@ -2489,7 +2490,7 @@ dependencies = [
[[package]]
name = "craft-xlsx"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"craft-drawingml",
"craft-opc",
@@ -2501,7 +2502,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"quick-xml 0.41.0",
"serde",
@@ -2511,7 +2512,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -3904,7 +3905,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
[[package]]
name = "hayro-cmap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"brotli 8.0.4",
"hayro-postscript",
@@ -3913,7 +3914,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -3931,7 +3932,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -3949,12 +3950,12 @@ dependencies = [
[[package]]
name = "hayro-postscript"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"flate2",
"hayro-ccitt",
@@ -4683,7 +4684,7 @@ dependencies = [
[[package]]
name = "krilla"
version = "0.8.2"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"base64 0.22.1",
"bumpalo",
@@ -4822,7 +4823,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
[[package]]
name = "linesweeper"
version = "0.5.0"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
dependencies = [
"arrayvec",
"kurbo",
@@ -10093,4 +10094,4 @@ source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f
[[patch.unused]]
name = "hayro"
version = "0.7.1"
source = "git+https://github.com/storytold/craft-libs?rev=ad10c35ae545f0fb816364381a1a8154012b2359#ad10c35ae545f0fb816364381a1a8154012b2359"
source = "git+https://github.com/storytold/craft-libs?rev=18499ec3a61f6d7a7d8a70951fa9765e5cf9853c#18499ec3a61f6d7a7d8a70951fa9765e5cf9853c"
+39 -39
View File
@@ -37,22 +37,22 @@ wordcraft-pdf = { path = "crates/pdf" }
# reads the ca-valencia pack), #589 (French elision suggestions first), #497 (flag-based
# compounding), #496 (review follow-ups, en-AU) and the merged #482–#490/#495 stack; the font
# store's `language-pack` kind is #486 (CP4.1).
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
wordcraft-engine = { path = "crates/engine" }
wordcraft-mcp = { path = "crates/mcp" }
wordcraft-zotero = { path = "crates/zotero" }
wordcraft-control-key = { path = "crates/control-key" }
wordcraft-ui-egui = { path = "crates/ui-egui" }
wordcraft-validate = { path = "crates/validate" }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", default-features = false }
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", default-features = false }
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
# foundation
kurbo = { version = "0.13", features = ["serde"] }
@@ -85,28 +85,28 @@ wuff = "0.2.9"
brotli-decompressor = "5"
vello_cpu = "0.2"
image = { version = "0.25", default-features = false }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", default-features = false, features = ["write"] }
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", default-features = false, features = ["write"] }
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["doc"] }
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["text"] }
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["flow"] }
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0", features = ["detect"] }
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", version = "=0.1.0" }
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["doc"] }
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["text"] }
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["flow"] }
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0", features = ["detect"] }
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", version = "=0.1.0" }
# zlib streams (compressed metafile pictures in `.doc` drawings); already in the lock as a dependency of other crates.
miniz_oxide = "0.9"
cfb = "0.15"
@@ -174,14 +174,14 @@ debug = 0
# The framework's patches, which Cargo does not carry over to dependents: its vendored crates from craft-libs,
# and the egui and winit forks it builds with.
[patch.crates-io]
krilla = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" }
+5 -32
View File
@@ -387,14 +387,6 @@ impl Counters {
Some(self.state.get(&abs.id).copied().unwrap_or([0; 9]))
}
/// The values counted so far for `num`, including implicitly counted ancestors and zero starts.
/// An unstarted level has no value even when its definition has a default start.
pub fn counted_values_indexed(&self, numbering: &NumberingIndex<'_>, num: u32) -> [Option<u32>; 9] {
let Some(abs) = numbering.abstract_of(num) else { return [None; 9] };
let (Some(values), Some(flags)) = (self.state.get(&abs.id), self.flags.get(&abs.id)) else { return [None; 9] };
std::array::from_fn(|level| flags[level].started.then_some(values[level]))
}
fn next_label_from(&mut self, n: &Num, abs: &AbstractNum, level: u8) -> Option<(String, Level)> {
let num = n.id;
let lv = (level as usize).min(8);
@@ -501,19 +493,16 @@ impl Counters {
}
}
fn placeholder_level(digit: char) -> Option<usize> {
digit.to_digit(10).filter(|d| (1..=9).contains(d)).map(|d| (d - 1) as usize)
}
/// The zero-based levels a label template shows (`"%1.%2"` → `[0, 1]`, `"(%3)"` → `[2]`).
pub fn template_levels(text: &str) -> Vec<usize> {
let mut out = Vec::new();
let mut chars = text.chars().take(MAX_LEVEL_TEXT).peekable();
while let Some(c) = chars.next() {
if c == '%'
&& let Some(k) = chars.peek().copied().and_then(placeholder_level)
&& let Some(d) = chars.peek().and_then(|d| d.to_digit(10))
{
chars.next();
let k = (d as usize).saturating_sub(1).min(8);
if !out.contains(&k) {
out.push(k);
}
@@ -529,9 +518,11 @@ fn render_label<'a>(level_def: impl Fn(usize) -> Option<&'a Level>, def: &Level,
let mut chars = def.text.chars().take(MAX_LEVEL_TEXT).peekable();
while let Some(c) = chars.next() {
if c == '%'
&& let Some(k) = chars.peek().copied().and_then(placeholder_level)
&& let Some(d) = chars.peek().and_then(|d| d.to_digit(10))
&& (1..=9).contains(&d)
{
chars.next();
let k = (d as usize).saturating_sub(1).min(8);
let val = vals.get(k).copied().unwrap_or(0);
let counted = started.get(k).is_some_and(|f| f.started);
let level = level_def(k);
@@ -878,23 +869,6 @@ mod tests {
assert_eq!(labels, ["0.", "1.", "2."]);
}
#[test]
fn a_counted_zero_ancestor_replaces_the_unstarted_fallback() {
let mut numbering = Numbering::default();
let num = numbering.add_list(ListKind::Numbered);
numbering.abstracts[0].levels[0].start = 7;
numbering.abstracts[0].levels[1] = Level { text: "%1.%2.".into(), ..Default::default() };
numbering.nums[0].start_overrides = vec![(0, 0)];
let index = NumberingIndex::new(&numbering);
let mut counters = Counters::default();
assert_eq!(counters.counted_values_indexed(&index, num)[0], None);
assert_eq!(counters.current_label(&numbering, num, 1).as_deref(), Some("7.1."));
let (label, _) = counters.next_label_indexed(&index, num, 1).unwrap();
assert_eq!(label, "0.1.");
assert_eq!(counters.counted_values_indexed(&index, num)[0], Some(0));
}
#[test]
fn placeholder_percent_zero_is_preserved_as_literal() {
let mut n = Numbering::default();
@@ -904,7 +878,6 @@ mod tests {
}
let mut c = Counters::default();
assert_eq!(c.next_label(&n, id, 0).unwrap().0, "%0 1.");
assert_eq!(template_levels("%0 %2. %9 %2"), [1, 8]);
}
#[test]
-1
View File
@@ -26,7 +26,6 @@ use generated::ENTRY_STYLE;
pub(crate) use generated::generated_list;
use generated::table_of_figures;
pub use generated::{figures_instr, update_generated};
pub(super) use generated::{is_list_entry, wrapped_list};
pub use render::{cite, entry};
pub use sources::update_citations;
use sources::{citation, sources};
+4 -77
View File
@@ -65,7 +65,6 @@ fn generated_list_with(s: &mut Session, instr: &str, title: &str, leader: Option
seed.props.tabs = Some(vec![TabStop { pos: 0.0, align: TabAlign::Right, leader }]);
s.doc.insert_block(StoryRef::Body, &Path::top(i.saturating_add(1)), Block::Para(seed))?;
}
s.touch();
update_generated(s)
}
@@ -75,7 +74,7 @@ const MAX_WRAPPED: usize = 10_000;
/// A generated list (index, bibliography, table of figures or authorities) held as a complex
/// field that starts at body block `i` and runs over its entries: its field code and the block
/// it ends in. `None` for anything else (a TOC has its own update).
pub(in crate::cmd) fn wrapped_list(s: &Session, i: usize) -> Option<(String, usize, usize, usize)> {
fn wrapped_list(s: &Session, i: usize) -> Option<(String, usize, usize, usize)> {
let p = s.doc.body.get(i)?.as_para()?;
let (k, off, instr) = p.objects_with_offsets().enumerate().find_map(|(k, (off, o))| match o {
InlineObject::FieldStart { instr, .. } => {
@@ -198,15 +197,9 @@ fn caption_body(p: &Paragraph, label: &str) -> String {
pub(super) const ENTRY_STYLE: &str = "ListEntry";
/// A result paragraph can share its style with a field header split out of an imported list.
pub(in crate::cmd) fn is_list_entry(p: &Paragraph) -> bool {
p.props.style.as_deref() == Some(ENTRY_STYLE) && list_kind(p).is_none()
}
/// Rebuild every generated list.
pub fn update_generated(s: &mut Session) -> Result<(), CmdError> {
let mut i = 0;
let mut relocated_index_leader = None;
while i < s.doc.body.len() {
// A list held as a field around its entries (as Word and ODT files hold them): made the
// field's own paragraph, as WordCraft inserts one, its old entries rebuilt below.
@@ -214,11 +207,7 @@ pub fn update_generated(s: &mut Session) -> Result<(), CmdError> {
// break, are the document's and stay.
// (The field it is made: what comes before it in its paragraph may hold other fields.)
let mut converted = None;
let mut index_leader = None;
if let Some((instr, start, last, end)) = wrapped_list(s, i) {
if instr.starts_with("INDEX") {
index_leader = crate::cmd::index::wrapped_entry_leader(s, i, start, last, end);
}
// The entries between its first and last paragraphs go.
for _ in i.saturating_add(1)..last {
s.doc.remove_block(StoryRef::Body, &Path::top(i + 1))?;
@@ -258,14 +247,9 @@ pub fn update_generated(s: &mut Session) -> Result<(), CmdError> {
let p = s.doc.para_mut(StoryRef::Body, &Path::top(i))?;
if p.objects_with_offsets().any(|(off, o)| off < start && list_field(o).is_some()) {
let list = p.split_off(start)?;
// Rebuilding the preceding list can shift the new paragraph's block index.
if let Some(leader) = index_leader.take() {
relocated_index_leader = Some((list.rev, leader));
}
s.doc.insert_block(StoryRef::Body, &Path::top(i + 1), Block::Para(list))?;
converted = None;
}
s.touch();
}
let kind = converted.or_else(|| s.doc.body.get(i).and_then(|b| b.as_para()).and_then(list_kind));
let Some(kind) = kind else {
@@ -274,11 +258,7 @@ pub fn update_generated(s: &mut Session) -> Result<(), CmdError> {
};
add_entry_style(s);
if kind.starts_with("INDEX") {
let index_leader = index_leader.or_else(|| {
let rev = s.doc.body.get(i)?.as_para()?.rev;
relocated_index_leader.take_if(|(relocated, _)| *relocated == rev).map(|(_, leader)| leader)
});
crate::cmd::index::rebuild_from(s, i, index_leader, kind)?;
crate::cmd::index::rebuild_from(s, i, None, kind)?;
i += 1;
continue;
}
@@ -310,11 +290,11 @@ pub fn update_generated(s: &mut Session) -> Result<(), CmdError> {
.body
.get(i + 1)
.and_then(|b| b.as_para())
.filter(|p| is_list_entry(p))
.filter(|p| p.props.style.as_deref() == Some(ENTRY_STYLE))
.and_then(|p| p.props.tabs.as_ref()?.last().map(|t| t.leader))
.or(saved_leader)
.unwrap_or(TabLeader::Dot);
while s.doc.body.get(i + 1).and_then(|b| b.as_para()).is_some_and(is_list_entry) {
while s.doc.body.get(i + 1).and_then(|b| b.as_para()).is_some_and(|p| p.props.style.as_deref() == Some(ENTRY_STYLE)) {
s.doc.remove_block(StoryRef::Body, &Path::top(i + 1))?;
}
let lines = entries_for(s, &kind);
@@ -330,7 +310,6 @@ pub fn update_generated(s: &mut Session) -> Result<(), CmdError> {
}
s.doc.insert_block(StoryRef::Body, &Path::top(i + 1 + k), Block::Para(para))?;
}
s.touch();
i += 1;
}
s.touch();
@@ -584,56 +563,4 @@ mod tests {
assert_eq!(lists, [Some("INDEX".to_string()), Some("BIBLIOGRAPHY".to_string())]);
}
}
#[test]
fn a_wrapped_index_keeps_its_leader_when_split_from_a_bibliography() {
let old_entry = "Old entry\t1";
let mut s = wrapped("Old entry\t1\n\nKilns are hot.", 0, 0, old_entry.len());
s.run("select.text", &serde_json::json!({"text": "Kilns"})).unwrap();
s.run("references.markEntry", &serde_json::json!({})).unwrap();
s.doc.sources.push(wordcraft_doc::Source { tag: "a".into(), kind: "book".into(), title: "Listed Source".into(), ..Default::default() });
let props = CharProps::default();
let instr = "INDEX \\e \"\t\"";
let p = s.doc.para_mut(StoryRef::Body, &Path::top(0)).unwrap();
p.objects[0] = InlineObject::FieldStart { instr: instr.into(), locked: false, dirty: false };
p.insert_object(
0,
InlineObject::Field {
instr: "BIBLIOGRAPHY".into(),
result: String::new(),
locked: false,
dirty: false,
code: false,
form: String::new(),
},
&props,
)
.unwrap();
p.props.style = Some(ENTRY_STYLE.into());
p.props.tabs = Some(vec![TabStop { pos: 120.0, align: TabAlign::Right, leader: TabLeader::Hyphen }]);
let p = s.doc.para_mut(StoryRef::Body, &Path::top(1)).unwrap();
// A separate INDEX with the same instruction has no prior result and must get the default.
p.insert_object(
0,
InlineObject::Field { instr: instr.into(), result: String::new(), locked: false, dirty: false, code: false, form: String::new() },
&props,
)
.unwrap();
s.touch();
let (_, start, last, end) = wrapped_list(&s, 0).unwrap();
assert_eq!(crate::cmd::index::wrapped_entry_leader(&mut s, 0, start, last, end), Some(TabLeader::Hyphen));
for _ in 0..2 {
update_generated(&mut s).unwrap();
let paras: Vec<_> = s.doc.body.iter().filter_map(|b| b.as_para()).collect();
assert_eq!(list_kind(paras[0]).as_deref(), Some("BIBLIOGRAPHY"));
assert!(paras[1].plain_text().contains("Listed Source"), "the bibliography inserts an entry before the relocated index");
for (header, leader) in [(2, TabLeader::Hyphen), (4, TabLeader::Dot)] {
assert_eq!(list_kind(paras[header]).as_deref(), Some(instr));
assert_eq!(paras[header + 1].plain_text(), "Kilns\t1");
assert_eq!(paras[header + 1].props.tabs.as_ref().unwrap()[0].leader, leader);
}
}
}
}
+26 -24
View File
@@ -332,6 +332,7 @@ mod tests {
/// Drawing commands must not search every page again for each glued connector.
#[test]
#[cfg_attr(coverage, ignore = "coverage instrumentation skews the measured time")]
fn rerouting_many_pages_does_not_rescan_all_objects_per_connector() {
use wordcraft_doc::{Document, Paragraph, para_block};
fn glued_pages(n: u32) -> Session {
@@ -362,33 +363,34 @@ mod tests {
assert_eq!(s.layout().pages.len(), n as usize);
s
}
const SMALL: u32 = 32;
const SCALE: u32 = 8;
let mut small = glued_pages(SMALL);
let mut big = glued_pages(SMALL * SCALE);
let layout = big.layout();
let small_steps = wordcraft_doc::work::count(|| assert!(reroute(&mut small)));
let big_steps = wordcraft_doc::work::count(|| assert!(reroute(&mut big)));
// One layout walk to build the index plus bounded work per connector: roughly 8x the
// steps for 8x the pages. Allow room for fixed differences in the first and last pages.
let budget = small_steps * 12;
assert!(small_steps > 0 && big_steps > small_steps, "reroute steps: {small_steps} -> {big_steps}");
assert!(big_steps <= budget, "reroute repeated lookup work: {small_steps} -> {big_steps} steps for {SCALE}x pages");
// The previous lookup starts at the caret's page for every connector. Run just that
// part of the old route to verify it would exceed the same budget on this fixture.
let connector_off = 2 * wordcraft_doc::para::OBJ.len_utf8();
let scan_steps = wordcraft_doc::work::count(|| {
for page in 0..layout.pages.len() {
let hit = layout.object(&Pos::body(page, connector_off), 0).unwrap();
assert_eq!(hit.page, page);
// Use the running thread's CPU time on Linux; scheduler pauses are not reroute work.
fn cpu_cost(mut f: impl FnMut()) -> f64 {
let ran = || std::fs::read_to_string("/proc/thread-self/schedstat").ok()?.split_whitespace().next()?.parse::<u64>().ok();
let (wall, before) = (std::time::Instant::now(), ran());
f();
match (before, ran()) {
(Some(a), Some(b)) if b > a => (b - a) as f64 * 1e-9,
_ => wall.elapsed().as_secs_f64(),
}
});
assert!(scan_steps > budget, "per-connector scans took only {scan_steps} steps for a budget of {budget}");
}
const SMALL: u32 = 500;
const SCALE: u32 = 8;
let (mut small_min, mut big_min) = (f64::INFINITY, f64::INFINITY);
let mut last_big = None;
for _ in 0..3 {
let mut small = glued_pages(SMALL);
small_min = small_min.min(cpu_cost(|| assert!(reroute(&mut small))));
let mut big = glued_pages(SMALL * SCALE);
big_min = big_min.min(cpu_cost(|| assert!(reroute(&mut big))));
last_big = Some(big);
}
let ratio = big_min / small_min.max(1e-9);
eprintln!("{SMALL} vs {} pages reroute: {small_min:.4}s vs {big_min:.4}s (ratio {ratio:.2}x)", SMALL * SCALE);
assert!(ratio < SCALE as f64 * 3.0, "reroute scaled superlinearly: {small_min:.4}s -> {big_min:.4}s ({ratio:.2}x for {SCALE}x pages)");
let mut big = last_big.unwrap();
for path in big.doc.para_paths(StoryRef::Body) {
let para = big.doc.para(StoryRef::Body, &path).unwrap();
let InlineObject::Shape { w, h, float, .. } = para.object_at(connector_off).unwrap() else { panic!("connector") };
let InlineObject::Shape { w, h, float, .. } = para.object_at(6).unwrap() else { panic!("connector") };
assert_eq!((*w, *h, float.x, float.y), (160.0, 0.0, 140.0, 210.0));
}
big.touch();
+4 -13
View File
@@ -7,9 +7,6 @@ use wordcraft_doc::{Path, Pos, StoryRef};
use super::{delete_selection, find_pattern, pos_json, sel_result};
use crate::{CmdError, CmdResult, CommandSpec, Selection, Session, p};
/// Ribbon location of the linked Cut, Copy and Paste commands.
pub const LINKED_CLIPBOARD_LOCATION: &str = "Home › Clipboard";
/// Browsers reserve Mod+Shift+C for their inspector. Keep the desktop binding, but
/// advertise a web alternative through the same registry/keymap as every other command.
/// Mod+Alt+C already inserts copyright, and Mod+Alt+Shift+V is Keep Text Only.
@@ -75,8 +72,8 @@ pub fn specs() -> Vec<CommandSpec> {
})
.key("Mod+Y / Mod+Shift+Z")
.pure(),
CommandSpec::new("edit.cut", "Cut", LINKED_CLIPBOARD_LOCATION, cut).key("Mod+X").when(has_sel),
CommandSpec::new("edit.copy", "Copy", LINKED_CLIPBOARD_LOCATION, copy).key("Mod+C / Mod+Insert").pure().when(has_sel),
CommandSpec::new("edit.cut", "Cut", "Home › Clipboard", cut).key("Mod+X").when(has_sel),
CommandSpec::new("edit.copy", "Copy", "Home › Clipboard", copy).key("Mod+C / Mod+Insert").pure().when(has_sel),
// Word's Spike (Ctrl+F3, Ctrl+Shift+F3; ⌘ on the Mac): the AutoText entry "Spike", so Quick
// Parts and AutoText insert it without emptying it, as in Word.
CommandSpec::new("edit.spike", "Spike", "Editing", spike).key("Mod+F3").when(has_text_sel),
@@ -89,7 +86,7 @@ pub fn specs() -> Vec<CommandSpec> {
Some("the Spike is empty")
}
}),
CommandSpec::new("edit.paste", "Paste", LINKED_CLIPBOARD_LOCATION, paste)
CommandSpec::new("edit.paste", "Paste", "Home › Clipboard", paste)
.key("Mod+V / Shift+Insert")
.params(r#"{"text"?: string, "html"?: string, "rtf"?: string, "privateClipboard"?: bool}"#),
CommandSpec::new("edit.pasteNestedTable", "Paste as Nested Table", "Home › Clipboard › Paste", paste_nested)
@@ -860,16 +857,10 @@ fn replace_all(s: &mut Session, v: &Value) -> CmdResult {
found.push(results);
}
let n: usize = found.iter().map(Vec::len).sum();
let saved_sel = s.sel.clone();
let orig_story_matched = found.iter().any(|r| r[0].a.story == saved_sel.focus.story);
// The main text comes last, so under Track Changes the caret ends where it did before;
// when the original story had no match, restore the selection so it stays there.
// The main text comes last, so under Track Changes the caret ends where it did before.
for results in found.into_iter().rev() {
replace_found(s, results)?;
}
if s.doc.settings.track_changes && !orig_story_matched {
s.sel = saved_sel;
}
s.status = format!("All done. We made {n} replacements.");
Ok(json!({"replaced": n}))
}
+5 -182
View File
@@ -9,8 +9,6 @@ use wordcraft_doc::para::InlineObject;
use wordcraft_doc::props::{CharProps, TabAlign, TabLeader, TabStop};
use wordcraft_doc::section::SectionStart;
use wordcraft_doc::{Block, Paragraph, Path, Pos, StoryRef};
use wordcraft_layout::para::ClKind;
use wordcraft_layout::{DocLayout, Placed, ViewMode};
use super::references::{FieldCode, field_arg, leader, page_at, page_formats, page_text};
use super::sel_result;
@@ -138,98 +136,6 @@ fn index_field(s: &Session) -> Option<(usize, String)> {
})
}
fn laid_out_leader(layout: &DocLayout, path: Path, offset: usize) -> Option<TabLeader> {
layout.index.get(&(StoryRef::Body, path))?.iter().find_map(|&(page, item)| {
let Placed::Lines { para, l0, l1, .. } = layout.pages.get(page)?.items.get(item)? else { return None };
para.lines.get(*l0..*l1)?.iter().find_map(|line| {
let tab = (line.c0..line.c1).find(|&i| para.clusters.get(i).is_some_and(|c| c.start == offset && c.kind == ClKind::Tab))?;
Some(line.leaders.iter().find(|&&(i, _)| i == tab).map_or(TabLeader::None, |&(_, leader)| leader))
})
})
}
/// Read the leader of the first page-number tab that is laid out. Layout chooses the next
/// stop after the text, including inherited and non-right stops.
fn entry_leader(s: &mut Session, tabs: &[(usize, usize)]) -> Option<TabLeader> {
if tabs.is_empty() {
return None;
}
let from_layout = |layout: &DocLayout| tabs.iter().find_map(|&(block, offset)| laid_out_leader(layout, Path::top(block), offset));
// A screen view can reflow the index to a different width or hide its result.
if !s.view.read_mode
&& s.view.mode == ViewMode::Print
&& !s.view.field_codes
&& let Some(leader) = from_layout(&s.layout())
{
return Some(leader);
}
if let Some(leader) = from_layout(&s.output_layout_of(&s.doc, false, false)) {
return Some(leader);
}
// Measure hidden separators without revealing other hidden text, which could move the tab
// past a different stop. The measurement leaves the document and view unchanged.
let mut measurement = s.doc.clone();
for &(block, offset) in tabs {
if let Ok(p) = measurement.para_mut(StoryRef::Body, &Path::top(block)) {
let _ = p.format(offset, offset + 1, &|props| props.hidden = Some(false));
}
}
if let Some(leader) = from_layout(&s.output_layout_of(&measurement, false, false)) {
return Some(leader);
}
// If the tab is still absent, retain an unambiguous saved leader.
let mut saved = tabs
.iter()
.filter_map(|&(block, _)| s.doc.body.get(block)?.as_para())
.flat_map(|p| s.doc.styles.resolve_para(&p.props).tabs)
.map(|tab| tab.leader);
let leader = saved.next()?;
saved.all(|other| other == leader).then_some(leader)
}
fn inline_entry_leader(s: &mut Session, i: usize) -> Option<TabLeader> {
let tabs: Vec<_> = s
.doc
.body
.iter()
.enumerate()
.skip(i + 1)
.map_while(|(j, b)| Some((j, b.as_para().filter(|p| super::citations::is_list_entry(p))?)))
.filter_map(|(j, p)| p.text.rfind('\t').map(|offset| (j, offset)))
.collect();
entry_leader(s, &tabs)
}
/// Read the leader before replacing a wrapped INDEX result, within the field's bounds.
pub(in crate::cmd) fn wrapped_entry_leader(s: &mut Session, i: usize, start: usize, last: usize, end: usize) -> Option<TabLeader> {
let tabs: Vec<_> = (i..=last)
.filter_map(|j| {
let p = s.doc.body.get(j)?.as_para()?;
let from = if j == i { start } else { 0 };
let to = if j == last { end } else { p.len() };
p.text.get(from..to)?.rfind('\t').map(|offset| (j, from + offset))
})
.collect();
entry_leader(s, &tabs)
}
/// The index Insert Index will update and the leader its current result shows.
pub fn index_settings(s: &mut Session) -> Option<(FieldCode, Option<TabLeader>)> {
if let Some((i, instr)) = index_field(s) {
let leader = inline_entry_leader(s, i);
return Some((FieldCode::parse(&instr), leader));
}
(0..s.doc.body.len()).find_map(|i| {
let (instr, start, last, end) = super::citations::wrapped_list(s, i)?;
let field = FieldCode::parse(&instr);
if field.name != "INDEX" {
return None;
}
Some((field, wrapped_entry_leader(s, i, start, last, end)))
})
}
/// Whether an INDEX field (a plain one or a range field, as Word files hold it) sits in the main
/// text's own paragraphs (`main`), or anywhere else a reader sees: a table cell, a text box, a
/// header or a footer in use. Stored headers and footers no page shows (a first-page header
@@ -282,7 +188,6 @@ fn range_index_after_text(s: &Session) -> bool {
fn insert_index(s: &mut Session, v: &Value) -> CmdResult {
let instr = index_instr(v);
check_index_reachable(s)?;
let leader = p::str(v, "tabLeader").map(leader).or_else(|| index_settings(s).and_then(|(_, leader)| leader)).unwrap_or(TabLeader::Dot);
// An index Word wrote as a range field is first made a plain field in its own paragraph, as
// Update Index makes it, so it takes the new settings rather than a second index being added
// beside it (#8034).
@@ -308,7 +213,7 @@ fn insert_index(s: &mut Session, v: &Value) -> CmdResult {
None => super::citations::generated_list(s, &instr, "Index")?,
}
if let Some((i, _)) = index_field(s) {
rebuild(s, i, Some(leader))?;
rebuild(s, i, p::str(v, "tabLeader").map(leader))?;
}
s.clamp_selection();
sel_result(s)
@@ -434,18 +339,16 @@ pub fn rebuild(s: &mut Session, i: usize, leader: Option<TabLeader>) -> Result<(
pub fn rebuild_from(s: &mut Session, i: usize, leader: Option<TabLeader>, instr: String) -> Result<(), CmdError> {
let f = FieldCode::parse(&instr);
// Old entries go; keep their leader and the section their columns had.
let leader = leader.or_else(|| inline_entry_leader(s, i)).unwrap_or(TabLeader::Dot);
let old_len = s.doc.body.len();
let mut old_leader = None;
let mut old_sect = None;
while let Some(p) = s.doc.body.get(i + 1).and_then(|b| b.as_para()).filter(|p| super::citations::is_list_entry(p)) {
while let Some(p) = s.doc.body.get(i + 1).and_then(|b| b.as_para()).filter(|p| p.props.style.as_deref() == Some(ENTRY_STYLE)) {
old_leader = old_leader.or_else(|| p.props.tabs.as_ref().and_then(|t| t.last()).map(|t| t.leader));
if p.section.is_some() {
old_sect = p.section.clone();
}
s.doc.remove_block(StoryRef::Body, &Path::top(i + 1))?;
}
if s.doc.body.len() != old_len {
s.touch();
}
let leader = leader.or(old_leader).unwrap_or(TabLeader::Dot);
let cols = f.arg('c').and_then(|c| c.trim().parse::<u32>().ok()).unwrap_or(1).clamp(1, 4);
let sep = f.arg('e').map(str::to_string).unwrap_or_else(|| ", ".into());
let run_in = f.has('r');
@@ -642,86 +545,6 @@ mod tests {
assert_eq!(s.doc.body[i + 2].as_para().unwrap().props.tabs.as_ref().unwrap()[0].leader, TabLeader::Hyphen);
}
#[test]
fn index_keeps_the_leader_used_by_the_page_number_tab() {
use std::sync::Arc;
let mut s = Session::new(wordcraft_doc::Document::from_text("Kilns are hot."));
s.run("references.markEntry", &json!({"entry": "Kilns"})).unwrap();
s.run("caret.docEnd", &json!({})).unwrap();
s.run("references.index", &json!({"rightAlign": true, "headings": false, "tabLeader": "hyphen"})).unwrap();
let (i, _) = index_field(&s).unwrap();
let path = Path::top(i + 1);
assert_eq!(s.doc.para(StoryRef::Body, &path).unwrap().plain_text(), "Kilns\t1");
for (align, leader, inherit_later_stop) in
[(TabAlign::Left, TabLeader::Underscore, false), (TabAlign::Right, TabLeader::Hyphen, true), (TabAlign::Left, TabLeader::None, true)]
{
let generated_pos = s.doc.para(StoryRef::Body, &path).unwrap().props.tabs.as_ref().unwrap()[0].pos;
Arc::make_mut(&mut s.doc.styles).get_mut(ENTRY_STYLE).unwrap().para.tabs =
inherit_later_stop.then(|| vec![TabStop { pos: generated_pos + 0.75, align: TabAlign::Right, leader: TabLeader::Dot }]);
let entry = s.doc.para_mut(StoryRef::Body, &path).unwrap();
// The text already runs past the first stop. The next one wins over the later style stop.
entry.props.tabs = Some(vec![TabStop { pos: 5.0, align: TabAlign::Right, leader: TabLeader::Dot }, TabStop { pos: 90.0, align, leader }]);
entry.touch();
s.touch();
assert_eq!(index_settings(&mut s).unwrap().1, Some(leader), "{align:?}, {inherit_later_stop}");
s.run("references.updateIndex", &json!({})).unwrap();
assert_eq!(index_settings(&mut s).unwrap().1, Some(leader), "kept on update: {align:?}, {inherit_later_stop}");
}
// Updating an imported field consumes the result, so its tab must be read before conversion.
let (_, instr) = index_field(&s).unwrap();
let header = s.doc.para_mut(StoryRef::Body, &Path::top(i)).unwrap();
let offset = header.object_offsets()[0];
header.delete(0, offset).unwrap();
header.objects[0] = InlineObject::FieldStart { instr, locked: false, dirty: false };
header.touch();
let entry = s.doc.para_mut(StoryRef::Body, &path).unwrap();
entry.props.tabs = Some(vec![TabStop { pos: 90.0, align: TabAlign::Center, leader: TabLeader::Hyphen }]);
entry.insert_object(entry.len(), InlineObject::FieldEnd, &CharProps::default()).unwrap();
s.touch();
assert_eq!(index_settings(&mut s).unwrap().1, Some(TabLeader::Hyphen));
s.run("references.updateIndex", &json!({})).unwrap();
assert!(s.doc.field_ranges(StoryRef::Body).is_empty());
assert_eq!(index_settings(&mut s).unwrap().1, Some(TabLeader::Hyphen), "kept through wrapped field conversion");
}
#[test]
fn index_keeps_the_page_number_leader_when_the_first_tab_is_hidden() {
let mut s = Session::new(wordcraft_doc::Document::from_text("Kilns and wheels."));
s.view.marks = false;
s.prefs.marks.hidden = false;
for entry in ["Kilns", "Wheels"] {
s.run("references.markEntry", &json!({"entry": entry})).unwrap();
}
s.run("caret.docEnd", &json!({})).unwrap();
s.run("references.index", &json!({"rightAlign": true, "headings": false, "tabLeader": "hyphen"})).unwrap();
let (i, _) = index_field(&s).unwrap();
assert_eq!(index_lines(&s), ["Kilns\t1", "Wheels\t1"]);
for (first, second, hide_second, expected) in [
(TabLeader::Dot, TabLeader::Hyphen, false, TabLeader::Hyphen),
(TabLeader::Hyphen, TabLeader::Hyphen, true, TabLeader::Hyphen),
(TabLeader::Hyphen, TabLeader::None, false, TabLeader::None),
] {
for (block, leader, hidden) in [(i + 1, first, true), (i + 2, second, hide_second)] {
let p = s.doc.para_mut(StoryRef::Body, &Path::top(block)).unwrap();
p.props.tabs.as_mut().unwrap()[0].leader = leader;
let tab = p.text.rfind('\t').unwrap();
p.format(tab, tab + 1, &|props| props.hidden = Some(hidden)).unwrap();
}
s.touch();
let l = s.layout();
assert_eq!(laid_out_leader(&l, Path::top(i + 1), "Kilns".len()), None, "the hidden tab has no layout leader");
assert_eq!(laid_out_leader(&l, Path::top(i + 2), "Wheels".len()), (!hide_second).then_some(second));
assert_eq!(index_settings(&mut s).unwrap().1, Some(expected));
s.run("references.updateIndex", &json!({})).unwrap();
assert_eq!(index_settings(&mut s).unwrap().1, Some(expected), "kept on update");
}
}
/// #3670: an index in a table cell or a text box (as imported documents have it) can't be
/// rebuilt where it is, so Insert and Update Index say so, and Insert Index doesn't add a
/// second index at the caret.
+2 -7
View File
@@ -14,7 +14,7 @@ mod links;
mod objects;
pub(crate) use header_footer::saved_copy;
use header_footer::{create_hf, edit_hf, header_footer, new_empty_headers, remove_first_hf, strip_headers};
use header_footer::{create_hf, edit_hf, header_footer, new_empty_headers, strip_headers};
pub use items::{
DropCapState, default_date_picture, default_time_picture, drop_cap_state, format_date, format_date_at, format_date_at_in, format_date_in,
format_date_parts, format_date_parts_in,
@@ -102,9 +102,6 @@ pub fn specs() -> Vec<CommandSpec> {
sel_result(s)
}),
CommandSpec::new("insert.removeHeader", "Remove Header", "Insert › Header & Footer › Header", |s, _| {
if remove_first_hf(s, true)? {
return sel_result(s);
}
s.doc.last_section.headers = Default::default();
for path in s.doc.para_paths(StoryRef::Body) {
if s.doc.para(StoryRef::Body, &path).is_some_and(|p| p.section.is_some())
@@ -117,9 +114,7 @@ pub fn specs() -> Vec<CommandSpec> {
sel_result(s)
}),
CommandSpec::new("insert.removeFooter", "Remove Footer", "Insert › Header & Footer › Footer", |s, _| {
if !remove_first_hf(s, false)? {
s.doc.last_section.footers = Default::default();
}
s.doc.last_section.footers = Default::default();
sel_result(s)
}),
CommandSpec::new("insert.dateTime", "Date & Time", "Insert › Text", date_time).params(r#"{"format"?: "M/d/yyyy", "update"?: bool, "language"?: "en-US|pt-BR"}"#),
@@ -120,35 +120,6 @@ pub(super) fn edit_hf(s: &mut Session, v: &Value, header: bool) -> CmdResult {
Ok(json!({"story": id}))
}
/// Remove the first-page variant while it is being edited, keeping the other page variants.
pub(super) fn remove_first_hf(s: &mut Session, header: bool) -> Result<bool, CmdError> {
let StoryRef::Part(story) = s.sel.focus.story else { return Ok(false) };
let page = s.page_hint;
let layout = s.layout();
let Some(page) = layout.pages.get(page) else { return Ok(false) };
let shown = if header { page.header_story } else { page.footer_story };
if page.hf_slot != wordcraft_layout::HfSlot::First || shown != Some(story) {
return Ok(false);
}
let index = page.section;
let sections = s.doc.sections();
let Some(&(end, _)) = sections.get(index) else { return Ok(false) };
let last = index + 1 == sections.len();
let inherits_first = sections[..index].iter().any(|(_, sec)| if header { sec.headers.first.is_some() } else { sec.footers.first.is_some() });
// An absent slot would show the previous section's first-page story again.
let replacement = if inherits_first {
let (kind, style) = if header { (PartKind::Header, "Header") } else { (PartKind::Footer, "Footer") };
Some(s.doc.try_add_part(kind, vec![para_block(Paragraph::new().styled(style))])?)
} else {
None
};
let section = if last { &mut s.doc.last_section } else { s.doc.section_mut(end) };
let set = if header { &mut section.headers } else { &mut section.footers };
set.first = replacement;
s.sel = s.hf_return.take().unwrap_or_else(|| Selection::caret(s.doc.start_of(StoryRef::Body)));
Ok(true)
}
/// The header (or footer) page `page` shows, if any; an error for a page that isn't there.
fn shown_hf(s: &mut Session, page: usize, header: bool) -> Result<Option<u32>, CmdError> {
let layout = s.layout();
-102
View File
@@ -133,108 +133,6 @@ fn different_first_page_header_is_reachable_from_page_one() {
assert_eq!((s.doc.last_section.footers.first, s.doc.last_section.footers.default), (Some(foot), None));
}
#[test]
fn removing_a_first_page_header_or_footer_keeps_the_default() {
let mut s = two_pages();
s.run("layout.differentFirstPage", &json!({"value": true})).unwrap();
for (cmd, page, text) in [
("insert.editHeader", 0, "Cover header"),
("insert.editHeader", 1, "Default header"),
("insert.editFooter", 0, "Cover footer"),
("insert.editFooter", 1, "Default footer"),
] {
s.run(cmd, &json!({"page": page})).unwrap();
s.run("text.insert", &json!({"text": text})).unwrap();
s.run("insert.closeHeader", &json!({})).unwrap();
}
let page_stories = |s: &mut Session| {
let pages = &s.layout().pages;
assert_eq!(pages.len(), 2);
[(pages[0].header_story, pages[0].footer_story), (pages[1].header_story, pages[1].footer_story)]
};
let [first, default] = page_stories(&mut s);
assert!(first.0.is_some() && first.1.is_some());
assert!(default.0.is_some() && default.1.is_some());
assert_ne!(first, default);
s.run("insert.editHeader", &json!({"page": 0})).unwrap();
s.run("insert.removeHeader", &json!({})).unwrap();
assert_eq!(page_stories(&mut s), [(None, first.1), default]);
assert_eq!(s.sel.focus.story, StoryRef::Body);
s.run("edit.undo", &json!({})).unwrap();
assert_eq!(page_stories(&mut s), [first, default]);
s.run("insert.closeHeader", &json!({})).unwrap();
s.run("insert.editFooter", &json!({"page": 0})).unwrap();
s.run("insert.removeFooter", &json!({})).unwrap();
assert_eq!(page_stories(&mut s), [(first.0, None), default]);
assert_eq!(s.sel.focus.story, StoryRef::Body);
s.run("edit.undo", &json!({})).unwrap();
assert_eq!(page_stories(&mut s), [first, default]);
}
#[test]
fn refused_first_page_removal_keeps_the_selection_for_close_header_and_footer() {
let mut s = two_pages();
s.run("layout.differentFirstPage", &json!({"value": true})).unwrap();
for (edit, text) in [("insert.editHeader", "Cover header"), ("insert.editFooter", "Cover footer")] {
s.run(edit, &json!({"page": 0})).unwrap();
s.run("text.insert", &json!({"text": text})).unwrap();
s.run("insert.closeHeader", &json!({})).unwrap();
}
s.run("select.text", &json!({"text": "Two"})).unwrap();
s.run("review.restrict", &json!({"exception": "add"})).unwrap();
s.run("review.restrict", &json!({"mode": "readOnly"})).unwrap();
let body_selection = s.sel.clone();
assert_eq!(s.selected_text(), "Two");
let before = s.doc.clone();
for (edit, remove) in [("insert.editHeader", "insert.removeHeader"), ("insert.editFooter", "insert.removeFooter")] {
s.run(edit, &json!({"page": 0})).unwrap();
let editing = s.sel.clone();
assert!(s.in_header_footer());
let error = s.run(remove, &json!({})).unwrap_err().to_string();
assert!(error.contains("only the editable regions"), "{error}");
assert_eq!(s.doc, before);
assert_eq!(s.sel, editing, "the refusal leaves the editor in the first-page story");
s.run("insert.closeHeader", &json!({})).unwrap();
assert_eq!(s.sel, body_selection, "explicit Close returns to the saved selection after {remove}");
}
}
#[test]
fn removing_an_inherited_first_page_header_keeps_the_previous_section() {
let mut s = two_pages();
s.run("layout.differentFirstPage", &json!({"value": true})).unwrap();
let first = s.run("insert.editHeader", &json!({"page": 0})).unwrap()["story"].as_u64().unwrap() as u32;
s.run("text.insert", &json!({"text": "Cover header"})).unwrap();
s.run("insert.closeHeader", &json!({})).unwrap();
s.run("layout.break", &json!({"kind": "nextPage"})).unwrap();
s.run("text.insert", &json!({"text": "Section two"})).unwrap();
s.run("layout.differentFirstPage", &json!({"value": true})).unwrap();
// Start with a linked first-page slot in the later section.
s.doc.last_section.headers.first = None;
s.touch();
let page = s.layout().pages.iter().position(|page| page.section == 1).unwrap();
assert_eq!(s.layout().pages[page].header_story, Some(first));
s.run("insert.editHeader", &json!({"page": page})).unwrap();
s.run("insert.removeHeader", &json!({})).unwrap();
let blank = s.doc.last_section.headers.first.unwrap();
assert_ne!(blank, first);
assert_eq!(s.layout().pages[0].header_story, Some(first));
assert_eq!(s.layout().pages[page].header_story, Some(blank));
assert!(s.doc.para(StoryRef::Part(blank), &Path(vec![0])).unwrap().text.is_empty());
let saved = wordcraft_docx::write(&s.doc).unwrap();
let mut reopened = Session::new(wordcraft_docx::read(&saved).unwrap());
let reopened_layout = reopened.layout();
let cover = reopened_layout.pages[0].header_story.unwrap();
let blank = reopened_layout.pages.iter().find(|page| page.section == 1).unwrap().header_story.unwrap();
assert_eq!(reopened.doc.para(StoryRef::Part(cover), &Path(vec![0])).unwrap().text.as_str(), "Cover header");
assert!(reopened.doc.para(StoryRef::Part(blank), &Path(vec![0])).unwrap().text.is_empty());
}
fn two_pages() -> Session {
let mut s = Session::new(wordcraft_doc::Document::new());
s.run("text.insert", &json!({"text": "One"})).unwrap();
+5 -67
View File
@@ -287,30 +287,6 @@ fn prepare_custom_dictionary(s: &Session, setting: Option<&str>) -> Result<(Opti
}
}
/// The user's home folder: `USERPROFILE` first on Windows, `HOME` first elsewhere, skipping
/// empty values. The recent list reads it in the same order (#8865), so `~/…` means one folder.
fn home_dir() -> Option<std::path::PathBuf> {
home_from(std::env::var_os("HOME"), std::env::var_os("USERPROFILE"))
}
/// [`home_dir`] without the environment: the order the two values are read in depends on the
/// platform, so it takes them as they are read.
fn home_from(home: Option<std::ffi::OsString>, userprofile: Option<std::ffi::OsString>) -> Option<std::path::PathBuf> {
let set = |v: Option<std::ffi::OsString>| v.filter(|h| !h.is_empty()).map(std::path::PathBuf::from);
let (first, second) = if cfg!(windows) { (userprofile, home) } else { (home, userprofile) };
set(first).or_else(|| set(second))
}
/// The path a folder setting names: `~/…` under the home folder, or the path as given. With no
/// home folder to expand under, `~/` is refused rather than left as a relative path.
fn expand_home(key: &str, f: &str, home: Option<&std::path::Path>) -> Result<std::path::PathBuf, CmdError> {
match (f.strip_prefix("~/"), home) {
(Some(rest), Some(h)) => Ok(h.join(rest)),
(Some(_), None) => Err(CmdError::Params(format!("`{key}`: cannot expand `~/` because HOME or USERPROFILE is not set"))),
(None, _) => Ok(std::path::PathBuf::from(f)),
}
}
/// A folder setting (`dictionariesFolder`, `userTemplatesFolder`): `auto` (or nothing) forgets
/// it; otherwise an existing folder, given as an absolute path or one starting with `~/`. With
/// `local_only`, a network folder is refused before anything looks at it (#2852): even checking
@@ -323,7 +299,11 @@ fn folder_setting(key: &str, f: &str, local_only: bool) -> Result<Option<String>
if f.chars().count() > MAX_FOLDER_CHARS || f.chars().any(char::is_control) {
return Err(CmdError::Params(format!("`{key}` isn't a folder path")));
}
let path = expand_home(key, f, home_dir().as_deref())?;
let home = std::env::var_os("HOME").filter(|h| !h.is_empty()).map(std::path::PathBuf::from);
let path = match (f.strip_prefix("~/"), home) {
(Some(rest), Some(h)) => h.join(rest),
_ => std::path::PathBuf::from(f),
};
if local_only && (super::templates::is_network_path(f) || super::templates::is_network_path(&path.to_string_lossy())) {
return Err(CmdError::Params(format!("`{key}` can't be a network folder")));
}
@@ -375,45 +355,3 @@ fn file_setting(key: &str, f: &str) -> Result<Option<String>, CmdError> {
pub fn use_dictionaries_folder(folder: Option<&str>) {
wordcraft_proof::set_dictionaries_folder(folder.map(std::path::PathBuf::from));
}
#[cfg(test)]
mod tests {
use super::{expand_home, home_from};
use std::ffi::OsString;
use std::path::{Path, PathBuf};
fn os(s: &str) -> Option<OsString> {
Some(OsString::from(s))
}
#[test]
fn the_home_folder_is_the_profile_folder_on_windows_and_home_elsewhere() {
let home = home_from(os("/home/u"), os("C:\\Users\\u"));
let expected = if cfg!(windows) { PathBuf::from("C:\\Users\\u") } else { PathBuf::from("/home/u") };
assert_eq!(home, Some(expected));
}
#[test]
fn an_empty_home_folder_is_skipped_for_the_other_one() {
assert_eq!(home_from(os(""), os("C:\\Users\\u")), Some(PathBuf::from("C:\\Users\\u")));
assert_eq!(home_from(os(""), None), None);
}
#[test]
fn no_home_folder_at_all_expands_to_nothing() {
assert_eq!(home_from(None, None), None);
}
#[test]
fn a_tilde_path_expands_under_the_home_folder() {
let home = Path::new("/home/u");
assert_eq!(expand_home("dictionariesFolder", "~/dic", Some(home)).unwrap(), PathBuf::from("/home/u/dic"));
assert_eq!(expand_home("dictionariesFolder", "/abs/dic", Some(home)).unwrap(), PathBuf::from("/abs/dic"));
}
#[test]
fn a_tilde_path_without_a_home_folder_is_refused() {
let err = expand_home("dictionariesFolder", "~/dic", None).unwrap_err();
assert!(format!("{err:?}").contains("cannot expand"), "{err:?}");
}
}
-30
View File
@@ -1129,36 +1129,6 @@ fn a_missing_references_error_is_in_the_interface_language() {
assert_eq!(shown, [french, "Target"]);
}
#[test]
fn full_context_ref_keeps_an_ancestor_when_the_label_contains_literal_percent_zero() {
use std::sync::Arc;
use wordcraft_doc::numbering::Level;
use wordcraft_doc::props::NumRef;
use wordcraft_doc::{Document, ListKind};
for (template, own, full) in [("%0-%2.", "%0-1", "1%0-1"), ("%1-%2.", "1-1", "1-1"), ("(%2).", "(1)", "1(1)")] {
let mut doc = Document::from_text("Parent\nTarget\nRefs ");
let numbering = Arc::make_mut(&mut doc.numbering);
let num = numbering.add_list(ListKind::Numbered);
numbering.nums[0].level_overrides = vec![(1, Level { text: template.into(), ..Default::default() })];
for level in 0..=1u8 {
doc.para_mut(StoryRef::Body, &Path::top(usize::from(level))).unwrap().props.numbering = Some(NumRef { num, level });
}
let mut s = Session::new(doc);
s.run("select.text", &json!({"text": "Target"})).unwrap();
s.run("insert.bookmark", &json!({"name": "Mark"})).unwrap();
s.run("caret.docEnd", &json!({})).unwrap();
for instr in [r"REF Mark \n", r"REF Mark \w"] {
s.run("insert.field", &json!({"instr": instr})).unwrap();
s.run("text.insert", &json!({"text": " "})).unwrap();
}
let refs = stale_last_paragraph(&mut s, "stale");
update_fields(&mut s).unwrap();
assert_eq!(results_in(&s.doc, &refs), [own, full], "{template}");
}
}
/// A REF showing the bookmarked paragraph's number (`\r`, `\n`, `\w`), which output doesn't
/// compute, keeps its stored number when printed or exported rather than show the paragraph's
/// text; a plain REF to the same bookmark is filled in.
-3
View File
@@ -155,8 +155,6 @@ impl Session {
// Commands may leave an equation (a whole-body replacement) even after they fail; put
// the editing session back with the document.
let math_before = spec.mutates.then(|| self.math.clone());
// A header or footer edit can take its saved body selection before the protection check.
let hf_return_before = spec.mutates.then(|| self.hf_return.clone()).flatten();
let before_doc: Option<RunSnapshot> = if spec.mutates {
Some((
self.doc.clone(),
@@ -302,7 +300,6 @@ impl Session {
if let Some((d, s, h, r, t, ev, c)) = before_doc {
self.doc = d;
self.sel = s;
self.hf_return = hf_return_before;
self.history = h;
self.redo = r;
self.typing_open = t;
+17 -50
View File
@@ -15853,47 +15853,36 @@ fn page_down_and_up_move_by_a_page_in_the_continuous_views() {
#[test]
fn page_down_and_up_never_stay_on_a_line_in_the_continuous_views() {
use wordcraft_doc::props::LineSpacing;
// The text area is less than an inch high, so the views use a 72 pt step. A step can cross
// different numbers of 30 pt lines in the two directions. Start inside the document so the
// test exercises movement in both directions without running into the first line.
let lead_in = 12;
let long = "Lorem ipsum dolor sit amet ".repeat(2);
let text = format!("{}{long}{}", "a\n".repeat(lead_in), "\na".repeat(60));
// A page with less than an inch of text area: the views move by the one-inch minimum. The
// caret ends a long line and the paragraphs after it are narrow (a large right indent): the
// line a page away, not the one the caret is on, is where Page Down goes, however far right
// of it the caret is.
for view in ["view.draft", "view.outline", "view.webLayout"] {
let mut s = Session::new(wordcraft_doc::Document::from_text(&text));
let mut s = s();
run(&mut s, "layout.margins", json!({"top": 370, "bottom": 370}));
for (i, path) in s.doc.para_paths(StoryRef::Body).iter().enumerate() {
let p = s.doc.para_mut(StoryRef::Body, path).unwrap();
p.props.space_before = Some(0.0);
p.props.space_after = Some(0.0);
p.props.line_spacing = Some(LineSpacing::Exactly(30.0));
if i != lead_in {
p.props.indent_right = Some(700.0);
let long = "Lorem ipsum dolor sit amet ".repeat(2);
run(&mut s, "text.insert", json!({"text": long}));
run(&mut s, "text.newParagraph", json!({}));
run(&mut s, "para.indents", json!({"right": 700}));
for i in 0..60 {
if i > 0 {
run(&mut s, "text.newParagraph", json!({}));
}
run(&mut s, "text.insert", json!({"text": "a"}));
}
run(&mut s, view, json!({}));
run(&mut s, "caret.set", json!({"pos": {"block": lead_in}}));
run(&mut s, "caret.docStart", json!({}));
run(&mut s, "caret.end", json!({}));
assert_eq!(s.sel.focus, Pos::body(lead_in, long.len()), "{view}: the long paragraph is one line");
assert_eq!(s.sel.focus.off, long.chars().count(), "{view}: the first paragraph is one line");
let mut at = s.sel.focus.clone();
let layout = s.layout();
let start = layout.caret(&at).unwrap();
let first = layout.caret(&Pos::body(0, 0)).unwrap();
assert!(start.top - first.top > 3.0 * 72.0, "{view}: there is room above the long line for all three reverse steps");
for step in 0..3 {
run(&mut s, "caret.pageDown", json!({}));
assert!(s.sel.focus.path > at.path, "{view}: Page Down {step} moves to a later paragraph from {at:?}");
assert!(s.sel.focus > at, "{view}: Page Down {step} moves on from {at:?}");
at = s.sel.focus.clone();
if step == 0 {
let next = s.layout().caret(&at).unwrap();
assert!(next.x < start.x, "{view}: the destination line ends left of the starting caret");
}
}
for step in 0..3 {
run(&mut s, "caret.pageUp", json!({}));
assert!(s.sel.focus.path < at.path, "{view}: Page Up {step} moves to an earlier paragraph from {at:?}");
assert!(s.sel.focus < at, "{view}: Page Up {step} moves back from {at:?}");
at = s.sel.focus.clone();
}
}
@@ -15982,28 +15971,6 @@ fn replace_all_replaces_in_every_story() {
assert!(story_text(&t, StoryRef::Part(ids[0])).contains("Jane"));
}
/// #9063: With Track Changes on, Replace All must not leave the caret in another story (e.g. a
/// header or footnote) when the caret's original story had no match.
#[test]
fn replace_all_with_track_changes_keeps_caret_when_original_story_has_no_match() {
use wordcraft_doc::StoryRef;
let mut t = s();
run(&mut t, "document.setText", json!({"text": "Main text only."}));
let header_id = run(&mut t, "insert.header", json!({"text": "Header: [NAME]"}))["story"].as_u64().unwrap() as u32;
t.sel = crate::session::Selection::caret(Pos::body(0, 0));
let before = t.sel.clone();
assert_eq!(before.focus.story, StoryRef::Body);
run(&mut t, "review.trackChanges", json!({"enabled": true}));
let r = run(&mut t, "edit.replaceAll", json!({"text": "[NAME]", "with": "Jane"}));
assert_eq!(r["replaced"], 1, "{r}");
assert_eq!(t.sel, before);
assert!(!t.in_header_footer());
assert!(
t.doc.para_at(&wordcraft_doc::Pos::new(StoryRef::Part(header_id), wordcraft_doc::Path::top(0), 0)).is_some_and(|p| p.text.contains("Jane"))
);
}
/// #9064: Replace All skips stories nothing shows any more (a removed header, a footnote whose
/// reference was deleted without tracking) and does not count them.
#[test]
-78
View File
@@ -4876,81 +4876,3 @@ fn enter_in_a_drop_cap_paragraph_makes_a_normal_paragraph() {
assert_eq!(second.drop_cap_font, None, "{position}");
}
}
/// #8986: Up/Down step along vertical lines and Left/Right cross stacked lines (preserving
/// goal distance, collapsing or extending selections, and falling back along the line when
/// there is no adjacent line in the flow) for both `tbRl` (`"down"`) and `btLr` (`"up"`).
#[test]
fn arrow_keys_navigate_vertical_text() {
use wordcraft_doc::Path;
let set = |s: &mut Session, anchor: Pos, focus: Pos| {
s.sel = crate::Selection { anchor, focus };
s.goal_x = None;
};
// 1. Top-to-bottom (`tbRl`): Down advances, Up retreats; Left goes to next line, Right to previous.
let mut doc = typed("abcd\nx\nabcd");
run(&mut doc, "layout.textDirection", json!({"value": "down"}));
set(&mut doc, Pos::body(0, 1), Pos::body(0, 1));
run(&mut doc, "caret.down", json!({}));
assert_eq!(doc.sel.focus, Pos::body(0, 2), "tbRl Down advances along the line");
run(&mut doc, "caret.up", json!({}));
assert_eq!(doc.sel.focus, Pos::body(0, 1), "tbRl Up moves back along the line");
set(&mut doc, Pos::body(0, 3), Pos::body(0, 3));
run(&mut doc, "caret.left", json!({}));
assert_eq!(doc.sel.focus, Pos::body(1, 1), "tbRl Left steps to the shorter next line");
run(&mut doc, "caret.left", json!({}));
assert_eq!(doc.sel.focus, Pos::body(2, 3), "tbRl Left keeps goal distance across the short middle line");
run(&mut doc, "caret.right", json!({}));
assert_eq!(doc.sel.focus, Pos::body(1, 1), "tbRl Right steps to the previous line");
run(&mut doc, "caret.right", json!({}));
assert_eq!(doc.sel.focus, Pos::body(0, 3), "tbRl Right returns to offset 3 with preserved goal distance");
set(&mut doc, Pos::body(0, 1), Pos::body(2, 2));
run(&mut doc, "caret.left", json!({}));
assert!(doc.sel.is_collapsed() && doc.sel.focus == Pos::body(2, 2), "tbRl Left collapses selection to end");
set(&mut doc, Pos::body(0, 1), Pos::body(2, 2));
run(&mut doc, "caret.right", json!({}));
assert!(doc.sel.is_collapsed() && doc.sel.focus == Pos::body(0, 1), "tbRl Right collapses selection to start");
set(&mut doc, Pos::body(1, 1), Pos::body(1, 1));
run(&mut doc, "caret.left", json!({"extend": true}));
assert_eq!((&doc.sel.anchor, &doc.sel.focus), (&Pos::body(1, 1), &Pos::body(2, 1)), "extend=true keeps anchor across lines");
// 2. Bottom-to-top (`btLr`): Up advances, Down retreats; Right goes to next line, Left to previous.
run(&mut doc, "layout.textDirection", json!({"value": "up"}));
set(&mut doc, Pos::body(0, 1), Pos::body(0, 1));
run(&mut doc, "caret.up", json!({}));
assert_eq!(doc.sel.focus, Pos::body(0, 2), "btLr Up advances along the line");
run(&mut doc, "caret.down", json!({}));
assert_eq!(doc.sel.focus, Pos::body(0, 1), "btLr Down moves back along the line");
set(&mut doc, Pos::body(0, 3), Pos::body(0, 3));
run(&mut doc, "caret.right", json!({}));
assert_eq!(doc.sel.focus, Pos::body(1, 1), "btLr Right steps to the shorter next line");
run(&mut doc, "caret.right", json!({}));
assert_eq!(doc.sel.focus, Pos::body(2, 3), "btLr Right keeps goal distance across the short middle line");
run(&mut doc, "caret.left", json!({}));
assert_eq!(doc.sel.focus, Pos::body(1, 1), "btLr Left steps to the previous line");
set(&mut doc, Pos::body(0, 1), Pos::body(2, 2));
run(&mut doc, "caret.left", json!({}));
assert!(doc.sel.is_collapsed() && doc.sel.focus == Pos::body(0, 1), "btLr Left collapses selection to start");
set(&mut doc, Pos::body(0, 1), Pos::body(2, 2));
run(&mut doc, "caret.right", json!({}));
assert!(doc.sel.is_collapsed() && doc.sel.focus == Pos::body(2, 2), "btLr Right collapses selection to end");
// 3. Single-line vertical table cell fallback: Left/Right stay inside the cell and step along its text.
let mut tbl = s();
run(&mut tbl, "insert.table", json!({"rows": 1, "cols": 2}));
run(&mut tbl, "text.insert", json!({"text": "abc"}));
run(&mut tbl, "table.textDirection", json!({"value": "down"}));
let cell0 = |off| Pos { story: StoryRef::Body, path: Path(vec![0, 0, 0, 0]), off };
set(&mut tbl, cell0(2), cell0(2));
run(&mut tbl, "caret.left", json!({}));
assert_eq!(tbl.sel.focus, cell0(1), "single-line vertical cell Left falls back backwards along text");
run(&mut tbl, "caret.right", json!({}));
assert_eq!(tbl.sel.focus, cell0(2), "single-line vertical cell Right falls back forwards along text");
}
+14 -61
View File
@@ -4,7 +4,7 @@
//! Export writes UTF-8 with CRLF line ends; list paragraphs get their label and a tab, table
//! cells are separated by tabs.
use wordcraft_doc::{Document, Paragraph, para_block};
use wordcraft_doc::Document;
pub use wordcraft_doc::encoding::cp1252;
@@ -66,24 +66,12 @@ pub fn decode_as(b: &[u8], label: &str) -> Option<String> {
Some(enc.decode(b).0.into_owned())
}
/// A document with one paragraph per line, with vertical tabs as manual line breaks.
/// A document with one paragraph per line.
pub fn import(bytes: &[u8]) -> Document {
let text = decode(bytes);
let text = text.replace("\r\n", "\n").replace('\r', "\n");
let clean: String = text.chars().filter(|c| !c.is_control() || matches!(c, '\n' | '\t' | '\u{000B}' | '\u{000C}' | '\u{000E}')).collect();
let mut doc = Document::new();
doc.body = clean
.split('\n')
.map(|line| {
let paragraph = if line.contains('\u{000B}') {
Paragraph::with_text(&line.replace('\u{000B}', "\n"), Default::default())
} else {
Paragraph::with_text(line, Default::default())
};
para_block(paragraph)
})
.collect();
doc
Document::from_text(&clean)
}
/// [`import`] onto `page`: plain text gives no page size (#1381).
@@ -106,12 +94,7 @@ fn blocks_text(blocks: &[FBlock], out: &mut Vec<String>, lists: &mut ListCounter
}
None => lists.reset(),
}
let text = p.shown_text();
if depth == 0 {
line.push_str(&text.replace('\n', "\r\n").replace(['\u{000C}', '\u{000E}'], ""));
} else {
line.push_str(&text.replace('\u{000C}', ""));
}
line.push_str(&p.shown_text().replace('\n', "\r\n").replace(['\u{000C}', '\u{000E}'], ""));
out.push(line);
}
FBlock::Table(t) => {
@@ -125,8 +108,8 @@ fn blocks_text(blocks: &[FBlock], out: &mut Vec<String>, lists: &mut ListCounter
} else {
let mut v = Vec::new();
blocks_text(&c.blocks, &mut v, &mut ListCounter::default(), depth + 1);
// Flatten breaks and tabs inside a field without changing its spacing.
cells.push(v.join(" ").replace("\r\n", " ").replace(['\t', '\r', '\n', '\u{000B}', '\u{000E}'], " "));
let text = v.join(" ").split_whitespace().collect::<Vec<_>>().join(" ");
cells.push(text);
}
for _ in 1..c.colspan.clamp(1, 63) {
cells.push(String::new());
@@ -155,8 +138,7 @@ pub fn export(doc: &Document) -> Vec<u8> {
mod tests {
use super::*;
use crate::model::{Cell, Fmt, Para};
use wordcraft_doc::para::{COLUMN_BREAK, LINE_BREAK, PAGE_BREAK};
use wordcraft_doc::{Block, CharProps, Paragraph, SectionProps, Table, para_block};
use wordcraft_doc::StoryRef;
#[test]
fn test_utf32_bom_decode_and_sniffing() {
@@ -182,39 +164,10 @@ mod tests {
#[test]
fn test_import_preserves_soft_breaks() {
let page = SectionProps { page_w: 432.0, ..Default::default() };
let doc = import_on(b"A\x0BB\nC\x0CD\x0EE\r\nF", &page);
let first = format!("A{LINE_BREAK}B");
let second = format!("C{PAGE_BREAK}D{COLUMN_BREAK}E");
assert_eq!(doc.body.len(), 3);
assert_eq!(doc.body[0].as_para().map(|p| p.text.as_str()), Some(first.as_str()));
assert_eq!(doc.body[1].as_para().map(|p| p.text.as_str()), Some(second.as_str()));
assert_eq!(doc.body[2].as_para().map(|p| p.text.as_str()), Some("F"));
assert_eq!(doc.last_section, page);
}
#[test]
fn imported_vertical_tab_round_trips_as_docx_line_break() -> Result<(), wordcraft_docx::DocxError> {
let doc = import(b"A\x0BB\nC");
let reopened = wordcraft_docx::read(&wordcraft_docx::write(&doc)?)?;
let first = format!("A{LINE_BREAK}B");
assert_eq!(reopened.body.len(), 2);
assert_eq!(reopened.body[0].as_para().map(|p| p.text.as_str()), Some(first.as_str()));
assert_eq!(reopened.body[1].as_para().map(|p| p.text.as_str()), Some("C"));
Ok(())
}
#[test]
fn test_txt_export_preserves_spaces_inside_table_cells() {
let paragraph = |text| para_block(Paragraph::with_text(text, CharProps::default()));
let mut table = Table::new(2, 2, 200.0);
table.rows[0].cells[0].blocks = vec![paragraph(" A\u{00A0}B C\tD\nE\u{000E}F"), paragraph("G\u{2009}H ")];
table.rows[0].cells[1].blocks = vec![paragraph("Right")];
table.rows[1].cells[1].blocks = vec![paragraph("Last")];
let mut doc = Document::new();
doc.body = vec![std::sync::Arc::new(Block::Table(table))];
assert_eq!(export(&doc), " A\u{00A0}B C D E F G\u{2009}H \tRight\r\n\tLast".as_bytes());
let raw = b"Line 1\x0BSoft break\x0ECol break";
let doc = import(raw);
let text = doc.plain_text(StoryRef::Body);
assert_eq!(text, "Line 1\u{000B}Soft break\u{000E}Col break");
}
#[test]
@@ -222,7 +175,7 @@ mod tests {
let mut t = crate::model::FTable::default();
let mut c1 = Cell { colspan: 2, ..Default::default() };
let mut p1 = Para::default();
p1.push_text("Merged\r\nHeader\tItem\rWith\u{000B}Breaks", &Fmt::default());
p1.push_text("Merged\nHeader\tItem", &Fmt::default());
c1.blocks.push(FBlock::Para(p1));
let mut c2 = Cell::default();
@@ -250,8 +203,8 @@ mod tests {
blocks_text(&blocks, &mut out, &mut ListCounter::default(), 0);
assert_eq!(out.len(), 2);
// The second field pads the two-column span of the first cell.
assert_eq!(out[0], "Merged Header Item With Breaks\t\tCol 3");
// Row 1: Merged Header Item (colspan 2) -> "Merged Header Item\t\tCol 3"
assert_eq!(out[0], "Merged Header Item\t\tCol 3");
// Row 2: Covered cell is empty -> "\tRow 2 Col 2\tRow 2 Col 3"
assert_eq!(out[1], "\tRow 2 Col 2\tRow 2 Col 3");
}
+2 -56
View File
@@ -652,39 +652,6 @@ impl<'a> Flow<'a> {
true
}
/// Keep with next for the end of a paragraph begun in an earlier column (#6829): in columns
/// being balanced, the piece holding its last line must leave room below for the next
/// paragraph to start (as [`Self::keep_together`] asks of a paragraph's start), or its last
/// lines (two under widow/orphan control) go over with that paragraph, as in Word. All of
/// them going over returns `l0`, and the caller moves on even from a column's top: the
/// balancing pass then runs onto another page and the columns are tried taller. Nothing
/// moves in the full-height pass that is the balancing's fallback, nor when the paragraph's
/// tail and the next paragraph's start could not fit a full column.
fn kept_tail_end(&self, ctx: &mut Ctx, pb: &PageBuilder, rooms: Rooms, fit: &Fit) -> usize {
let (rp, n, l0) = (&self.pl.rp, self.n(), self.l0);
// Not in the full-height fallback pass, which must keep the original layout.
let column = pb.uncapped_bottom() - pb.top;
let balancing = pb.balance.is_some_and(|(page, h)| page + 1 == pb.pages.len() && h + 0.01 < column);
if l0 == 0 || fit.l1 < n || fit.forced.is_some() || !rp.keep_next || !balancing || pb.web {
return fit.l1;
}
let (Some(first), Some(last)) = (self.pl.lines.get(l0), self.pl.lines.last()) else { return fit.l1 };
let tail = last.top + last.height - first.top + rooms.bottom;
let need = tail
+ gap_after(ctx, self.block, rp, self.label.is_some())
+ next_first_line(ctx, self.block, self.laid_width, 0, pb.next_starts_page, &mut ctx.counters.clone());
// A need no column can hold is left alone, as `keep_together` leaves it.
if pb.y + need <= pb.bottom + 0.01 || need > column + 0.01 {
return fit.l1;
}
let mut l1 = n.saturating_sub(if rp.widow_control { 2 } else { 1 }).max(l0);
// A row (text both sides of a floating object) stays together (`settled_end`).
while l1 > l0 && self.pl.lines.get(l1).is_some_and(|l| l.beside) {
l1 -= 1;
}
l1
}
/// The end of the lines on this page after widow/orphan control, and keeping the rows beside
/// floating objects together.
/// Also says whether, balancing from Word 2013's layout, widow/orphan control alone moved every
@@ -1113,14 +1080,11 @@ fn place_para_in_flow(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, block:
let notes = para_notes(ctx.doc, p, &f.pl);
let mut fit = f.fit_lines(ctx, pb, &notes, lead);
let (end, widowed) = f.settled_end(ctx, pb, &fit);
let settled = end;
fit.l1 = end;
fit.l1 = f.kept_tail_end(ctx, pb, rooms, &fit);
let kept_over = fit.l1 < settled;
// On a fresh column an unfitting line can overflow. Strict widow control instead moves
// the lines on without emitting anything and must release their late floats as well.
let overflow = fit.l1 == f.l0 && f.fresh(pb) && !widowed && !kept_over;
if f.settle_late(pb, fit.l1, overflow) {
let overflow = end == f.l0 && f.fresh(pb) && !widowed;
if f.settle_late(pb, end, overflow) {
continue;
}
if fit.l1 == f.l0 {
@@ -1262,24 +1226,6 @@ fn space_after_kept(ctx: &Ctx, block: usize, rp: &wordcraft_doc::resolve::Resolv
after
}
/// The room the space after body paragraph `block` adds between it and the paragraph after it,
/// beyond that paragraph's own space before (which [`next_first_line`] counts): the merged gap
/// (the larger of the two, ISO/IEC 29500-1 §17.3.1.9), or both when they are summed. Nothing when
/// contextual spacing or automatic spacing between list items drops it.
fn gap_after(ctx: &Ctx, block: usize, rp: &wordcraft_doc::resolve::ResolvedPara, listed: bool) -> f32 {
let after = space_after_kept(ctx, block, rp, listed);
if after <= 0.0 {
return 0.0;
}
let Some(Block::Para(next)) = ctx.doc.body.get(block + 1).map(|b| &**b) else { return after };
let nrp = ctx.doc.styles.resolve_para(&next.props);
// The next paragraph's contextual spacing, and automatic spacing between two list items,
// drop its own space before.
let dropped = (nrp.style == rp.style && nrp.contextual_spacing) || (listed && nrp.before_auto && ctx.has_label(next));
let before = if dropped { 0.0 } else { nrp.space_before.max(0.0) };
if ctx.doc.settings.sum_paragraph_spacing { after } else { (after - before).max(0.0) }
}
/// The room the paragraphs after `block` need on the page for keep with next: enough of the
/// next one to start there — its first line, two of its lines with widow/orphan control (it
/// doesn't leave a single line at the bottom of a page; it moves over whole instead), all three
+7 -10
View File
@@ -12,7 +12,7 @@ use crate::{DocLayout, Page, Placed};
/// Caret geometry on a page: a bar from (`x`, `top`) to (`x + width`, `top + height`). It is
/// upright (`width` 0) except in turned text (a table cell's text direction), where it lies
/// across the page (`height` 0).
/// across the page (`height` 0), and `turn` is the direction its line reads in.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Caret {
pub page: usize,
@@ -20,6 +20,7 @@ pub struct Caret {
pub top: f32,
pub height: f32,
pub width: f32,
pub turn: TextDirection,
}
/// An equation as [`DocLayout::equation_box`] finds it, in page coordinates: its left edge
@@ -141,8 +142,7 @@ fn all_objects(page: &Page, index: usize) -> impl Iterator<Item = ObjectHit> + '
}
fn objects_in(items: &[Placed], index: usize) -> impl Iterator<Item = ObjectHit> + '_ {
// Count each item inspected, including pages a lookup searches without finding its object.
items.iter().rev().inspect(|_| wordcraft_doc::work::steps(1)).filter_map(move |it| match it {
items.iter().rev().filter_map(move |it| match it {
Placed::Object { rect, spin, story, path, off, text_box, wrap, origin, .. } => Some(ObjectHit {
page: index,
rect: *rect,
@@ -758,7 +758,7 @@ impl DocLayout {
let base = top + (l.baseline - l.top);
let ctop = (base - asc).max(top);
let r = crate::turn_rect(*turn, *x, *y, Rect::new(cx, ctop, 0.0, (base + desc - ctop).max(4.0)));
return Some(Caret { page: pi, x: r.x, top: r.y, height: r.h, width: r.w });
return Some(Caret { page: pi, x: r.x, top: r.y, height: r.h, width: r.w, turn: *turn });
}
None
}
@@ -766,18 +766,15 @@ impl DocLayout {
/// The style run text typed at `pos` would take (the character's before it, or at the start
/// of a paragraph the first character's) and the baseline it sits on, on the page: `pos`'s
/// line's, raised or lowered by the run's shift (superscript, `w:position`). An input method's
/// composition is drawn with them, as Word draws it in the text's own font and size. `None` in
/// turned text, whose lines aren't horizontal.
/// composition is drawn with them, as Word draws it in the text's own font and size. In turned
/// text the baseline is meaningless (the lines aren't horizontal); use the run only.
pub fn typing_style(&self, pos: &Pos, page_hint: usize) -> Option<(StyleRun, f32)> {
for (_, it) in self.pieces(pos.story, &pos.path, page_hint) {
let Placed::Lines { para, l0, l1, y, turn, .. } = it else { continue };
let Placed::Lines { para, l0, l1, y, .. } = it else { continue };
let li = para.line_of(pos.off);
if li < *l0 || li >= *l1 {
continue;
}
if *turn != TextDirection::Horizontal {
return None;
}
let first = para.lines.get(*l0)?;
let line = para.lines.get(li)?;
let at = |off: usize| para.clusters.iter().find(|c| c.start <= off && off < c.end).and_then(|c| para.styles.get(c.style as usize));
+2 -2
View File
@@ -188,13 +188,13 @@ impl StyleIndex {
&& let Some((l, def)) = counters.next_label_indexed(&numbering, n.num, n.level)
&& def.format != NumFormat::Bullet
{
let vals = counters.counted_values_indexed(&numbering, n.num);
let vals = counters.values_indexed(&numbering, n.num).unwrap_or_default();
for (k, v) in vals.iter().enumerate().take(usize::from(n.level.min(8)) + 1) {
let Some(lv) = numbering.level(n.num, k as u8) else { continue };
if matches!(lv.format, NumFormat::None | NumFormat::Bullet) {
continue;
}
let v = v.unwrap_or(lv.start);
let v = if *v == 0 { lv.start } else { *v };
let fmt = if def.legal && lv.format != NumFormat::DecimalZero { NumFormat::Decimal } else { lv.format };
levels.push((k as u8, fmt.format(v), def.text.contains(&format!("%{}", k + 1))));
}
+6 -10
View File
@@ -2132,22 +2132,18 @@ mod width_tests {
#[test]
fn grid_before_row_keeps_grid() {
let mut table = Table::new(2, 3, 300.0);
let cell_widths = [80.0, 100.0, 120.0];
for row in &mut table.rows {
for (cell, width) in row.cells.iter_mut().zip(cell_widths) {
cell.props.width = Some(width);
for cell in &mut row.cells {
cell.props.width = Some(100.0);
}
}
table.rows[1].props.grid_before = 1;
table.grid = vec![150.0, 150.0, 150.0];
table.props.width = Some(300.0);
assert_eq!(stale_grid_widths(&table, &table.grid).as_deref(), Some(cell_widths.as_slice()));
let mut grid = table.grid.clone();
// Omit the first grid column. The cells still end at the same two edges as row one.
let row = &mut table.rows[1];
row.cells.remove(0);
row.props.grid_before = 1;
row.props.w_before = Some(cell_widths[0]);
assert_eq!(stale_grid_widths(&table, &table.grid), None);
apply_cell_widths(&table, &mut grid);
assert_eq!(grid, [150.0, 150.0, 150.0]);
}
#[test]
-205
View File
@@ -13248,211 +13248,6 @@ fn columns_before_a_continuous_break_are_balanced() {
}
}
/// #6829's case: Letter page, three columns, exact 14 pt lines. 135 one-line filler paragraphs,
/// then P (5 lines, kept with the next) with `space_after` after it, then Q, then a section after
/// Q starting continuously, so the columns of the section ending at Q are balanced.
fn continued_tail_doc(space_after: f32) -> (Document, usize) {
use wordcraft_doc::props::LineSpacing;
use wordcraft_doc::section::{SectionProps, SectionStart};
let lb = wordcraft_doc::para::LINE_BREAK;
let filler = 135;
let mut text: Vec<String> = (0..filler).map(|i| format!("F{i}")).collect();
text.push("P1".into());
text.push("Q".into());
text.push("After".into());
let mut d = Document::from_text(&text.join("\n"));
for block in &mut d.body {
if let Block::Para(para) = Arc::make_mut(block) {
para.props.line_spacing = Some(LineSpacing::Exactly(14.0));
para.props.space_before = Some(0.0);
para.props.space_after = Some(0.0);
}
}
let p = d.para_mut(StoryRef::Body, &Path::top(filler)).unwrap();
p.insert_text(2, &format!("{lb}P2{lb}P3{lb}P4{lb}P5"), &Default::default()).unwrap();
p.props.keep_next = Some(true);
p.props.space_after = Some(space_after);
let mut s = SectionProps::default();
s.columns.count = 3;
d.para_mut(StoryRef::Body, &Path::top(filler + 1)).unwrap().section = Some(Box::new(s));
d.last_section.start = SectionStart::Continuous;
(d, filler)
}
/// Body paragraph `block`'s pieces in `l`: (page, x, top, line count).
fn pieces_of(l: &DocLayout, block: usize) -> Vec<(usize, f32, f32, usize)> {
l.pages
.iter()
.enumerate()
.flat_map(|(pi, pg)| {
pg.items.iter().filter_map(move |it| match it {
Placed::Lines { story: StoryRef::Body, path, l0, l1, x, y, .. } if path.0[..] == [block as u32] => Some((pi, *x, *y, l1 - l0)),
_ => None,
})
})
.collect()
}
/// #6829: in balanced columns, the last lines of a paragraph begun on the page before stay with
/// the paragraph after it when the paragraph is kept with the next (Word 16.0, compatibility
/// mode 15: three columns, exact 14 pt lines, the tail P4–P5 and Q all in column 1).
#[test]
fn balanced_columns_keep_a_continued_tail_with_the_next_paragraph() {
crate::test_fonts();
let (d, filler) = continued_tail_doc(0.0);
let l = lay(&d);
let pieces = pieces_of(&l, filler);
assert_eq!(pieces.len(), 2, "P begins on page 1 and ends on page 2: {pieces:?}");
let (tail_page, tail_x, tail_top, tail_lines) = pieces[1];
assert_eq!((pieces[0].0, tail_page, tail_lines), (0, 1, 2), "P4 and P5 on page 2: {pieces:?}");
let q = para_boxes(&l)[filler + 1];
assert_eq!(q.0, 1, "Q on page 2: {q:?}");
assert!((q.1 - tail_x).abs() < 0.5, "Q in the column of P4 and P5: Q {q:?}, P {pieces:?}");
assert!((q.2 - (tail_top + 28.0)).abs() < 0.5, "Q right under P5: Q {q:?}, P {pieces:?}");
}
/// #6829: the space after the continued paragraph counts too. With 28 pt after P, leaving room
/// for P4–P5 and Q's first line alone takes Q past the end of the column, and the tail stays
/// behind while Q moves on. The tail must go over with Q, and the columns grow to hold both.
#[test]
fn balanced_columns_keep_a_continued_tail_with_the_space_after_it() {
crate::test_fonts();
let (d, filler) = continued_tail_doc(28.0);
let l = lay(&d);
let pieces = pieces_of(&l, filler);
assert_eq!(pieces.len(), 2, "P begins on page 1 and ends on page 2: {pieces:?}");
let (tail_page, tail_x, tail_top, tail_lines) = pieces[1];
assert_eq!((pieces[0].0, tail_page, tail_lines), (0, 1, 2), "P4 and P5 on page 2: {pieces:?}");
let q = para_boxes(&l)[filler + 1];
assert_eq!(q.0, 1, "Q on page 2: {q:?}");
assert!((q.1 - tail_x).abs() < 0.5, "Q in the column of P4 and P5: Q {q:?}, P {pieces:?}");
assert!((q.2 - (tail_top + 28.0 + 28.0)).abs() < 0.5, "Q under P5's space after: Q {q:?}, P {pieces:?}");
}
/// #6829: the lines going over with the next paragraph keep their row together. Text on the far
/// side of a floating object is part of the same row (`settled_end`), and the end
/// `kept_tail_end` picks must not split it: the whole row goes over with the next paragraph.
#[test]
fn balanced_columns_keep_a_continued_tail_row_together() {
crate::test_fonts();
use wordcraft_doc::para::{Anchor, Float, Wrap};
use wordcraft_doc::props::LineSpacing;
use wordcraft_doc::section::{SectionProps, SectionStart};
let lb = wordcraft_doc::para::LINE_BREAK;
let filler = 135;
let mut text: Vec<String> = (0..filler).map(|i| format!("F{i}")).collect();
text.push("P1".into());
text.push("Q1".into());
text.push("After".into());
let mut d = Document::from_text(&text.join("\n"));
for block in &mut d.body {
if let Block::Para(para) = Arc::make_mut(block) {
para.props.line_spacing = Some(LineSpacing::Exactly(14.0));
para.props.space_before = Some(0.0);
para.props.space_after = Some(0.0);
}
}
let p = d.para_mut(StoryRef::Body, &Path::top(filler)).unwrap();
p.insert_text(2, &format!("{lb}P2{lb}P3{lb}word word word word word"), &Default::default()).unwrap();
p.props.keep_next = Some(true);
let q = d.para_mut(StoryRef::Body, &Path::top(filler + 1)).unwrap();
q.insert_text(2, &format!("{lb}Q2{lb}Q3{lb}Q4{lb}Q5"), &Default::default()).unwrap();
let mut s = SectionProps::default();
s.columns.count = 3;
d.para_mut(StoryRef::Body, &Path::top(filler + 1)).unwrap().section = Some(Box::new(s));
d.last_section.start = SectionStart::Continuous;
// A float in the middle of the column, anchored at P's tail: each of its first rows holds a
// word on each side of it.
let f = Float { wrap: Wrap::Square, h_rel: Anchor::Column, v_rel: Anchor::Paragraph, x: 36.0, ..Default::default() };
d.insert_object(&Pos::body(filler, 9), rect_shape(60.0, 42.0, f), &Default::default()).unwrap();
let l = lay(&d);
let mut continued = false;
let mut row = false;
for (pi, pg) in l.pages.iter().enumerate() {
for it in &pg.items {
let Placed::Lines { story: StoryRef::Body, path, para, l0, l1, .. } = it else { continue };
if path.0[..] != [filler as u32] || *l0 == 0 {
continue;
}
continued = true;
if pi == 1 {
row |= para.lines[*l0..].iter().any(|l| l.beside);
}
if *l1 < para.lines.len() {
assert!(!para.lines[*l1].beside, "a piece ends in the middle of a row: l0 {l0}, l1 {l1} of {}", para.lines.len());
}
}
}
assert!(continued, "P continues on page 2");
assert!(row, "the float splits a row beside the tail on page 2");
assert_eq!(para_boxes(&l)[filler + 1].0, 1, "Q on page 2");
}
/// Lines of body paragraph `block` placed in `l`, over all its pieces.
fn placed_lines(l: &DocLayout, block: usize) -> usize {
pieces_of(l, block).iter().map(|p| p.3).sum()
}
/// #6829: when the tail of a continued paragraph and the next paragraph could never fit one
/// column (a 60-line Q kept together), the tail stays where it is: nothing is pushed over to a
/// third page and the columns are balanced on page 2 as without the rule.
#[test]
fn a_continued_tail_that_cannot_fit_with_the_next_paragraph_stays_in_place() {
crate::test_fonts();
let lb = wordcraft_doc::para::LINE_BREAK;
let (mut d, filler) = continued_tail_doc(0.0);
let q = d.para_mut(StoryRef::Body, &Path::top(filler + 1)).unwrap();
let more: String = (2..=60).map(|i| format!("{lb}Q{i}")).collect();
q.insert_text(1, &more, &Default::default()).unwrap();
q.props.keep_lines = Some(true);
let l = lay(&d);
assert_eq!(l.pages.len(), 2, "everything on two pages");
assert_eq!(placed_lines(&l, filler), 5, "P is placed whole");
assert_eq!(placed_lines(&l, filler + 1), 60, "Q is placed whole");
assert!(pieces_of(&l, filler + 1).iter().all(|p| p.0 == 1), "Q on page 2");
assert!(pieces_of(&l, filler)[1..].iter().all(|p| p.0 == 1), "P's tail on page 2");
}
/// #6829: when the rule cannot be satisfied at any height, the balancing's fallback (the original
/// full-height columns) keeps the original layout and every paragraph is placed: a 49-line
/// paragraph kept with the next fills column 1 of page 2, then Q and 91 one-line paragraphs
/// fill the page.
#[test]
fn balancing_fallback_places_every_paragraph() {
crate::test_fonts();
use wordcraft_doc::props::LineSpacing;
use wordcraft_doc::section::{SectionProps, SectionStart};
let lb = wordcraft_doc::para::LINE_BREAK;
let (filler, after) = (135, 91);
let mut text: Vec<String> = (0..filler).map(|i| format!("F{i}")).collect();
text.push("P1".into());
text.push("Q".into());
text.extend((0..after).map(|i| format!("A{i}")));
text.push("Next".into());
let mut d = Document::from_text(&text.join("\n"));
for block in &mut d.body {
if let Block::Para(para) = Arc::make_mut(block) {
para.props.line_spacing = Some(LineSpacing::Exactly(14.0));
para.props.space_before = Some(0.0);
para.props.space_after = Some(0.0);
}
}
let p = d.para_mut(StoryRef::Body, &Path::top(filler)).unwrap();
let more: String = (2..=49).map(|i| format!("{lb}P{i}")).collect();
p.insert_text(2, &more, &Default::default()).unwrap();
p.props.keep_next = Some(true);
let last = filler + 1 + after;
let mut s = SectionProps::default();
s.columns.count = 3;
d.para_mut(StoryRef::Body, &Path::top(last)).unwrap().section = Some(Box::new(s));
d.last_section.start = SectionStart::Continuous;
let l = lay(&d);
for block in 0..=last + 1 {
let want = if block == filler { 49 } else { 1 };
assert_eq!(placed_lines(&l, block), want, "block {block} is placed");
}
}
#[test]
fn columns_before_a_page_break_or_a_column_break_are_not_balanced() {
crate::test_fonts();
-34
View File
@@ -1,10 +1,8 @@
//! STYLEREF fields in headers and footers (#775): each page shows its own result.
use crate::*;
use wordcraft_doc::numbering::Level;
use wordcraft_doc::para::InlineObject;
use wordcraft_doc::props::{CharProps, NumRef};
use wordcraft_doc::section::NumFormat;
use wordcraft_doc::{ListKind, PartKind, Pos, para_block};
fn field(instr: &str) -> InlineObject {
@@ -104,38 +102,6 @@ fn character_styles_and_paragraph_numbers() {
assert_eq!(h[3], ["two", "3", "3.a", "3"]);
}
#[test]
fn styleref_preserves_a_counted_zero_in_plain_and_full_numbering() {
crate::test_fonts();
let codes = [r#"STYLEREF "Heading 1" \n \t"#, r#"STYLEREF "Heading 2" \n \t"#, r#"STYLEREF "Heading 2" \w"#, r#"STYLEREF "Heading 2" \r"#];
let mut d = doc(&[("Heading1", "Chapter", false), ("Heading2", "Section", false)], &codes);
let numbering = Arc::make_mut(&mut d.numbering);
let num = numbering.add_list(ListKind::Numbered);
let instance = &mut numbering.nums[0];
instance.start_overrides = vec![(0, 0)];
instance.level_overrides = vec![
(0, Level { text: "Chapter%1.".into(), ..Default::default() }),
(1, Level { format: NumFormat::DecimalZero, text: "%2.".into(), ..Default::default() }),
];
for level in 0..=1u8 {
d.para_mut(StoryRef::Body, &Path::top(usize::from(level))).unwrap().props.numbering = Some(NumRef { num, level });
}
let mut cache = LayoutCache::new();
let laid_out = layout(&d, &mut cache, &LayoutOptions::default());
let page = &laid_out.pages[0];
let labels: Vec<&str> = page
.items
.iter()
.filter_map(|item| match item {
Placed::Lines { para, .. } => para.label.as_ref().map(|label| label.text.as_str()),
_ => None,
})
.collect();
assert_eq!(labels, ["Chapter0.", "01."]);
assert_eq!(shown(&page.header), ["0", "01", "0.01", "0.01"]);
}
/// #4985: a heading on a "none" list level (its label is its text, `Note`) shows its parent's
/// number in full context (`\w`): the parent is not taken for the heading's own level, which
/// has no number to list.
+2 -2
View File
@@ -17,7 +17,7 @@ craft = { workspace = true, features = [
"text-find", "web-api", "web-host", "window",
] }
craft-html = { workspace = true }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359" }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c" }
wordcraft-geom = { workspace = true, features = ["image"] }
wordcraft-doc = { workspace = true }
wordcraft-fonts = { workspace = true }
@@ -77,7 +77,7 @@ craft-ui-test-kit = { workspace = true }
craft = { workspace = true, features = ["ui-testing"] }
[build-dependencies]
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "ad10c35ae545f0fb816364381a1a8154012b2359", features = ["subset"] }
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "18499ec3a61f6d7a7d8a70951fa9765e5cf9853c", features = ["subset"] }
serde_json = { workspace = true }
toml = "1"
+6 -2
View File
@@ -271,8 +271,12 @@ impl WordApp {
let roots = self.pass_roots.take();
wordcraft_engine::file_access::confine(roots.as_ref(), || self.run_fired(&ctx, &out));
self.canvas.take_focus_after_pass(&ctx);
self.native_scale = theme::usable_scale(ctx.native_pixels_per_point().unwrap_or(1.0));
if let Some(native) = ctx.native_pixels_per_point()
// The zoom is context-wide but the display scale is per window: read it from the active
// document window. The windowless root has no window, so it reports none (#8853).
let active = self.active_viewport();
let native_now = ctx.input_for(active, |i| i.viewport().native_pixels_per_point).or_else(|| ctx.native_pixels_per_point());
self.native_scale = theme::usable_scale(native_now.unwrap_or(1.0));
if let Some(native) = native_now
&& let Some(old) = self.legacy_interface_size.take()
{
self.ui.interface_size = theme::migrate_legacy_interface_size(old, native);
+69 -16
View File
@@ -13,6 +13,7 @@ use craft::ui::primitives::{FaceRun, PaintShape, StrokeWidth, TextRun};
use craft::ui::runtime::env::Label;
use craft::ui::style::{ComponentStyle, DataColor, StyleColor, StyleCx};
use egui::{Color32, Pos2, Rect, Response, Ui, pos2, vec2};
use wordcraft_doc::props::TextDirection;
use wordcraft_layout::DocLayout;
use super::cursor::{caret_color_at, preedit_cursor_chars};
@@ -39,8 +40,13 @@ struct Placement {
/// The selection is collapsed, so a caret is drawn.
collapsed: bool,
/// The face, size and baseline on screen text typed at the caret takes, which a composition is drawn in. `None`
/// in an equation, in turned text and without a style run.
/// in an equation and without a style run. In turned text the baseline is unused.
typing: Option<TypingFace>,
/// The direction the caret's line reads in; turned text has a composition running down or up the page.
turn: TextDirection,
/// Turned text: the caret's top on screen, where the composition starts, and the line's width across the page.
y0: f32,
across: f32,
}
/// The face text typed at the caret asks for, its size and its baseline on screen (`DocLayout::typing_style`).
@@ -76,6 +82,9 @@ fn place(app: &WordApp, doc: &DocLayout, pages: &[PlacedPage]) -> Option<Placeme
in_equation: true,
collapsed: true,
typing: None,
turn: TextDirection::Horizontal,
y0,
across: 0.0,
});
}
let sel = preview_sel(app).unwrap_or(&app.session.sel);
@@ -105,15 +114,17 @@ fn place(app: &WordApp, doc: &DocLayout, pages: &[PlacedPage]) -> Option<Placeme
} else {
[pos2(x.round() + 0.5, y0), pos2(x.round() + 0.5, y1)]
};
// Word draws a composition in the font and size of the text it goes into; not in turned text, whose lines aren't
// horizontal.
let typing = if c.width > 0.0 {
None
} else {
doc.typing_style(&sel.focus, app.session.page_hint)
.filter(|(run, base)| run.size.is_finite() && run.size > 0.0 && base.is_finite())
.map(|(run, base)| TypingFace { face: run.requested_face, size: run.size * scale, baseline: pr.rect.min.y + base * scale })
};
// Word draws a composition in the font and size of the text it goes into, along the line (turned text: down or up
// the page).
let turned = c.width > 0.0;
let typing = doc
.typing_style(&sel.focus, app.session.page_hint)
.filter(|(run, base)| run.size.is_finite() && run.size > 0.0 && (turned || base.is_finite()))
.map(|(run, base)| TypingFace {
face: run.requested_face,
size: run.size * scale,
baseline: if turned { 0.0 } else { pr.rect.min.y + base * scale },
});
Some(Placement {
bar,
page: c.page,
@@ -124,6 +135,9 @@ fn place(app: &WordApp, doc: &DocLayout, pages: &[PlacedPage]) -> Option<Placeme
in_equation: false,
collapsed: sel.is_collapsed(),
typing,
turn: c.turn,
y0,
across: c.width * scale,
})
}
@@ -204,6 +218,9 @@ pub(crate) fn paint_caret(app: &mut WordApp, ui: &mut Ui, pass: &ToolPass, body:
cursor,
color: ink(app),
typing: pl.typing,
turn: pl.turn,
y0: pl.y0,
across: pl.across,
});
} else {
let look = step(app, request(pl.bar, shown));
@@ -224,8 +241,8 @@ pub(crate) fn paint_caret(app: &mut WordApp, ui: &mut Ui, pass: &ToolPass, body:
// them an empty rect that clips their strokes away.
let out = CaretMarks::new(tl!("Text cursor").to_string(), bars, composition).show_at(ui, pass.rect);
// The candidate window sits at the input method's cursor inside the composition, as production placed it.
if let Some(x) = out.composition_caret {
report = Rect::from_min_max(pos2(x, report.min.y), pos2(x + 1.0, report.max.y));
if let Some(r) = out.composition_caret {
report = if pl.turn.is_turned() { r } else { Rect::from_min_max(pos2(r.min.x, report.min.y), pos2(r.min.x + 1.0, report.max.y)) };
}
}
// Reported after the marks, which lay the composition out: this pass's final caret for the input method.
@@ -245,6 +262,11 @@ struct Composition {
color: Color32,
/// The face, size and baseline it is drawn in; without them, the interface font from the caret's bottom.
typing: Option<TypingFace>,
/// The line's direction; turned, the composition's characters stack upright down or up from `y0`, in a column
/// `across` wide starting at `left`.
turn: TextDirection,
y0: f32,
across: f32,
}
/// The style of the caret marks: the composition's ink.
@@ -265,8 +287,9 @@ pub(crate) struct CaretMarks {
common: Common,
bars: Vec<(Bar, Color32)>,
composition: Option<Composition>,
/// Where the paint put the caret inside the composition (screen x), measured from the laid-out text.
composition_caret: Option<f32>,
/// Where the paint put the caret inside the composition (a bar in screen points; turned text: the rect the
/// composition fills), measured from the laid-out text.
composition_caret: Option<Rect>,
}
impl CaretMarks {
@@ -279,7 +302,7 @@ impl CaretMarks {
/// What the marks report: the caret's place inside the composition they drew, for the candidate window.
pub(crate) struct CaretMarksOutput {
response: Response,
composition_caret: Option<f32>,
composition_caret: Option<Rect>,
}
impl Outcome for CaretMarksOutput {
@@ -330,6 +353,12 @@ impl Component for CaretMarks {
}
let Some(c) = &self.composition else { return };
let color = DataColor::new(c.color);
if c.turn.is_turned()
&& let Some(t) = &c.typing
{
self.composition_caret = Some(paint_turned(&draw, c, t, color));
return;
}
let (layout, top, bottom) = match &c.typing {
// In the text's own face and size, its first baseline on the line's, as typed text would sit. Characters the
// face lacks (CJK in a Latin font) come from the interface fonts; a size past the font atlas is capped.
@@ -350,7 +379,7 @@ impl Component for CaretMarks {
draw.stroke(&PaintShape::Path(underline), StrokeWidth::Thin, color);
let x = (c.left + layout.char_x(c.cursor)).round() + 0.5;
draw.stroke(&PaintShape::Path(vec![pos2(x, top), pos2(x, bottom)]), StrokeWidth::Medium, color);
self.composition_caret = Some(x);
self.composition_caret = Some(Rect::from_min_max(pos2(x, top), pos2(x, bottom)));
}
fn access(&self, access: &mut Access, _: &Cx<'_, Self>) {
@@ -361,3 +390,27 @@ impl Component for CaretMarks {
CaretMarksOutput { response: cx.response.clone(), composition_caret: self.composition_caret }
}
}
/// A composition in turned text: its characters upright, each in a cell of the run's size, stacked from the caret down
/// the page (`Down`) or up it (`Up`) in a column across the line, with the underline along the column's left edge and
/// the input method's cursor across it. Returns the rect the composition fills, which the candidate window avoids.
fn paint_turned(draw: &craft::ui::primitives::Draw<'_>, c: &Composition, t: &TypingFace, color: DataColor) -> Rect {
let key = face_key(t.face);
let sign = if c.turn == TextDirection::Up { -1.0 } else { 1.0 };
// The cell's edge `i` characters from the start.
let edge = |i: usize| c.y0 + sign * t.size * i as f32;
let n = c.text.chars().count();
for (i, ch) in c.text.chars().enumerate() {
let mut buf = [0; 4];
let s: &str = ch.encode_utf8(&mut buf);
// Centred in the column as an em-wide ideograph; the baseline sits at 0.86 em in the cell, where its body lies.
let top = edge(i).min(edge(i + 1));
let at = pos2(c.left + (c.across - t.size) / 2.0, top + 0.86 * t.size);
draw.face_run(at, &FaceRun::new(s, &key, t.size, color), || face_bytes(t.face));
}
let end = edge(n);
draw.stroke(&PaintShape::Path(vec![pos2(c.left, c.y0), pos2(c.left, end)]), StrokeWidth::Thin, color);
let at = edge(c.cursor.min(n)).round() + 0.5;
draw.stroke(&PaintShape::Path(vec![pos2(c.left, at), pos2(c.left + c.across, at)]), StrokeWidth::Medium, color);
Rect::from_two_pos(pos2(c.left, c.y0), pos2(c.left + c.across, end))
}
+1 -1
View File
@@ -66,7 +66,7 @@ pub(crate) struct EquationFrameStyle {
line: StyleColor,
accent: StyleColor,
soft: StyleColor,
/// Painted over the equation's text (so must stay translucent): the argument the caret is in.
/// Behind the equation's text, so translucent: the argument the caret is in.
shade: StyleColor,
handle_fill: StyleColor,
handle_stroke: StyleColor,
+5 -11
View File
@@ -158,21 +158,16 @@ impl<'a> PageTextTool<'a> {
}
}
/// The hyperlink under `pos`: an object or text-box link when `allow_object` is true, or a text link.
fn link_at(&self, pos: Pos2, allow_object: bool) -> Option<String> {
/// The tip for the link under `pos`: where it goes and how to follow it.
fn link_tip(&self, pos: Pos2) -> Option<String> {
let app = &*self.app;
let (page, x, y) = page_of(self.body.pages, pos)?;
let layout = &*self.layout;
// A linked picture or shape under the pointer comes first: it lies over the text (#5267).
// The text is the story under the pointer, as for the tracked change tip that follows.
let story = pointer_story(app, layout, page, x, y, app.session.sel.focus.story);
let object = allow_object.then(|| crate::objects::link_at(app, layout, self.body, pos)).flatten();
object.or_else(|| layout.hit(page, x, y, story).and_then(|at| link_under(app, layout, page, x, y, &at)))
}
/// The tip for the link under `pos`: where it goes and how to follow it.
fn link_tip(&self, pos: Pos2) -> Option<String> {
let link = self.link_at(pos, true)?;
let link = crate::objects::link_at(app, layout, self.body, pos)
.or_else(|| layout.hit(page, x, y, story).and_then(|at| link_under(app, layout, page, x, y, &at)))?;
let target = if is_generated_bookmark_link(&link) { tl!("Current Document").to_string() } else { link };
Some(format!("{target}\n{}", crate::i18n::fmt(tl!("{key}+Click to follow link"), &[("key", self.link_key)])))
}
@@ -306,8 +301,7 @@ impl CanvasTool for PageTextTool<'_> {
return Cursor::System(CursorIcon::Copy);
}
// Word: Ctrl/⌘ held over a link shows the hand, as a click there follows it.
// A text box's own link only follows when Shift is not held; inner text links follow either way.
if pointer.mods.cmd && self.link_at(pointer.pos, !pointer.mods.shift).is_some() {
if pointer.mods.cmd && self.link_tip(pointer.pos).is_some() {
return Cursor::System(CursorIcon::PointingHand);
}
text()
+23 -183
View File
@@ -1249,54 +1249,6 @@ fn a_handled_press_skips_the_link_tooltip() {
assert!(tips(&h) > 0, "hovering again shows the tooltip");
}
/// Hovering a link with Ctrl/⌘ held shows the pointing hand cursor (while plain hover keeps
/// the text cursor, plain text with Ctrl/⌘ keeps the text cursor, and Format Painter still takes
/// precedence).
#[test]
fn holding_command_over_a_link_shows_the_hand_cursor() {
use craft::behavior::cursor::{Cursor, CursorIcon, PaintedCursor};
use egui::{Event, Modifiers};
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text("See here")), Default::default());
a.run("select.text", json!({"text": "here"})).unwrap();
a.run("insert.link", json!({"url": "https://example.com/"})).unwrap();
a.run("view.commentsPane", json!({"value": false})).unwrap();
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
steps(&mut h, 6);
let caret_at = |h: &mut H, off: usize| {
let c = h.state_mut().session.layout().caret(&Pos { story: StoryRef::Body, path: wordcraft_doc::Path::top(0), off }).expect("caret");
screen(h, c.x, c.top + c.height / 2.0)
};
let over_plain = caret_at(&mut h, 1);
let over_link = caret_at(&mut h, 5);
let painted = {
let env = craft::ui::runtime::env::Env::of_root(&h.ctx);
let shell = env.view().shell();
shell.os == craft::host::target::Os::Windows && shell.runtime == craft::host::target::Runtime::Native
};
let text = if painted { Cursor::Painted(PaintedCursor::IBeam) } else { Cursor::System(CursorIcon::Text) };
let cursor_at = |h: &mut H, at: Pos2, mods: Modifiers| -> Option<Cursor> {
h.event(Event::ModifiersChanged(mods));
h.event(Event::PointerMoved(at));
h.app_frame();
craft::ui::runtime::cursor::current(&h.ctx)
};
assert_eq!(cursor_at(&mut h, over_link, Modifiers::NONE), Some(text.clone()), "plain hover over link keeps text cursor");
assert_eq!(cursor_at(&mut h, over_link, Modifiers::COMMAND), Some(Cursor::System(CursorIcon::PointingHand)), "Ctrl/Cmd over link shows hand");
h.event(Event::ModifiersChanged(Modifiers::NONE));
h.app_frame();
assert_eq!(craft::ui::runtime::cursor::current(&h.ctx), Some(text.clone()), "releasing Ctrl/Cmd over link restores text cursor");
assert_eq!(cursor_at(&mut h, over_plain, Modifiers::COMMAND), Some(text), "Ctrl/Cmd over plain text keeps text cursor");
h.state_mut().run("edit.formatPainter", json!({})).unwrap();
assert_eq!(cursor_at(&mut h, over_link, Modifiers::COMMAND), Some(Cursor::System(CursorIcon::Copy)), "Format Painter still wins over link");
}
/// With Hide White Space on, a click in a page's band puts the caret on that page, and a click
/// on the cut margins either side of the seam lands on the page whose band it is nearest to.
#[test]
@@ -2519,75 +2471,6 @@ fn a_picture_linked_from_its_context_menu_shows_and_follows_its_link() {
}
}
/// #9145: Ctrl/⌘ over a linked picture or shape shows the pointing hand (even when selected),
/// while Ctrl/⌘+Shift keeps the object drag/copy cursor since Shift suppresses link following.
#[test]
fn ctrl_over_linked_object_shows_pointing_hand() {
use craft::behavior::cursor::{Cursor, CursorIcon};
for case in ["inline-picture", "floating-picture", "shape"] {
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
if case == "shape" {
a.run("insert.shape", json!({"kind": "rectangle", "width": 160, "height": 80})).unwrap();
} else {
let img = image::RgbaImage::from_pixel(40, 20, image::Rgba([200, 30, 30, 255]));
let png = wordcraft_geom::picture::encode_format(&image::DynamicImage::ImageRgba8(img), image::ImageFormat::Png).unwrap();
a.run("insert.picture", json!({"data": wordcraft_engine::cmd::insert::base64_encode(&png), "width": 160})).unwrap();
if case == "floating-picture" {
a.run("arrange.wrap", json!({"wrap": "inFrontOfText"})).unwrap();
}
}
let pos = wordcraft_engine::cmd::objects::selected(&a.session).unwrap().0;
let end = Pos { off: pos.off + wordcraft_doc::para::OBJ.len_utf8(), ..pos.clone() };
a.run("insert.link", json!({"url": "https://example.com/obj"})).unwrap();
// Also test when unselected (caret back in body text).
a.session.sel = wordcraft_engine::Selection::caret(Pos::body(0, 0));
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
steps(&mut h, 6);
let rect = h.state_mut().session.layout().object(&pos, 0).expect("the object is laid out").rect;
let at = page_to_screen(h.state_mut(), 0, rect.x + rect.w / 2.0, rect.y + rect.h / 2.0).expect("on screen");
let cursor_at = |h: &mut H, mods: egui::Modifiers| {
h.event(egui::Event::ModifiersChanged(mods));
h.event(egui::Event::PointerMoved(at));
h.app_frame();
craft::ui::runtime::cursor::current(&h.ctx)
};
assert_eq!(
cursor_at(&mut h, egui::Modifiers::COMMAND),
Some(Cursor::System(CursorIcon::PointingHand)),
"{case} unselected: Ctrl/Cmd shows hand"
);
assert_eq!(
cursor_at(&mut h, egui::Modifiers::COMMAND | egui::Modifiers::SHIFT),
Some(Cursor::System(CursorIcon::Move)),
"{case} unselected: Ctrl/Cmd+Shift keeps move cursor"
);
// Now select the object and verify Ctrl/Cmd still shows the hand, while Ctrl/Cmd+Shift shows Copy.
h.state_mut().run("select.range", json!({"anchor": pos, "focus": end})).unwrap();
steps(&mut h, 2);
assert_eq!(
cursor_at(&mut h, egui::Modifiers::COMMAND),
Some(Cursor::System(CursorIcon::PointingHand)),
"{case} selected: Ctrl/Cmd shows hand"
);
assert_eq!(
cursor_at(&mut h, egui::Modifiers::COMMAND | egui::Modifiers::SHIFT),
Some(Cursor::System(CursorIcon::Copy)),
"{case} selected: Ctrl/Cmd+Shift keeps copy cursor"
);
}
}
/// #5267: inside a linked text box, hovering shows the box's link and Ctrl/⌘+click follows it,
/// although a click there reaches the box's text rather than the box.
#[test]
@@ -2636,72 +2519,6 @@ fn a_linked_text_box_shows_and_follows_its_link_from_inside() {
assert!(s.sel.is_collapsed() && s.sel.focus == start, "the caret went to the bookmark: {:?}", s.sel);
}
/// #9146: Ctrl/⌘+Shift inside a linked text box does not follow the box's link on click, so it
/// shows the text cursor over plain text inside the box while still showing the hand over inner
/// text links (which Ctrl/⌘+Shift+click follows) and on plain Ctrl/⌘.
#[test]
fn ctrl_shift_inside_linked_text_box_shows_text_cursor() {
use craft::behavior::cursor::{Cursor, CursorIcon, PaintedCursor};
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
a.run("insert.textBox", json!({"text": "Plain inner"})).unwrap();
let bx = a.session.layout().find_object(0, |o| o.text_box.is_some()).expect("the box");
let box_story = StoryRef::Part(bx.text_box.expect("text box id"));
let end = Pos { off: bx.off + wordcraft_doc::para::OBJ.len_utf8(), ..bx.pos() };
a.run("select.range", json!({"anchor": bx.pos(), "focus": end})).unwrap();
a.run("insert.link", json!({"url": "https://example.com/box"})).unwrap();
a.run("select.range", json!({"anchor": Pos::new(box_story, wordcraft_doc::Path::top(0), "Plain ".len()), "focus": Pos::new(box_story, wordcraft_doc::Path::top(0), "Plain inner".len())})).unwrap();
a.run("insert.link", json!({"url": "https://example.com/inner"})).unwrap();
a.session.sel = wordcraft_engine::Selection::caret(Pos::body(0, 0));
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
steps(&mut h, 6);
let plain_caret = h.state_mut().session.layout().caret(&Pos::new(box_story, wordcraft_doc::Path::top(0), 2)).expect("plain text caret");
let over_plain =
page_to_screen(h.state_mut(), plain_caret.page, plain_caret.x, plain_caret.top + plain_caret.height / 2.0).expect("plain on screen");
let inner_caret =
h.state_mut().session.layout().caret(&Pos::new(box_story, wordcraft_doc::Path::top(0), "Plain in".len())).expect("inner link caret");
let over_inner =
page_to_screen(h.state_mut(), inner_caret.page, inner_caret.x, inner_caret.top + inner_caret.height / 2.0).expect("inner on screen");
let painted = {
let env = craft::ui::runtime::env::Env::of_root(&h.ctx);
let shell = env.view().shell();
shell.os == craft::host::target::Os::Windows && shell.runtime == craft::host::target::Runtime::Native
};
let text = if painted { Cursor::Painted(PaintedCursor::IBeam) } else { Cursor::System(CursorIcon::Text) };
let cursor_at = |h: &mut H, pos: Pos2, mods: egui::Modifiers| {
h.event(egui::Event::ModifiersChanged(mods));
h.event(egui::Event::PointerMoved(pos));
h.app_frame();
craft::ui::runtime::cursor::current(&h.ctx)
};
assert_eq!(
cursor_at(&mut h, over_plain, egui::Modifiers::COMMAND),
Some(Cursor::System(CursorIcon::PointingHand)),
"Ctrl/Cmd over plain text inside linked text box shows hand"
);
assert_eq!(
cursor_at(&mut h, over_plain, egui::Modifiers::COMMAND | egui::Modifiers::SHIFT),
Some(text),
"Ctrl/Cmd+Shift over plain text inside linked text box shows text cursor"
);
assert_eq!(
cursor_at(&mut h, over_inner, egui::Modifiers::COMMAND | egui::Modifiers::SHIFT),
Some(Cursor::System(CursorIcon::PointingHand)),
"Ctrl/Cmd+Shift over inner hyperlink still shows hand"
);
}
/// Unit-level checks for #7742 (`hostile_numbers_are_ignored` logic): invalid `ScrollSpeed`
/// codes, non-finite framework wheel/ease inputs, out-of-range `view.zoom` commands, and
/// `sync_view_state` recovery from non-finite `session.view.zoom`.
@@ -3148,3 +2965,26 @@ fn mouse_wheel_notch_scrolls_document_line_distance_and_accelerates_on_flick() {
let flicked = h.state().canvas.view.offset.1 - flick_start;
assert!(flicked > 5.0 * eased_notch, "a rapid 5-notch flick ({flicked}) should accelerate past 5 single notches ({})", 5.0 * eased_notch);
}
/// In vertical text the composition runs down the line, upright and at the text's size, and the candidate window
/// reports the column it fills, not a horizontal strip (#8980).
#[test]
fn a_composition_in_vertical_text_runs_down_the_line() {
let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
app.run("document.setText", json!({"text": "Hello"})).unwrap();
app.run("layout.textDirection", json!({"value": "tbRl"})).unwrap();
app.run("caret.docEnd", json!({})).unwrap();
let mut h = composing_harness(app);
kana_test_glyphs(&h.ctx);
h.event(egui::Event::Ime(egui::ImeEvent::Preedit { text: "にほん".into(), active_range_chars: None }));
for _ in 0..4 {
h.app_frame();
}
let kana: Vec<_> = ["に", "ほ", "ん"].iter().filter_map(|k| drawn_composition(&h, k)).collect();
assert_eq!(kana.len(), 3, "each kana is drawn on its own");
let at = |i: usize| kana[i].pos;
assert!(at(0).y < at(1).y && at(1).y < at(2).y, "the kana stack down the page");
assert!((at(0).x - at(2).x).abs() < 1.0, "in one column");
let ime = h.output().platform_output.ime.clone().expect("the canvas places the candidate window").cursor_rect;
assert!(ime.height() > ime.width(), "the candidate window sits by the column: {ime:?}");
}
+31 -34
View File
@@ -22,10 +22,6 @@ fn window_dt(a: WordApp, dt: Option<f32>) -> H {
/// the window fast.
fn sized_window(a: WordApp, size: egui::Vec2, dt: Option<f32>, settle: usize) -> H {
let mut b = crate::test_harness::builder().with_size(size);
if settle == 0 {
// Stop kittest's build-time settle loop after one step when the caller wants zero settle frames.
b = b.with_max_steps(0);
}
if let Some(dt) = dt {
b = b.with_step_dt(dt);
}
@@ -46,31 +42,27 @@ fn button(at: Pos2, button: egui::PointerButton, pressed: bool) -> egui::Event {
egui::Event::PointerButton { pos: at, button, pressed, modifiers: Default::default() }
}
/// A primary click at `at` (press and release a frame apart).
/// A primary click at `at`, press and release a frame apart, then three frames to settle.
fn click_at(h: &mut H, at: Pos2) {
h.event(egui::Event::PointerMoved(at));
h.event(button(at, egui::PointerButton::Primary, true));
h.app_frame();
h.event(button(at, egui::PointerButton::Primary, false));
h.app_frame();
steps(h, 3);
}
/// A primary double click at `at`: lets any prior click age past egui's double click delay, sends two clicks inside it,
/// then one frame for the resulting UI change to draw.
/// A primary double click at `at`: two clicks a few frames apart, inside egui's double click delay.
fn double_click_at(h: &mut H, at: Pos2) {
let delay = h.ctx.options(|o| o.input_options.max_double_click_delay);
let dt = f64::from(h.ctx.input(|i| i.predicted_dt)).max(1e-3);
// Let any prior click clear `delay` by Click 1's release (at least 2*dt later).
let since = f64::from(h.ctx.input(|i| i.pointer.time_since_last_click()));
if since + 2.0 * dt <= delay + 1e-3 {
steps(h, ((delay + 1e-3 - since - 2.0 * dt) / dt).ceil() as usize);
}
// Let the click before it age out, or the pair would count as a triple click.
steps(h, 40);
h.event(egui::Event::PointerMoved(at));
for _ in 0..2 {
h.event(button(at, egui::PointerButton::Primary, true));
h.app_frame();
h.event(button(at, egui::PointerButton::Primary, false));
h.app_frame();
}
h.app_frame();
steps(h, 3);
}
/// A primary drag from `from` to `to` in six moves.
@@ -285,7 +277,7 @@ fn comment_harness_in(size: egui::Vec2, settle: usize) -> (H, u32) {
a.run("select.text", json!({"text": "text"})).unwrap();
let id = a.run("review.newComment", json!({"text": "Original"})).unwrap()["id"].as_u64().unwrap() as u32;
a.run("view.commentsPane", json!({"value": false})).unwrap();
(sized_window(a, size, Some(0.08), settle), id)
(sized_window(a, size, Some(1.0 / 60.0), settle), id)
}
/// Click comment `id`'s balloon (from no selected balloon): the card is selected with no edit open (as in Word), then
@@ -296,19 +288,22 @@ fn click_balloon(h: &mut H, id: u32) {
}
/// Double-clicks comment `id`'s card to open message 0 for editing, unless a draft is already open (a refused one
/// is kept), and ensures its field has the keyboard. Nothing opens where comments can't change.
/// is kept), and clicks into its field. Nothing opens where comments can't change.
fn open_edit(h: &mut H, id: u32) {
if crate::app::command_board::command_enabled(h.state(), "review.editComment") && h.state().canvas.comments.editing.is_none() {
let card = h.state().canvas.balloon_rects.iter().find(|(i, _)| *i == id).map(|(_, r)| *r).expect("the comment has a balloon");
double_click_at(h, card.left_top() + vec2(30.0, 8.0));
assert!(h.state().canvas.comments.editing.is_some(), "a double click on the card opens its edit");
if crate::app::command_board::command_enabled(h.state(), "review.editComment") {
if h.state().canvas.comments.editing.is_none() {
let card = h.state().canvas.balloon_rects.iter().find(|(i, _)| *i == id).map(|(_, r)| *r).expect("the comment has a balloon");
double_click_at(h, card.left_top() + vec2(30.0, 8.0));
assert!(h.state().canvas.comments.editing.is_some(), "a double click on the card opens its edit");
}
steps(h, 2);
}
use egui::accesskit::Role;
let field = h.query_by_role_and_label(Role::MultilineTextInput, "Edit").or_else(|| h.query_by_role_and_label(Role::TextInput, "Edit"));
if let Some(n) = field
&& !n.is_focused()
{
let at = n.rect().center();
let field = h
.query_by_role_and_label(Role::MultilineTextInput, "Edit")
.or_else(|| h.query_by_role_and_label(Role::TextInput, "Edit"))
.map(|n| n.rect().center());
if let Some(at) = field {
click_at(h, at);
assert_eq!(h.state().canvas.selected_balloon(), Some(id), "the card stays selected");
}
@@ -316,13 +311,10 @@ fn open_edit(h: &mut H, id: u32) {
/// Clicks comment `id`'s card (from no selected balloon): it is selected with no edit open, so Reply shows.
fn select_balloon_card(h: &mut H, id: u32) {
if h.state().canvas.selected_balloon().is_some() {
h.state_mut().canvas.comments.selected = craft::behavior::Selection::default();
h.app_frame();
}
h.state_mut().canvas.comments.selected = craft::behavior::Selection::default();
steps(h, 2);
let card = h.state().canvas.balloon_rects.iter().find(|(i, _)| *i == id).map(|(_, r)| *r).expect("the comment has a balloon");
click_at(h, card.left_top() + vec2(30.0, 8.0));
h.app_frame();
assert_eq!(h.state().canvas.selected_balloon(), Some(id), "the click selected the balloon");
}
@@ -335,7 +327,12 @@ fn type_in(h: &mut H, text: &str) {
/// Leave the comment field by clicking on the page (which also leaves the balloon).
fn leave_field(h: &mut H) {
let at = h.state().canvas.page_rects().next().map(|(_, r)| r.center()).expect("a page is shown");
click_at(h, at);
h.event(egui::Event::PointerMoved(at));
for pressed in [true, false] {
h.event(button(at, egui::PointerButton::Primary, pressed));
h.app_frame();
}
steps(h, 3);
}
/// The text of comment `id` in the document.
@@ -371,7 +368,7 @@ fn an_empty_comment_balloon_deletes() {
}
let id = a.run("review.newComment", json!({})).unwrap()["id"].as_u64().unwrap() as u32;
a.run("view.commentsPane", json!({"value": false})).unwrap();
let mut h = window_dt(a, Some(0.08));
let mut h = window_dt(a, Some(1.0 / 60.0));
click_balloon(&mut h, id);
let resolve = h.get_by_label("Resolve").rect().center();
click_at(&mut h, resolve);
+12 -2
View File
@@ -9,10 +9,11 @@ use craft::theme::ControlSize;
use craft::theme::variant::Variant;
use craft::ui::bars::{Bar, BarKind};
use craft::ui::buttons::{Button, ButtonOutput, IconButton, ToggleButton};
use craft::ui::contract::{Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
use craft::ui::contract::{AfterInk, Bind, BodyCx, Gap, Props as _, Show as _, ShowContainer as _, TooltipSpec, Trigger};
use craft::ui::display::{Divider, Text};
use craft::ui::layout_components::Row;
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::runtime::env::with_env;
use craft::ui::value_drag::{Slider, SliderScale};
use egui::Ui;
use serde_json::json;
@@ -45,7 +46,16 @@ pub(crate) fn show(ui: &mut Ui, _cx: &mut BodyCx<'_>, app: &mut WordApp) {
})
.show(ui, |ui, _| {
if let Ok(mut a) = app.try_borrow_mut() {
page.set(Some(readouts(&mut a, ui)));
// The readouts are secondary text, as v0.19.1 drew them (#8811): craft's ghost button takes the muted ink
// where it passes text contrast.
let rect = with_env(
ui,
|o| {
o.values.set(AfterInk::Muted);
},
|ui| readouts(&mut a, ui),
);
page.set(Some(rect));
}
});
if let (Some(page), Some(group), Ok(mut a)) = (page.get(), group.get(), app.try_borrow_mut()) {
@@ -52,15 +52,7 @@ fn assignable(binding: &Binding) -> bool {
/// The ribbon tab a command lives on, in English (the first part of its path).
fn tab(def: &CommandDef) -> &str {
if let Some(tab) = def.paths.first().and_then(|path| path.first()) {
return tab;
}
// The runtime owns these definitions and their bindings. Use the engine's ribbon location
// for classification when the linked definition has no path of its own.
match def.command.id.as_str() {
"edit.cut" | "edit.copy" | "edit.paste" => wordcraft_engine::cmd::edit::LINKED_CLIPBOARD_LOCATION.split(" › ").next().unwrap_or_default(),
_ => "",
}
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.
@@ -375,28 +367,4 @@ mod tests {
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"));
}
#[test]
fn linked_clipboard_commands_are_listed_once_under_home() {
let mut a = app();
let app_catalog = a.catalog().expect("app catalog");
let mut h = crate::test_harness::builder().build_eframe(|_| a);
h.run_steps(2);
let keymap = craft::ui::runtime::commands::keymap(&h.ctx).expect("command board installs a keymap");
let areas = super::areas();
for (id, category, shortcut) in
[("edit.cut", "Home", "Mod+X"), ("edit.copy", "Home", "Mod+C"), ("edit.paste", "Home", "Mod+V"), ("edit.undo", "Other", "Mod+Z")]
{
let command = CommandRef::new(id);
assert!(app_catalog.defs().iter().all(|def| def.command != command), "{id} is owned by the linked set");
let mut rows = keymap.catalog().iter().filter(|def| def.command == command);
let row = rows.next().unwrap_or_else(|| panic!("{id} is listed"));
assert!(rows.next().is_none(), "{id} is listed once");
let categories: Vec<_> = areas.iter().filter(|area| (area.rows)(row)).map(|area| area.id).collect();
assert_eq!(categories, [category, "All Commands"], "{id} is filed under the expected tab");
let shortcut = Binding::parse(shortcut).unwrap();
assert!(keymap.bindings(&command).iter().any(|binding| binding.trigger == shortcut.trigger), "{id} retains its shortcut");
}
}
}
@@ -31,7 +31,7 @@ use crate::widgets::font_box::font_picker;
/// A symbol inserted from the Symbol dialog, kept for its Recently used row and the ribbon's
/// Symbol gallery (`font` empty = the text's own font).
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct RecentSymbol {
pub ch: String,
@@ -650,9 +650,11 @@ fn recent_row(ui: &mut Ui, form: &mut SymbolForm, dark: bool) -> bool {
Text::new(word("Recently used symbols:")).show(ui);
return false;
}
let positions: Vec<usize> = (0..form.recent.len()).collect();
let source = keyed(&positions, |at: &usize| *at);
let mut events = Vec::new();
Field::new(word("Recently used symbols:")).show(ui, |ui, _| {
let source = keyed(&form.recent, |r: &RecentSymbol| r.clone());
let recent = &form.recent;
events = TileGrid::new(word("Recently used symbols:"))
.thumb_size(ThumbSize::Medium)
.select(SelectMode::Single)
@@ -660,10 +662,11 @@ fn recent_row(ui: &mut Ui, form: &mut SymbolForm, dark: bool) -> bool {
.card_columns(RECENT_SYMBOLS)
.natural_height(true)
.selection(Bind::given(Selection::default()))
.show_items(ui, &source, &mut |r, _| {
.show_items(ui, &source, &mut |at, _| {
let r = recent.get(*at).cloned().unwrap_or_default();
let ch = r.ch.chars().next().unwrap_or(' ');
let font = r.font.clone();
Tile::new(r.ch.clone()).thumb(ThumbAspect::SQUARE, move |cx, rect| paint_glyph(cx, rect, ch, &font, dark))
let font = r.font;
Tile::new(r.ch).thumb(ThumbAspect::SQUARE, move |cx, rect| paint_glyph(cx, rect, ch, &font, dark))
})
.response
.events;
@@ -671,7 +674,7 @@ fn recent_row(ui: &mut Ui, form: &mut SymbolForm, dark: bool) -> bool {
let (mut picked, mut activated) = (None, false);
for event in events {
match event {
CollectionEvent::Selection { change: SelectionChange::Set(rows), .. } => picked = rows.last().cloned().or(picked),
CollectionEvent::Selection { change: SelectionChange::Set(rows), .. } => picked = rows.last().copied().or(picked),
CollectionEvent::Activate(row) => {
picked = Some(row);
activated = true;
@@ -679,7 +682,7 @@ fn recent_row(ui: &mut Ui, form: &mut SymbolForm, dark: bool) -> bool {
_ => {}
}
}
if let Some(r) = picked
if let Some(r) = picked.and_then(|i| form.recent.get(i)).cloned()
&& let Some(c) = r.ch.chars().next()
{
form.font = r.font;
@@ -242,50 +242,6 @@ fn cross_font_recent_symbol_inserts_clicked_character() {
assert!(h.state().dialog_host.get_dyn(id).is_some(), "insert mode keeps the Symbol dialog open");
}
/// #9004: Pressing Enter twice on a focused recent symbol tile inserts the same symbol (and its
/// font) both times even after `remember_symbol` moves it to the front of the row.
#[test]
fn enter_twice_on_recent_symbol_tile_inserts_same_symbol_and_font() {
use egui::{Event, Key, Modifiers, PointerButton};
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
// Put © with Source Sans 3 at index 1 behind © with DejaVu Sans at index 0 so both character
// identity and font identity are tested when the second tile moves to the front.
remember_symbol(&mut a, "©", "Source Sans 3");
remember_symbol(&mut a, "©", "DejaVu Sans");
let mut h = testing::harness(a);
let id = crate::dialogs::open(h.state_mut(), "symbol", &json!({})).expect("symbol dialog opens");
h.run_steps(3);
// Click the second recent tile (index 1: © in Source Sans 3) to focus it without activating.
let recent_rect = h.get_by_role_and_label(egui::accesskit::Role::ListBox, "Recently used symbols:").rect();
let mut tiles: Vec<egui::Rect> = h.query_all_by_label("©").map(|n| n.rect()).filter(|r| recent_rect.contains_rect(*r)).collect();
tiles.sort_by(|a, b| a.min.x.total_cmp(&b.min.x));
assert_eq!(tiles.len(), 2, "both recent tiles render");
let second = tiles[1].center();
h.event(Event::PointerMoved(second));
h.event(Event::PointerButton { pos: second, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
h.step();
h.event(Event::PointerButton { pos: second, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });
h.run_steps(3);
for press in 1..=2 {
h.event(Event::Key { key: Key::Enter, physical_key: Some(Key::Enter), pressed: true, repeat: false, modifiers: Modifiers::NONE });
h.step();
h.event(Event::Key { key: Key::Enter, physical_key: Some(Key::Enter), pressed: false, repeat: false, modifiers: Modifiers::NONE });
h.run_steps(3);
let text = h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body);
assert_eq!(text.chars().count(), press, "Enter #{press} inserts one symbol: {text:?}");
}
let text = h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body);
assert!(text.starts_with("©©"), "both Enters insert ©: {text:?}");
let para = h.state().session.doc.body.first().and_then(|b| b.as_para()).unwrap();
assert_eq!(para.props_of_char(0).font.as_deref(), Some("Source Sans 3"), "first insert uses Source Sans 3");
assert_eq!(para.props_of_char("©".len()).font.as_deref(), Some("Source Sans 3"), "second insert keeps focus on Source Sans 3 tile");
assert!(h.state().dialog_host.get_dyn(id).is_some(), "insert mode keeps the Symbol dialog open");
}
/// The Field dialog builds the field code from its options.
#[test]
fn field_dialog_builds_the_instruction() {
@@ -16,10 +16,9 @@ use craft::ui::text::{NumberField, TextField};
use egui::Ui;
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use wordcraft_doc::props::TabLeader;
use wordcraft_engine::cmd::references::FieldCode;
use super::sample::{LEADERS, sample_card};
use super::sample::{LEADERS, leader_char, sample_card};
use crate::WordApp;
use crate::dialogs::host::{Asks, Filed, WordForm, captioned, labelled, open_form};
@@ -55,20 +54,22 @@ pub(super) fn body_field(app: &WordApp, name: &str) -> Option<FieldCode> {
impl IndexForm {
/// The index in the document, or Word's defaults for a new one (two columns).
pub fn read(app: &mut WordApp) -> IndexForm {
match wordcraft_engine::cmd::index::index_settings(&mut app.session) {
Some((f, leader)) => IndexForm {
pub fn read(app: &WordApp) -> IndexForm {
// Insert Index updates an inline index first. Otherwise it rebuilds the range field
// before writing the settings, so the dialog needs to read those switches too.
let index = body_field(app, "INDEX").or_else(|| {
app.session.doc.body.iter().filter_map(|b| b.as_para()).flat_map(|p| p.objects.iter()).find_map(|o| {
let wordcraft_doc::InlineObject::FieldStart { instr, .. } = o else { return None };
let field = FieldCode::parse(instr);
(field.name == "INDEX").then_some(field)
})
});
match index {
Some(f) => IndexForm {
kind: if f.has('r') { "runIn" } else { "indented" }.into(),
columns: f.arg('c').and_then(|c| c.trim().parse().ok()).unwrap_or(1).clamp(1, 4),
right_align: f.arg('e').is_some_and(|e| e.contains('\t')),
leader: match leader.unwrap_or(TabLeader::Dot) {
TabLeader::None => "none",
TabLeader::Dot => "dot",
TabLeader::Hyphen => "hyphen",
TabLeader::Underscore => "underscore",
TabLeader::MiddleDot => "middleDot",
}
.into(),
leader: "dot".into(),
headings: f.has('h'),
},
None => IndexForm { kind: "indented".into(), columns: 2, right_align: false, leader: "dot".into(), headings: true },
@@ -111,8 +112,7 @@ impl WordForm for IndexForm {
}
fn body(&mut self, ui: &mut Ui, _cx: &mut FormCx<'_, '_>, asks: &mut Vec<Asks>) -> bool {
let leader = wordcraft_engine::cmd::references::leader(&self.leader).char();
sample_card(tl!("Preview"), self.sample_lines(), self.right_align, leader).show(ui);
sample_card(tl!("Preview"), self.sample_lines(), self.right_align, leader_char(&self.leader)).show(ui);
let kind = captioned(ui, Label::from(tl!("Type:").to_string()), |name, ui| {
RadioGroup::new(name, Bind::given(self.kind.clone())).show(ui, |ui, _| {
Row::new().show(ui, |ui, _| {
@@ -132,10 +132,7 @@ impl WordForm for IndexForm {
}
Checkbox::new(Bind::bound(&mut self.right_align)).label(Label::from(tl!("Page numbers at the right margin").to_string())).show(ui);
let title = Label::from(tl!("Tab leader:").to_string());
let mut entries = leaders();
if self.leader == "middleDot" {
entries.push(Entry::new("middleDot".to_string(), Label::from("········")));
}
let entries = leaders();
let leader = Field::new(title.clone())
.show(ui, |ui, _| {
Select::new(title.clone(), Bind::given(Mixed::Same(self.leader.clone())), &entries)
@@ -235,43 +235,28 @@ fn index_and_mark_entry_dialogs_write_switches() {
f.right_align = true;
a.run("references.index", f.params()).unwrap();
assert!(instrs(&a).contains(&"INDEX \\h \"A\" \\c \"2\" \\e \"\t\" \\r".to_string()), "{:?}", instrs(&a));
assert_eq!(IndexForm::read(&mut a), f, "the dialog shows the index's settings");
assert_eq!(IndexForm::read(&a), f, "the dialog shows the index's settings");
}
#[test]
fn index_dialog_keeps_range_field_settings_when_confirmed_without_edits() {
use std::sync::Arc;
use egui::accesskit::{Role, Toggled};
use egui_kittest::kittest::{NodeT, Queryable};
use wordcraft_doc::Path;
use wordcraft_doc::props::{TabAlign, TabLeader};
use wordcraft_doc::{Block, Paragraph, Path};
let mut a = app("Kilns are hot.");
a.run("select.text", json!({"text": "Kilns"})).unwrap();
a.session.run("references.markEntry", &json!({})).unwrap();
// Wrap a generated entry so the imported field has a real result with a non-dot leader.
a.session.run("caret.docEnd", &json!({})).unwrap();
a.session.run("references.index", &json!({"type": "runIn", "columns": 3, "rightAlign": true, "headings": false, "tabLeader": "hyphen"})).unwrap();
// Original synthetic range field with non-default type, columns, alignment and headings.
let instr = "INDEX \\c \"3\" \\e \"\t\" \\r";
let is_index = |o: &InlineObject| matches!(o, InlineObject::Field { instr: code, .. } if code == instr);
let header = a.session.doc.body.iter().position(|b| b.as_para().is_some_and(|p| p.objects.iter().any(is_index))).unwrap();
let p = a.session.doc.para_mut(StoryRef::Body, &Path::top(header)).unwrap();
let field_offset = p.objects_with_offsets().find(|(_, o)| is_index(o)).unwrap().0;
p.delete(0, field_offset).unwrap();
*p.objects.iter_mut().find(|o| is_index(o)).unwrap() = InlineObject::FieldStart { instr: instr.into(), locked: false, dirty: false };
let entry = a.session.doc.para_mut(StoryRef::Body, &Path::top(header + 1)).unwrap();
entry.insert_object(entry.len(), InlineObject::FieldEnd, &Default::default()).unwrap();
let mut para = Paragraph::new();
para.insert_object(0, InlineObject::FieldEnd, &Default::default()).unwrap();
para.insert_object(0, InlineObject::FieldStart { instr: instr.into(), locked: false, dirty: false }, &Default::default()).unwrap();
let last = a.session.doc.body.len();
a.session.doc.insert_block(StoryRef::Body, &Path::top(last), Block::Para(para)).unwrap();
a.session.touch();
let entry_tab = |a: &WordApp| {
let p = a.session.doc.body.get(header + 1).and_then(|b| b.as_para()).expect("the generated entry");
assert!(p.plain_text().contains("Kilns\t"));
*p.props.tabs.as_ref().unwrap().last().unwrap()
};
let expected_tab = entry_tab(&a);
assert_eq!((expected_tab.align, expected_tab.leader), (TabAlign::Right, TabLeader::Hyphen));
assert_eq!(a.run("references.index", json!({})).unwrap(), json!({"pending": "index"}));
let mut h = crate::test_harness::builder().with_size(vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
@@ -285,7 +270,6 @@ fn index_dialog_keeps_range_field_settings_when_confirmed_without_edits() {
h.get_by_role_and_label(Role::Dialog, "Index");
let opened = form::<IndexForm>(h.state());
assert_eq!((opened.kind.as_str(), opened.columns, opened.right_align, opened.headings), ("runIn", 3, true, false));
assert_eq!(opened.leader, "hyphen");
assert_eq!(h.state().session.doc.field_ranges(StoryRef::Body)[0].instr, instr, "opening leaves the range field intact");
let right_aligned = h.get_by_role_and_label(Role::CheckBox, "Page numbers at the right margin").accesskit_node().toggled();
assert_eq!(right_aligned, Some(Toggled::True));
@@ -296,110 +280,6 @@ fn index_dialog_keeps_range_field_settings_when_confirmed_without_edits() {
let indexes: Vec<_> = instrs(h.state()).into_iter().filter(|i| i.starts_with("INDEX")).collect();
assert_eq!(indexes, [instr.to_string()], "the rebuilt index keeps the same switches");
assert!(h.state().session.doc.field_ranges(StoryRef::Body).is_empty(), "the range was replaced in place");
assert_eq!(entry_tab(h.state()), expected_tab, "OK preserves the leader, alignment and stop");
// The converted inline index keeps the leader on a second unedited confirmation.
h.state_mut().run("references.index", json!({})).unwrap();
h.run_steps(3);
assert_eq!(form::<IndexForm>(h.state()).leader, "hyphen");
h.get_by_role_and_label(Role::Button, "OK").click();
h.run_steps(3);
assert_eq!(entry_tab(h.state()), expected_tab);
// The inline entry can also get its tab stop from its paragraph style.
let a = h.state_mut();
let doc = &mut a.session.doc;
let entry = doc.para_mut(StoryRef::Body, &Path::top(header + 1)).unwrap();
assert_eq!(entry.props.style.as_deref(), Some("ListEntry"));
let tabs = entry.props.tabs.take().expect("the generated entry's tab");
entry.touch();
Arc::make_mut(&mut doc.styles).get_mut("ListEntry").unwrap().para.tabs = Some(tabs);
a.session.touch();
h.state_mut().run("references.index", json!({})).unwrap();
h.run_steps(3);
assert_eq!(form::<IndexForm>(h.state()).leader, "hyphen", "the dialog reads the inherited leader");
h.get_by_role_and_label(Role::Button, "OK").click();
h.run_steps(3);
assert_eq!(entry_tab(h.state()), expected_tab, "OK preserves the inherited leader");
h.state_mut().run("references.index", json!({})).unwrap();
h.run_steps(3);
let ctx = h.ctx.clone();
let id = craft::ui::dialog::dialog_id("index");
h.state_mut().dialog_host.set_json_field(&ctx, id, "leader", json!("underscore")).unwrap();
h.get_by_role_and_label(Role::Button, "OK").click();
h.run_steps(3);
let changed_tab = entry_tab(h.state());
assert_eq!(changed_tab.leader, TabLeader::Underscore);
assert_eq!((changed_tab.align, changed_tab.pos), (expected_tab.align, expected_tab.pos));
assert_eq!(instrs(h.state()).into_iter().filter(|i| i.starts_with("INDEX")).collect::<Vec<_>>(), [instr.to_string()]);
}
#[test]
fn index_dialog_and_update_preserve_the_leader_for_a_hidden_tab() {
use egui::accesskit::Role;
use egui_kittest::kittest::Queryable;
use wordcraft_doc::Path;
use wordcraft_doc::props::{CharProps, TabAlign, TabLeader, TabStop};
let mut a = app("Kilns are hot.");
a.session.view.marks = false;
a.session.prefs.marks.hidden = false;
a.session.run("references.markEntry", &json!({"entry": "Kilns"})).unwrap();
a.session.run("caret.docEnd", &json!({})).unwrap();
a.session.run("references.index", &json!({"rightAlign": true, "headings": false, "tabLeader": "hyphen"})).unwrap();
let header = a
.session
.doc
.body
.iter()
.position(|b| {
b.as_para().is_some_and(|p| p.objects.iter().any(|o| matches!(o, InlineObject::Field { instr, .. } if instr.starts_with("INDEX"))))
})
.unwrap();
let path = Path::top(header + 1);
let add_hidden_tab = |a: &mut WordApp| {
let p = a.session.doc.para_mut(StoryRef::Body, &path).unwrap();
assert_eq!(p.plain_text(), "Kilns\t1");
// A full hidden-text render would move the separator past the 90-point stop.
p.insert_text(0, &"W".repeat(24), &CharProps { hidden: Some(true), ..Default::default() }).unwrap();
p.props.tabs = Some(vec![
TabStop { pos: 5.0, align: TabAlign::Right, leader: TabLeader::Dot },
TabStop { pos: 90.0, align: TabAlign::Right, leader: TabLeader::Hyphen },
TabStop { pos: 380.0, align: TabAlign::Right, leader: TabLeader::Underscore },
]);
let offset = p.text.rfind('\t').unwrap();
a.session.touch();
assert_eq!(IndexForm::read(a).leader, "hyphen", "the visible tab uses the 90-point stop");
let p = a.session.doc.para_mut(StoryRef::Body, &path).unwrap();
p.format(offset, offset + 1, &|props| props.hidden = Some(true)).unwrap();
a.session.touch();
offset
};
let tab_offset = add_hidden_tab(&mut a);
assert_eq!(a.run("references.index", json!({})).unwrap(), json!({"pending": "index"}));
let mut h = crate::test_harness::builder().with_size(vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
h.run_steps(4);
assert_eq!(form::<IndexForm>(h.state()).leader, "hyphen");
let before = h.state().session.doc.para(StoryRef::Body, &path).unwrap();
assert_eq!(before.props_of_char(tab_offset).hidden, Some(true), "opening the dialog leaves the original tab hidden");
h.get_by_role_and_label(Role::Button, "OK").click();
h.run_steps(3);
assert!(!is_open::<IndexForm>(h.state()));
let leader = |a: &WordApp| a.session.doc.para(StoryRef::Body, &path).unwrap().props.tabs.as_ref().unwrap()[0].leader;
assert_eq!(leader(h.state()), TabLeader::Hyphen, "unchanged OK preserves the hidden tab's leader");
add_hidden_tab(h.state_mut());
h.state_mut().session.run("references.updateIndex", &json!({})).unwrap();
assert_eq!(leader(h.state()), TabLeader::Hyphen, "Update Index preserves the hidden tab's leader");
}
/// #402: Custom Table of Contents and its Options make the TOC switches, and the dialog
+1 -1
View File
@@ -52,7 +52,7 @@ fn anchor_skips_rects_scrolled_offscreen_and_clips_partial_ones() {
/// #7317: a viewport narrower than the bar still places the mini toolbar inside the canvas and viewport on all four sides.
#[test]
fn the_bar_stays_inside_a_narrow_window() {
fn a_viewport_narrower_than_the_bar_still_yields_a_rect() {
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
a.run("text.insert", json!({"text": "The quick brown fox"})).unwrap();
a.run("select.text", json!({"text": "quick"})).unwrap();
+1 -3
View File
@@ -730,9 +730,7 @@ impl ObjectGesture {
let o = grab_at(app, layout, body, at)?;
let (pp, x, y) = page_at(body, layout, at)?;
let in_member_text = o.member.is_some() && in_text(&o, x, y, edge_of(pp));
let icon = if mods.cmd && !mods.shift && object_link(app, &o).is_some() {
CursorIcon::PointingHand
} else if in_member_text && !fixed(app, &o) {
let icon = if in_member_text && !fixed(app, &o) {
CursorIcon::Text
} else if fixed(app, &o) || size_only(app, &o) {
CursorIcon::Default
+7 -10
View File
@@ -44,7 +44,8 @@ fn card(app: &mut WordApp, ui: &mut Ui, ctx: &egui::Context, document: u64, id:
Text::new(tl!("Resolved").to_owned()).show(ui);
}
});
comment_field(app, ui, document, id, resolved);
// Editable comment text (one undo step per edit, like the balloons).
comment_field(app, ui, document, id);
let open_key = egui::Id::unique(("comment_reply_open", document, id));
let mut replying = ui.data(|d| d.get_temp::<bool>(open_key)).unwrap_or(false);
Row::new().wrap(true).show(ui, |ui, _| {
@@ -133,16 +134,15 @@ pub(crate) const COMMENT_ROWS: usize = 10;
/// at its own, narrower length would come out lines short of its text.
const FIELD_LINES: usize = 2;
/// An open comment's text is editable in place. Typing stays in a draft until the field's value lands (focus leaves it);
/// A comment's text, editable in place. Typing stays in a draft until the field's value lands (focus leaves it);
/// then [`commit_comment`] writes it back with one `review.editComment`, so each editing session is one undo step.
/// Escape gives back the text from before, so the draft goes.
fn comment_field(app: &mut WordApp, ui: &mut Ui, document: u64, id: u32, resolved: bool) {
fn comment_field(app: &mut WordApp, ui: &mut Ui, document: u64, id: u32) {
let Some(part) = app.session.doc.comments.get(&id).map(|c| c.part) else { return };
let (thread, index) = (thread_of(app, id), message_index(app, id));
let draft = if resolved { None } else { draft_of(app, id) };
let shown = draft.unwrap_or_else(|| app.session.doc.plain_text(StoryRef::Part(part)));
// Resolved text stays visible, but the card cannot start or commit an edit until reopened.
let editable = !resolved && crate::app::command_board::command_enabled(app, "review.editComment");
let shown = draft_of(app, id).unwrap_or_else(|| app.session.doc.plain_text(StoryRef::Part(part)));
// Read-only where comments can't change (a protected document), so nothing is typed in vain.
let editable = crate::app::command_board::command_enabled(app, "review.editComment");
let field = ui.make_persistent_id(("comment_edit", document, id));
let out = TextField::new(tl!("Comment").to_owned(), Bind::given(shown))
.id(field)
@@ -152,9 +152,6 @@ fn comment_field(app: &mut WordApp, ui: &mut Ui, document: u64, id: u32, resolve
.placeholder(tl!("Add a comment").to_owned())
.enabled(editable)
.show(ui);
if resolved {
return;
}
for event in out.events.iter() {
match event {
EditEvent::Update { value, .. } => drafts(app).editing = Some((thread, index, value.clone())),
-58
View File
@@ -408,64 +408,6 @@ mod comment_wrapping {
assert_eq!(text, "Parent comment. Edited.\nSecond line.", "leaving the field wrote both lines");
assert_eq!(h.state().session.undo_depth(), depth + 1, "as one undo step");
}
#[test]
fn a_resolved_comment_card_stays_read_only_until_reopened() {
use serde_json::json;
use wordcraft_doc::StoryRef;
const FIRST: &str = "First comment.";
const SECOND: &str = "Second comment.";
let mut h = pane(&[FIRST.to_owned(), SECOND.to_owned()]);
let ids: Vec<u32> = h.state().session.doc.comments.keys().copied().collect();
let read = |h: &H, id| {
let doc = &h.state().session.doc;
doc.plain_text(StoryRef::Part(doc.comments[&id].part))
};
let attempt_edit = |h: &mut H, text, editable| {
let field = field_lines(h, "Comment", text).0.center();
click_at(h, field);
let focused = [Role::TextInput, Role::MultilineTextInput]
.into_iter()
.any(|role| h.query_all_by_role_and_label(role, "Comment").any(|node| node.value().as_deref() == Some(text) && node.is_focused()));
assert_eq!(focused, editable, "focus for {text:?}");
press_key(h, egui::Key::End);
type_text(h, " Edited.");
let page = h.state().canvas.page_rects().next().map(|(_, r)| r.center()).expect("a page is shown");
click_at(h, page);
};
let resolve =
h.query_all_by_role_and_label(Role::Button, "Resolve").map(|node| node.rect().center()).min_by(|a, b| a.y.total_cmp(&b.y)).unwrap();
click_at(&mut h, resolve);
assert!(h.state().session.doc.comments[&ids[0]].resolved);
attempt_edit(&mut h, FIRST, false);
assert_eq!(read(&h, ids[0]), FIRST);
assert!(!crate::panes::has_comment_drafts(h.state()));
attempt_edit(&mut h, SECOND, true);
assert_eq!(read(&h, ids[1]), "Second comment. Edited.");
let own_author = h.state().session.doc.comments[&ids[0]].author.clone();
h.state_mut().run("file.setAuthor", json!({"name": "Different Author"})).unwrap();
crate::test_harness::frames(&mut h, 3);
assert_ne!(h.state().session.author, own_author);
attempt_edit(&mut h, FIRST, false);
assert_eq!(read(&h, ids[0]), FIRST);
h.state_mut().run("file.setAuthor", json!({"name": own_author})).unwrap();
crate::test_harness::frames(&mut h, 3);
let reopen = h.get_by_role_and_label(Role::Button, "Reopen").rect().center();
click_at(&mut h, reopen);
assert!(!h.state().session.doc.comments[&ids[0]].resolved);
attempt_edit(&mut h, FIRST, true);
assert_eq!(read(&h, ids[0]), "First comment. Edited.");
h.state_mut().run("review.restrict", json!({"mode": "readOnly"})).unwrap();
crate::test_harness::frames(&mut h, 3);
attempt_edit(&mut h, "First comment. Edited.", false);
assert_eq!(read(&h, ids[0]), "First comment. Edited.");
assert!(!crate::panes::has_comment_drafts(h.state()));
}
}
/// Numbered headings are listed with the number they show, and numbered body paragraphs in
+2 -15
View File
@@ -9,7 +9,6 @@ use craft::ui::contract::{Bind, BodyCx, Gap, Props as _, Show as _, ShowContaine
use craft::ui::controls::disclosure::DisclosureGlyph;
use craft::ui::display::Divider;
use craft::ui::form::Field;
use craft::ui::layout::RowAlign;
use craft::ui::layout_components::{Row, Stack};
use craft::ui::list::ThumbAspect;
use craft::ui::menu::{Menu, MenuItem, MenuOutput};
@@ -85,25 +84,13 @@ pub(crate) fn painted_ibeam_over(ui: &Ui, response: &egui::Response) {
/// Two rows of small controls spread over the ribbon's body, `row(ui, 0)` above `row(ui, 1)`, with as much room above
/// the first, between them and under the second, so a two-row group fills the height of the three rows beside it and
/// leaves no empty band over its title.
pub(super) fn two_rows(ui: &mut Ui, row: impl FnMut(&mut Ui, usize)) {
two_rows_aligned(ui, false, row);
}
/// The same vertical row grid, with each row's controls centred across the widest row's width.
/// The controls keep their natural sizes and gap; only the shorter row's edge space is shared.
pub(super) fn centred_two_rows(ui: &mut Ui, row: impl FnMut(&mut Ui, usize)) {
two_rows_aligned(ui, true, row);
}
fn two_rows_aligned(ui: &mut Ui, centred: bool, mut row: impl FnMut(&mut Ui, usize)) {
pub(super) fn two_rows(ui: &mut Ui, mut row: impl FnMut(&mut Ui, usize)) {
// The third row's height and the two gaps of three rows, shared out three ways.
let air = (f32::from(super::RIBBON_LOOK.row) + 2.0 * Gap::Tight.points(ui)) / 3.0;
Stack::new().gap(Gap::None).show(ui, |ui, _| {
for at in 0..2 {
ui.add_space(air);
let line = Row::new().gap(Gap::None);
let line = if centred { line.fill_width().align(RowAlign::Center) } else { line };
line.show(ui, |ui, _| row(ui, at));
Row::new().gap(Gap::None).show(ui, |ui, _| row(ui, at));
}
ui.add_space(air);
});
+2 -75
View File
@@ -14,7 +14,7 @@ use craft::ui::primitives::{HAlign, TextRun};
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
use wordcraft_doc::props::Align;
use super::common::{centred_two_rows, icon_only, menu_button, painted_ibeam_over, two_rows};
use super::common::{icon_only, menu_button, painted_ibeam_over, two_rows};
use super::underline::underline_menu;
use egui::vec2;
use serde_json::Value;
@@ -294,7 +294,7 @@ pub(super) fn home(row: &mut RibbonRow<'_>, app: &mut WordApp) {
let (align, rtl) = rp.as_ref().map_or((Align::Left, false), |r| (r.align.visual(r.bidi), r.bidi));
let marks = app.session.view.marks;
icon_only(ui, |ui| {
centred_two_rows(ui, |ui, at| {
two_rows(ui, |ui, at| {
if at == 0 {
SplitButton::<String>::command(
CommandRef::with_params("para.bullets", json!({})),
@@ -528,79 +528,6 @@ mod tests {
use serde_json::json;
use wordcraft_engine::Session;
/// Unequal rows share the Paragraph body's horizontal centre, also in an RTL layout and in
/// the collapsed group's popover. Centring must not stretch, shrink, overlap or drop controls.
#[test]
fn paragraph_rows_share_a_centre_without_changing_their_controls() {
const ROWS: [&[&str]; 2] = [
&["Bullets", "Numbering", "Multilevel List", "Decrease Indent", "Increase Indent", "Sort", "Show/Hide ¶"],
&[
"Align Left",
"Center",
"Align Right",
"Justify",
"Left-to-Right Text Direction",
"Right-to-Left Text Direction",
"Line and Paragraph Spacing",
"Shading",
"Borders",
],
];
let mut original_sizes: Option<Vec<egui::Vec2>> = None;
for (width, rtl, collapsed) in [(1440.0, false, false), (700.0, false, true), (1440.0, true, false), (700.0, true, true)] {
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
app.ui.language = "en".into();
let mut h = crate::test_harness::builder().with_size(vec2(width, 900.0)).build_ui_state(
move |ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
// Keep names in English: this fixture tests the layout direction, not translations.
ctx.global_style_mut(|style| style.right_to_left = rtl);
let direction = if rtl { craft::i18n::Direction::Rtl } else { craft::i18n::Direction::Ltr };
craft::ui::runtime::env::with_env(ui, |overrides| overrides.direction = Some(direction), |ui| app.ui(ui));
ctx.global_style_mut(|style| style.right_to_left = false);
},
app,
);
crate::test_harness::cjk_stand_in(&h.ctx);
crate::test_harness::frames(&mut h, 6);
if collapsed {
assert!(h.query_all(By::new().role(Role::Button).label("Bullets")).next().is_none(), "narrow Paragraph starts collapsed");
h.get_by_role_and_label(Role::Button, "Paragraph").click();
crate::test_harness::frames(&mut h, 4);
}
let bounds = ROWS.map(|names| names.iter().map(|name| h.get_by_role_and_label(Role::Button, name).rect()).collect::<Vec<_>>());
let rows = bounds.each_ref().map(|rects| rects.iter().fold(egui::Rect::NOTHING, |all, rect| all.union(*rect)));
assert!(
(rows[0].center().x - rows[1].center().x).abs() <= 0.5,
"width={width}, rtl={rtl}, collapsed={collapsed}: Paragraph row contents should share a centre: {rows:?}"
);
let sizes = bounds.iter().flatten().map(egui::Rect::size).collect::<Vec<_>>();
if let Some(original) = &original_sizes {
for (size, before) in sizes.iter().zip(original) {
assert!((*size - *before).length() <= 0.5, "a direction or group-level change resized a control: {before:?} -> {size:?}");
}
} else {
original_sizes = Some(sizes);
}
for (names, rects) in ROWS.iter().zip(&bounds) {
for (name, rect) in names.iter().zip(rects) {
assert!(rect.width() >= 23.5 && rect.height() >= 23.5, "{name}: the 24-point command target shrank: {rect:?}");
}
for pair in rects.windows(2) {
assert!((pair[0].center().y - pair[1].center().y).abs() <= 0.5, "controls left their row: {pair:?}");
let (left, right) = if rtl { (pair[1], pair[0]) } else { (pair[0], pair[1]) };
assert!((left.right() - right.left()).abs() <= 0.5, "controls should remain adjacent, without overlaps or new gaps: {pair:?}");
}
}
for name in ["Bullets", "Numbering", "Multilevel List", "Shading", "Borders"] {
let whole = h.get_by_role_and_label(Role::Button, name).rect();
let arrow = h.get_by_role_and_label(Role::Button, &format!("{name} options")).rect();
assert!(whole.expand(0.5).contains_rect(arrow), "{name}'s menu target left the split button: {arrow:?}, {whole:?}");
}
}
}
/// #7317: focusing a real ribbon control (`Bold` -> `Tab`) via keyboard shows its hint only
/// after `tooltip::DELAY`, and hides it while a ribbon menu is open.
#[test]
+5 -8
View File
@@ -413,6 +413,11 @@ fn smart_art_design_layouts_are_one_strip_and_size_is_labelled() {
/// control lies inside its group's access node.
#[test]
fn ribbon_groups_fit_above_their_labels() {
if crate::i18n::Lang::all().any(|l| l.code() == "ar")
&& crate::test_harness::skip_without_embedded_script("ribbon::tests::ribbon_groups_fit_above_their_labels", "Arab")
{
return;
}
fn rects(node: &egui_kittest::Node<'_>, out: &mut Vec<egui::Rect>) {
for child in node.children() {
// The framework's parts (a split button's arrow, a field's adornments) can be nodes with no
@@ -439,14 +444,6 @@ fn ribbon_groups_fit_above_their_labels() {
// app's groups; they are never drawn, so they cannot run into a label. Only what lies on screen is checked.
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(2560.0, 900.0));
for lang in crate::i18n::Lang::all() {
let missing_script = match lang.code() {
"ar" => crate::test_harness::skip_without_embedded_script("ribbon::tests::ribbon_groups_fit_above_their_labels (ar)", "Arab"),
"hi" => crate::test_harness::skip_without_embedded_script("ribbon::tests::ribbon_groups_fit_above_their_labels (hi)", "Deva"),
_ => false,
};
if missing_script {
continue;
}
h.state_mut().run("ui.language", json!({"value": lang.code()})).unwrap();
for tab in super::TABS.iter().filter(|t| **t != "File") {
h.state_mut().run("ui.tab", json!({"tab": tab})).unwrap();
-12
View File
@@ -678,18 +678,6 @@ impl WordApp {
return;
}
let ctx = ui.ctx().clone();
// A press or a key in this window makes it the active one, as gaining focus does: a desktop that keeps focus
// on this window when another opens (GNOME on Wayland) sends it no focus change when it is used again, and the
// commands it fires would run in the other window (#9128).
let used = ui.input(|i| {
i.events.iter().any(|e| matches!(e, egui::Event::PointerButton { pressed: true, .. } | egui::Event::Key { pressed: true, .. }))
});
if self.windows.native
&& used
&& let Some(id) = self.windows.id_of(key)
{
self.windows.list.focus(id);
}
let queued = self.windows.get_mut(key).map(|w| std::mem::take(&mut w.requests)).unwrap_or_default();
for req in queued {
self.handle_request(&req);
-29
View File
@@ -1423,32 +1423,3 @@ fn ui_closewindow_reports_not_requested_while_a_prompt_is_up() {
let r = ctl(&mut a, &rig, "ui.closeWindow", json!({}));
assert_eq!(r["result"]["requested"], false, "{r}");
}
/// #9128: a desktop that keeps focus on the first window when New opens a second (GNOME on Wayland) sends the first
/// no focus change when it is clicked again. The click still makes it the active window, so the command it fires
/// (View › New Window) runs there and copies its document, not the blank one.
#[test]
fn a_click_in_a_window_that_kept_focus_runs_its_command_there() {
use craft::ui::runtime::commands::{CommandRef, FirePhase, FireSource, Fired};
use craft::ui::runtime::frame::FrameOutput;
let mut rig = Rig::new();
let mut a = app("Typed");
rig.focus(ViewportId::ROOT);
rig.frames(&mut a, 2);
let typed = a.windows.shown();
a.run("file.new", json!({})).unwrap();
rig.frames(&mut a, 2);
let blank = a.windows.shown();
assert_ne!(blank, typed);
assert_eq!(a.windows.active(), Some(blank), "New makes the blank window active while the desktop keeps focus on the first");
let at = egui::pos2(100.0, 100.0);
let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };
rig.frame_events(&mut a, vec![egui::Event::PointerMoved(at), press(true), press(false)], Vec::new());
let mut out = FrameOutput::default();
out.fired.push(Fired::new(CommandRef::new("view.newWindow"), FireSource::Pointer, FirePhase::Press, 0.0));
a.run_fired(&rig.ctx(), &out);
rig.frames(&mut a, 2);
assert_eq!(a.window_count(), 3);
assert_eq!(text(&a), "Typed", "the new window shows the clicked window's document");
}
+1 -10
View File
@@ -1,6 +1,6 @@
# WordCraft architecture
> **Last reviewed:** 2026-10-28 · **Last updated:** 2026-12-05 · **Change:** trivial (document the layering rules enforced by `cargo xtask layers`, including `craft-ui`, `craft-ui-test-kit`, `craft-window` and `craft-update` staying at L6+; previously trivial: the hostile-parameter test now has a sibling for `file.*`, `insert.picture` and `insert.textFromFile`; previously trivial: craft-proof's row says what a build without the Language data keeps: English spelling from an installed Hunspell English or the built-in list, rule hyphenation for Bulgarian, Turkish and Russian; previously minor: proofing moved out: `wordcraft-proof` is craft-libs' `craft-proof`, its Language data craft-i18n's `language-data/` embedded from `CRAFT_I18N_DIR`; previously major: crate and layer inventory, source counts, proofing languages and module boundaries re-measured from this checkout; previously minor: `proof` is per language: English and Polish; previously major: first committed version; `plan/architecture.md` is local-only) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
> **Last reviewed:** 2026-10-28 · **Last updated:** 2026-11-05 · **Change:** trivial (the hostile-parameter test now has a sibling for `file.*`, `insert.picture` and `insert.textFromFile`; previously trivial: craft-proof's row says what a build without the Language data keeps: English spelling from an installed Hunspell English or the built-in list, rule hyphenation for Bulgarian, Turkish and Russian; previously minor: proofing moved out: `wordcraft-proof` is craft-libs' `craft-proof`, its Language data craft-i18n's `language-data/` embedded from `CRAFT_I18N_DIR`; previously major: crate and layer inventory, source counts, proofing languages and module boundaries re-measured from this checkout; previously minor: `proof` is per language: English and Polish; previously major: first committed version; `plan/architecture.md` is local-only) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
How WordCraft is built today. The longer design notes in
`plan/architecture.md` are gitignored and local to the original author's machine; this file is the
@@ -38,14 +38,6 @@ crate name links to its source tree.
| apps | [`wordcraft-web`](../apps/wordcraft-web/src) | 1,159 | Browser build (eframe web runner, WebGPU with WebGL2 fallback) |
| tooling | [`xtask`](../xtask/src) | 1,488 | Workspace maintenance and quality-gate commands, including `layers` |
`cargo xtask layers` (`xtask/src/layers.rs`) enforces these rules across all workspace crates:
- Every workspace crate must be listed in `TABLE` (`apps`, `xtask` and `testkit` are exempt or special-cased).
- `Standalone` L0 crates (`control-key`, `validate`) may not depend on any workspace crate.
- Normal, dev and build dependencies between layered crates must point strictly to lower layers, except the explicit intra-layer orderings (`doc` → `fonts` in L1, `docx` → `formats` in L2).
- `testkit` may only be used as a dev-dependency, and itself may not depend on L6 crates.
- Crates below L6 (`ui-egui`) may not depend on UI toolkit or windowing crates (`egui`, `eframe`, `winit`, `egui_kittest`, `rfd`, `bevy*`, `craft-ui`, `craft-ui-test-kit`, `craft-window`, `craft-update`).
## Data flow
1. **Open:** `engine::io` picks a reader by extension (`docx`, `docbin`, `formats`, JSON) and
@@ -78,7 +70,6 @@ crate name links to its source tree.
| Date | Change | Summary |
|---|---|---|
| 2026-12-05 | trivial | Documented the dependency layering rules enforced by `cargo xtask layers` and added `craft-ui`, `craft-ui-test-kit`, `craft-window` and `craft-update` to the below-L6 UI check (#6057) |
| 2026-11-05 | trivial | `hostile_file_params_never_panic` runs `file.*`, `insert.picture` and `insert.textFromFile` with junk params and unusable paths (#3719) |
| 2026-11-02 | trivial | craft-proof's row: without the Language data English spelling falls back to an installed Hunspell English or the built-in Moby list, and only pattern hyphenation is off (#5202 review) |
| 2026-11-01 | minor | `proof` left the workspace: it is `craft-proof` in storytold/craft-libs (with its history), and the spelling and hyphenation data is craft-i18n's `language-data/` (`CRAFT_I18N_DIR`); `assets/spelling` and `assets/hyphenation` are gone |
+2 -3
View File
@@ -245,9 +245,8 @@ not activate the native window.
`ui.capsLock`, `ui.drop` and `ui.focus` defer their successful replies (`"result": null`). The current app
can send a deferred reply during the final input pass, before the UI has applied that pass.
`ui.clickText` replies at once with the window point it clicks (`"screen": [x, y]`), before
the click is processed. A later `ui.type` is queued behind the click only when both requests
target the same viewport; changing the active window can route them to separate queues. Other
requests, such as `ui.inspect` or `engine.execute`, can run before the click lands. `ui.click` with
the click is processed. `ui.type` sent after it is queued behind the click, but other requests,
such as `ui.inspect` or `engine.execute`, can run before the click lands. `ui.click` with
`"coordinates": "document"` and the same `page`, `x` and `y` clicks the same point and defers
its reply. Check that the resulting document or widget state is the one expected before
continuing with an operation that depends on it; do not replay an edit merely because its
File diff suppressed because one or more lines are too long
+2 -12
View File
@@ -1,6 +1,6 @@
# Localization parity with Microsoft Word
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-12-05 · **Change:** trivial (RFC-0011 cutover confirmation (#7861): documented release `CRAFT_I18N_DIR`/`CRAFT_I18N_REQUIRED=1` enforcement and recorded the measured binary and web sizes for English and the carry-over packs); previously minor (Hindi interface: `hi` in the language list, `hi-IN` system locales, Devanagari interface face, catalog in storytold/craft-i18n); previously minor (Bosnian interface: `bs` in the language list, `bs-BA` system locales, catalog in storytold/craft-i18n); previously trivial (Arabic: the Home tab's Styles gallery reads from the right, its arrows at the left (#5566); readiness unchanged); previously trivial (table sort and formulas read the Panamanian balboa's `B/.` around a number (`B/. 1,250.50`, `1,250.50 B/.`), as Word does, matched only at the ends of the text so `1/.5` stays a fraction); previously trivial (Arabic: the dialogs of the mirrored Arabic interface read right to left: label-and-field rows, tables (list columns, the Models table), tile galleries and the Add/Remove arrows follow the reading direction, through one `rtl::Table` helper that draws exactly as before in English; no ranked gap closed, readiness estimates unchanged); previously minor (Options › Language redesign: Your languages, Add a language…, Set as default; the Dictionaries folder moved from Proofing); previously trivial (Language packs: the missing-pack bar works on a fresh install and counts the caret's language); previously trivial (Language lists: every installed and available Language pack's language can be chosen in Set Proofing Language, installed ones in Review › Language and the status bar; craft-i18n.rev at 9d6d54d: region names and the Language (Region) template in 35 locales, craft-i18n#145); previously trivial (craft-i18n.rev at cde4900: rows for Options › Language, the missing-pack bar and 28 Language pack language names in 35 locales, craft-i18n#136); previously trivial (craft-proof pin: French elision suggestions first, ca-ES-valencia reads the ca-valencia pack); previously minor (Arabic `ar` interface: craft-i18n catalog, mirrored shell, font fallback, #1195; 28 languages); previously trivial (Language packs: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland)); previously trivial (Language packs: language-packs-1 is published and pinned, 61 packs; the language requests it covers); previously minor (Language packs: languages beyond English install their spelling dictionary and hyphenation as a pack from File › Options › Language or the missing-pack bar; the default build embeds English Language data only) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-12-01 · **Change:** minor (Hindi interface: `hi` in the language list, `hi-IN` system locales, Devanagari interface face, catalog in storytold/craft-i18n); previously minor (Bosnian interface: `bs` in the language list, `bs-BA` system locales, catalog in storytold/craft-i18n); previously trivial (Arabic: the Home tab's Styles gallery reads from the right, its arrows at the left (#5566); readiness unchanged); previously trivial (table sort and formulas read the Panamanian balboa's `B/.` around a number (`B/. 1,250.50`, `1,250.50 B/.`), as Word does, matched only at the ends of the text so `1/.5` stays a fraction); previously trivial (Arabic: the dialogs of the mirrored Arabic interface read right to left: label-and-field rows, tables (list columns, the Models table), tile galleries and the Add/Remove arrows follow the reading direction, through one `rtl::Table` helper that draws exactly as before in English; no ranked gap closed, readiness estimates unchanged); previously minor (Options › Language redesign: Your languages, Add a language…, Set as default; the Dictionaries folder moved from Proofing); previously trivial (Language packs: the missing-pack bar works on a fresh install and counts the caret's language); previously trivial (Language lists: every installed and available Language pack's language can be chosen in Set Proofing Language, installed ones in Review › Language and the status bar; craft-i18n.rev at 9d6d54d: region names and the Language (Region) template in 35 locales, craft-i18n#145); previously trivial (craft-i18n.rev at cde4900: rows for Options › Language, the missing-pack bar and 28 Language pack language names in 35 locales, craft-i18n#136); previously trivial (craft-proof pin: French elision suggestions first, ca-ES-valencia reads the ca-valencia pack); previously minor (Arabic `ar` interface: craft-i18n catalog, mirrored shell, font fallback, #1195; 28 languages); previously trivial (Language packs: language-packs-2 is published and pinned: 75 packs, adding Danish, German (Germany, Austria, Switzerland), Esperanto, Estonian, Persian, Croatian, Hungarian, Norwegian (Bokmål, Nynorsk), Dutch and Swedish (Sweden, Finland)); previously trivial (Language packs: language-packs-1 is published and pinned, 61 packs; the language requests it covers); previously minor (Language packs: languages beyond English install their spelling dictionary and hyphenation as a pack from File › Options › Language or the missing-pack bar; the default build embeds English Language data only) · **Target:** Microsoft Word (Microsoft 365) for Mac 16.113.4
Interface languages, script support and proofing per language. How translation works (adding a
language, the embedded catalogs): `crates/ui-egui/src/i18n.rs`. The catalogs, their format and
@@ -201,16 +201,7 @@ pinned pack index and installed through the font store into `<font store>/langua
carry-over data embedded (English, plus the German, Polish, Portuguese and Italian patterns and
`ru-extra`) until craft-proof's default embed becomes English only. A Language build embeds English plus the locales named in `CRAFT_PROOF_EMBED`
(`en` alone: English only); `cargo xtask language` checks nothing else is embedded. The web
build is English only. All release builds (`craft-common-actions` `release.yml`,
`nightly-unsigned.yml`, `checkout-craft-i18n`) and Flatpak builds check out `craft-i18n.rev` and
set `CRAFT_I18N_DIR` and `CRAFT_I18N_REQUIRED=1`. At `217f413` (against a build with the same
interface catalogs and no `language-data/`), English plus the small `*-extra.txt` supplements
(2,629,371 bytes raw English data plus 7,498 bytes `ru-extra.txt`) add 2,672,384 bytes to the
stripped Linux x86_64 release binary (+1,253,249 bytes gzip-9, +809,089 bytes zstd) and
2,675,400 bytes to the `wasm-opt -Oz` `.wasm` (+1,252,928 bytes gzip-9, +805,898 bytes zstd);
the four carry-over pattern files (`de`, `pl`, `pt`, `it`; 319,225 bytes raw) add a further
320,000 bytes to the stripped native binary (+138,475 bytes gzip-9, +129,241 bytes zstd) and
319,637 bytes to the `.wasm` (+138,849 bytes gzip-9, +99,764 bytes zstd).
build is English only.
- Lithuanian [#4707](https://github.com/storytold/wordcraft/issues/4707), Romanian [#3438](https://github.com/storytold/wordcraft/issues/3438), Catalan [#2895](https://github.com/storytold/wordcraft/issues/2895)/[#4947](https://github.com/storytold/wordcraft/issues/4947), French [#1325](https://github.com/storytold/wordcraft/issues/1325), Greek [#2561](https://github.com/storytold/wordcraft/issues/2561), Slovak [#3806](https://github.com/storytold/wordcraft/issues/3806), Serbian [#4968](https://github.com/storytold/wordcraft/issues/4968) and Latvian [#4438](https://github.com/storytold/wordcraft/issues/4438) are available as Language packs, with Polish, Portuguese, Italian, Russian, Czech, Spanish, Bulgarian, Bosnian, Slovenian and the rest; language-packs-2 (75 packs) adds Dutch [#4145](https://github.com/storytold/wordcraft/issues/4145)/[#2505](https://github.com/storytold/wordcraft/issues/2505), German (Germany, Austria, Switzerland), Danish, Persian, Esperanto, Estonian, Croatian, Hungarian, Norwegian and Swedish through craft-proof's flag-based compounding. Mongolian (slow suggestions) and Thai (word segmentation) wait on craft-proof; Basque, Ukrainian and Uyghur are excluded on licence grounds. A language craft-proof has no rules of its own for
(Lithuanian, Romanian, Dutch…) is spell-checked from its pack alone (`ProofLang::Pack`: the
shared affix engine with default tuning, the pack's hyphenation, no grammar rules).
@@ -286,7 +277,6 @@ WordCraft keeps 2,54 cm).
| Date | Change | Summary |
|---|---|---|
| 2026-12-05 | trivial | RFC-0011 cutover confirmation (#7861): confirmed releases (`release.yml`, `nightly-unsigned.yml`, `checkout-craft-i18n`, Flatpak manifest) set `CRAFT_I18N_DIR` and `CRAFT_I18N_REQUIRED=1`, and recorded the native release and `.wasm` size impact (raw, gzip-9, zstd) of English and the carry-over packs at `craft-i18n.rev` `217f413` |
| 2026-12-01 | minor | Hindi interface (`hi`, Devanagari): listed in `LANGUAGES`, `hi-IN` system locales, saved preference and bundled-font tests; catalog in storytold/craft-i18n (`locales/hi/wordcraft.tsv`), `craft-i18n.rev` at 217f413; no Hindi proofing |
| 2026-10-29 | minor | Bosnian interface (`bs`, Latin script): listed in `LANGUAGES`, `bs-BA` system locales, saved preference and bundled-font tests; catalog in storytold/craft-i18n (`locales/bs/wordcraft.tsv`); no Bosnian proofing |
| 2026-11-06 | trivial | Arabic: the Home tab's Styles gallery reads from the right: Normal is the rightmost tile and the scroll arrows and More sit at the gallery's left end, as the rest of the mirrored ribbon (#5566); left to right is unchanged; regression test `the_styles_gallery_reads_from_the_right_in_a_right_to_left_interface` |
@@ -20,9 +20,12 @@ finish-args:
# The shared updater inspects and updates this installation via flatpak-spawn --host.
- --talk-name=org.freedesktop.Flatpak
- --filesystem=xdg-data/ArtCraft/versions:ro
# Display: Wayland first; X11 only when no Wayland compositor is running.
# Display: Wayland, plus X11 always. The clipboard (arboard) needs the Wayland data-control
# protocol, which KWin does not offer to apps; it then falls back to the X11 clipboard, which
# XWayland bridges. With fallback-x11 the sandbox has no X11 under Wayland and paste fails
# (#8969, #8868). Remove --socket=x11 once the clipboard uses wl_data_device.
- --socket=wayland
- --socket=fallback-x11
- --socket=x11
# X11 shared memory (MIT-SHM). Without it the X11 fallback is slow or fails.
- --share=ipc
# GPU access for the wgpu renderer (Vulkan, or GL as a fallback).
@@ -21,9 +21,12 @@ finish-args:
# The shared updater inspects and updates this installation via flatpak-spawn --host.
- --talk-name=org.freedesktop.Flatpak
- --filesystem=xdg-data/ArtCraft/versions:ro
# Display: Wayland first; X11 only when no Wayland compositor is running.
# Display: Wayland, plus X11 always. The clipboard (arboard) needs the Wayland data-control
# protocol, which KWin does not offer to apps; it then falls back to the X11 clipboard, which
# XWayland bridges. With fallback-x11 the sandbox has no X11 under Wayland and paste fails
# (#8969, #8868). Remove --socket=x11 once the clipboard uses wl_data_device.
- --socket=wayland
- --socket=fallback-x11
- --socket=x11
# X11 shared memory (MIT-SHM). Without it the X11 fallback is slow or fails.
- --share=ipc
# GPU access for the wgpu renderer (Vulkan, or GL as a fallback).
+13 -21
View File
@@ -1,4 +1,4 @@
//! Dependency layering rules (docs/architecture.md, Layers).
//! Dependency layering rules (plan/architecture.md §3).
//!
//! The rule engine works on a small, metadata-independent model so it can be
//! unit-tested; `from_metadata` builds that model from `cargo metadata`.
@@ -56,8 +56,10 @@ pub const TABLE: &[(&str, Class)] = &[
("xtask", Class::Exempt),
];
/// Explicit orderings *within* a layer (earlier may be used by later):
/// in L1 `fonts` may use `doc`, and in L2 `formats` uses `docx`.
/// Explicit orderings *within* a layer (earlier may be used by later).
/// The L0 foundation is a small chain: `raster` builds on `color` and
/// `geom`, which the §3 diagram draws on one line. The GPU backend (`gpu`)
/// reuses the CPU reference (`compose`) for LUTs and parity tests.
pub const INTRA_LAYER_ORDER: &[&[&str]] = &[&["doc", "fonts"], &["docx", "formats"]];
fn intra_layer_allowed(from: &str, to: &str) -> bool {
@@ -70,11 +72,7 @@ fn intra_layer_allowed(from: &str, to: &str) -> bool {
/// External crates that constitute a UI toolkit / windowing dependency.
/// Entries ending in `*` are prefixes.
/// `craft-ui` depends on `egui`, `craft-ui-test-kit` wraps `egui_kittest`, and
/// `craft-window` and `craft-update` carry `egui` features enabled in this workspace,
/// so none of them may be depended on below L6.
pub const UI_CRATES: &[&str] =
&["egui", "eframe", "winit", "egui_kittest", "rfd", "bevy*", "craft-ui", "craft-ui-test-kit", "craft-window", "craft-update"];
pub const UI_CRATES: &[&str] = &["egui", "eframe", "winit", "egui_kittest", "rfd", "bevy*"];
/// First layer allowed to use UI crates.
pub const UI_MIN_LAYER: u8 = 6;
@@ -129,7 +127,7 @@ impl std::fmt::Display for Violation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Violation::Unregistered { krate } => {
write!(f, "{krate}: unknown workspace crate; register it in xtask/src/layers.rs TABLE (see docs/architecture.md, Layers)")
write!(f, "{krate}: unknown workspace crate; register it in xtask/src/layers.rs TABLE (see plan/architecture.md §3)")
}
Violation::Upward { krate, dep, from, to, kind } => {
write!(f, "{krate} (L{from}) -> {dep} (L{to}) [{kind:?}]: may only depend on strictly lower layers")
@@ -164,9 +162,6 @@ pub fn check(crates: &[Crate]) -> Vec<Violation> {
if d.name == c.name {
continue;
}
if layer < UI_MIN_LAYER && is_ui_crate(&d.name) {
out.push(Violation::UiBelowL6 { krate: c.name.clone(), dep: d.name.clone(), layer });
}
if d.workspace {
if class == Class::Standalone {
out.push(Violation::StandaloneHasWorkspaceDep { krate: c.name.clone(), dep: d.name.clone() });
@@ -191,6 +186,8 @@ pub fn check(crates: &[Crate]) -> Vec<Violation> {
}
}
}
} else if layer < UI_MIN_LAYER && is_ui_crate(&d.name) {
out.push(Violation::UiBelowL6 { krate: c.name.clone(), dep: d.name.clone(), layer });
}
}
}
@@ -286,13 +283,9 @@ mod tests {
#[test]
fn ui_crates_below_l6_flagged() {
for dep in
["egui", "eframe", "winit", "egui_kittest", "rfd", "bevy_ecs", "bevy", "craft-ui", "craft-ui-test-kit", "craft-window", "craft-update"]
{
for workspace in [false, true] {
let v = check(&[c("wordcraft-engine", &[(dep, Normal, workspace)])]);
assert!(matches!(v[..], [Violation::UiBelowL6 { layer: 4, .. }]), "{dep} (workspace={workspace})");
}
for dep in ["egui", "eframe", "winit", "egui_kittest", "rfd", "bevy_ecs", "bevy"] {
let v = check(&[c("wordcraft-engine", &[(dep, Normal, false)])]);
assert!(matches!(v[..], [Violation::UiBelowL6 { layer: 4, .. }]), "{dep}");
}
assert!(check(&[c("wordcraft-engine", &[("egui_extras_not", Normal, false)])]).is_empty());
assert!(!check(&[c("wordcraft-mcp", &[("winit", Normal, false)])]).is_empty());
@@ -302,8 +295,7 @@ mod tests {
fn unregistered_crate_is_error() {
let v = check(&[c("wordcraft-mystery", &[])]);
assert!(matches!(&v[..], [Violation::Unregistered { krate }] if krate == "wordcraft-mystery"));
let msg = v[0].to_string();
assert!(msg.contains("register") && msg.contains("docs/architecture.md"), "{msg}");
assert!(v[0].to_string().contains("register"));
}
#[test]