mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-29 21:59:14 +00:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c738c6d77c | ||
|
|
c161c7039c | ||
|
|
d240c1adcd | ||
|
|
c79a12c9ba | ||
|
|
6d9553a826 | ||
|
|
564b281813 | ||
|
|
ed712acdab | ||
|
|
4279762e28 | ||
|
|
66d56083e9 | ||
|
|
99b15ac2d1 | ||
|
|
0fdf358ba5 | ||
|
|
ad46c883ff | ||
|
|
6dd8396e20 |
@@ -2,13 +2,13 @@
|
||||
"schema": "craft-nightly-release-policy/v3",
|
||||
"repository": "storytold/wordcraft",
|
||||
"repository_id": 1408489772,
|
||||
"producer_workflow_id": 429734489,
|
||||
"producer_workflow_id": null,
|
||||
"producer_workflow_path": ".github/workflows/nightly.yml",
|
||||
"producer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
|
||||
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
|
||||
"producer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
|
||||
"producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea",
|
||||
"signer_workflow_path": ".github/workflows/nightly-sign.yml",
|
||||
"signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba",
|
||||
"release_branch": "nightly-signer",
|
||||
"signer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea",
|
||||
"release_branch": "release",
|
||||
"manual_actors": [
|
||||
"bflatastic",
|
||||
"dylanmtaylor",
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
name: Dispatch release-ref nightly
|
||||
|
||||
# Transport only, never authorization. No checkout, payload parsing or release environment.
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [WordCraft unsigned nightly]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
dispatch:
|
||||
# SOURCE PREPARATION: literal off until immutable shared tooling and policy qualification.
|
||||
if: >-
|
||||
false && github.repository == 'storytold/wordcraft' &&
|
||||
github.event_name == 'workflow_run'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
actions: write
|
||||
steps:
|
||||
- name: Dispatch only the exact completed producer run and attempt
|
||||
shell: python
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
import json
|
||||
import os
|
||||
import urllib.request
|
||||
|
||||
def require(value, message):
|
||||
if not value:
|
||||
raise RuntimeError(message)
|
||||
|
||||
# These filters reduce noise; the protected signer-branch validator repeats admission
|
||||
# against authenticated API metadata and required attestation/quality evidence.
|
||||
require(os.environ.get('GITHUB_REPOSITORY') == 'storytold/wordcraft', 'wrong repository')
|
||||
require(os.environ.get('GITHUB_EVENT_NAME') == 'workflow_run', 'wrong event')
|
||||
with open(os.environ['GITHUB_EVENT_PATH'], encoding='utf-8') as stream:
|
||||
event = json.load(stream)
|
||||
require(event.get('action') == 'completed', 'producer is not complete')
|
||||
require(event.get('repository', {}).get('full_name') == 'storytold/wordcraft', 'wrong event repository')
|
||||
producer = event.get('workflow_run', {})
|
||||
require(producer.get('head_repository', {}).get('full_name') == 'storytold/wordcraft', 'foreign producer')
|
||||
require(producer.get('path') == '.github/workflows/nightly.yml', 'wrong producer path')
|
||||
require(producer.get('head_branch') == 'main', 'wrong producer branch')
|
||||
require(producer.get('status') == 'completed' and producer.get('conclusion') == 'success', 'producer did not succeed')
|
||||
# First scheduled attempt only; reviewed manual/re-run authority belongs to release policy.
|
||||
require(producer.get('event') == 'schedule', 'not an automatic scheduled producer')
|
||||
run_id, attempt = producer.get('id'), producer.get('run_attempt')
|
||||
require(type(run_id) is int and run_id > 0, 'invalid producer run id')
|
||||
require(type(attempt) is int and attempt == 1, 'invalid automatic producer attempt')
|
||||
body = json.dumps({'ref': 'refs/heads/nightly-signer', 'inputs': {
|
||||
'producer_run_id': str(run_id), 'producer_run_attempt': str(attempt)
|
||||
}}).encode('utf-8')
|
||||
request = urllib.request.Request(
|
||||
'https://api.github.com/repos/storytold/wordcraft/actions/workflows/nightly-sign.yml/dispatches',
|
||||
data=body, method='POST', headers={
|
||||
'Authorization': 'Bearer ' + os.environ['GH_TOKEN'],
|
||||
'Accept': 'application/vnd.github+json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
'User-Agent': 'wordcraft-nightly-dispatch'
|
||||
})
|
||||
class NoRedirect(urllib.request.HTTPRedirectHandler):
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
raise RuntimeError('dispatch redirects are forbidden')
|
||||
# One bounded request, no retry: duplicate transport is not publication authority.
|
||||
with urllib.request.build_opener(NoRedirect()).open(request, timeout=20) as response:
|
||||
require(response.status == 204, 'dispatch was not accepted')
|
||||
print('Dispatched producer run/attempt to the release-ref validator; not a signing result.')
|
||||
@@ -1,8 +1,7 @@
|
||||
name: WordCraft release-ref nightly signer
|
||||
|
||||
# Enabled for supervised manual dispatch on the dedicated nightly-signer branch, which only ever
|
||||
# fast-forwards to reviewed main commits (never the stable release branch).
|
||||
# A reusable callee does not change context; this must be a real top-level signer-branch dispatch.
|
||||
# Enabled for supervised manual dispatch on release. Main/release contents must match.
|
||||
# A reusable callee does not change context; this must be a real top-level release dispatch.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -23,23 +22,21 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
# Actual context guards: official repository, manual dispatch, real nightly-signer branch.
|
||||
# Actual context guards: official repository, manual dispatch, real release branch.
|
||||
if: >-
|
||||
github.repository == 'storytold/wordcraft' &&
|
||||
github.event_name == 'workflow_dispatch' &&
|
||||
github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'
|
||||
github.ref == 'refs/heads/release' && github.ref_type == 'branch'
|
||||
permissions:
|
||||
contents: write
|
||||
actions: read
|
||||
checks: read
|
||||
attestations: write
|
||||
id-token: write
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@605d58766e8f536564da8fc81d3676ac86816dea
|
||||
with:
|
||||
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
|
||||
app-name: wordcraft
|
||||
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
|
||||
producer_run_id: ${{ inputs.producer_run_id }}
|
||||
producer_run_attempt: ${{ inputs.producer_run_attempt }}
|
||||
# No secrets: inherit or raw platform values in this caller. Only the isolated native
|
||||
# callee job may bind the existing release environment (which trusts release and
|
||||
# nightly-signer) and export keys in its signing step.
|
||||
# callee job may bind the existing release environment and export keys in its signing step.
|
||||
|
||||
@@ -22,13 +22,13 @@ jobs:
|
||||
actions: read
|
||||
attestations: write
|
||||
id-token: write
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba
|
||||
uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea
|
||||
with:
|
||||
tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba
|
||||
tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea
|
||||
app-name: wordcraft
|
||||
manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]'
|
||||
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
|
||||
# One producer run builds every listed platform for one all-or-nothing release. The pin is the
|
||||
# craft-common-actions main commit that merged the exact-analysis admission (#371, after #370,
|
||||
# #369 and #364).
|
||||
# craft-common-actions main commit that merged #339 (bounded lineage compares), on top of the
|
||||
# Linux/macOS signer (#342).
|
||||
platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'
|
||||
|
||||
@@ -70,5 +70,3 @@ jobs:
|
||||
run: bash packaging/linux/nightly-arch-tar-test.sh
|
||||
- name: Render and run the Nightly tar launcher (no build)
|
||||
run: bash packaging/linux/nightly-package-test.sh
|
||||
- name: Check the flat Nightly tar's shared template launcher (no build)
|
||||
run: bash packaging/linux/nightly-tar-launch-test.sh
|
||||
|
||||
Generated
+109
-132
@@ -1183,7 +1183,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
@@ -1221,20 +1221,10 @@ dependencies = [
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-appkit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"objc2-app-kit 0.3.2",
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-atomic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"rustix 1.1.6",
|
||||
]
|
||||
@@ -1242,7 +1232,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-automation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1267,7 +1257,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-behavior"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"bitflags 2.13.2",
|
||||
@@ -1285,7 +1275,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-browse"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-docpath",
|
||||
@@ -1303,12 +1293,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cfb"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
[[package]]
|
||||
name = "craft-cloud-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
@@ -1316,7 +1306,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cms"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"md-5",
|
||||
"rayon",
|
||||
@@ -1325,12 +1315,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-codepage"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
[[package]]
|
||||
name = "craft-color"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1338,7 +1328,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-color-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-cms",
|
||||
@@ -1358,7 +1348,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"serde",
|
||||
@@ -1368,7 +1358,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dds"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
@@ -1376,7 +1366,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dialogs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"craft-atomic",
|
||||
@@ -1401,7 +1391,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-doc-binary"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-cfb",
|
||||
@@ -1418,7 +1408,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1426,7 +1416,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docx"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"chrono",
|
||||
@@ -1446,7 +1436,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-draw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1465,7 +1455,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-drawingml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-xml",
|
||||
@@ -1477,7 +1467,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-flow"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-wordmodel",
|
||||
"image",
|
||||
@@ -1487,7 +1477,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"fontique",
|
||||
"harfrust 0.13.3",
|
||||
@@ -1502,7 +1492,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-manager"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -1515,27 +1505,17 @@ dependencies = [
|
||||
"egui",
|
||||
"log",
|
||||
"serde",
|
||||
"skrifa 0.47.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-font-os-windows"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
dependencies = [
|
||||
"windows-registry",
|
||||
"windows-sys 0.61.2",
|
||||
"skrifa 0.44.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-font-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"cap-primitives",
|
||||
"craft-atomic",
|
||||
"craft-font-catalog",
|
||||
"craft-font-os-windows",
|
||||
"flate2",
|
||||
"log",
|
||||
"ruzstd",
|
||||
@@ -1547,13 +1527,12 @@ dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
"toml",
|
||||
"ureq",
|
||||
"wuff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-font-subset"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"brotli 9.1.3",
|
||||
"harfbuzz-subset-sys",
|
||||
@@ -1566,7 +1545,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-font-subset",
|
||||
]
|
||||
@@ -1574,7 +1553,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-gpu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"egui-wgpu",
|
||||
"log",
|
||||
@@ -1586,7 +1565,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-i18n",
|
||||
@@ -1599,7 +1578,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-html"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"craft-flow",
|
||||
@@ -1612,7 +1591,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"fixed_decimal",
|
||||
@@ -1640,7 +1619,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-image-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-dds",
|
||||
"craft-jpeg",
|
||||
@@ -1667,7 +1646,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-imaging"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1685,7 +1664,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1693,7 +1672,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-keymap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
@@ -1708,7 +1687,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-latex"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-flow",
|
||||
"craft-math",
|
||||
@@ -1719,7 +1698,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-markdown"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-flow",
|
||||
"craft-html",
|
||||
@@ -1729,7 +1708,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-math"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-xml",
|
||||
"roxmltree",
|
||||
@@ -1739,7 +1718,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mcp-server"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
@@ -1747,7 +1726,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-menu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1765,7 +1744,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metadata"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"brotli-decompressor 6.3.1",
|
||||
"chrono",
|
||||
@@ -1777,7 +1756,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metafile"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"image",
|
||||
@@ -1788,7 +1767,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mime"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"chrono",
|
||||
@@ -1799,7 +1778,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-odf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64 0.23.1",
|
||||
@@ -1825,7 +1804,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ods"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-odf",
|
||||
"craft-sheet",
|
||||
@@ -1836,7 +1815,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-offcrypto"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64 0.23.1",
|
||||
@@ -1853,7 +1832,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-opc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-xml",
|
||||
"craft-zip",
|
||||
@@ -1864,7 +1843,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pages"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -1880,7 +1859,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"krilla",
|
||||
"serde",
|
||||
@@ -1890,7 +1869,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-platform"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"async-channel",
|
||||
@@ -1926,7 +1905,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1950,7 +1929,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-proof"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"log",
|
||||
"miniz_oxide 0.9.1",
|
||||
@@ -1961,7 +1940,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-quit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"egui",
|
||||
@@ -1974,7 +1953,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-review"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1993,7 +1972,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-rtf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"craft-flow",
|
||||
@@ -2006,7 +1985,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-settings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
@@ -2023,17 +2002,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-sheet"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ssip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
[[package]]
|
||||
name = "craft-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-xml",
|
||||
"flate2",
|
||||
@@ -2050,7 +2029,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-table"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2062,7 +2041,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2086,7 +2065,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-tracked",
|
||||
@@ -2101,7 +2080,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2116,7 +2095,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tiff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2126,7 +2105,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-time"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2135,7 +2114,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-timeline"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2150,12 +2129,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tracked"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-cloud-ui",
|
||||
"craft-ui-canvas",
|
||||
@@ -2169,7 +2148,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-canvas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -2185,7 +2164,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-contract"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"craft-behavior",
|
||||
@@ -2223,7 +2202,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2234,7 +2213,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-panels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2252,7 +2231,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-patterns"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2273,7 +2252,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-shell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2294,7 +2273,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-test-kit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2305,7 +2284,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-widgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2324,7 +2303,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-host",
|
||||
@@ -2353,7 +2332,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-api"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde_json",
|
||||
@@ -2364,7 +2343,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-platform",
|
||||
@@ -2376,7 +2355,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-win32"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"winsafe",
|
||||
]
|
||||
@@ -2384,9 +2363,8 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-window"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-appkit",
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2402,7 +2380,6 @@ dependencies = [
|
||||
"serde_json",
|
||||
"wayland-client",
|
||||
"winsafe",
|
||||
"x11rb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2416,7 +2393,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-wordmodel"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-math",
|
||||
@@ -2430,7 +2407,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xls"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-cfb",
|
||||
"craft-sheet",
|
||||
@@ -2443,7 +2420,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xlsx"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"craft-drawingml",
|
||||
"craft-opc",
|
||||
@@ -2455,7 +2432,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -2465,7 +2442,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2783,7 +2760,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"emath",
|
||||
@@ -2792,7 +2769,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -2827,7 +2804,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
@@ -2846,7 +2823,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-wgpu"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -2865,7 +2842,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"accesskit_winit",
|
||||
"arboard",
|
||||
@@ -2891,7 +2868,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_extras"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"egui",
|
||||
@@ -2904,7 +2881,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -2917,7 +2894,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_kittest"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"dify",
|
||||
"eframe",
|
||||
@@ -2943,7 +2920,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
@@ -3024,7 +3001,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -3050,7 +3027,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint_default_fonts"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
@@ -3773,7 +3750,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
|
||||
[[package]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"brotli 8.0.4",
|
||||
"hayro-postscript",
|
||||
@@ -3782,7 +3759,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -3800,7 +3777,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -3818,12 +3795,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -4497,9 +4474,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-encoder"
|
||||
version = "0.7.1"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0370574b86f7eca156b9f298392b5e69a23f8c86f3f865add60bbc2e79467a6"
|
||||
checksum = "b454d911ac55068f53495488d8ccd0646eaa540c033a28ee15b07838afafb01f"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
@@ -4552,7 +4529,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "krilla"
|
||||
version = "0.8.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bumpalo",
|
||||
@@ -4691,7 +4668,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
|
||||
[[package]]
|
||||
name = "linesweeper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"kurbo",
|
||||
@@ -9864,19 +9841,19 @@ dependencies = [
|
||||
[[patch.unused]]
|
||||
name = "egui_demo_lib"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_inspection"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "egui_system_font_provider"
|
||||
version = "0.37.0"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564"
|
||||
source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560"
|
||||
|
||||
[[patch.unused]]
|
||||
name = "hayro"
|
||||
version = "0.7.1"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=0b8bbaf4c842da2d47de7b3fddd7170ba6115541#0b8bbaf4c842da2d47de7b3fddd7170ba6115541"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=b436ae992591173ce53fdb1314421ba2d8897e49#b436ae992591173ce53fdb1314421ba2d8897e49"
|
||||
|
||||
+52
-52
@@ -37,20 +37,20 @@ 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 = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
wordcraft-proof = { package = "craft-proof", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-ssip = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", 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" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", default-features = false }
|
||||
craft-ui-test-kit = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
|
||||
# foundation
|
||||
kurbo = { version = "0.13", features = ["serde"] }
|
||||
@@ -81,28 +81,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 = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", default-features = false, features = ["write"] }
|
||||
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", version = "=0.1.0" }
|
||||
craft-wordmodel = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-docx = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-mcp-server = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["doc"] }
|
||||
craft-doc-binary = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-flow = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-odf = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["text"] }
|
||||
craft-markdown = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-html = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["flow"] }
|
||||
craft-latex = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-math = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0", features = ["detect"] }
|
||||
craft-sheet = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-ods = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-xls = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", version = "=0.1.0" }
|
||||
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", 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"
|
||||
@@ -170,27 +170,27 @@ 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 = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
ecolor = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
emath = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
epaint = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui-winit = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_glow = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_extras = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
eframe = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" }
|
||||
winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" }
|
||||
|
||||
|
||||
-13
@@ -66,16 +66,3 @@ _Avoid_: Tofu, box, notdef character
|
||||
A picture the document refers to that the output cannot include: its part is absent, its data
|
||||
cannot be decoded, its format is unsupported, or it is linked from outside the file.
|
||||
_Avoid_: Broken image, dropped image
|
||||
|
||||
## Windows
|
||||
|
||||
**Document window**:
|
||||
A top-level window showing one open document. A document can be shown in several document windows
|
||||
at once (View › New Window); each window shows exactly one.
|
||||
_Avoid_: Viewport (that is the framework's surface), root window, tab
|
||||
|
||||
**Save prompt**:
|
||||
The question "Save changes?" asked when the last document window showing a document with unsaved
|
||||
changes is about to close. It belongs to that window and appears there; while it is up, the other
|
||||
windows wait.
|
||||
_Avoid_: Close guard, save dialog, unsaved-changes dialog
|
||||
|
||||
@@ -167,6 +167,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm
|
||||
- 2026-11-17: File formats, codecs and protocols now come from the shared libraries (storytold/craft-libs#778): legacy code pages (craft-codepage, #6785), plain-text encoding detection (craft-mime, #6950), the ZIP entry-count guard (craft-zip, #6948), Read Aloud's Speech Dispatcher wire format (craft-ssip, #6951), picture probes for clipboard DIBs, JPEG memory, PNG and WebP (craft-image-codecs, #6949, #6955) and the MCP stdio server (craft-mcp-server, #6956), all with craft-libs pinned at main `93dac78c` (#6954, #6960). Opening documents and pictures behaves as before, except that large non-interleaved JPEGs are refused sooner (a 4:4:4 picture from about 60 Mpx, was 67 Mpx), invalid PNGs are refused more strictly, a lossless WebP's transparency is now seen, and MCP clients get tool errors for unknown or mistyped arguments and a 1,000-message batch cap (docs/mcp.md). The old code stays as test-only references the shared code is checked against.
|
||||
- 2026-11-15: Get the Missing Fonts. A document opened from a file that is missing fonts their publisher gives away (Microsoft's Aptos family, the default in recent Word documents; Cascadia Code and Mono) brings up a box naming each font, the font drawn instead, the publisher's download page and how to install the download, with Don't show this again. `font.missing` reports the same page, so agents get it without the box. WordCraft links to the page only; it downloads and bundles nothing.
|
||||
- 2026-10-30: Track Changes: a list item deleted whole, text and paragraph mark, shows its number as deleted text, in the deletion's colour and with its mark (struck through by default, or caret, #, bold, italic, underline), and hides it with No Markup or when Track Changes Options hide deletions (#4828). Readiness unchanged.
|
||||
fix/6146-touchpad-scroll-speed
|
||||
- 2026-11-09: Touchpad and mouse-wheel scroll speed settings (#6146): scales Wayland touchpad point input by default (4×) so two-finger scrolling matches desktop speed rather than crawling 1:1, and scales mouse wheel line distance; File › Options › Advanced › Scrolling; commands ui.scrollSpeed and ui.touchpadScrollSpeed.
|
||||
|
||||
- 2026-11-15: Layout: from Word 2013's layout (compatibility mode 15), balancing the columns before a continuous break keeps the last two, three or five lines of a paragraph that began on the page before together, keeps a two- or three-line paragraph that begins the last page whole, and holds a paragraph with keep lines together (or keep with next) whole in the first column when the strict rules fit. Synthetic tests also cover a footnote and a float (#6821); mode 14 splits them as before. Readiness estimates unchanged.
|
||||
|
||||
@@ -37,9 +37,9 @@ use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use craft::host::{FileError, Files, PendingPick, PickId, PickRequest, Picked, WriteIntent};
|
||||
use craft::host::{FileError, Files, PickId, PickRequest, Picked, WriteIntent};
|
||||
use craft::platform::browser_files::BrowserFiles;
|
||||
use craft::platform::open::{DroppedFile, IntakeSender};
|
||||
use craft::platform::open::{DropTarget, DroppedFile, IntakeSender};
|
||||
use craft::web_host::web::{FileData, Host, Message};
|
||||
use wordcraft_ui_egui::{Services, WordApp};
|
||||
|
||||
@@ -131,7 +131,7 @@ fn deliver_open(intake: &IntakeSender, name: &str, data: &FileData) {
|
||||
return;
|
||||
}
|
||||
let file = DroppedFile { path: None, name, bytes: Some(Arc::from(array.to_vec())) };
|
||||
intake.dropped(vec![file]);
|
||||
intake.dropped(vec![file], DropTarget::Elsewhere);
|
||||
}
|
||||
|
||||
/// The files of a hosted page: reads go to the browser's files, but a save goes to the host page,
|
||||
@@ -167,8 +167,8 @@ impl Files for HostedFiles {
|
||||
}
|
||||
}
|
||||
|
||||
fn pending_pick(&self) -> Option<PendingPick> {
|
||||
self.inner.pending_pick()
|
||||
fn pick_pending(&self) -> bool {
|
||||
self.inner.pick_pending()
|
||||
}
|
||||
|
||||
fn read(&self, path: &Path) -> Result<Vec<u8>, FileError> {
|
||||
@@ -192,7 +192,7 @@ impl Files for HostedFiles {
|
||||
let answer = match sent {
|
||||
// A Save As or first Save makes the page hold the document as this file: the answer
|
||||
// names it, and the next Save posts the name with `save_as` false.
|
||||
Ok(()) if request.save_as => Picked::Saved { path: PathBuf::from(&name), file_type: None },
|
||||
Ok(()) if request.save_as => Picked::Paths(vec![PathBuf::from(&name)]),
|
||||
// An overwrite of the opened file, or a copy: the document's file stays as it is.
|
||||
Ok(()) => Picked::Downloaded(name),
|
||||
Err(error) => Picked::Failed(error),
|
||||
|
||||
@@ -10,7 +10,7 @@ use craft::host::{Files, Host, Wake};
|
||||
use craft::platform::appearance::SystemReader;
|
||||
use craft::platform::browser_files::BrowserFiles;
|
||||
use craft::platform::clipboard::{Clipboard, ClipboardError, EventClipboard, Flavor, LateOffers, TEXT};
|
||||
use craft::platform::open::{DroppedFile, FileIntake, IntakeSender};
|
||||
use craft::platform::open::{DropTarget, DroppedFile, FileIntake, IntakeSender};
|
||||
use craft::print::spool::Spool;
|
||||
use craft::settings::SharedSettings;
|
||||
use craft::ui::InstallSpec;
|
||||
@@ -227,7 +227,7 @@ impl eframe::App for WebShell {
|
||||
match f.bytes_async().await {
|
||||
Ok(bytes) => {
|
||||
let file = DroppedFile { path: None, name, bytes: Some(Arc::from(bytes)) };
|
||||
sender.dropped(vec![file]);
|
||||
sender.dropped(vec![file], DropTarget::Elsewhere);
|
||||
}
|
||||
Err(e) => log::error!("couldn't read dropped file {name}: {e}"),
|
||||
}
|
||||
@@ -412,7 +412,7 @@ fn guard_unload(dirty: Rc<Cell<bool>>, files: Arc<BrowserFiles>) -> Result<(), S
|
||||
let window = web_sys::window().ok_or("no window")?;
|
||||
let on_unload = wasm_bindgen::closure::Closure::<dyn FnMut(web_sys::BeforeUnloadEvent)>::new(move |e: web_sys::BeforeUnloadEvent| {
|
||||
// A save still in the browser's picker hasn't written anything yet.
|
||||
if dirty.get() || files.pending_pick().is_some() {
|
||||
if dirty.get() || files.pick_pending() {
|
||||
e.prevent_default();
|
||||
// Older browsers ask only when `returnValue` is set.
|
||||
e.set_return_value("unsaved changes");
|
||||
|
||||
@@ -226,64 +226,4 @@ mod tests {
|
||||
|
||||
control.shut_down();
|
||||
}
|
||||
|
||||
/// Post-#7101 adaptation of `params_key_is_only_a_secret_for_auth` (#124, tracked under #7317 / #7729):
|
||||
/// `craft::automation::server` replaced legacy `"key"` / `params.key` secrets with one-time
|
||||
/// per-connection `auth` using `params.token` (`docs/control-protocol.md`, Token).
|
||||
#[test]
|
||||
fn params_token_is_only_a_secret_for_auth() {
|
||||
let (port, rx, control) = boot();
|
||||
|
||||
// Neither `params.token` on a non-`auth` method nor legacy `params.key` on
|
||||
// `document.inspect` or `auth` authenticates.
|
||||
for (id, line) in [
|
||||
(1, format!(r#"{{"id":1,"method":"document.inspect","params":{{"token":"{TOKEN}"}}}}"#)),
|
||||
(2, format!(r#"{{"id":2,"method":"document.inspect","params":{{"key":"{TOKEN}"}}}}"#)),
|
||||
(3, format!(r#"{{"id":3,"method":"auth","params":{{"key":"{TOKEN}"}}}}"#)),
|
||||
] {
|
||||
let mut c = Conn::open(port);
|
||||
assert_eq!(c.call(&line), serde_json::json!({"id": id, "ok": false, "error": "authentication required"}));
|
||||
assert!(c.closed());
|
||||
}
|
||||
assert!(rx.try_recv().is_err(), "refused requests must not reach the UI");
|
||||
|
||||
// Authenticate once with `params.token`; `params.key` and `params.token` on subsequent
|
||||
// non-`auth` methods are forwarded untouched as ordinary parameters.
|
||||
let mut c = Conn::open(port);
|
||||
let auth_resp = c.call(&format!(r#"{{"id":1,"method":"auth","params":{{"token":"{TOKEN}"}}}}"#));
|
||||
assert_eq!(auth_resp, serde_json::json!({"id": 1, "ok": true, "result": {"authenticated": true}}));
|
||||
|
||||
c.send(r#"{"id":2,"method":"ui.key","params":{"key":"Enter"}}"#);
|
||||
let req = answer(&rx);
|
||||
assert_eq!((req.method.as_str(), &req.params), ("ui.key", &serde_json::json!({"key": "Enter"})));
|
||||
let r = c.recv();
|
||||
assert_eq!((&r["ok"], &r["id"]), (&serde_json::json!(true), &serde_json::json!(2)));
|
||||
|
||||
c.send(r#"{"id":3,"method":"document.inspect","params":{"token":"ordinary"}}"#);
|
||||
let req = answer(&rx);
|
||||
assert_eq!((req.method.as_str(), &req.params), ("document.inspect", &serde_json::json!({"token": "ordinary"})));
|
||||
let r = c.recv();
|
||||
assert_eq!((&r["ok"], &r["id"]), (&serde_json::json!(true), &serde_json::json!(3)));
|
||||
drop(c);
|
||||
|
||||
control.shut_down();
|
||||
}
|
||||
|
||||
/// Post-#7101 adaptation of `a_wrong_key_is_refused_and_closed` (#124, tracked under #7317):
|
||||
/// wrong, short, and long `params.token` values are refused and close the connection without
|
||||
/// reaching the UI.
|
||||
#[test]
|
||||
fn a_wrong_token_is_refused_and_closed() {
|
||||
let (port, rx, control) = boot();
|
||||
let wrong = TOKEN.replace('0', "1");
|
||||
let long = format!("{TOKEN}0");
|
||||
for token in ["nope", wrong.as_str(), &TOKEN[..63], long.as_str()] {
|
||||
let mut c = Conn::open(port);
|
||||
let resp = c.call(&format!(r#"{{"id":1,"method":"auth","params":{{"token":"{token}"}}}}"#));
|
||||
assert_eq!(resp, serde_json::json!({"id": 1, "ok": false, "error": "authentication required"}), "{token}");
|
||||
assert!(c.closed(), "{token}");
|
||||
}
|
||||
assert!(rx.try_recv().is_err(), "refused auth attempts must not reach the UI");
|
||||
control.shut_down();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,23 +54,6 @@ pub fn identity() -> AppIdentity {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Every type the button claims is included in identity, and plain text/Markdown are never claimed.
|
||||
#[test]
|
||||
fn xdg_mime_sets_every_word_type_in_one_call() {
|
||||
let id = identity();
|
||||
assert_eq!(id.desktop_id, "ai.storyteller.wordcraft.desktop");
|
||||
assert_eq!(id.registered_name, "WordCraft");
|
||||
for t in [
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/msword",
|
||||
"application/rtf",
|
||||
"application/vnd.oasis.opendocument.text",
|
||||
] {
|
||||
assert!(id.mime_types.iter().any(|a| a == t), "{t}");
|
||||
}
|
||||
assert!(!id.mime_types.iter().any(|a| a == "text/plain" || a == "text/markdown"), "plain text and Markdown are never claimed");
|
||||
}
|
||||
|
||||
/// Every type the button claims is one the desktop entry declares, or desktops ignore it.
|
||||
#[test]
|
||||
fn the_desktop_entry_declares_every_claimed_type() {
|
||||
|
||||
@@ -111,14 +111,6 @@ pub fn prepare(mut launch: Launch, validate: impl FnOnce(&Path) -> Result<PathBu
|
||||
Ok(launch)
|
||||
}
|
||||
|
||||
/// The root the Launcher hands a nightly on this platform, in that platform's own spelling: `C:\NightlyData\profiles\wordcraft`
|
||||
/// on Windows, `/nightly-data/profiles/wordcraft` elsewhere. A test that fixtures the hand-off uses this rather than a
|
||||
/// literal, because a root literal in the other platform's spelling is not absolute here and `parse` refuses it (#7849).
|
||||
#[cfg(test)]
|
||||
pub(crate) fn launcher_root() -> &'static str {
|
||||
if cfg!(windows) { r"C:\NightlyData\profiles\wordcraft" } else { "/nightly-data/profiles/wordcraft" }
|
||||
}
|
||||
|
||||
/// Resolve the selected private root before the caller's first startup effect.
|
||||
pub fn validate_root(root: &Path) -> Result<PathBuf, String> {
|
||||
crate::profile_root::validate(root, |key| std::env::var_os(key), std::env::current_exe().ok().as_deref(), crate::profile_root::probe_writable)
|
||||
@@ -132,7 +124,7 @@ mod tests {
|
||||
values.iter().map(OsString::from).collect()
|
||||
}
|
||||
fn absolute() -> &'static str {
|
||||
super::launcher_root()
|
||||
if cfg!(windows) { r"C:\NightlyData\profiles\wordcraft" } else { "/nightly-data/profiles/wordcraft" }
|
||||
}
|
||||
fn nightly() -> Vec<OsString> {
|
||||
args(&["--launch-profile", VERSION, "--profile-root", absolute(), "--"])
|
||||
@@ -172,16 +164,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7849: `/nightly-data/...` carries no drive prefix and so is not absolute on Windows, and `C:\...`
|
||||
/// is one relative name on Unix. A launch that carries the other platform's root spelling is refused
|
||||
/// instead of run against a directory this platform never meant.
|
||||
#[test]
|
||||
fn a_root_absolute_only_in_the_other_platforms_spelling_is_refused() {
|
||||
let foreign = if cfg!(windows) { "/nightly-data/profiles/wordcraft" } else { r"C:\NightlyData\profiles\wordcraft" };
|
||||
let argv = args(&["--launch-profile", VERSION, "--profile-root", foreign, "--"]);
|
||||
assert!(parse(argv).is_err(), "the other platform's root spelling must not stand in: {foreign}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_launcher_version_check_is_a_version_query_only_in_its_exact_form() {
|
||||
let pair = &["--launch-profile", VERSION, "--profile-root", absolute()];
|
||||
|
||||
+9
-119
@@ -38,7 +38,7 @@ use craft::platform::appearance::SystemReader;
|
||||
use craft::platform::clipboard::{Clipboard, ClipboardImage, SystemClipboard};
|
||||
use craft::platform::default_app::{DefaultApp, DefaultAppError};
|
||||
use craft::platform::logs::{self, LogNames, crash};
|
||||
use craft::platform::open::{DroppedFile, FileIntake, IntakeSender};
|
||||
use craft::platform::open::{DropTarget, DroppedFile, FileIntake, IntakeSender};
|
||||
use craft::print::spool::Spool;
|
||||
use craft::settings::SharedSettings;
|
||||
use craft::ui::InstallSpec;
|
||||
@@ -121,7 +121,7 @@ impl eframe::App for App {
|
||||
// Once per frame, before any pass; the files stay in `raw` for the runtime's own reading.
|
||||
let files = dropped_files(raw);
|
||||
if !files.is_empty() {
|
||||
self.drops.dropped(files);
|
||||
self.drops.dropped(files, DropTarget::Elsewhere);
|
||||
}
|
||||
embed::before_input(ctx, |out| self.app.frame_input(out));
|
||||
}
|
||||
@@ -273,30 +273,6 @@ fn build_sha() -> &'static str {
|
||||
option_env!("WORDCRAFT_BUILD_SHA").map(|s| s.get(..8).unwrap_or(s)).unwrap_or("dev")
|
||||
}
|
||||
|
||||
/// Split the command line at its first `--`: the options before it, the documents after it. The
|
||||
/// Launcher's nightly hand-off arrives as `--` followed by the file names (`launch_profile::parse`
|
||||
/// puts that separator first), so it is dropped here rather than opened as a document.
|
||||
fn split_at_delimiter(args: Vec<String>) -> (Vec<String>, Vec<String>) {
|
||||
match args.iter().position(|a| a == "--") {
|
||||
Some(i) => {
|
||||
let mut options = args;
|
||||
let files = options.split_off(i + 1);
|
||||
options.pop();
|
||||
(options, files)
|
||||
}
|
||||
None => (args, Vec::new()),
|
||||
}
|
||||
}
|
||||
|
||||
/// The documents to open, in the order the command line gave them: the words before `--` that the flag
|
||||
/// loop kept, then the ones after it. The separator moves no document, and the Launcher, which sends
|
||||
/// none before it, opens just its own file names in order.
|
||||
fn documents_to_open(before: Vec<String>, after: Vec<String>) -> Vec<String> {
|
||||
let mut documents = before;
|
||||
documents.extend(after);
|
||||
documents
|
||||
}
|
||||
|
||||
/// The arguments as text, and apart the files whose names aren't valid Unicode, such as a Latin-1
|
||||
/// one (#1440). A `--control` port, a token or a token file that isn't is an error.
|
||||
fn text_args(arguments: Vec<std::ffi::OsString>) -> (Vec<String>, Vec<std::path::PathBuf>) {
|
||||
@@ -366,24 +342,14 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit
|
||||
)
|
||||
}
|
||||
|
||||
/// Whether a refusal may also open a native message box. Standard error always carries the reason;
|
||||
/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert
|
||||
/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hung in
|
||||
/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26).
|
||||
fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool {
|
||||
build_flavor::needs_native_error(flavor, desktop_session) && !macos
|
||||
}
|
||||
|
||||
/// Tell the person why a Launcher launch was refused: on standard error always, and with a native
|
||||
/// message box on a desktop session whose modal renders without the app's run loop (Windows,
|
||||
/// X11/Wayland) — a Launcher start has no terminal to read standard error from, and on macOS a modal
|
||||
/// before the event loop never appears.
|
||||
/// Tell the person why a Launcher launch was refused, with a native message box on a desktop
|
||||
/// session (a Launcher start has no terminal to read standard error from).
|
||||
fn report_launch_profile_error(error: &str) {
|
||||
complain(format_args!("launch profile: {error}"));
|
||||
let desktop_session = cfg!(windows)
|
||||
|| cfg!(target_os = "macos")
|
||||
|| (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty())));
|
||||
if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) {
|
||||
if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) {
|
||||
if let Err(identity) = initialize_nightly_process_identity() {
|
||||
complain(format_args!("launch profile: {identity}"));
|
||||
return;
|
||||
@@ -479,16 +445,11 @@ fn main() -> eframe::Result {
|
||||
log::error!("couldn't start again without another program's AppImage variables, so the self-update is off in this window: {e}");
|
||||
}
|
||||
let mut flags = ControlOptions::default();
|
||||
let mut files = Vec::new();
|
||||
let mut sample = false;
|
||||
let (args, other_files) = text_args(arguments);
|
||||
// The Launcher's own hand-off: `--` ends the options, so nothing after it is read as one and
|
||||
// the separator itself never becomes a document.
|
||||
let (args, after_separator) = split_at_delimiter(args);
|
||||
// Only macOS (Finder / LaunchServices) adds these, and only to the options: a Finder launch carries
|
||||
// no separator for them to sit after, and the Launcher starts the app itself, so a document whose
|
||||
// name merely looks like one of these (`-NSNotes.docx`) is still opened (#7849 review).
|
||||
// Only macOS (Finder / LaunchServices) adds these; elsewhere `-NS…` could be a real file name.
|
||||
let args = if cfg!(target_os = "macos") { without_launch_args(args) } else { args };
|
||||
let mut documents: Vec<String> = Vec::new();
|
||||
let mut bad_control: Option<Option<String>> = None;
|
||||
let mut missing_value: Option<&'static str> = None;
|
||||
let mut args = args.into_iter().peekable();
|
||||
@@ -531,12 +492,9 @@ fn main() -> eframe::Result {
|
||||
let _ = std::io::Write::write_all(&mut std::io::stdout(), USAGE.as_bytes());
|
||||
return Ok(());
|
||||
}
|
||||
_ => documents.push(a),
|
||||
_ => files.push(a),
|
||||
}
|
||||
}
|
||||
// After the loop, so a document before `--` opens before the ones after it (a stable launch's
|
||||
// `a.docx -- b.docx` used to be reversed when the Launcher's list was the one collected first).
|
||||
let files = documents_to_open(documents, after_separator);
|
||||
// After the loop, so `--version` later on the line still wins.
|
||||
if let Some(port) = bad_control {
|
||||
let got = port.map(|p| format!(", got {p:?}")).unwrap_or_default();
|
||||
@@ -1078,7 +1036,7 @@ mod smoke {
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("dropped.txt");
|
||||
std::fs::write(&path, "Dropped words").unwrap();
|
||||
run.sender.dropped(vec![DroppedFile { path: Some(path), name: "dropped.txt".into(), bytes: None }]);
|
||||
run.sender.dropped(vec![DroppedFile { path: Some(path), name: "dropped.txt".into(), bytes: None }], DropTarget::Elsewhere);
|
||||
run.settle();
|
||||
assert!(run.app.app.session.doc.plain_text(wordcraft_doc::StoryRef::Body).contains("Dropped words"), "the dropped file opened");
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
@@ -1119,71 +1077,3 @@ mod smoke {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod command_line_tests {
|
||||
use super::{documents_to_open, split_at_delimiter};
|
||||
|
||||
/// The argv the Launcher starts a nightly with, as `prepare_launch` hands it on. The root is the one this
|
||||
/// platform would pass: `/nightly-data/...` has no drive prefix, so on Windows `parse` rightly refuses it.
|
||||
fn launcher_argv(tail: &[&str]) -> Vec<String> {
|
||||
let mut argv: Vec<std::ffi::OsString> = ["--launch-profile", "nightly-v1", "--profile-root", super::launch_profile::launcher_root(), "--"]
|
||||
.iter()
|
||||
.map(std::ffi::OsString::from)
|
||||
.collect();
|
||||
argv.extend(tail.iter().map(std::ffi::OsString::from));
|
||||
super::launch_profile::parse(argv).unwrap().args.iter().map(|a| a.to_string_lossy().into_owned()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_launchers_separator_is_never_a_document() {
|
||||
let (options, files) = split_at_delimiter(launcher_argv(&[]));
|
||||
assert!(options.is_empty(), "{options:?}");
|
||||
assert!(files.is_empty(), "the separator must not reach the documents: {files:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn documents_after_the_separator_are_kept_in_order() {
|
||||
let (options, files) = split_at_delimiter(launcher_argv(&["a.file"]));
|
||||
assert!(options.is_empty(), "{options:?}");
|
||||
assert_eq!(files, ["a.file"]);
|
||||
let (_, files) = split_at_delimiter(launcher_argv(&["a.file", "--version", "--sample"]));
|
||||
assert_eq!(files, ["a.file", "--version", "--sample"], "after -- every word is a document");
|
||||
// A real document path, as Windows hands one on: kept whole, in order, backslashes and spaces intact.
|
||||
let (_, files) = split_at_delimiter(launcher_argv(&[r"C:\Users\user\Holiday letter.docx", "a.file"]));
|
||||
assert_eq!(files, [r"C:\Users\user\Holiday letter.docx", "a.file"], "a real path after -- stays a document, in order");
|
||||
}
|
||||
|
||||
/// A document whose name looks like a LaunchServices option is one only after the separator: the strip
|
||||
/// for macOS runs on the options, after the split, so `-- -NSNotes.docx report.docx` opens both.
|
||||
#[test]
|
||||
fn a_document_named_like_a_launch_argument_survives_the_separator() {
|
||||
let (options, after) = split_at_delimiter(["-psn_0_12345", "--", "-NSNotes.docx", "report.docx"].map(String::from).to_vec());
|
||||
assert!(super::without_launch_args(options).is_empty(), "the option before the separator goes");
|
||||
let hazard: Vec<String> = ["-NSNotes.docx", "report.docx"].map(String::from).to_vec();
|
||||
assert!(super::without_launch_args(hazard).is_empty(), "before the split the strip takes the document and the one after it");
|
||||
assert_eq!(documents_to_open(Vec::new(), after), ["-NSNotes.docx", "report.docx"], "what follows the separator is opened, in order");
|
||||
}
|
||||
|
||||
/// A stable line that carries its own separator: `a.file` before `--` opens before `b.file` after it.
|
||||
/// The flag loop keeps `a.file` (its `_` arm, one push) and `documents_to_open` puts the two lists
|
||||
/// back in command-line order; the reverse, appending the loop's list to the separator's, opened them
|
||||
/// backwards (found in review of #7849).
|
||||
#[test]
|
||||
fn documents_before_the_separator_keep_their_place_before_the_ones_after_it() {
|
||||
let (options, after) = split_at_delimiter(["--sample", "a.file", "--", "b.file"].map(String::from).to_vec());
|
||||
assert_eq!(options, ["--sample", "a.file"], "--sample is a switch and a.file is left for the loop");
|
||||
assert_eq!(documents_to_open(vec!["a.file".into()], after), ["a.file", "b.file"]);
|
||||
let (_, after) = split_at_delimiter(launcher_argv(&["b.file"]));
|
||||
assert_eq!(documents_to_open(Vec::new(), after), ["b.file"], "the Launcher sends nothing before the separator");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() {
|
||||
use crate::build_flavor::BuildFlavor;
|
||||
assert!(super::refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders");
|
||||
assert!(!super::refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang");
|
||||
assert!(!super::refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box");
|
||||
assert!(!super::refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,17 +110,7 @@ fn unmodelled_settings_survive_a_save_and_owned_ones_follow_the_model() {
|
||||
assert!(!s.contains("trackRevisions"), "{s}");
|
||||
assert_eq!(s.matches("compatibilityMode").count(), 1, "{s}");
|
||||
assert!(s.contains("mailMerge"), "{s}");
|
||||
let rel_id = s
|
||||
.split("<w:dataSource")
|
||||
.nth(1)
|
||||
.and_then(|after| after.split("r:id=\"").nth(1))
|
||||
.and_then(|after| after.split('"').next())
|
||||
.expect("dataSource r:id");
|
||||
let rels = text(&files, "word/_rels/settings.xml.rels");
|
||||
let expected_rel = format!(
|
||||
r#"<Relationship Id="{rel_id}" Type="{REL}/mailMergeSource" Target="file:///__wordcraft_missing_source__/letters.xlsx" TargetMode="External"/>"#
|
||||
);
|
||||
assert!(rels.contains(&expected_rel), "missing matching relationship for {rel_id}: {rels}");
|
||||
assert!(text(&files, "word/_rels/settings.xml.rels").contains("file:///__wordcraft_missing_source__/letters.xlsx"));
|
||||
// The privacy options are the model's (#1062): written once each, and gone when turned off.
|
||||
assert_eq!(s.matches("removePersonalInformation").count(), 1, "{s}");
|
||||
assert_eq!(s.matches("removeDateAndTime").count(), 1, "{s}");
|
||||
@@ -142,37 +132,6 @@ fn unmodelled_settings_survive_a_save_and_owned_ones_follow_the_model() {
|
||||
assert_eq!(text(&save(&again), "word/settings.xml"), s);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn changed_zoom_survives_merged_settings_and_reads_back_as_page_width() {
|
||||
let old_zoom = r#"<w:zoom w:percent="120"/>"#;
|
||||
let updated_zoom = r#"<w:zoom w:val="bestFit" w:percent="145"/>"#;
|
||||
for original in [SETTINGS.to_string(), SETTINGS.replace(old_zoom, "")] {
|
||||
let mut doc = wordcraft_docx::read(&with_settings(&original)).unwrap();
|
||||
assert!(doc.passthrough.contains_key("wordcraft:settings.orig"));
|
||||
doc.settings.zoom = Some(wordcraft_doc::Zoom { percent: 145, fit: Some(wordcraft_doc::ZoomFit::PageWidth) });
|
||||
let bytes = wordcraft_docx::write(&doc).unwrap();
|
||||
let settings = text(&unzip(&bytes), "word/settings.xml");
|
||||
assert_eq!(settings.matches("<w:zoom ").count(), 1, "{settings}");
|
||||
assert!(settings.contains(updated_zoom), "{settings}");
|
||||
// The retained root and unrelated child bytes still belong to the original file.
|
||||
let root_end = original.find("><w:").unwrap() + 1;
|
||||
assert!(settings.starts_with(&original[..root_end]), "{settings}");
|
||||
for kept in [
|
||||
r#"<w:proofState w:spelling="clean" w:grammar="clean"/>"#,
|
||||
r#"<w:docVars><w:docVar w:name="ClauseSet" w:val="B"/></w:docVars>"#,
|
||||
r#"<w:rsids><w:rsidRoot w:val="00A1B2C3"/><w:rsid w:val="00A1B2C3"/></w:rsids>"#,
|
||||
] {
|
||||
assert!(settings.contains(kept), "{kept} lost: {settings}");
|
||||
}
|
||||
assert!(pos(&settings, "<w:zoom ") < pos(&settings, "<w:proofState"));
|
||||
let again = wordcraft_docx::read(&bytes).unwrap();
|
||||
let zoom = again.settings.zoom.unwrap();
|
||||
assert_eq!(zoom.percent, 145);
|
||||
assert!(matches!(zoom.fit, Some(wordcraft_doc::ZoomFit::PageWidth)));
|
||||
assert_eq!(text(&save(&again), "word/settings.xml"), settings);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_written_by_wordcraft_keep_no_original() {
|
||||
let doc = wordcraft_doc::Document::new();
|
||||
|
||||
@@ -927,32 +927,4 @@ mod shortcut_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copy_format_web_alias_respects_user_removal_and_reassignment() {
|
||||
use craft_keymap::{Binding, Chord, CommandRef, Overrides, Policy};
|
||||
|
||||
let mut commands = super::super::registry().all().to_vec();
|
||||
commands.iter_mut().find(|c| c.id == "edit.copyFormat").unwrap().shortcut = copy_format_shortcut(true);
|
||||
let registry = Registry::new(commands);
|
||||
|
||||
let mut keymap = crate::keymap::registry_keymap(®istry, &Overrides::default());
|
||||
let copy_cmd = CommandRef::new("edit.copyFormat");
|
||||
let bold_cmd = CommandRef::new("format.bold");
|
||||
let chord = Chord::parse("Mod+Alt+Shift+C").unwrap();
|
||||
let binding = Binding::parse("Mod+Alt+Shift+C").unwrap();
|
||||
|
||||
assert!(keymap.bindings(©_cmd).iter().any(|b| b.trigger.chord == chord));
|
||||
assert!(keymap.remove(©_cmd, &binding));
|
||||
assert_eq!(keymap.holder(&chord), None);
|
||||
|
||||
keymap.assign(&bold_cmd, binding, Policy::Steal).unwrap();
|
||||
assert_eq!(keymap.holder(&chord).as_ref().map(|c| c.id.as_str()), Some("format.bold"));
|
||||
assert_eq!(keymap.holder(&Chord::parse("Mod+Shift+C").unwrap()).as_ref().map(|c| c.id.as_str()), Some("edit.copyFormat"));
|
||||
|
||||
let overrides = keymap.overrides().clone();
|
||||
let restored = crate::keymap::registry_keymap(®istry, &overrides);
|
||||
assert_eq!(restored.holder(&chord).as_ref().map(|c| c.id.as_str()), Some("format.bold"));
|
||||
assert_eq!(restored.holder(&Chord::parse("Mod+Shift+C").unwrap()).as_ref().map(|c| c.id.as_str()), Some("edit.copyFormat"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,28 +398,6 @@ mod tests {
|
||||
assert!(!page_text(&mut s).contains("{ AUTHOR }"));
|
||||
}
|
||||
|
||||
/// #980: F11 is full screen, as people expect of a desktop app; the field walk keeps Word's
|
||||
/// other keys, Alt+F1 and Alt+Shift+F1 (and Shift+F11).
|
||||
#[test]
|
||||
fn f11_is_full_screen_and_alt_f1_walks_fields() {
|
||||
let s = Session::new(wordcraft_doc::Document::new());
|
||||
let keymap = crate::keymap::registry_keymap(&s.registry, s.keymap());
|
||||
let chord = |c: &str| craft_keymap::Chord::parse(c).unwrap();
|
||||
let key = |k: &str| keymap.holder(&chord(k)).map(|c| c.id);
|
||||
assert_eq!(key("F11").as_deref(), Some("view.fullScreen"));
|
||||
assert_eq!(key("Alt+F1").as_deref(), Some("fields.next"));
|
||||
assert_eq!(key("Alt+Shift+F1").as_deref(), Some("fields.previous"));
|
||||
assert_eq!(key("Shift+F11").as_deref(), Some("fields.previous"));
|
||||
assert_eq!(key("Mod+F11").as_deref(), Some("fields.lock"));
|
||||
let shortcut = s.registry.get("view.fullScreen").map(|c| c.shortcut);
|
||||
if cfg!(target_os = "macos") {
|
||||
assert_eq!(shortcut, Some("Mod+Ctrl+F / F11"));
|
||||
assert_eq!(key("Mod+Ctrl+F").as_deref(), Some("view.fullScreen"));
|
||||
} else {
|
||||
assert_eq!(shortcut, Some("F11"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Editing a code changes the instruction and the result; lock keeps a result through updates;
|
||||
/// unlink turns the field into its text in one undo step; Alt+F1/Shift+F11 walk the fields.
|
||||
#[test]
|
||||
|
||||
+8
-189
@@ -1,8 +1,7 @@
|
||||
use super::ctx::{Ctx, Joining, page_anchored};
|
||||
use super::ctx::{Ctx, page_anchored};
|
||||
use super::floats::{
|
||||
ObjFrame, ObjectPlacement, WrapArea, align_in, float_rect, floating, left_out_objects, place_objects, rel_exclusions, wrap_area,
|
||||
};
|
||||
use super::flow::again;
|
||||
use super::page::PageFrame;
|
||||
use super::placed::Placed;
|
||||
use super::table_flow::below;
|
||||
@@ -263,19 +262,12 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
let frames = !matches!(story, StoryRef::Part(id) if ctx.doc.parts.get(&id).is_some_and(|p| p.kind == wordcraft_doc::PartKind::TextBox));
|
||||
// The bottom of the last paragraph's lines.
|
||||
let mut prev_end = 0.0f32;
|
||||
// Where the last paragraph, whose mark is hidden, ended: the next one goes on from there.
|
||||
let mut joint: Option<Joint> = None;
|
||||
let outer_joined = ctx.joined;
|
||||
for (i, b) in blocks.iter().enumerate() {
|
||||
last_top = y;
|
||||
let mut path = prefix.to_vec();
|
||||
path.push(i as u32);
|
||||
match &**b {
|
||||
Block::Para(p) => {
|
||||
// A paragraph after one whose mark is hidden goes on from that one's last line
|
||||
// (Word, #3986; see `Joint`); one that shows nothing passes the place on.
|
||||
let (mark_hidden, shows_nothing, taken) = Joint::arrive(ctx, &mut joint, (i, p), (width, frames), table);
|
||||
let p = taken.as_ref().map_or(p, |t| &t.para);
|
||||
let label = ctx.next_label(p);
|
||||
let listed = label.is_some();
|
||||
let mut pl = ctx.para_labelled(p, width, table, &[], label.clone());
|
||||
@@ -314,10 +306,8 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
});
|
||||
// Paragraph-relative floats start above the effective space before, as in the
|
||||
// body path. Keep text and wrap exclusions relative to the text's actual top.
|
||||
// A paragraph going on from a shared line has its origin at that line's top.
|
||||
let para_top = taken.as_ref().map_or(y, |t| t.joint.top);
|
||||
let para_top = y;
|
||||
y += if i == 0 { before } else { before.max(0.0) };
|
||||
TakenUp::start(taken.as_ref(), &mut y, &mut excl);
|
||||
// Floating objects anchored here: place them, then wrap the text around them.
|
||||
// One left out of the layout (hidden, or deleted in the final text) takes no room.
|
||||
let mut floats = HashMap::new();
|
||||
@@ -364,11 +354,10 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
if !rel.is_empty() {
|
||||
pl = ctx.para_labelled(p, width, table, &rel, label);
|
||||
}
|
||||
TakenUp::clear(taken.as_ref(), &mut excl);
|
||||
// Bordered paragraphs: room for their borders, those of a group joined in one box.
|
||||
let cell = table.map(|t| &t.para);
|
||||
let (above, below) = (joined(ctx.doc, blocks, i, i.checked_sub(1), cell), joined(ctx.doc, blocks, i, Some(i + 1), cell));
|
||||
let mut edges = Edges::own(&pl, 0, pl.lines.len()).sharing(&pl);
|
||||
let mut edges = Edges::own(&pl, 0, pl.lines.len());
|
||||
if above {
|
||||
edges.top = 0.0;
|
||||
}
|
||||
@@ -381,7 +370,6 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
edges.up = (y + lead - prev_end).max(0.0);
|
||||
}
|
||||
prev_end = push_para(&mut items, (story, &path), &pl, (0, pl.lines.len()), (0.0, y + lead), width, edges);
|
||||
joint = Joint::after(&pl, (0, pl.lines.len()), i, (0.0, y + lead), edges.bottom).filter(|_| mark_hidden && !shows_nothing).or(joint);
|
||||
// Pictures, shapes and text boxes: drawn, their areas and text boxes' text.
|
||||
if !p.objects.is_empty() {
|
||||
let at = ObjFrame {
|
||||
@@ -424,9 +412,7 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
let last = i + 1 == blocks.len();
|
||||
let normal = || pl.rp.style == "Normal" || ctx.doc.styles.get(&pl.rp.style).is_none();
|
||||
let after = if last && (pl.rp.after_auto || (in_cell && ctxl && normal())) { 0.0 } else { pl.rp.space_after };
|
||||
y += edges.top + pl.height + edges.bottom;
|
||||
// One going on from the line of the paragraph before ends below that line (#3986).
|
||||
y = TakenUp::end(taken.as_ref(), ctx, (y, after), outer_joined);
|
||||
y += edges.top + pl.height + edges.bottom + after;
|
||||
prev_after = after;
|
||||
prev_after_auto = pl.rp.after_auto;
|
||||
prev_listed = listed;
|
||||
@@ -459,7 +445,6 @@ pub(crate) fn layout_box(ctx: &mut Ctx, input: BoxInput<'_>) -> BoxLayout {
|
||||
y = y.max(legacy_header_reach(y, &legacy_reach));
|
||||
let floats_bottom = float_tables.iter().map(|r| r.bottom()).fold(float_objects_bottom, f32::max);
|
||||
ctx.hide_deleted = outer_hide;
|
||||
ctx.joined = outer_joined;
|
||||
BoxLayout { items, height: y.max(0.0), floats_bottom, last_top: last_top.max(0.0), table_areas, page_table_wraps }
|
||||
}
|
||||
|
||||
@@ -715,162 +700,6 @@ impl Edges {
|
||||
joined: [false; 2],
|
||||
}
|
||||
}
|
||||
|
||||
/// A paragraph going on from the line of the one before, whose mark is hidden (#3986), takes
|
||||
/// no room for its borders on that line, nor below it when that line is all it has: the
|
||||
/// shared line shows the first paragraph's shading and borders (Word).
|
||||
pub(crate) fn sharing(mut self, pl: &ParaLayout) -> Edges {
|
||||
if pl.shares_line() {
|
||||
self.top = 0.0;
|
||||
if pl.lines.len() <= 1 {
|
||||
self.bottom = 0.0;
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a paragraph whose mark is hidden ends (#3986). Word shows it on one line with the next
|
||||
/// paragraph: that one's text goes on from where this one's ends, beside it on its last line.
|
||||
/// Paragraphs that show nothing (an empty one with a hidden mark, say) pass the place on.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) struct Joint {
|
||||
/// The block that goes on from here.
|
||||
pub(crate) next: usize,
|
||||
/// The page (the count of pages) and column of the last line (body text only).
|
||||
pub(crate) page: usize,
|
||||
pub(crate) col: usize,
|
||||
/// The last line's top, height and baseline (from its top), the left edge of its column and
|
||||
/// the x its text ends at.
|
||||
pub(crate) top: f32,
|
||||
pub(crate) height: f32,
|
||||
baseline: f32,
|
||||
left: f32,
|
||||
end: f32,
|
||||
/// The room under the line for the paragraph's bottom border: what follows the shared line
|
||||
/// starts below it.
|
||||
room: f32,
|
||||
}
|
||||
|
||||
impl Joint {
|
||||
/// After lines `l0..l1` of paragraph layout `pl`, block `block`, the first of them at `y` in
|
||||
/// a column whose left edge is at `x`, with `room` under them for its bottom border.
|
||||
pub(crate) fn after(pl: &ParaLayout, (l0, l1): (usize, usize), block: usize, (x, y): (f32, f32), room: f32) -> Option<Joint> {
|
||||
let li = l1.checked_sub(1)?;
|
||||
let (first, last) = (pl.lines.get(l0)?, pl.lines.get(li)?);
|
||||
// Right-to-left text runs the other way: its lines aren't joined.
|
||||
if pl.rp.bidi || !last.vis.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let end = pl.x_of(li, pl.text_len)?;
|
||||
let (top, height, baseline) = (y + last.top - first.top, last.height, last.baseline - last.top);
|
||||
Some(Joint { next: block + 1, page: 0, col: 0, top, height, baseline, left: x, end: x + end, room })
|
||||
}
|
||||
|
||||
/// Paragraph `p`, block `i`, arriving at `joint`: whether its mark is hidden, whether it shows
|
||||
/// nothing, and how it goes on from the place the one before left (if that one's mark was hidden).
|
||||
fn arrive(
|
||||
ctx: &mut Ctx,
|
||||
joint: &mut Option<Joint>,
|
||||
(i, p): (usize, &Paragraph),
|
||||
(width, frames): (f32, bool),
|
||||
table: Option<¶::CellText>,
|
||||
) -> (bool, bool, Option<TakenUp>) {
|
||||
let chr = table.map(|t| &t.chr);
|
||||
let mark_hidden = ctx.mark_hidden(p, chr);
|
||||
let shows_nothing = mark_hidden && ctx.text_hidden(p, chr);
|
||||
let came = joint.take().filter(|j| j.next == i);
|
||||
*joint = came.filter(|_| shows_nothing).map(|j| Joint { next: i + 1, ..j });
|
||||
let taken = came.filter(|_| !shows_nothing).and_then(|j| j.take_up(ctx, p, (width, frames), table));
|
||||
(mark_hidden, shows_nothing, taken)
|
||||
}
|
||||
|
||||
/// The bottom of the shared line, with the room for the first paragraph's bottom border.
|
||||
pub(crate) fn bottom(&self) -> f32 {
|
||||
self.top + self.height + self.room
|
||||
}
|
||||
|
||||
/// How the next paragraph `q`, laid out `width` wide, goes on from here: how far below the
|
||||
/// shared line's top it starts (its first line's text sits on this paragraph's baseline, not
|
||||
/// above it), and the areas it keeps clear of: its first line, this paragraph's text, down to
|
||||
/// the bottom of that line only; its later lines, the rest of the shared line (a heading's,
|
||||
/// taller than the text going on from it), with the room for its bottom border (Word).
|
||||
pub(crate) fn fit(&self, ctx: &mut Ctx, q: &Paragraph, width: f32, table: Option<¶::CellText>) -> (f32, Vec<WrapArea>) {
|
||||
let eq = ctx.eq_count;
|
||||
let probe = again(ctx, eq, |ctx| ctx.para_labelled(q, width, table, &[], None));
|
||||
let (gap, height) = probe.lines.first().map_or((0.0, self.height), |l| ((self.baseline - (l.baseline - l.top)).max(0.0), l.height));
|
||||
let rect = Rect::new(self.left, self.top, (self.end - self.left).max(0.0), (gap + height - 0.01).max(0.01));
|
||||
let mut areas = vec![(rect, false, None, WrapText::Right, false)];
|
||||
// Just below the first row as the line breaker tests it: the breaker tests every row at
|
||||
// its estimate (`row_est`), not at the line's height, so the first row never meets this
|
||||
// area and every later row, starting lower, does and moves below it. The probe's own first
|
||||
// line can be taller than the real one (a large word that wraps off the narrower shared
|
||||
// line), so its height can't be used here.
|
||||
let below = self.top + gap + probe.row_est + 0.01;
|
||||
if self.bottom() > below {
|
||||
areas.push((Rect::new(self.left, below, width.max(0.01), self.bottom() - below), true, None, WrapText::BothSides, false));
|
||||
}
|
||||
(gap, areas)
|
||||
}
|
||||
|
||||
/// The areas [`Joint::fit`] gave taken out of `excl` again, the paragraph laid out.
|
||||
pub(crate) fn unfit(areas: &[WrapArea], excl: &mut Vec<WrapArea>) {
|
||||
for area in areas {
|
||||
if let Some(k) = excl.iter().position(|a| a.0 == area.0 && a.1 == area.1 && a.2.is_none() && a.3 == area.3) {
|
||||
excl.remove(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Paragraph `p` of a box `width` wide going on from here, unless a page break comes before
|
||||
/// it, it runs right to left or it is a text frame (`frames`: placed apart, sharing no line):
|
||||
/// without its space before, as [`Joint::fit`] lays it out.
|
||||
fn take_up(self, ctx: &mut Ctx, p: &Paragraph, (width, frames): (f32, bool), table: Option<¶::CellText>) -> Option<TakenUp> {
|
||||
let own = ctx.doc.styles.resolve_para_in(&p.props, table.map(|t| &t.para));
|
||||
if own.page_break_before || own.bidi || (frames && own.frame.is_some()) {
|
||||
return None;
|
||||
}
|
||||
let mut para = p.clone();
|
||||
para.props.space_before = Some(0.0);
|
||||
para.props.space_before_auto = Some(false);
|
||||
ctx.joined = Some(Joining::new(para.rev, 0.0));
|
||||
let (gap, areas) = self.fit(ctx, ¶, width, table);
|
||||
Some(TakenUp { joint: self, para, gap, areas })
|
||||
}
|
||||
}
|
||||
|
||||
/// A paragraph of a box going on from a [`Joint`]: the paragraph without its space before, how
|
||||
/// far below the shared line's top it starts and the areas its lines keep clear of.
|
||||
struct TakenUp {
|
||||
joint: Joint,
|
||||
para: Paragraph,
|
||||
gap: f32,
|
||||
areas: Vec<WrapArea>,
|
||||
}
|
||||
|
||||
impl TakenUp {
|
||||
/// Where it starts: `y` below the shared line's top, its lines keeping clear of that line.
|
||||
fn start(taken: Option<&TakenUp>, y: &mut f32, excl: &mut Vec<WrapArea>) {
|
||||
let Some(t) = taken else { return };
|
||||
*y = t.joint.top + t.gap;
|
||||
excl.extend(t.areas.iter().cloned());
|
||||
}
|
||||
|
||||
/// Its lines laid out: the areas they kept clear of come out of `excl`.
|
||||
fn clear(taken: Option<&TakenUp>, excl: &mut Vec<WrapArea>) {
|
||||
if let Some(t) = taken {
|
||||
Joint::unfit(&t.areas, excl);
|
||||
}
|
||||
}
|
||||
|
||||
/// Where what follows a paragraph ending at `y`, with `after` its space after, starts: below
|
||||
/// the shared line at least, with the first paragraph's bottom border. With the copy laid
|
||||
/// out, the paragraph's own layouts are its own again (`outer`).
|
||||
fn end(taken: Option<&TakenUp>, ctx: &mut Ctx, (y, after): (f32, f32), outer: Option<Joining>) -> f32 {
|
||||
let Some(t) = taken else { return y + after };
|
||||
ctx.joined = outer;
|
||||
y.max(t.joint.bottom()) + after
|
||||
}
|
||||
}
|
||||
|
||||
/// Paragraph lines plus their shading and borders; returns the bottom of the lines. The
|
||||
@@ -888,21 +717,12 @@ pub(crate) fn push_para(
|
||||
return y;
|
||||
};
|
||||
let h = last.top + last.height - first.top;
|
||||
let lines = Placed::Lines { story, path: Path(path.to_vec()), para: pl.clone(), l0, l1, x, y, turn: TextDirection::Horizontal };
|
||||
// The line a paragraph shares with the one before, whose mark is hidden, shows that one's
|
||||
// shading and borders: this one's start on its own next line, without a top border (Word, #3986).
|
||||
let shared = l0 == 0 && pl.shares_line();
|
||||
let Some(own) = pl.lines.get(if shared { 1 } else { l0 }).filter(|_| !shared || l1 > 1) else {
|
||||
items.push(lines);
|
||||
return y + h;
|
||||
};
|
||||
let (y_own, e) = if shared { (y + own.top - first.top, Edges { top: 0.0, up: 0.0, ..e }) } else { (y, e) };
|
||||
// Indents are logical: a right-to-left paragraph's start indent (and hanging indent) is on the right.
|
||||
let start = pl.rp.indent_left.min(pl.rp.indent_left + pl.rp.indent_first);
|
||||
let (li, ri) = if pl.rp.bidi { (pl.rp.indent_right, start) } else { (start, pl.rp.indent_right) };
|
||||
let left = x + li;
|
||||
let right = x + width - ri;
|
||||
let (top, bottom) = (y_own - e.top - e.up, y + h + e.bottom);
|
||||
let (top, bottom) = (y - e.top - e.up, y + h + e.bottom);
|
||||
// The outer edges of the side borders.
|
||||
let sides = pl.rp.borders.unwrap_or_default();
|
||||
let (lx, rx) = (left - border_room(sides.left), right + border_room(sides.right));
|
||||
@@ -911,7 +731,7 @@ pub(crate) fn push_para(
|
||||
let (sl, sr) = (lx.min(left - pad), rx.max(right + pad));
|
||||
items.push(Placed::Fill { rect: Rect::new(sl, top, sr - sl, bottom - top), color: c });
|
||||
}
|
||||
items.push(lines);
|
||||
items.push(Placed::Lines { story, path: Path(path.to_vec()), para: pl.clone(), l0, l1, x, y, turn: TextDirection::Horizontal });
|
||||
if let Some(b) = &pl.rp.borders {
|
||||
// All four lines lie beyond their distance from the text (`lx`, `rx`: the side lines'
|
||||
// outer edges); `box_rules` runs the top and bottom over the side lines to those edges.
|
||||
@@ -919,10 +739,9 @@ pub(crate) fn push_para(
|
||||
let (cl, cr) = (lx + half(b.left), rx - half(b.right));
|
||||
let tb = b.top.filter(|t| e.top > 0.0 && t.is_visible());
|
||||
let bb = b.bottom.filter(|t| e.bottom > 0.0 && t.is_visible());
|
||||
let ty = tb.map_or(top, |t| y_own - t.space - t.width / 2.0);
|
||||
let ty = tb.map_or(top, |t| y - t.space - t.width / 2.0);
|
||||
let by = bb.map_or(bottom, |t| y + h + t.space + t.width / 2.0);
|
||||
// Open at the top where it goes on over the shared line.
|
||||
box_rules(items, (cl, ty, cr, by), [tb, bb, b.left, b.right], [e.joined[0] || shared, e.joined[1]]);
|
||||
box_rules(items, (cl, ty, cr, by), [tb, bb, b.left, b.right], e.joined);
|
||||
}
|
||||
y + h
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@ pub(crate) struct Key {
|
||||
pub(crate) sref: u64,
|
||||
/// The word being typed in this paragraph, left without a spelling squiggle.
|
||||
pub(crate) typing: Option<(usize, usize)>,
|
||||
/// A copy of the paragraph going on from the line of the one before (`ctx::Joining`): its
|
||||
/// space before and whether it shares that line ([`ParaEnv::joined`](crate::para::ParaEnv)).
|
||||
pub(crate) joined: Option<(u32, bool)>,
|
||||
}
|
||||
|
||||
/// Memoised paragraph layouts.
|
||||
|
||||
@@ -51,9 +51,6 @@ pub(crate) struct Ctx<'a> {
|
||||
/// Empty body paragraphs with hidden marks or continuous section breaks, in order:
|
||||
/// they take no room (see [`place_para`]).
|
||||
pub(crate) quiet_marks: Vec<usize>,
|
||||
/// The paragraph being laid out as going on from the line of the one before, whose mark is
|
||||
/// hidden: its list number is counted but not drawn (#3986).
|
||||
pub(crate) joined: Option<Joining>,
|
||||
/// Empty paragraphs closing a continuous section right after another section's mark, in
|
||||
/// order: each takes its line while it fits, then stays at the page's bottom (#3907).
|
||||
pub(crate) stacked_marks: Vec<usize>,
|
||||
@@ -82,31 +79,6 @@ pub(crate) struct Ctx<'a> {
|
||||
pub(crate) header_repeats: usize,
|
||||
}
|
||||
|
||||
/// A paragraph going on from the line of the one before, whose mark is hidden (#3986): a copy of
|
||||
/// the document's, which keeps its revision, given the space before that puts its text on that
|
||||
/// line's baseline.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(crate) struct Joining {
|
||||
/// The paragraph's revision.
|
||||
pub(crate) rev: u64,
|
||||
/// The space before the copy is given.
|
||||
before: f32,
|
||||
/// Whether it still shares that line: not once its first line has moved on to the next
|
||||
/// column or page, where it is laid out as on its own (the copy's space before kept).
|
||||
pub(crate) shares: bool,
|
||||
}
|
||||
|
||||
impl Joining {
|
||||
pub(crate) fn new(rev: u64, before: f32) -> Self {
|
||||
Joining { rev, before, shares: true }
|
||||
}
|
||||
|
||||
/// What tells the copy's layouts apart from each other and from the paragraph's own.
|
||||
fn key(self) -> (u32, bool) {
|
||||
(self.before.to_bits(), self.shares)
|
||||
}
|
||||
}
|
||||
|
||||
struct ParaEnvInput<'a> {
|
||||
width: f32,
|
||||
label: Option<(String, Level)>,
|
||||
@@ -115,7 +87,6 @@ struct ParaEnvInput<'a> {
|
||||
eq_number: u32,
|
||||
typing_word: Option<(usize, usize)>,
|
||||
fitted: &'a [(usize, f32)],
|
||||
joined: bool,
|
||||
}
|
||||
|
||||
/// A header or footer (`story`) laid out for page `number` of a section (`sect`, `mirror`): its
|
||||
@@ -256,31 +227,12 @@ impl Ctx<'_> {
|
||||
grid: para::Grid::default(),
|
||||
fit_objects: false,
|
||||
fitted: &[],
|
||||
joined: false,
|
||||
};
|
||||
let pl = Arc::new(para::layout_para(&p, &env));
|
||||
self.numbers.insert(n, pl.clone());
|
||||
pl
|
||||
}
|
||||
|
||||
/// Whether `p` is laid out going on from the line of the paragraph before, sharing it (#3986).
|
||||
fn shares_line(&self, p: &Paragraph) -> bool {
|
||||
self.joined.is_some_and(|j| j.rev == p.rev && j.shares)
|
||||
}
|
||||
|
||||
/// Whether `p`'s paragraph mark is hidden, with hidden text not shown: Word then shows the
|
||||
/// paragraph on one line with the next one (#3986). A section's closing mark never joins.
|
||||
pub(crate) fn mark_hidden(&self, p: &Paragraph, table_chr: Option<&CharProps>) -> bool {
|
||||
!self.opts.show_hidden && p.section.is_none() && self.doc.styles.resolve_char_in(p.props.style.as_deref(), table_chr, &p.mark).hidden
|
||||
}
|
||||
|
||||
/// Whether `p` shows none of its text (it has none, or all of it is hidden and not shown).
|
||||
pub(crate) fn text_hidden(&self, p: &Paragraph, table_chr: Option<&CharProps>) -> bool {
|
||||
p.text.is_empty()
|
||||
|| (!self.opts.show_hidden
|
||||
&& p.runs.iter().all(|r| r.len == 0 || self.doc.styles.resolve_char_in(p.props.style.as_deref(), table_chr, &r.props).hidden))
|
||||
}
|
||||
|
||||
/// The list label of `p`, advancing the list counters: call it once per paragraph, in
|
||||
/// document order (only for paragraphs that will show).
|
||||
/// Whether `p` gets a list label ([`Ctx::next_label`] is `Some`), without counting it.
|
||||
@@ -317,16 +269,7 @@ impl Ctx<'_> {
|
||||
let typing = key.typing;
|
||||
let pl = Arc::new(para::layout_para(
|
||||
p,
|
||||
&self.para_env(ParaEnvInput {
|
||||
width,
|
||||
label,
|
||||
table,
|
||||
exclusions,
|
||||
eq_number,
|
||||
typing_word: typing,
|
||||
fitted: &fitted,
|
||||
joined: self.shares_line(p),
|
||||
}),
|
||||
&self.para_env(ParaEnvInput { width, label, table, exclusions, eq_number, typing_word: typing, fitted: &fitted }),
|
||||
));
|
||||
self.cache.paras.insert(key, pl.clone());
|
||||
pl
|
||||
@@ -359,16 +302,7 @@ impl Ctx<'_> {
|
||||
self.cache.misses += 1;
|
||||
let pl = Arc::new(para::layout_para(
|
||||
p,
|
||||
&self.para_env(ParaEnvInput {
|
||||
width,
|
||||
label,
|
||||
table: None,
|
||||
exclusions: &[],
|
||||
eq_number,
|
||||
typing_word: None,
|
||||
fitted: &[],
|
||||
joined: self.shares_line(p),
|
||||
}),
|
||||
&self.para_env(ParaEnvInput { width, label, table: None, exclusions: &[], eq_number, typing_word: None, fitted: &[] }),
|
||||
));
|
||||
self.cache.paras.insert(key, pl.clone());
|
||||
Some(pl)
|
||||
@@ -396,16 +330,7 @@ impl Ctx<'_> {
|
||||
let typing = key.typing;
|
||||
let m = measure(¶::layout_para(
|
||||
p,
|
||||
&self.para_env(ParaEnvInput {
|
||||
width,
|
||||
label,
|
||||
table,
|
||||
exclusions: &[],
|
||||
eq_number,
|
||||
typing_word: typing,
|
||||
fitted: &fitted,
|
||||
joined: self.shares_line(p),
|
||||
}),
|
||||
&self.para_env(ParaEnvInput { width, label, table, exclusions: &[], eq_number, typing_word: typing, fitted: &fitted }),
|
||||
));
|
||||
self.cache.measures.insert(key, m);
|
||||
m
|
||||
@@ -490,7 +415,6 @@ impl Ctx<'_> {
|
||||
hide_deleted: self.hide_deleted,
|
||||
sref: if self.fields.styleref.is_some() && styleref::has_styleref(p) { self.fields.styleref_key(p) } else { 0 },
|
||||
typing: self.opts.typing_word.filter(|t| t.rev == p.rev).map(|t| (t.start, t.end)),
|
||||
joined: self.joined.filter(|j| j.rev == p.rev).map(Joining::key),
|
||||
};
|
||||
(key, eq_number)
|
||||
}
|
||||
@@ -511,7 +435,7 @@ impl Ctx<'_> {
|
||||
}
|
||||
|
||||
fn para_env<'b>(&'b self, input: ParaEnvInput<'b>) -> para::ParaEnv<'b> {
|
||||
let ParaEnvInput { width, label, table, exclusions, eq_number, typing_word, fitted, joined } = input;
|
||||
let ParaEnvInput { width, label, table, exclusions, eq_number, typing_word, fitted } = input;
|
||||
para::ParaEnv {
|
||||
doc: self.doc,
|
||||
width,
|
||||
@@ -530,7 +454,6 @@ impl Ctx<'_> {
|
||||
grid: self.grid,
|
||||
fit_objects: self.boxes.inside(),
|
||||
fitted,
|
||||
joined,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -602,7 +525,6 @@ mod tests {
|
||||
track_totals: false,
|
||||
pct_base: None,
|
||||
quiet_marks: Vec::new(),
|
||||
joined: None,
|
||||
stacked_marks: Vec::new(),
|
||||
mirror: false,
|
||||
table_keys: Vec::new(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::boxes::{BoxInput, BoxLayout, Edges, Joint, joined, layout_box, push_para};
|
||||
use super::boxes::{BoxInput, BoxLayout, Edges, joined, layout_box, push_para};
|
||||
use super::cache::has_page_number_fields;
|
||||
use super::ctx::{Ctx, Joining};
|
||||
use super::ctx::Ctx;
|
||||
use super::floats::{
|
||||
FloatAnchor, LateFloats, ObjFrame, ObjectPlacement, anchor_floats, body_wraps, continued_exclusions, fitting, late_floats, place_late,
|
||||
place_objects,
|
||||
@@ -15,89 +15,9 @@ use super::{
|
||||
#[cfg(test)]
|
||||
use crate::WRAP_RELAYS;
|
||||
|
||||
/// A body paragraph. One after a paragraph whose mark is hidden goes on from that one's last line,
|
||||
/// as Word shows them, on one line (#3986): see [`Joint`].
|
||||
pub(crate) fn place_para(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, block: usize, body_top: f32) {
|
||||
let joint = pb.joint.take().filter(|j| !pb.web && j.next == block && j.page == pb.pages.len() && j.col == pb.col);
|
||||
let mark_hidden = ctx.mark_hidden(p, None);
|
||||
// Nothing of it is shown: the place passes on to the paragraph after it.
|
||||
if mark_hidden && ctx.text_hidden(p, None) {
|
||||
place_para_alone(ctx, pb, p, block, body_top);
|
||||
pb.joint = joint.map(|mut j| {
|
||||
j.next = block + 1;
|
||||
j
|
||||
});
|
||||
return;
|
||||
}
|
||||
let goes_on = joint.filter(|_| {
|
||||
p.section.is_none()
|
||||
&& ctx.quiet_marks.binary_search(&block).is_err()
|
||||
&& ctx.stacked_marks.binary_search(&block).is_err()
|
||||
&& !ctx.doc.styles.resolve_para(&p.props).page_break_before
|
||||
&& !ctx.doc.styles.resolve_para(&p.props).bidi
|
||||
});
|
||||
match goes_on {
|
||||
Some(j) => place_para_joined(ctx, pb, p, (block, body_top), j),
|
||||
None => place_para_alone(ctx, pb, p, block, body_top),
|
||||
}
|
||||
if mark_hidden {
|
||||
let path = Path::top(block);
|
||||
pb.joint = pb.page().and_then(|page| {
|
||||
page.items.iter().rev().find_map(|it| match it {
|
||||
Placed::Lines { story: StoryRef::Body, path: at, para, l0, l1, x, y, turn: TextDirection::Horizontal, .. } if *at == path => {
|
||||
let room = if *l1 >= para.lines.len() { Rooms::of(ctx, block, para).bottom } else { 0.0 };
|
||||
Joint::after(para, (*l0, *l1), block, (*x, *y), room)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
});
|
||||
if let Some(j) = pb.joint.as_mut() {
|
||||
(j.page, j.col) = (pb.pages.len(), pb.col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `p` going on from the last line of the paragraph before (`j`): its first line starts at that
|
||||
/// line's top, beside that paragraph's text, with no space before and its list number counted
|
||||
/// but not drawn; its space after and line spacing are its own (Word, #3986).
|
||||
fn place_para_joined(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, (block, body_top): (usize, f32), j: Joint) {
|
||||
// The copy keeps the paragraph's revision, so the word being typed in it is found and its
|
||||
// layouts are reused from one pass to the next: the cache tells them apart by `Joining`.
|
||||
let mut q = p.clone();
|
||||
q.props.space_before = Some(0.0);
|
||||
q.props.space_before_auto = Some(false);
|
||||
let outer = ctx.joined.replace(Joining::new(q.rev, 0.0));
|
||||
let (gap, areas) = j.fit(ctx, &q, pb.col_w(), None);
|
||||
if gap > 0.0 {
|
||||
q.props.space_before = Some(gap);
|
||||
ctx.joined = Some(Joining::new(q.rev, gap));
|
||||
}
|
||||
pb.y = j.top;
|
||||
pb.prev = None;
|
||||
pb.unmark_block();
|
||||
pb.excl.extend(areas.iter().cloned());
|
||||
place_para_alone(ctx, pb, &q, block, body_top);
|
||||
ctx.joined = outer;
|
||||
Joint::unfit(&areas, &mut pb.excl);
|
||||
// The shared line is at least as tall as the first paragraph's, with its bottom border: what
|
||||
// follows starts below it.
|
||||
if (pb.pages.len(), pb.col) == (j.page, j.col) {
|
||||
pb.y = pb.y.max(j.bottom() + ctx.doc.styles.resolve_para(&q.props).space_after);
|
||||
}
|
||||
}
|
||||
|
||||
/// A paragraph going on from the line of the one before (#3986) whose first line moves on to the
|
||||
/// next column or page no longer shares that line: it is laid out as it is on its own there, its
|
||||
/// list number drawn and its first-line indent and alignment its own.
|
||||
fn unjoin(ctx: &mut Ctx, p: &Paragraph) {
|
||||
if let Some(j) = ctx.joined.as_mut().filter(|j| j.rev == p.rev) {
|
||||
j.shares = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// A closing mark before a continuous section takes no room after content. An otherwise empty
|
||||
/// section starting a new page retains its paragraph line.
|
||||
fn place_para_alone(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, block: usize, body_top: f32) {
|
||||
pub(crate) fn place_para(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, block: usize, body_top: f32) {
|
||||
if !pb.web && ctx.quiet_marks.binary_search(&block).is_ok() {
|
||||
let follows_section = block.checked_sub(1).and_then(|i| ctx.doc.body.get(i)).and_then(|b| b.as_para()).is_some_and(|p| p.section.is_some());
|
||||
let section = pb.sect_idx;
|
||||
@@ -207,7 +127,7 @@ impl Rooms {
|
||||
fn of(ctx: &Ctx, block: usize, pl: &ParaLayout) -> Self {
|
||||
let above = joined(ctx.doc, &ctx.doc.body, block, block.checked_sub(1), None);
|
||||
let below = joined(ctx.doc, &ctx.doc.body, block, Some(block + 1), None);
|
||||
let own = Edges::own(pl, 0, pl.lines.len()).sharing(pl);
|
||||
let own = Edges::own(pl, 0, pl.lines.len());
|
||||
Rooms { above, below, top: if above { 0.0 } else { own.top }, bottom: if below { 0.0 } else { own.bottom } }
|
||||
}
|
||||
}
|
||||
@@ -440,7 +360,6 @@ impl<'a> Flow<'a> {
|
||||
// keeps the lines and the next paragraph together at the top of a column too (#6821).
|
||||
if pb.y + need > pb.bottom + 0.01 && (!pb.fresh() || Self::strict_widow_control(ctx, pb)) && need <= pb.next_room(self.body_top) {
|
||||
pb.advance(self.block, self.body_top);
|
||||
unjoin(ctx, self.p);
|
||||
pb.y += rp.space_before.min(0.0);
|
||||
return rp.space_before.min(0.0);
|
||||
}
|
||||
@@ -638,7 +557,6 @@ impl<'a> Flow<'a> {
|
||||
fn move_on(&mut self, ctx: &mut Ctx, pb: &mut PageBuilder) {
|
||||
pb.advance(self.block, self.body_top);
|
||||
if self.l0 == 0 {
|
||||
unjoin(ctx, self.p);
|
||||
let y0 = pb.y;
|
||||
self.reanchor(ctx, pb, (y0, 0.0), &[]);
|
||||
self.anchor_y = y0;
|
||||
@@ -928,11 +846,6 @@ fn line_numbers(ctx: &mut Ctx, pb: &mut PageBuilder, pl: &ParaLayout, (l0, l1):
|
||||
{
|
||||
for li in l0..l1 {
|
||||
let Some(line) = pl.lines.get(li).filter(|l| !l.beside) else { continue };
|
||||
// The first line of a paragraph going on from the line of the one before (#3986)
|
||||
// shares that line, numbered already, unless its first word went on the next one.
|
||||
if li == 0 && pl.shares_line() {
|
||||
continue;
|
||||
}
|
||||
pb.line_no = pb.line_no.saturating_add(1);
|
||||
let n = pb.line_no.saturating_add(ln.start.saturating_sub(1));
|
||||
if ln.count_by > 1 && !n.is_multiple_of(ln.count_by) {
|
||||
@@ -982,7 +895,7 @@ fn place_para_in_flow(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, block:
|
||||
}
|
||||
let before = f.gap_before(ctx, pb, broke_before);
|
||||
pb.y += before;
|
||||
let mut rooms = Rooms::of(ctx, block, &f.pl);
|
||||
let rooms = Rooms::of(ctx, block, &f.pl);
|
||||
let applied_before = f.keep_together(ctx, pb, rooms, before);
|
||||
// A different top only matters when there is something to wrap around.
|
||||
if spot(pb) != placed_at || ((pb.y - f.guess).abs() > 0.01 && !pb.excl.is_empty()) {
|
||||
@@ -991,10 +904,7 @@ fn place_para_in_flow(ctx: &mut Ctx, pb: &mut PageBuilder, p: &Paragraph, block:
|
||||
f.anchor_y = y0 - applied_before;
|
||||
}
|
||||
while f.l0 < f.n() {
|
||||
// A paragraph moved on from the shared line (`unjoin`) is laid out again with borders of its own.
|
||||
rooms = Rooms::of(ctx, block, &f.pl);
|
||||
f.keep_again(ctx, pb, rooms);
|
||||
rooms = Rooms::of(ctx, block, &f.pl);
|
||||
f.place_due_late(ctx, pb);
|
||||
f.relay_wrap(ctx, pb);
|
||||
f.relay_pages(ctx, pb);
|
||||
@@ -1188,7 +1098,6 @@ fn next_first_line(ctx: &mut Ctx, block: usize, width: f32, depth: usize, new_pa
|
||||
grid: ctx.grid,
|
||||
fit_objects: false,
|
||||
fitted: &[],
|
||||
joined: false,
|
||||
};
|
||||
Arc::new(para::layout_para(p, &env))
|
||||
}
|
||||
|
||||
@@ -319,14 +319,6 @@ pub fn page_lines(page: &Page, story: StoryRef) -> Vec<LineHit<'_>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A paragraph going on from the last line of one whose mark is hidden shares that line
|
||||
// (#3986): the first one's part of it ends where the second one's text starts.
|
||||
let joins: Vec<(f32, f32, f32)> = v.iter().filter(|l| l.para.shares_line() && l.li == 0).map(|l| (l.top, l.bottom, l.left)).collect();
|
||||
for (top, bottom, left) in joins {
|
||||
for l in v.iter_mut().filter(|l| l.top < bottom && top < l.bottom && l.left < left && left < l.right) {
|
||||
l.right = left;
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::boxes::{BoxInput, Joint, box_rules, layout_box};
|
||||
use super::boxes::{BoxInput, box_rules, layout_box};
|
||||
use super::ctx::{Ctx, with_pin};
|
||||
use super::floats::{EarlyFloats, WrapArea};
|
||||
use super::notes::{NOTE_SEP, NOTE_SEP_W, NoteBox, NoteSeps, v_span};
|
||||
@@ -35,8 +35,6 @@ pub(crate) struct PageBuilder<'a> {
|
||||
/// The previous paragraph ended with a page break (its mark stayed with the break): the next
|
||||
/// paragraph, first on the new page, gets no space before (Word).
|
||||
pub(crate) after_break_mark: bool,
|
||||
/// Where the last paragraph, whose mark is hidden, ended: the next one goes on from there.
|
||||
pub(crate) joint: Option<Joint>,
|
||||
/// The next section starts on a new page: this section's closing mark, when empty, needs no
|
||||
/// room (Word leaves it on a full page rather than starting a page for it).
|
||||
pub(crate) next_starts_page: bool,
|
||||
@@ -230,16 +228,6 @@ impl PageBuilder<'_> {
|
||||
self.block_marks.push(pg.items.len().saturating_sub(behind));
|
||||
}
|
||||
}
|
||||
/// Takes back the mark of a block that has placed nothing yet: it goes on from the line of
|
||||
/// the block before (#3986), and justified vertical alignment keeps the two together.
|
||||
pub(crate) fn unmark_block(&mut self) {
|
||||
if let Some(pg) = self.pages.last() {
|
||||
let behind = self.behind.last().copied().unwrap_or(0);
|
||||
if self.block_marks.last() == Some(&pg.items.len().saturating_sub(behind)) {
|
||||
self.block_marks.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Justified vertical alignment: share the room left below the page's text out equally
|
||||
/// between the gaps of its blocks, so the last line sits on the bottom margin (above the
|
||||
/// footnotes). A page with one block, or several columns, stays at the top.
|
||||
|
||||
@@ -101,20 +101,9 @@ pub struct ParaLayout {
|
||||
/// Room after a cluster between Asian text and Latin text or digits ([`auto_space`]), by
|
||||
/// cluster index, sorted. It is part of the cluster's advance, but takes no room at a line's end.
|
||||
pub auto_space: Vec<(usize, f32)>,
|
||||
/// It goes on from the last line of the paragraph before, whose mark is hidden, and shares
|
||||
/// that line ([`ParaEnv::joined`]).
|
||||
pub joined: bool,
|
||||
/// How tall the line breaker takes a row to be when it checks it against wrap areas.
|
||||
pub(crate) row_est: f32,
|
||||
}
|
||||
|
||||
impl ParaLayout {
|
||||
/// Whether its first line is the one it shares with the paragraph before, whose mark is
|
||||
/// hidden (#3986), rather than a line of its own below it (its first word didn't fit there).
|
||||
pub(crate) fn shares_line(&self) -> bool {
|
||||
self.joined && self.lines.first().is_some_and(|l| l.top <= 0.01)
|
||||
}
|
||||
|
||||
/// The room a horizontal rule at cluster `k` is placed in, from its left edge to the end of
|
||||
/// what the line has left. A first-line indent moves that end along (Word, measured with
|
||||
/// 50 % and fixed-width rules beside floats on either side and with first-line and hanging
|
||||
@@ -370,7 +359,6 @@ mod label_spacing_tests {
|
||||
read_line_spacing: None,
|
||||
fit_objects: false,
|
||||
fitted: &[],
|
||||
joined: false,
|
||||
};
|
||||
let mut p = Paragraph::with_text(if wrap { "Alpha probe synthetic business text repeated" } else { "Alpha probe" }, Default::default());
|
||||
p.props.line_spacing = Some(spacing);
|
||||
|
||||
@@ -63,9 +63,6 @@ struct Breaker<'e> {
|
||||
row_first: usize,
|
||||
/// Spans skipped in a row because the next word didn't fit (see `Scan::skip`).
|
||||
skipped: usize,
|
||||
/// The paragraph goes on from the line of the one before (#3986): its first line starts right
|
||||
/// after that one's text, and takes its place there whatever its own alignment.
|
||||
joined: bool,
|
||||
/// A left tab past the right indent that wrapped to start the next line.
|
||||
wrapped_tab: Option<usize>,
|
||||
}
|
||||
@@ -191,9 +188,7 @@ impl<'e> Breaker<'e> {
|
||||
n: pl.clusters.len(),
|
||||
width,
|
||||
base_right: (width - rp.indent_right).max(1.0),
|
||||
// On the line it shares with the paragraph before (#3986), kept clear of that one's
|
||||
// text by an exclusion, a joined paragraph's own indents don't hold its text back.
|
||||
first_left: if env.joined { (rp.indent_left + rp.indent_first).min(0.0) } else { rp.indent_left + rp.indent_first },
|
||||
first_left: rp.indent_left + rp.indent_first,
|
||||
default_tab: settings.default_tab,
|
||||
hanging_at: if rp.indent_first < 0.0 { Some(rp.indent_left) } else { None },
|
||||
tab_origin: if settings.odf.is_some_and(|o| o.tabs_from_indent) { rp.indent_left } else { 0.0 },
|
||||
@@ -227,20 +222,13 @@ impl<'e> Breaker<'e> {
|
||||
row_rest: VecDeque::new(),
|
||||
row_first: 0,
|
||||
skipped: 0,
|
||||
joined: env.joined,
|
||||
wrapped_tab: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The first line's start: a joined paragraph's first line pushed below the shared line (its
|
||||
/// first word didn't fit there) starts at the paragraph's left indent, as its other lines do.
|
||||
fn first_indent(&self) -> f32 {
|
||||
if self.joined && self.top > 0.0 { self.rp.indent_left } else { self.first_left }
|
||||
}
|
||||
|
||||
/// The left edge of the row's first span: the indent, behind a drop cap on its lines.
|
||||
fn row_left(&self, pl: &ParaLayout) -> f32 {
|
||||
let lo = if self.first { self.first_indent() } else { self.rp.indent_left };
|
||||
let lo = if self.first { self.first_left } else { self.rp.indent_left };
|
||||
match pl.drop_cap {
|
||||
Some((_, dl, dw)) if dw > 0.0 && self.lines.len() < dl as usize => self.first_left.max(self.rp.indent_left) + dw,
|
||||
_ => lo,
|
||||
@@ -283,7 +271,7 @@ impl<'e> Breaker<'e> {
|
||||
/// The start of a line: its span, and the list label if it is the first.
|
||||
fn begin_line(&mut self, pl: &mut ParaLayout) -> Scan {
|
||||
let beside = !self.row_rest.is_empty() && self.lines.len() > self.row_first;
|
||||
let row_lo = if self.first { self.first_indent() } else { self.rp.indent_left };
|
||||
let row_lo = if self.first { self.first_left } else { self.rp.indent_left };
|
||||
let (left, right_edge, narrowed) = self.next_span(pl);
|
||||
let x = if self.first { self.place_label(pl, left) } else { left };
|
||||
Scan {
|
||||
@@ -575,10 +563,7 @@ impl<'e> Breaker<'e> {
|
||||
let last_tab = (c0..c1).rev().find(|k| pl.clusters.get(*k).is_some_and(|c| c.kind == ClKind::Tab));
|
||||
let align_from = last_tab.map(|k| k + 1).unwrap_or(c0);
|
||||
let display = pl.displays.iter().find(|(ci, _)| *ci >= c0 && *ci < c1).map(|d| d.1);
|
||||
// The line a paragraph shares with the one before, whose mark is hidden, starts in that
|
||||
// one, and takes its place right after that one's text (Word, #3986).
|
||||
let align = if self.joined && self.lines.is_empty() { Align::Left } else { rp.align };
|
||||
let shift = match (display, align) {
|
||||
let shift = match (display, rp.align) {
|
||||
(Some(MathJc::Left), _) => 0.0,
|
||||
(Some(MathJc::Right), _) => slack,
|
||||
(Some(_), _) => slack / 2.0,
|
||||
@@ -602,13 +587,13 @@ impl<'e> Breaker<'e> {
|
||||
}
|
||||
// A line ending in a manual line break is stretched too, unless `doNotExpandShiftReturn` says not to.
|
||||
let stretch_end = sc.end == LineEnd::Wrap || (sc.end == LineEnd::LineBreak && self.expand_break);
|
||||
let justify = display.is_none() && ((align == Align::Justify && stretch_end) || align == Align::Distribute);
|
||||
let justify = display.is_none() && ((rp.align == Align::Justify && stretch_end) || rp.align == Align::Distribute);
|
||||
// A line that only fits with shrunk spaces is shrunk, the last line of the paragraph too.
|
||||
let shrink = display.is_none() && self.shrink_spaces && slack < 0.0 && last_tab.is_none();
|
||||
if shrink {
|
||||
shrink_line_spaces(pl, &mut sc.xs, c0, c1, content_end, slack);
|
||||
} else if justify && slack > 0.0 {
|
||||
justify_line(pl, &mut sc.xs, (c0, c1, align_from), (content_end, slack), align == Align::Distribute);
|
||||
justify_line(pl, &mut sc.xs, (c0, c1, align_from), (content_end, slack), rp.align == Align::Distribute);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,7 +692,6 @@ impl<'e> Breaker<'e> {
|
||||
fn finish(mut self, pl: &mut ParaLayout) {
|
||||
self.hang_drop_cap(pl);
|
||||
pl.height = self.top;
|
||||
pl.row_est = self.est_h;
|
||||
pl.lines = std::mem::take(&mut self.lines);
|
||||
let label_shift = self.label_shifts.get(pl.label_line()).copied().unwrap_or(0.0);
|
||||
if let Some(lab) = pl.label.as_mut() {
|
||||
|
||||
@@ -401,7 +401,4 @@ pub struct ParaEnv<'a> {
|
||||
/// Heights of the paragraph's inline text boxes that resize to fit their text, by object
|
||||
/// index: they take these instead of their saved heights.
|
||||
pub fitted: &'a [(usize, f32)],
|
||||
/// The paragraph goes on from the line of the one before, whose mark is hidden (#3986): its
|
||||
/// list number is counted and sets its indents, but isn't drawn.
|
||||
pub joined: bool,
|
||||
}
|
||||
|
||||
@@ -533,14 +533,13 @@ fn mark_break_opportunities(clusters: &mut [Cluster], bt: &BreakText, rp: &Resol
|
||||
}
|
||||
}
|
||||
|
||||
/// The list label, shaped; none on a paragraph containing only a page break, nor on one that goes
|
||||
/// on from the line of the paragraph before (#3986): Word hides it there. The list counter has
|
||||
/// already advanced, so the following item keeps its number.
|
||||
/// The list label, shaped; none on a paragraph containing only a page break: Word hides it there.
|
||||
/// The list counter has already advanced, so the following item keeps its number.
|
||||
fn list_label(cx: &Cx, b: &mut Builder, mark_style: u32) -> Option<Label> {
|
||||
let (p, rp) = (cx.p, cx.rp);
|
||||
let break_only =
|
||||
b.clusters.iter().any(|c| c.kind == ClKind::PageBreak) && b.clusters.iter().all(|c| matches!(c.kind, ClKind::PageBreak | ClKind::Marker));
|
||||
let (text, lvl) = cx.env.label.as_ref().filter(|_| !break_only && !cx.env.joined)?;
|
||||
let (text, lvl) = cx.env.label.as_ref().filter(|_| !break_only)?;
|
||||
let rc = cx.res.char(&p.mark.clone().overlaid(&lvl.chr));
|
||||
// A bullet no installed font can draw would come from whatever icon font has its
|
||||
// private-use code (Font Awesome's Twitter logo at U+F081, #1683): it shows the level's
|
||||
@@ -714,8 +713,6 @@ pub fn layout_para(p: &Paragraph, env: &ParaEnv) -> ParaLayout {
|
||||
left_out: Vec::new(),
|
||||
enclosures,
|
||||
auto_space,
|
||||
joined: env.joined,
|
||||
row_est: 0.0,
|
||||
};
|
||||
let auto = env.doc.settings.auto_hyphenation && !pl.rp.suppress_hyphens;
|
||||
pl.hyph_after = hyphenation_points(&bt.text, |i| bt.to_para(i), &pl, auto, env.doc.settings.hyphenate_caps, &runs);
|
||||
|
||||
@@ -110,7 +110,6 @@ fn new_ctx<'a>(
|
||||
track_totals: true,
|
||||
pct_base: None,
|
||||
quiet_marks: Vec::new(),
|
||||
joined: None,
|
||||
stacked_marks: Vec::new(),
|
||||
mirror: false,
|
||||
table_keys: Vec::new(),
|
||||
@@ -212,7 +211,6 @@ fn new_page_builder<'p>(
|
||||
orig_bottom: 0.0,
|
||||
prev: None,
|
||||
after_break_mark: false,
|
||||
joint: None,
|
||||
next_starts_page: false,
|
||||
restart_at: None,
|
||||
excl: Vec::new(),
|
||||
|
||||
@@ -233,7 +233,6 @@ pub fn measure_table_columns(doc: &wordcraft_doc::Document, t: &Table) -> Vec<(f
|
||||
grid: crate::para::Grid::default(),
|
||||
fit_objects: false,
|
||||
fitted: &[],
|
||||
joined: false,
|
||||
};
|
||||
let (mut min, mut max) = (EMPTY_TEXT, EMPTY_TEXT);
|
||||
if cell.props.vmerge != VMerge::Continue && !cell.props.text_direction.is_turned() {
|
||||
|
||||
@@ -13,7 +13,6 @@ mod complex;
|
||||
mod float_top;
|
||||
mod grid;
|
||||
mod header_legacy_float;
|
||||
mod joined;
|
||||
mod keep_next_section;
|
||||
mod ligature;
|
||||
pub(crate) mod linear;
|
||||
@@ -2253,410 +2252,6 @@ fn empty_list_paragraph_with_a_hidden_mark_counts_but_shows_nothing() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_paragraph_with_a_hidden_mark_goes_on_into_the_next_one() {
|
||||
// Word (#3986): a paragraph whose mark is hidden is shown on one line with the next one. The
|
||||
// next one's text goes on from where the first one's ends; its number is counted but not
|
||||
// drawn ("1. AlphaOmega", then "3. Beta") and it takes no line of its own. A paragraph that
|
||||
// shows nothing in between passes the joint on. In a table cell as in the body.
|
||||
let doc = |paras: &[(&str, bool)], in_cell: bool| {
|
||||
let text: Vec<&str> = paras.iter().map(|(t, _)| *t).collect();
|
||||
let mut d = Document::from_text(&text.join("\n"));
|
||||
let id = Arc::make_mut(&mut d.numbering).add_list(wordcraft_doc::ListKind::Numbered);
|
||||
let last = d.body.len() - 1;
|
||||
let end = paras.last().map_or(0, |(t, _)| t.len());
|
||||
d.format_paragraphs(&Pos::body(0, 0), &Pos::body(last, end), &|p| {
|
||||
p.numbering = Some(wordcraft_doc::props::NumRef { num: id, level: 0 });
|
||||
})
|
||||
.unwrap();
|
||||
for (i, (_, hidden)) in paras.iter().enumerate() {
|
||||
if *hidden {
|
||||
d.para_mut(StoryRef::Body, &Path::top(i)).unwrap().mark.hidden = Some(true);
|
||||
}
|
||||
}
|
||||
if in_cell {
|
||||
let mut table = Table::new(1, 1, 400.0);
|
||||
table.rows[0].cells[0].blocks = std::mem::take(&mut d.body);
|
||||
d.body = vec![std::sync::Arc::new(Block::Table(table))];
|
||||
}
|
||||
d
|
||||
};
|
||||
// Each paragraph's number, the top of its first line, and the x its text starts and ends at.
|
||||
let laid = |d: &Document, show_hidden: bool| {
|
||||
let l = layout(d, &mut LayoutCache::new(), &LayoutOptions { show_hidden, ..Default::default() });
|
||||
let lines: Vec<(Option<String>, f32, f32, f32)> = l
|
||||
.pages
|
||||
.iter()
|
||||
.flat_map(|p| &p.items)
|
||||
.filter_map(|it| match it {
|
||||
Placed::Lines { para, l0, l1, x, y, .. } => {
|
||||
let last = l1.checked_sub(1)?;
|
||||
Some((para.label.as_ref().map(|label| label.text.clone()), *y, x + para.x_of(*l0, 0)?, x + para.x_of(last, para.text_len)?))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
lines
|
||||
};
|
||||
for in_cell in [false, true] {
|
||||
let plain = laid(&doc(&[("Alpha", false), ("Beta", false)], in_cell), false);
|
||||
let beta_y = plain[1].1;
|
||||
|
||||
// Text: "Omega" on Alpha's line, after Alpha's text.
|
||||
let joined = laid(&doc(&[("Alpha", true), ("Omega", false), ("Beta", false)], in_cell), false);
|
||||
let labels: Vec<_> = joined.iter().map(|l| l.0.as_deref()).collect();
|
||||
assert_eq!(labels, vec![Some("1."), None, Some("3.")], "in_cell={in_cell}");
|
||||
assert!((joined[1].1 - joined[0].1).abs() < 0.01, "in_cell={in_cell}: Omega at {} not on Alpha's line {}", joined[1].1, joined[0].1);
|
||||
assert!((joined[1].2 - joined[0].3).abs() < 0.5, "in_cell={in_cell}: Omega starts at {}, Alpha ends at {}", joined[1].2, joined[0].3);
|
||||
assert!((joined[2].1 - beta_y).abs() < 0.01, "in_cell={in_cell}: Beta at {} instead of {beta_y}", joined[2].1);
|
||||
|
||||
// An empty paragraph: no line of its own, no number.
|
||||
let empty = laid(&doc(&[("Alpha", true), ("", false), ("Beta", false)], in_cell), false);
|
||||
let labels: Vec<_> = empty.iter().map(|l| l.0.as_deref()).collect();
|
||||
assert_eq!(labels, vec![Some("1."), None, Some("3.")], "in_cell={in_cell}");
|
||||
assert!((empty[2].1 - beta_y).abs() < 0.01, "in_cell={in_cell}: Beta at {} instead of {beta_y}", empty[2].1);
|
||||
|
||||
// Through an empty paragraph with a hidden mark (which shows nothing).
|
||||
let chain = laid(&doc(&[("Alpha", true), ("", true), ("Omega", false), ("Beta", false)], in_cell), false);
|
||||
let labels: Vec<_> = chain.iter().map(|l| l.0.as_deref()).collect();
|
||||
assert_eq!(labels, vec![Some("1."), None, None, Some("4.")], "in_cell={in_cell}");
|
||||
assert!((chain[2].1 - chain[0].1).abs() < 0.01, "in_cell={in_cell}: Omega not on Alpha's line");
|
||||
|
||||
// Hidden text shown: each paragraph on its own line, with its number.
|
||||
let shown = laid(&doc(&[("Alpha", true), ("Omega", false), ("Beta", false)], in_cell), true);
|
||||
let labels: Vec<_> = shown.iter().map(|l| l.0.as_deref()).collect();
|
||||
assert_eq!(labels, vec![Some("1."), Some("2."), Some("3.")], "in_cell={in_cell}");
|
||||
assert!(shown[1].1 > shown[0].1 + 5.0, "in_cell={in_cell}: shown hidden text keeps the paragraphs apart");
|
||||
}
|
||||
// A click on the joined text lands in the paragraph it belongs to.
|
||||
let d = doc(&[("Alpha", true), ("Omega", false), ("Beta", false)], false);
|
||||
let l = lay(&d);
|
||||
let omega = l.caret(&Pos::body(1, 2)).unwrap();
|
||||
let hit = l.hit(omega.page, omega.x + 0.5, omega.top + omega.height / 2.0, StoryRef::Body).unwrap();
|
||||
assert_eq!(hit.path, Path::top(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_going_on_from_a_larger_heading_sits_on_its_baseline() {
|
||||
// A heading with a hidden mark followed by body text (a style separator in Word, #3986): the
|
||||
// body text's first line goes on beside the heading, on the heading's baseline; its next lines
|
||||
// start at the margin, below both.
|
||||
let body = "Body text that is long enough to wrap onto a second line in this column. ".repeat(3);
|
||||
let mut d = Document::from_text(&format!("Heading\n{body}"));
|
||||
d.format_range(&Pos::body(0, 0), &Pos::body(0, 7), &|c| c.size = Some(18.0)).unwrap();
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
let l = lay(&d);
|
||||
let lines: Vec<(Path, f32, f32, f32)> = l.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|it| match it {
|
||||
Placed::Lines { path, para, l0, l1, x, y, .. } => {
|
||||
let first = para.lines.get(*l0)?;
|
||||
let (x, y) = (*x, *y);
|
||||
Some((*l0..*l1).filter_map(move |li| {
|
||||
let line = para.lines.get(li)?;
|
||||
Some((path.clone(), y + line.baseline - first.top, x + para.x_of(li, line.start)?, y + line.top - first.top))
|
||||
}))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
let heading = lines.iter().find(|l| l.0 == Path::top(0)).unwrap();
|
||||
let body: Vec<_> = lines.iter().filter(|l| l.0 == Path::top(1)).collect();
|
||||
assert!(body.len() >= 2, "{lines:?}");
|
||||
assert!((body[0].1 - heading.1).abs() < 0.01, "body baseline {} vs heading {}", body[0].1, heading.1);
|
||||
assert!(body[0].2 > 100.0, "the body text starts after the heading's, at {}", body[0].2);
|
||||
assert!((body[1].2 - 72.0).abs() < 0.5, "the next line starts at the margin, not at {}", body[1].2);
|
||||
assert!(body[1].3 > heading.1, "the next line is below the shared one");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_text_box_anchored_in_a_paragraph_with_a_hidden_mark_is_not_joined() {
|
||||
// A text box anchored in the first paragraph lays its own story out, whose first line has
|
||||
// the same path as that paragraph (#3986). The next paragraph goes on from the paragraph's
|
||||
// text, not from the box's, which is drawn after it.
|
||||
let mut d = Document::from_text("Alpha\nOmega");
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
let float = wordcraft_doc::para::Float {
|
||||
wrap: wordcraft_doc::para::Wrap::InFrontOfText,
|
||||
h_rel: wordcraft_doc::para::Anchor::Column,
|
||||
v_rel: wordcraft_doc::para::Anchor::Paragraph,
|
||||
x: 200.0,
|
||||
y: 100.0,
|
||||
dist: 0.0,
|
||||
..Default::default()
|
||||
};
|
||||
text_box(&mut d, 0, "Box", 100.0, 40.0, float);
|
||||
let l = lay(&d);
|
||||
// The top of a story's line at a block, and the x its text starts and ends at.
|
||||
let line = |story: StoryRef, block: usize| {
|
||||
l.pages[0].items.iter().find_map(|it| match it {
|
||||
Placed::Lines { story: s, path, para, l0, l1, x, y, .. } if *s == story && *path == Path::top(block) => {
|
||||
Some((*y, x + para.x_of(*l0, 0)?, x + para.x_of(l1.checked_sub(1)?, para.text_len)?))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
};
|
||||
let (alpha, omega) = (line(StoryRef::Body, 0).unwrap(), line(StoryRef::Body, 1).unwrap());
|
||||
assert!((omega.0 - alpha.0).abs() < 0.01, "Omega at {} not on Alpha's line {}", omega.0, alpha.0);
|
||||
assert!((omega.1 - alpha.2).abs() < 0.5, "Omega starts at {}, Alpha ends at {}", omega.1, alpha.2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_paragraph_moved_to_the_next_page_has_its_own_number() {
|
||||
// A paragraph going on from one with a hidden mark (#3986) that moves whole to the next page
|
||||
// (its lines kept together) no longer shares that line: there its number is drawn and its
|
||||
// text starts at its own indent.
|
||||
let omega = "Omega ".repeat(60);
|
||||
let build = |filler: usize| {
|
||||
let mut text: Vec<String> = (0..filler).map(|i| format!("Filler {i}")).collect();
|
||||
text.push("Alpha".into());
|
||||
text.push(omega.clone());
|
||||
let mut d = Document::from_text(&text.join("\n"));
|
||||
let id = Arc::make_mut(&mut d.numbering).add_list(wordcraft_doc::ListKind::Numbered);
|
||||
d.format_paragraphs(&Pos::body(filler, 0), &Pos::body(filler + 1, omega.len()), &|p| {
|
||||
p.numbering = Some(wordcraft_doc::props::NumRef { num: id, level: 0 });
|
||||
})
|
||||
.unwrap();
|
||||
d.para_mut(StoryRef::Body, &Path::top(filler)).unwrap().mark.hidden = Some(true);
|
||||
d.para_mut(StoryRef::Body, &Path::top(filler + 1)).unwrap().props.keep_lines = Some(true);
|
||||
d
|
||||
};
|
||||
// The page of a paragraph's first line, with its number there.
|
||||
let first = |l: &DocLayout, block: usize| {
|
||||
l.pages.iter().enumerate().find_map(|(pi, page)| {
|
||||
page.items.iter().find_map(|it| match it {
|
||||
Placed::Lines { path, para, l0: 0, .. } if *path == Path::top(block) => {
|
||||
Some((pi, para.label.as_ref().map(|label| label.text.clone())))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
})
|
||||
};
|
||||
for filler in 20..80 {
|
||||
let d = build(filler);
|
||||
let l = lay(&d);
|
||||
let (Some((0, alpha)), Some((1, omega_label))) = (first(&l, filler), first(&l, filler + 1)) else { continue };
|
||||
assert_eq!(alpha.as_deref(), Some("1."));
|
||||
assert_eq!(omega_label.as_deref(), Some("2."), "the moved paragraph draws its number");
|
||||
let (a, o) = (l.caret(&Pos::body(filler, 0)).unwrap(), l.caret(&Pos::body(filler + 1, 0)).unwrap());
|
||||
assert_eq!(o.page, 1);
|
||||
assert!((o.x - a.x).abs() < 0.5, "the moved paragraph's text starts at its own indent: {} vs {}", o.x, a.x);
|
||||
return;
|
||||
}
|
||||
panic!("no filler put Alpha last on the first page with the joined paragraph moved on");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_first_word_that_does_not_fit_goes_on_the_next_line_at_the_indent() {
|
||||
// Word (#3986): when the next paragraph's first word doesn't fit after the first one's text,
|
||||
// it goes on the next line, still joined (no number drawn), at the indent of the list's text.
|
||||
let build = |n: usize| {
|
||||
let alpha = vec!["aa"; n].join(" ");
|
||||
let omega = "Omegaomegaomega tail";
|
||||
let mut d = Document::from_text(&format!("{alpha}\n{omega}"));
|
||||
let id = Arc::make_mut(&mut d.numbering).add_list(wordcraft_doc::ListKind::Numbered);
|
||||
d.format_paragraphs(&Pos::body(0, 0), &Pos::body(1, omega.len()), &|p| {
|
||||
p.numbering = Some(wordcraft_doc::props::NumRef { num: id, level: 0 });
|
||||
})
|
||||
.unwrap();
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
(d, alpha.len())
|
||||
};
|
||||
for n in 20..200 {
|
||||
let (d, alpha_len) = build(n);
|
||||
let l = lay(&d);
|
||||
let (end, start) = (l.caret(&Pos::body(0, alpha_len)).unwrap(), l.caret(&Pos::body(1, 0)).unwrap());
|
||||
if (start.top - end.top).abs() < 0.5 {
|
||||
continue; // still on the shared line
|
||||
}
|
||||
let indent = l.caret(&Pos::body(0, 0)).unwrap().x;
|
||||
assert!(start.top > end.top, "the first word goes below the shared line");
|
||||
assert!((start.x - indent).abs() < 0.5, "at the list text's indent {indent}, not {}", start.x);
|
||||
let label = l.pages.iter().flat_map(|p| &p.items).find_map(|it| match it {
|
||||
Placed::Lines { path, para, .. } if *path == Path::top(1) => Some(para.label.as_ref().map(|label| label.text.clone())),
|
||||
_ => None,
|
||||
});
|
||||
assert_eq!(label, Some(None), "still joined: no number drawn");
|
||||
return;
|
||||
}
|
||||
panic!("no length of the first paragraph left its last line too full for the next one's first word");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_shared_line_is_one_line_for_line_numbers_and_vertical_alignment() {
|
||||
// Word (#3986): the line two paragraphs share through a hidden mark is one line. Line
|
||||
// numbering gives it one number ("Line one", the shared line, "After": 1, 2, 3), and justified
|
||||
// vertical alignment keeps the two paragraphs together as one block.
|
||||
let doc = |valign: wordcraft_doc::section::PageVAlign| {
|
||||
let mut d = Document::from_text("Line one\nAlpha\nOmega\nAfter");
|
||||
for b in d.body.iter_mut() {
|
||||
if let Block::Para(p) = std::sync::Arc::make_mut(b) {
|
||||
p.props.space_before = Some(0.0);
|
||||
p.props.space_after = Some(0.0);
|
||||
}
|
||||
}
|
||||
d.para_mut(StoryRef::Body, &Path::top(1)).unwrap().mark.hidden = Some(true);
|
||||
d.last_section.valign = valign;
|
||||
d
|
||||
};
|
||||
let mut d = doc(wordcraft_doc::section::PageVAlign::Top);
|
||||
d.last_section.line_numbers = Some(Default::default());
|
||||
let l = lay(&d);
|
||||
let numbers: Vec<f32> = l.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|it| match it {
|
||||
Placed::Lines { story, y, .. } if *story == DECOR_STORY => Some(*y),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(numbers.len(), 3, "one number per shown line: {numbers:?}");
|
||||
assert!(numbers.windows(2).all(|w| w[1] > w[0] + 5.0), "no two numbers on one line: {numbers:?}");
|
||||
|
||||
let l = lay(&doc(wordcraft_doc::section::PageVAlign::Justify));
|
||||
let y = |off: (usize, usize)| l.caret(&Pos::body(off.0, off.1)).unwrap().top;
|
||||
assert!((y((2, 0)) - y((1, 0))).abs() < 0.01, "Omega stays on Alpha's line: {} vs {}", y((2, 0)), y((1, 0)));
|
||||
let (g1, g2) = (y((1, 0)) - y((0, 0)), y((3, 0)) - y((1, 0)));
|
||||
assert!(g1 > 100.0 && (g1 - g2).abs() < 0.05, "equal gaps around the shared line: {g1} {g2}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_line_with_a_hanging_indent_still_starts_after_the_text_before() {
|
||||
// The joined paragraph's first-line indent reaches left of the margin: its text still starts
|
||||
// after the text of the paragraph before, never left of it (#3986).
|
||||
let mut d = Document::from_text("Alpha\na b c");
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
let q = d.para_mut(StoryRef::Body, &Path::top(1)).unwrap();
|
||||
q.props.indent_left = Some(0.0);
|
||||
q.props.indent_first = Some(-36.0);
|
||||
let l = lay(&d);
|
||||
let (end, start) = (l.caret(&Pos::body(0, 5)).unwrap(), l.caret(&Pos::body(1, 0)).unwrap());
|
||||
assert!((start.top - end.top).abs() < 0.01, "on the shared line");
|
||||
assert!(start.x >= end.x - 0.01, "after Alpha: starts at {}, Alpha ends at {}", start.x, end.x);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_paragraphs_shading_and_borders_start_below_the_shared_line() {
|
||||
// Word (synthetic DOCX, 16.0.20625): the line a paragraph shares with the one before, whose
|
||||
// mark is hidden, shows that one's shading and borders, not its own. Its own start on its next
|
||||
// line (no top border there), and a paragraph that is all on the shared line shows neither and
|
||||
// takes no room for its borders; what follows starts below the first one's bottom border.
|
||||
let yellow = wordcraft_doc::props::Rgb(0xFF, 0xFF, 0);
|
||||
let boxed = || Some(Borders::all(Border { space: 1.0, ..Border::single(1.5) }));
|
||||
// "Alpha" (mark hidden) with `first`'s formatting, then `second` with its own, then "After".
|
||||
let doc = |first: &dyn Fn(&mut ParaProps), second_text: &str, second: &dyn Fn(&mut ParaProps), in_cell: bool| {
|
||||
let mut d = Document::from_text(&format!("Alpha\n{second_text}\nAfter"));
|
||||
let a = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap();
|
||||
a.mark.hidden = Some(true);
|
||||
first(&mut a.props);
|
||||
second(&mut d.para_mut(StoryRef::Body, &Path::top(1)).unwrap().props);
|
||||
if in_cell {
|
||||
let mut table = Table::new(1, 1, 400.0);
|
||||
table.props.borders = Some(Borders::all(Border { style: BorderStyle::None, width: 0.0, color: None, space: 0.0 }));
|
||||
table.rows[0].cells[0].blocks = std::mem::take(&mut d.body);
|
||||
d.body = vec![std::sync::Arc::new(Block::Table(table))];
|
||||
}
|
||||
d
|
||||
};
|
||||
let path = |i: u32, in_cell: bool| if in_cell { Path(vec![0, 0, 0, i]) } else { Path::top(i as usize) };
|
||||
// The shared line (top, bottom), "After"'s top, fills and the paragraphs' horizontal rules.
|
||||
let laid = |d: &Document, in_cell: bool| {
|
||||
crate::test_fonts();
|
||||
let l = lay(d);
|
||||
let at = |i: u32| l.caret(&Pos { story: StoryRef::Body, path: path(i, in_cell), off: 0 }).unwrap();
|
||||
let (alpha, after) = (at(0), at(2));
|
||||
let fills: Vec<Rect> = l.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|i| if let Placed::Fill { rect, color } = i { (*color == yellow).then_some(*rect) } else { None })
|
||||
.collect();
|
||||
let rules: Vec<(f32, f32, f32, f32)> = l.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(
|
||||
|i| if let Placed::Rule { x0, y0, x1, y1, border } = i { (border.width == 1.5).then_some((*x0, *y0, *x1, *y1)) } else { None },
|
||||
)
|
||||
.collect();
|
||||
(alpha.top, alpha.top + alpha.height, after.top, fills, rules)
|
||||
};
|
||||
let none = |_: &mut ParaProps| {};
|
||||
let long = format!("Omega {}", "zeta ".repeat(30));
|
||||
for in_cell in [false, true] {
|
||||
let (top, bottom, after, ..) = laid(&doc(&none, "Omega", &none, in_cell), in_cell);
|
||||
|
||||
// The second one shaded, all of it on the shared line: no shading over "Alpha".
|
||||
let (t, _, a, fills, _) = laid(&doc(&none, "Omega", &|p| p.shading = Some(yellow), in_cell), in_cell);
|
||||
assert!(fills.is_empty(), "in_cell={in_cell}: {fills:?}");
|
||||
assert!((t - top).abs() < 0.01 && (a - after).abs() < 0.01, "in_cell={in_cell}");
|
||||
|
||||
// Shaded and running on: the shading starts on its own next line.
|
||||
let (_, b, _, fills, _) = laid(&doc(&none, &long, &|p| p.shading = Some(yellow), in_cell), in_cell);
|
||||
assert_eq!(fills.len(), 1, "in_cell={in_cell}: {fills:?}");
|
||||
assert!(fills[0].y >= b - 0.01, "in_cell={in_cell}: shading from {} over the shared line ending at {b}", fills[0].y);
|
||||
|
||||
// The first one shaded: the shared line is.
|
||||
let (t, b, _, fills, _) = laid(&doc(&|p| p.shading = Some(yellow), "Omega", &none, in_cell), in_cell);
|
||||
assert_eq!(fills.len(), 1, "in_cell={in_cell}: {fills:?}");
|
||||
assert!(fills[0].y <= t + 0.01 && fills[0].bottom() >= b - 0.01, "in_cell={in_cell}: {fills:?}");
|
||||
|
||||
// The second one boxed, all of it on the shared line: no borders, no room for them.
|
||||
let (t, _, a, _, rules) = laid(&doc(&none, "Omega", &|p| p.borders = boxed(), in_cell), in_cell);
|
||||
assert!(rules.is_empty(), "in_cell={in_cell}: {rules:?}");
|
||||
assert!((t - top).abs() < 0.01 && (a - after).abs() < 0.01, "in_cell={in_cell}: {t} {a}");
|
||||
|
||||
// Boxed and running on: its box is around its own lines, open at the top, with its bottom
|
||||
// border's room under it; the shared line stays where it is.
|
||||
let (t, b, _, _, rules) = laid(&doc(&none, &long, &|p| p.borders = boxed(), in_cell), in_cell);
|
||||
assert!((t - top).abs() < 0.01, "in_cell={in_cell}: shared line moved to {t}");
|
||||
assert_eq!(rules.iter().filter(|r| r.1 == r.3).count(), 1, "in_cell={in_cell}: only the bottom border: {rules:?}");
|
||||
assert!(rules.iter().all(|r| r.1.min(r.3) >= b - 0.01), "in_cell={in_cell}: a border over the shared line: {rules:?}");
|
||||
|
||||
// The first one boxed: what follows starts below its bottom border.
|
||||
let (_, _, a, _, rules) = laid(&doc(&|p| p.borders = boxed(), "Omega", &none, in_cell), in_cell);
|
||||
let bottom_rule = rules.iter().filter(|r| r.1 == r.3).map(|r| r.1).fold(f32::MIN, f32::max);
|
||||
assert!(bottom_rule > bottom, "in_cell={in_cell}: {rules:?}");
|
||||
assert!(a >= bottom_rule + 0.75 - 0.01, "in_cell={in_cell}: After at {a}, over the border at {bottom_rule}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_paragraph_keeps_its_revision_for_the_cache_and_the_word_being_typed() {
|
||||
// The joined paragraph is laid out as a copy without its space before (#3986). The copy keeps
|
||||
// the document's revision: the word being typed in it gets no squiggle, and laying the
|
||||
// document out again reuses its layouts.
|
||||
crate::test_fonts();
|
||||
let mut d = Document::from_text("Alpha\nhelo wrld\nAfter");
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
let rev = d.para(StoryRef::Body, &Path::top(1)).unwrap().rev;
|
||||
let marks = |l: &DocLayout| -> Vec<String> {
|
||||
l.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|i| match i {
|
||||
Placed::Lines { para, path, .. } if *path == Path::top(1) => {
|
||||
Some(para.issues.iter().filter(|i| !i.2).map(|i| "helo wrld"[i.0..i.1].to_string()).collect::<Vec<_>>())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.flatten()
|
||||
.collect()
|
||||
};
|
||||
let mut c = LayoutCache::new();
|
||||
let opts = LayoutOptions { proofing: true, ..LayoutOptions::default() };
|
||||
let both = layout(&d, &mut c, &opts);
|
||||
assert_eq!(marks(&both), ["helo", "wrld"]);
|
||||
let (a, b) = (both.caret(&Pos::body(0, 5)).unwrap(), both.caret(&Pos::body(1, 0)).unwrap());
|
||||
assert!((a.top - b.top).abs() < 0.01, "joined");
|
||||
let misses = c.misses;
|
||||
let again = layout(&d, &mut c, &opts);
|
||||
assert_eq!(marks(&again), ["helo", "wrld"]);
|
||||
assert_eq!(c.misses, misses, "nothing laid out again");
|
||||
let typing = layout(&d, &mut c, &LayoutOptions { typing_word: Some(TypingWord { rev, start: 5, end: 9 }), ..opts.clone() });
|
||||
assert_eq!(marks(&typing), ["helo"], "the word being typed is left alone");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_numbered_heading_opening_with_a_page_break_takes_its_number_along() {
|
||||
crate::test_fonts();
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
//! A paragraph going on from the line of one whose mark is hidden (#3986): what changes when it
|
||||
//! moves off that line or is placed apart from it.
|
||||
|
||||
use super::lay;
|
||||
use crate::{Arc, DocLayout, Placed, StoryRef, hit};
|
||||
use wordcraft_doc::para::{Anchor, Float, Wrap};
|
||||
use wordcraft_doc::props::{Border, Borders, LineSpacing, NumRef, TextFrame};
|
||||
use wordcraft_doc::{Block, Document, Path, Pos, Table};
|
||||
|
||||
/// A table around the document's paragraphs (the cell paths are `[0, 0, 0, i]`).
|
||||
fn in_cell(d: &mut Document) {
|
||||
let mut table = Table::new(1, 1, 400.0);
|
||||
table.rows[0].cells[0].blocks = std::mem::take(&mut d.body);
|
||||
d.body = vec![Arc::new(Block::Table(table))];
|
||||
}
|
||||
|
||||
/// The top of the lines of the body block or cell paragraph at `path`.
|
||||
fn top_of(l: &DocLayout, path: &Path) -> f32 {
|
||||
l.pages[0]
|
||||
.items
|
||||
.iter()
|
||||
.find_map(|it| match it {
|
||||
Placed::Lines { story: StoryRef::Body, path: p, y, .. } if p == path => Some(*y),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_else(|| panic!("no lines at {path:?}"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_paragraph_moved_to_the_next_page_gets_its_top_border() {
|
||||
// Sharing the line it takes no room for a top border; moved whole to the next page it is
|
||||
// laid out on its own and draws one above its first line.
|
||||
let omega = "Omega ".repeat(60);
|
||||
let boxed = Some(Borders::all(Border { space: 1.0, ..Border::single(1.5) }));
|
||||
for filler in 20..80 {
|
||||
let mut text: Vec<String> = (0..filler).map(|i| format!("Filler {i}")).collect();
|
||||
text.push("Alpha".into());
|
||||
text.push(omega.clone());
|
||||
let mut d = Document::from_text(&text.join("\n"));
|
||||
d.para_mut(StoryRef::Body, &Path::top(filler)).unwrap().mark.hidden = Some(true);
|
||||
let o = d.para_mut(StoryRef::Body, &Path::top(filler + 1)).unwrap();
|
||||
(o.props.keep_lines, o.props.borders) = (Some(true), boxed);
|
||||
let l = lay(&d);
|
||||
let o = l.caret(&Pos::body(filler + 1, 0)).unwrap();
|
||||
if l.caret(&Pos::body(filler, 0)).unwrap().page != 0 || o.page != 1 {
|
||||
continue;
|
||||
}
|
||||
let tops = l.pages[1].items.iter().filter(|i| matches!(i, Placed::Rule { y0, y1, border, .. } if y0 == y1 && border.width == 1.5));
|
||||
let above = tops.filter(|i| matches!(i, Placed::Rule { y0, .. } if *y0 < o.top)).count();
|
||||
assert_eq!(above, 1, "the moved paragraph draws its top border above its first line");
|
||||
return;
|
||||
}
|
||||
panic!("no filler moved the joined paragraph to the next page");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_first_line_below_the_shared_line_does_not_cut_the_line_above() {
|
||||
// "Omega"'s first word does not fit after "Alpha", so its first line goes below; its indent
|
||||
// (inside "Alpha"'s text) must not cut "Alpha"'s hit extent.
|
||||
let mut d = Document::from_text(&format!("Alpha\n{} tail", "W".repeat(48)));
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
d.para_mut(StoryRef::Body, &Path::top(1)).unwrap().props.indent_left = Some(20.0);
|
||||
let l = lay(&d);
|
||||
let lines = hit::page_lines(&l.pages[0], StoryRef::Body);
|
||||
let alpha = lines.iter().find(|h| h.path == &Path::top(0)).unwrap();
|
||||
let omega = lines.iter().find(|h| h.path == &Path::top(1) && h.li == 0).unwrap();
|
||||
assert!(omega.top > alpha.top + 1.0, "setup: the first word moved below the shared line");
|
||||
let text_end = l.caret(&Pos::body(0, 5)).unwrap().x;
|
||||
assert!(alpha.right >= text_end - 0.5, "Alpha's line reaches {} but its text ends at {text_end}", alpha.right);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_paragraphs_drawings_are_relative_to_the_shared_line() {
|
||||
// A drawing anchored to the paragraph, at its top: the paragraph's top is the shared line's,
|
||||
// not the end of the paragraph before.
|
||||
let mut d = Document::from_text("Alpha\nOmega\nAfter");
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
let float =
|
||||
Float { wrap: Wrap::InFrontOfText, h_rel: Anchor::Column, v_rel: Anchor::Paragraph, x: 200.0, y: 0.0, dist: 0.0, ..Default::default() };
|
||||
super::text_box_at(&mut d, &Pos::body(1, 0), "Box", 100.0, 40.0, float);
|
||||
in_cell(&mut d);
|
||||
let l = lay(&d);
|
||||
let alpha = top_of(&l, &Path(vec![0, 0, 0, 0]));
|
||||
let boxed = l.pages[0].items.iter().find_map(|it| match it {
|
||||
Placed::Lines { story: StoryRef::Part(_), y, .. } => Some(*y),
|
||||
_ => None,
|
||||
});
|
||||
let boxed = boxed.expect("the box's text is laid out");
|
||||
assert!(boxed < alpha + 12.0, "the box's text at {boxed} is below the shared line at {alpha}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_text_frame_after_a_hidden_mark_is_not_joined() {
|
||||
// A framed paragraph is placed apart, so it shares no line with the one before: its number is
|
||||
// drawn (it is counted either way). The frame is its own, or given by the table's style.
|
||||
let frame =
|
||||
TextFrame { x_align: Some("right".into()), h_anchor: "text".into(), v_anchor: "text".into(), wrap: "around".into(), ..Default::default() };
|
||||
for from_style in [false, true] {
|
||||
let mut d = Document::from_text("Alpha\n7");
|
||||
let id = Arc::make_mut(&mut d.numbering).add_list(wordcraft_doc::ListKind::Numbered);
|
||||
d.format_paragraphs(&Pos::body(0, 0), &Pos::body(1, 1), &|p| p.numbering = Some(NumRef { num: id, level: 0 })).unwrap();
|
||||
d.para_mut(StoryRef::Body, &Path::top(0)).unwrap().mark.hidden = Some(true);
|
||||
// From the table's style, the frame is given to "Alpha" too: zero dimensions cancel it there.
|
||||
let (at, own) = if from_style { (0, TextFrame { w: Some(0.0), h: Some(0.0), ..frame.clone() }) } else { (1, frame.clone()) };
|
||||
d.para_mut(StoryRef::Body, &Path::top(at)).unwrap().props.frame = Some(own);
|
||||
in_cell(&mut d);
|
||||
if from_style {
|
||||
Arc::make_mut(&mut d.styles).get_mut("TableGrid").expect("Table Grid").para.frame = Some(frame.clone());
|
||||
if let Some(Block::Table(t)) = d.body.first_mut().map(Arc::make_mut) {
|
||||
t.props.style = Some("TableGrid".into());
|
||||
}
|
||||
}
|
||||
let l = lay(&d);
|
||||
let label = l.pages[0].items.iter().find_map(|it| match it {
|
||||
Placed::Lines { path, para, .. } if path.0 == [0, 0, 0, 1] => Some(para.label.is_some()),
|
||||
_ => None,
|
||||
});
|
||||
assert_eq!(label, Some(true), "the framed paragraph keeps its number (frame from the table style: {from_style})");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_joined_paragraphs_later_lines_start_below_a_taller_shared_line() {
|
||||
// A heading whose mark is hidden, then body text going on from it: the text's first line
|
||||
// shares the heading's line; its later lines start below that line and the heading's bottom
|
||||
// border, not inside it (Word), whatever the text's line spacing.
|
||||
let spacings = [None, Some(LineSpacing::Exactly(12.0)), Some(LineSpacing::AtLeast(12.0)), Some(LineSpacing::Multiple(2.0))];
|
||||
// A large word that fits the first line of the text laid out alone but wraps off the
|
||||
// narrower shared line onto the second (`big`), so the two first lines differ in height.
|
||||
let cases = [false, true].into_iter().flat_map(|c| spacings.into_iter().flat_map(move |s| [(c, s, false, None), (c, s, true, None)]));
|
||||
let big = [60, 70, 80].into_iter().flat_map(|at| [(false, None, false, Some(at)), (true, None, false, Some(at))]);
|
||||
for (cell, spacing, bordered, large) in cases.chain(big) {
|
||||
let case = format!("cell {cell}, {spacing:?}, border {bordered}, large word at {large:?}");
|
||||
let mut d = Document::from_text(&format!("Heading\n{}", "body text ".repeat(40)));
|
||||
d.format_range(&Pos::body(0, 0), &Pos::body(0, 7), &|c| c.size = Some(40.0)).unwrap();
|
||||
if let Some(at) = large {
|
||||
d.format_range(&Pos::body(1, at), &Pos::body(1, at + 4), &|c| c.size = Some(30.0)).unwrap();
|
||||
}
|
||||
let heading = d.para_mut(StoryRef::Body, &Path::top(0)).unwrap();
|
||||
heading.mark.hidden = Some(true);
|
||||
if bordered {
|
||||
heading.props.borders = Some(Borders { bottom: Some(Border { space: 4.0, ..Border::single(1.5) }), ..Default::default() });
|
||||
}
|
||||
d.para_mut(StoryRef::Body, &Path::top(1)).unwrap().props.line_spacing = spacing;
|
||||
if cell {
|
||||
in_cell(&mut d);
|
||||
}
|
||||
let l = lay(&d);
|
||||
let lines = hit::page_lines(&l.pages[0], StoryRef::Body);
|
||||
let heading = lines.iter().find(|h| h.path.0.last() == Some(&0)).unwrap();
|
||||
// The shared line's bottom, with the heading's bottom border under it.
|
||||
let rule = l.pages[0].items.iter().filter_map(|it| match it {
|
||||
Placed::Rule { y0, y1, border, .. } if y0 == y1 && border.width == 1.5 => Some(*y0),
|
||||
_ => None,
|
||||
});
|
||||
let floor = rule.fold(heading.bottom, f32::max);
|
||||
assert!(!bordered || floor > heading.bottom, "setup: the border is drawn below the shared line ({case})");
|
||||
let body: Vec<_> = lines.iter().filter(|h| h.path.0.last() == Some(&1)).collect();
|
||||
assert!(body.len() > 2, "setup: the body text runs to several lines ({case})");
|
||||
assert!(body[0].top < heading.bottom - 1.0, "the first line at {} shares the heading's line ({case})", body[0].top);
|
||||
for line in &body[1..] {
|
||||
assert!(line.top >= floor - 0.01, "line {} at {} starts inside the shared line, ending {floor} ({case})", line.li, line.top);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ craft = { workspace = true, features = [
|
||||
"color", "color-ui", "control", "draw", "font-manager", "gpu", "menu", "pages", "print", "review", "table", "text",
|
||||
"text-find", "web-api", "web-host", "window",
|
||||
] }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
wordcraft-geom = { workspace = true, features = ["image"] }
|
||||
wordcraft-doc = { workspace = true }
|
||||
wordcraft-fonts = { workspace = true }
|
||||
@@ -76,7 +76,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 = "0b8bbaf4c842da2d47de7b3fddd7170ba6115541", features = ["subset"] }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", features = ["subset"] }
|
||||
serde_json = { workspace = true }
|
||||
toml = "1"
|
||||
|
||||
|
||||
@@ -102,8 +102,6 @@ impl WordApp {
|
||||
command_catalog_lang: "",
|
||||
key_overrides: Default::default(),
|
||||
command_states: Default::default(),
|
||||
command_states_cache: None,
|
||||
keytip_cache: None,
|
||||
fonts_frames: 0,
|
||||
clipboard_published: false,
|
||||
printing: Default::default(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The app's side of the framework command runtime: the catalog of commands and their default
|
||||
//! chords, the per-frame state (enabled, checked, hint) and the running of what the runtime fired.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::keymap::Overrides;
|
||||
@@ -83,62 +83,6 @@ fn with_word_chords(catalog: AppCatalog) -> AppCatalog {
|
||||
.fold(catalog, |catalog, command| catalog.replace_defaults(command.id(), Vec::new()))
|
||||
}
|
||||
|
||||
/// Precomputed command references, translated hints, and last gate results for
|
||||
/// [`WordApp::command_input`], rebuilt when the engine registry or interface language changes.
|
||||
///
|
||||
/// Every command's gate predicate still runs on every frame so enabled/disabled state is never
|
||||
/// stale; only the per-frame `CATALOG.lines()` parsing, `i18n` hint formatting, and full
|
||||
/// `CommandStates` map rebuild are skipped when nothing changed.
|
||||
pub(crate) struct CommandStatesCache {
|
||||
registry: Arc<wordcraft_engine::Registry>,
|
||||
lang: &'static str,
|
||||
/// `(id, location, label, prebuilt CommandRef, last (enabled, reason))` for every registered
|
||||
/// engine command, in registry order.
|
||||
registered: Vec<(&'static str, &'static str, &'static str, CommandRef, Option<(bool, Option<&'static str>)>)>,
|
||||
/// `(id, prebuilt CommandRef, last enabled)` for gated `ui.*` commands.
|
||||
ui_commands: Vec<(&'static str, CommandRef, Option<bool>)>,
|
||||
/// `(id, prebuilt CommandRef, last enabled)` for unimplemented Word catalog commands.
|
||||
unimplemented: Vec<(&'static str, CommandRef, Option<bool>)>,
|
||||
/// Precomputed `CommandRef` and last enabled state for `ui.dialog {"name": "commands"}`.
|
||||
commands_dialog: (CommandRef, Option<bool>),
|
||||
/// Translated fallback hint shared by all unimplemented catalog commands.
|
||||
unavailable_hint: Option<Arc<str>>,
|
||||
/// Cached translated hints by `(spec index, disabled reason)` for the current language.
|
||||
hints: HashMap<(usize, Option<&'static str>), Option<Arc<str>>>,
|
||||
}
|
||||
|
||||
impl CommandStatesCache {
|
||||
fn new(registry: Arc<wordcraft_engine::Registry>, lang: &'static str) -> Self {
|
||||
let registered = registry.all().iter().map(|spec| (spec.id, spec.location, spec.label, CommandRef::new(spec.id), None)).collect();
|
||||
let ui_commands = ["ui.collapseRibbon", "ui.resetInterfaceSize", "ui.print", "ui.printSubmit"]
|
||||
.into_iter()
|
||||
.chain(GATED_UI_COMMANDS.iter().map(|(id, _)| *id))
|
||||
.map(|id| (id, CommandRef::new(id), None))
|
||||
.collect();
|
||||
let unimplemented = unimplemented_catalog_commands(®istry).map(|(id, _)| (id, CommandRef::new(id), None)).collect();
|
||||
let commands_dialog = (CommandRef::with_params("ui.dialog", json!({"name": "commands"})), None);
|
||||
let unavailable_hint = crate::widgets::command_hint("", "", Some("")).map(Arc::from);
|
||||
CommandStatesCache { registry, lang, registered, ui_commands, unimplemented, commands_dialog, unavailable_hint, hints: HashMap::new() }
|
||||
}
|
||||
|
||||
fn matches(&self, registry: &Arc<wordcraft_engine::Registry>, lang: &'static str) -> bool {
|
||||
self.lang == lang && Arc::ptr_eq(&self.registry, registry)
|
||||
}
|
||||
|
||||
fn hint_for(&mut self, idx: usize, location: &str, label: &str, reason: Option<&'static str>) -> Option<Arc<str>> {
|
||||
self.hints.entry((idx, reason)).or_insert_with(|| crate::widgets::command_hint(location, label, reason).map(Arc::from)).clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Gate check for a command known to live in `app.session.registry` (skips the extra registry lookup).
|
||||
fn gate_registered(app: &WordApp, id: &str) -> (bool, Option<&'static str>) {
|
||||
if !app.has_document() && !super::commands::works_without_document(id) {
|
||||
return (false, None);
|
||||
}
|
||||
let reason = app.session.why_disabled(id);
|
||||
(reason.is_none(), reason)
|
||||
}
|
||||
|
||||
impl WordApp {
|
||||
/// The app's commands as the keymap knows them: every engine command with its default
|
||||
/// chords, then the interface commands. The interface commands come last because a tie in the
|
||||
@@ -233,78 +177,36 @@ impl WordApp {
|
||||
if let Some(catalog) = self.catalog() {
|
||||
input = input.catalog(catalog);
|
||||
}
|
||||
let lang = crate::i18n::current().code();
|
||||
let (mut cache, fresh_cache) = match self.command_states_cache.take() {
|
||||
Some(cache) if cache.matches(®istry, lang) => (cache, false),
|
||||
_ => (CommandStatesCache::new(registry, lang), true),
|
||||
};
|
||||
|
||||
// Re-evaluate every command's gate without allocating on idle frames. A fresh cache has
|
||||
// `None` in every `last` slot, so the same compare pass collects every entry for it.
|
||||
let mut reg_changes: Vec<(usize, bool, Option<&'static str>)> = Vec::new();
|
||||
for (i, &(id, _, _, _, last)) in cache.registered.iter().enumerate() {
|
||||
let current = gate_registered(self, id);
|
||||
if last != Some(current) {
|
||||
reg_changes.push((i, current.0, current.1));
|
||||
let mut states = CommandStates::new();
|
||||
for spec in registry.all() {
|
||||
let (enabled, reason) = gate(self, spec.id); // A toggle's checked state is bound at its ribbon button, not here.
|
||||
let mut state = CommandState::new().enabled(enabled);
|
||||
if let Some(hint) = crate::widgets::command_hint(spec.location, spec.label, reason) {
|
||||
state = state.hint(hint);
|
||||
}
|
||||
states.set(CommandRef::new(spec.id), state);
|
||||
}
|
||||
let mut ui_changes: Vec<(usize, bool)> = Vec::new();
|
||||
for (i, &(id, _, last)) in cache.ui_commands.iter().enumerate() {
|
||||
let enabled = command_enabled(self, id);
|
||||
if last != Some(enabled) {
|
||||
ui_changes.push((i, enabled));
|
||||
// Print acts on the document, so with none open it is off like the engine's commands (#1129); a command with
|
||||
// no state here resolves as enabled.
|
||||
let ids = ["ui.collapseRibbon", "ui.resetInterfaceSize", "ui.print", "ui.printSubmit"]
|
||||
.into_iter()
|
||||
.chain(GATED_UI_COMMANDS.iter().map(|(id, _)| *id));
|
||||
for id in ids {
|
||||
states.set(CommandRef::new(id), CommandState::new().enabled(command_enabled(self, id)));
|
||||
}
|
||||
let unavailable_hint: Option<Arc<str>> = crate::widgets::command_hint("", "", Some("")).map(Arc::from);
|
||||
for (id, _) in unimplemented_catalog_commands(®istry) {
|
||||
let mut state = CommandState::new().enabled(command_enabled(self, id));
|
||||
if let Some(hint) = unavailable_hint.as_ref() {
|
||||
state = state.hint(Arc::clone(hint));
|
||||
}
|
||||
states.set(CommandRef::new(id), state);
|
||||
}
|
||||
let mut unimpl_changes: Vec<(usize, bool)> = Vec::new();
|
||||
for (i, &(id, _, last)) in cache.unimplemented.iter().enumerate() {
|
||||
let enabled = command_enabled(self, id);
|
||||
if last != Some(enabled) {
|
||||
unimpl_changes.push((i, enabled));
|
||||
}
|
||||
let commands = CommandRef::with_params("ui.dialog", json!({"name": "commands"}));
|
||||
states.set(commands, CommandState::new().enabled(command_enabled(self, "ui.dialog")));
|
||||
if *self.command_states != states {
|
||||
self.command_states.edit(|kept| *kept = states);
|
||||
}
|
||||
let dialog_enabled = command_enabled(self, "ui.dialog");
|
||||
let dialog_changed = cache.commands_dialog.1 != Some(dialog_enabled);
|
||||
|
||||
let any_changed = !reg_changes.is_empty() || !ui_changes.is_empty() || !unimpl_changes.is_empty() || dialog_changed;
|
||||
if fresh_cache || any_changed {
|
||||
let apply = |kept: &mut CommandStates| {
|
||||
for (i, enabled, reason) in reg_changes {
|
||||
let (_, location, label, _, _) = cache.registered[i];
|
||||
cache.registered[i].4 = Some((enabled, reason));
|
||||
let mut state = CommandState::new().enabled(enabled);
|
||||
if let Some(hint) = cache.hint_for(i, location, label, reason) {
|
||||
state = state.hint(hint);
|
||||
}
|
||||
kept.set(cache.registered[i].3.clone(), state);
|
||||
}
|
||||
for (i, enabled) in ui_changes {
|
||||
cache.ui_commands[i].2 = Some(enabled);
|
||||
kept.set(cache.ui_commands[i].1.clone(), CommandState::new().enabled(enabled));
|
||||
}
|
||||
for (i, enabled) in unimpl_changes {
|
||||
cache.unimplemented[i].2 = Some(enabled);
|
||||
let mut state = CommandState::new().enabled(enabled);
|
||||
if let Some(hint) = cache.unavailable_hint.as_ref() {
|
||||
state = state.hint(Arc::clone(hint));
|
||||
}
|
||||
kept.set(cache.unimplemented[i].1.clone(), state);
|
||||
}
|
||||
if dialog_changed {
|
||||
cache.commands_dialog.1 = Some(dialog_enabled);
|
||||
kept.set(cache.commands_dialog.0.clone(), CommandState::new().enabled(dialog_enabled));
|
||||
}
|
||||
};
|
||||
if fresh_cache {
|
||||
let mut states = CommandStates::new();
|
||||
apply(&mut states);
|
||||
if *self.command_states != states {
|
||||
self.command_states.edit(|kept| *kept = states);
|
||||
}
|
||||
} else {
|
||||
self.command_states.edit(apply);
|
||||
}
|
||||
}
|
||||
self.command_states_cache = Some(cache);
|
||||
input.states(&self.command_states)
|
||||
}
|
||||
|
||||
@@ -419,64 +321,4 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Cached `command_input()` keeps steady-state idle calls zero-change while immediately reflecting
|
||||
/// table/context transitions and document-open state changes.
|
||||
#[test]
|
||||
fn command_input_cache_tracks_state_transitions_and_is_noop_when_idle() {
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
let _ = app.command_input();
|
||||
let rev_after_first = app.command_states.revision();
|
||||
assert!(
|
||||
!app.command_states.get(&CommandRef::new("table.deleteRow")).unwrap().is_enabled(),
|
||||
"table.deleteRow starts disabled outside a table"
|
||||
);
|
||||
assert!(app.command_states.get(&CommandRef::new("format.bold")).unwrap().is_enabled(), "format.bold starts enabled");
|
||||
|
||||
// Repeated idle calls must not mutate `command_states` or bump its revision.
|
||||
for _ in 0..5 {
|
||||
let _ = app.command_input();
|
||||
}
|
||||
assert_eq!(app.command_states.revision(), rev_after_first, "idle frames leave command_states revision untouched");
|
||||
|
||||
// Entering a table enables `table.deleteRow` immediately on the next `command_input()`.
|
||||
app.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let _ = app.command_input();
|
||||
let rev_after_table = app.command_states.revision();
|
||||
assert_ne!(rev_after_table, rev_after_first, "state change bumps command_states revision");
|
||||
assert!(app.command_states.get(&CommandRef::new("table.deleteRow")).unwrap().is_enabled(), "table.deleteRow is enabled inside a table");
|
||||
|
||||
// Closing the document disables document commands immediately.
|
||||
app.no_document = Some(app.session.document_id());
|
||||
let _ = app.command_input();
|
||||
assert!(!app.command_states.get(&CommandRef::new("format.bold")).unwrap().is_enabled(), "format.bold disables when no document is open");
|
||||
|
||||
// Dropping the cache and rebuilding from scratch must produce the exact same `CommandStates`.
|
||||
let incremental = (*app.command_states).clone();
|
||||
app.command_states_cache = None;
|
||||
let _ = app.command_input();
|
||||
assert_eq!(*app.command_states, incremental, "incremental cache matches full rebuild exactly");
|
||||
|
||||
// Swapping the registry rebuilds `command_states` cleanly and drops commands that are no
|
||||
// longer registered.
|
||||
app.no_document = None;
|
||||
let full_registry = app.session.registry.clone();
|
||||
app.session.registry = std::sync::Arc::new(wordcraft_engine::Registry::new(vec![wordcraft_engine::CommandSpec::new(
|
||||
"test.ephemeral",
|
||||
"Ephemeral",
|
||||
"Home",
|
||||
|_, _| Ok(json!({})),
|
||||
)]));
|
||||
let _ = app.command_input();
|
||||
assert!(
|
||||
app.command_states.get(&CommandRef::new("test.ephemeral")).is_some_and(|s| s.is_enabled()),
|
||||
"custom registry command is published when registered"
|
||||
);
|
||||
app.session.registry = full_registry;
|
||||
let _ = app.command_input();
|
||||
assert!(
|
||||
app.command_states.get(&CommandRef::new("test.ephemeral")).is_none(),
|
||||
"swapping back to the default registry clears removed commands from command_states"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use craft::host::{PickId, Picked};
|
||||
use craft::platform::open::{DroppedFile, Intake};
|
||||
use craft::platform::open::{DropTarget, DroppedFile, Intake};
|
||||
use craft::quit::{CloseAnswer, CloseGuard, CloseScope, GuardStep};
|
||||
use craft::ui::dialog::{DialogId, DialogResult, UnsavedChangesDialog};
|
||||
use craft::ui::shell::embed::CloseDecision;
|
||||
@@ -181,7 +181,6 @@ impl WordApp {
|
||||
/// Close prompt `id` from outside and drop the answer that leaves behind.
|
||||
pub(crate) fn close_prompt(&mut self, id: DialogId) {
|
||||
if let Some(ctx) = self.ctx.clone() {
|
||||
crate::dialogs::chrome::forget_nudge(&ctx, id);
|
||||
self.dialog_host.cancel_by_id(&ctx, id);
|
||||
}
|
||||
let _ = self.dialog_host.take_by_id::<UnsavedChangesDialog>(id);
|
||||
@@ -192,9 +191,6 @@ impl WordApp {
|
||||
pub(crate) fn pump_close_prompt(&mut self) {
|
||||
let Some(id) = self.closing.as_ref().and_then(|c| c.prompt) else { return };
|
||||
let Some(result) = self.dialog_host.take_by_id::<UnsavedChangesDialog>(id) else { return };
|
||||
if let Some(ctx) = self.ctx.as_ref() {
|
||||
crate::dialogs::chrome::forget_nudge(ctx, id);
|
||||
}
|
||||
if let Some(closing) = self.closing.as_mut() {
|
||||
closing.prompt = None;
|
||||
}
|
||||
@@ -333,7 +329,7 @@ impl WordApp {
|
||||
// A save that never reached its destination leaves no stamp of it, when the document is as
|
||||
// the save left it (an edit since keeps its own marks and stays unsaved).
|
||||
let mut undone = false;
|
||||
if !matches!(picked, Picked::Paths(_) | Picked::Saved { .. } | Picked::Downloaded(_))
|
||||
if !matches!(picked, Picked::Paths(_) | Picked::Downloaded(_))
|
||||
&& save.document == current
|
||||
&& save.rev == self.session.rev()
|
||||
&& let Some(undo) = save.undo_stamp.take()
|
||||
@@ -342,7 +338,7 @@ impl WordApp {
|
||||
undone = true;
|
||||
}
|
||||
// A download the browser accepted is a finished save too: the page holds no file of it.
|
||||
if matches!(picked, Picked::Paths(_) | Picked::Saved { .. } | Picked::Downloaded(_)) {
|
||||
if matches!(picked, Picked::Paths(_) | Picked::Downloaded(_)) {
|
||||
log::info!("saved {} through the save picker", save.name);
|
||||
// The page now holds the document as that file (a hosted Save As or first Save, S-L159):
|
||||
// the next Save goes back to it. A download names nothing the app could reopen.
|
||||
@@ -385,14 +381,12 @@ impl WordApp {
|
||||
}
|
||||
let result = match picked {
|
||||
// Only when nothing changed since and no later save of it is still unconfirmed.
|
||||
Picked::Paths(_) | Picked::Saved { .. } | Picked::Downloaded(_)
|
||||
if !self.session.dirty && self.session.rev() == save.rev && !self.save_unconfirmed() =>
|
||||
{
|
||||
Picked::Paths(_) | Picked::Downloaded(_) if !self.session.dirty && self.session.rev() == save.rev && !self.save_unconfirmed() => {
|
||||
let step = self.with_guard(|g| g.saved());
|
||||
self.drive_guard(step, None)
|
||||
}
|
||||
// Edited while the picker was open (those edits may not be written yet): ask again.
|
||||
Picked::Paths(_) | Picked::Saved { .. } | Picked::Downloaded(_) => {
|
||||
Picked::Paths(_) | Picked::Downloaded(_) => {
|
||||
let step = self.with_guard(|g| g.retry_after_failure());
|
||||
self.drive_guard(step, None)
|
||||
}
|
||||
@@ -638,7 +632,7 @@ impl WordApp {
|
||||
let Some(intake) = self.services.intake.as_ref() else { return };
|
||||
for item in intake.take() {
|
||||
match item {
|
||||
Intake::Dropped { files } => self.open_dropped(&files),
|
||||
Intake::Dropped { files, target } => self.open_dropped(&files, target),
|
||||
Intake::Open(paths) | Intake::OpenFor { paths, .. } => {
|
||||
for p in paths {
|
||||
// A path that is not Unicode cannot be passed on as text: skipped.
|
||||
@@ -670,7 +664,7 @@ impl WordApp {
|
||||
/// Route files dropped on the window, in drop order: the one place the drop rules live. A drop
|
||||
/// behind a modal dialog does nothing, since it would insert a picture or open a document
|
||||
/// under it. Every drop target routes by file kind, so `_target` does not change the routing.
|
||||
pub(crate) fn open_dropped(&mut self, files: &[DroppedFile]) {
|
||||
pub(crate) fn open_dropped(&mut self, files: &[DroppedFile], _target: DropTarget) {
|
||||
if self.modal_open() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,19 +151,11 @@ impl WordApp {
|
||||
// PLAN: assumed `updates_ui::run(app: &mut WordApp)` (shell-w13, sh.A20) opens the updater's dialogs on the host.
|
||||
updates_ui::run(self);
|
||||
crate::dialogs::host::prepare(self);
|
||||
let had_dialogs = !self.dialog_host.is_empty();
|
||||
self.dialog_host.run(ui);
|
||||
crate::dialogs::host::settle(self, ctx);
|
||||
crate::dialogs::chrome::apply_modal_nudge(self, ui);
|
||||
if moved(self) {
|
||||
return;
|
||||
}
|
||||
if had_dialogs && self.dialog_host.is_empty() && !self.file_dialog_open() && !self.ui.backstage {
|
||||
self.canvas.focus_page(ctx);
|
||||
self.canvas.focus_pending = true;
|
||||
self.canvas.focus_page_after_pass();
|
||||
ctx.request_repaint();
|
||||
}
|
||||
self.refocus_after_chrome_click(ctx, regions);
|
||||
if let Some(url) = self.canvas.open_url.take() {
|
||||
ctx.open_url(egui::OpenUrl::new_tab(url));
|
||||
|
||||
@@ -253,24 +253,6 @@ fn drawing_over_the_pages_follows_the_read_mode_page_color() {
|
||||
assert_eq!(blank(&a), Rgb::WHITE, "the paper under the raster, not the page color");
|
||||
}
|
||||
|
||||
/// #299: the caret's colour is worked out only when the caret is drawn: with text selected
|
||||
/// there is no caret, so the page's draw list isn't built for it.
|
||||
#[test]
|
||||
fn caret_colour_is_not_worked_out_while_the_caret_is_hidden() {
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::from_text("Hello WordCraft")), Default::default());
|
||||
a.run("select.text", json!({"text": "Hello"})).unwrap();
|
||||
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,
|
||||
);
|
||||
h.run_steps(4);
|
||||
assert!(h.state().canvas.caret_bg.is_none(), "no caret, no colour lookup");
|
||||
}
|
||||
|
||||
/// Show revisions in balloons: a document whose only revision is a deletion gets the markup
|
||||
/// area for its balloon; the other modes have nothing to show there, and neither does the view
|
||||
/// while the Comments pane is open.
|
||||
|
||||
@@ -260,19 +260,6 @@ fn table_gridlines_skip_edges_a_border_draws() {
|
||||
);
|
||||
}
|
||||
|
||||
/// #5967: a new table has borders on every edge, so it shows no gridline at all; with its
|
||||
/// borders removed every edge shows one.
|
||||
#[test]
|
||||
fn a_bordered_table_shows_no_gridlines() {
|
||||
let mut a = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), Default::default());
|
||||
a.run("insert.table", json!({"rows": 2, "cols": 3})).unwrap();
|
||||
assert!(a.session.view.table_gridlines, "View Gridlines is on by default");
|
||||
let segs = |a: &mut WordApp| gridline_segments(&a.session.layout().pages[0], true, None).len();
|
||||
assert_eq!(segs(&mut a), 0);
|
||||
a.run("table.borders", json!({"kind": "none"})).unwrap();
|
||||
assert_eq!(segs(&mut a), 6 * 4, "every edge of the six cells");
|
||||
}
|
||||
|
||||
/// The drawing grid the page shows starts at the text area's top left, stays inside it, spaces
|
||||
/// its lines by the settings the same both ways or differently across and down, and falls back
|
||||
/// to the spec's 1/8 inch for a missing spacing.
|
||||
|
||||
@@ -4,9 +4,9 @@ use craft::behavior::IconId;
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::ui::buttons::IconButton;
|
||||
use craft::ui::contract::{Bind, Props as _, Show as _, TooltipSpec};
|
||||
use craft::ui::menu::search::{HelpEntry, SearchIndex, SearchWords, Synonyms};
|
||||
use craft::ui::menu::HelpEntry;
|
||||
use craft::ui::patterns::panels::{CommandPalette, PaletteFace};
|
||||
use craft::ui::runtime::env::{Env, Label, WordTemplate};
|
||||
use craft::ui::runtime::env::{Label, WordTemplate};
|
||||
use craft::ui::runtime::inspect;
|
||||
use egui::Ui;
|
||||
use serde_json::json;
|
||||
@@ -64,10 +64,7 @@ pub(super) fn show(app: &mut WordApp, ui: &mut Ui, compact: bool) -> egui::Rect
|
||||
}
|
||||
rect = Some(button.response.rect);
|
||||
}
|
||||
let env = Env::of(ui);
|
||||
let view = env.view();
|
||||
let index = SearchIndex::new(&view, &entries, &Synonyms::of(&view.words::<SearchWords>()));
|
||||
let out = CommandPalette::new(name.clone(), &entries, &index, Bind::bound(&mut open))
|
||||
let out = CommandPalette::new(name.clone(), &entries, Bind::bound(&mut open))
|
||||
.face(if compact { PaletteFace::Dialog } else { PaletteFace::InPlace })
|
||||
.placeholder(Label::from(name.clone()))
|
||||
.suggested((Label::from(tl!("Suggested").to_string()), suggested))
|
||||
|
||||
@@ -76,34 +76,6 @@ fn new_app() -> WordApp {
|
||||
WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), crate::Services::default())
|
||||
}
|
||||
|
||||
/// A saved .docx (so AutoSave can cover it) in the harness.
|
||||
fn autosave_harness() -> (egui_kittest::Harness<'static, WordApp>, std::path::PathBuf) {
|
||||
let dir = std::env::temp_dir().join(format!("wordcraft-ui-autosave-label-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("draft.docx");
|
||||
let mut a = new_app();
|
||||
a.run("text.insert", json!({"text": "Hello"})).unwrap();
|
||||
a.run("file.save", json!({"path": path.to_string_lossy()})).unwrap();
|
||||
assert!(a.autosaves(), "a saved .docx is covered by AutoSave");
|
||||
let h = harness(a);
|
||||
(h, dir)
|
||||
}
|
||||
|
||||
/// #3370: clicking the AutoSave switch label toggles AutoSave on and off.
|
||||
#[test]
|
||||
fn clicking_the_autosave_label_toggles_autosave() {
|
||||
let (mut h, dir) = autosave_harness();
|
||||
assert!(h.state().autosaves());
|
||||
h.get_by_label("AutoSave").click();
|
||||
crate::test_harness::frames(&mut h, 2);
|
||||
assert!(!h.state().autosaves(), "clicking the text turns AutoSave off");
|
||||
h.get_by_label("AutoSave").click();
|
||||
crate::test_harness::frames(&mut h, 2);
|
||||
assert!(h.state().autosaves(), "and clicking it again turns it back on");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// #701: the arrow beside Undo lists the session's undo steps, newest first; clicking the third
|
||||
/// row undoes three steps at once.
|
||||
#[test]
|
||||
|
||||
@@ -13,7 +13,7 @@ use craft::color_ui::ui::{ColorPickerDialog, ColorPickerDialogLayout, ColorPicke
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::theme::Srgba;
|
||||
use craft::ui::buttons::{SplitButton, SplitMenu};
|
||||
use craft::ui::choice::{CellMarks, SwatchTable};
|
||||
use craft::ui::choice::SwatchTable;
|
||||
use craft::ui::contract::{BodyCx, Hover, NoValue, Props as _, Show as _, clicked};
|
||||
use craft::ui::dialog::{DialogId, DialogResult};
|
||||
use craft::ui::menu::{MenuItem, MenuItemOutput};
|
||||
@@ -307,7 +307,7 @@ fn swatch_table(
|
||||
let out = SwatchTable::new(name.to_string(), &swatches)
|
||||
.per_row(per_row)
|
||||
.tips(true)
|
||||
.marks(|i: &usize| CellMarks::default().edge(colors.get(*i).copied() == current && current.is_some()))
|
||||
.marked(|i: &usize| colors.get(*i).copied() == current && current.is_some())
|
||||
.show_all(ui);
|
||||
let picked = out.selected.and_then(|i| colors.get(i).copied());
|
||||
let preview = match out.preview {
|
||||
@@ -490,7 +490,7 @@ fn highlight_body(ui: &mut Ui, app: &mut WordApp, cx: &mut BodyCx<'_>) -> ColorP
|
||||
let out = SwatchTable::new("Highlight Colors".to_string(), &swatches)
|
||||
.per_row(5)
|
||||
.tips(true)
|
||||
.marks(|i: &usize| CellMarks::default().edge(shown.get(*i).is_some_and(|(h, _)| h.ooxml() == in_effect)))
|
||||
.marked(|i: &usize| shown.get(*i).is_some_and(|(h, _)| h.ooxml() == in_effect))
|
||||
.show_all(ui);
|
||||
let mut picked = None;
|
||||
if let Some((h, c)) = out.selected.and_then(|i| shown.get(i)) {
|
||||
|
||||
@@ -163,58 +163,3 @@ mod nightly_about_tests {
|
||||
assert_eq!(name, "WordCraft");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use craft::ui::contract::Role;
|
||||
use craft::ui::dialog::DialogHost;
|
||||
use craft::ui::testing::Fixture;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn column_header(fixture: &Fixture, label: &str) -> egui::Rect {
|
||||
fixture
|
||||
.by_role(Role::COLUMN_HEADER)
|
||||
.into_iter()
|
||||
.find(|cell| fixture.tree().name_of(cell.node) == Some(label))
|
||||
.unwrap_or_else(|| panic!("missing column header {label:?}"))
|
||||
.rect
|
||||
}
|
||||
|
||||
fn table_rect(fixture: &Fixture) -> egui::Rect {
|
||||
fixture.by_role(Role::TABLE).first().expect("the credits table shows").rect
|
||||
}
|
||||
|
||||
/// Verifies that WordCraft's `about(AboutTab::Models)` (`AboutLayout::Listed` with the baked
|
||||
/// `MODELS` table) fits within the dialog and refits its `Company` column when narrowed.
|
||||
/// The original drag-then-content-change refit check (#5588) belongs in `craft-libs` and is
|
||||
/// tracked in `storytold/craft-libs#3372`.
|
||||
#[test]
|
||||
fn models_table_refits_to_narrower_window() {
|
||||
let wide = egui::vec2(1400.0, 800.0);
|
||||
let narrow = egui::vec2(660.0, 800.0);
|
||||
|
||||
let host = Rc::new(RefCell::new(DialogHost::new()));
|
||||
let shown_host = Rc::clone(&host);
|
||||
let mut fixture = Fixture::new(move |ui| shown_host.borrow_mut().run(ui));
|
||||
fixture.room(wide);
|
||||
host.borrow_mut().open(about(AboutTab::Models));
|
||||
fixture.settle();
|
||||
|
||||
let wide_table = table_rect(&fixture);
|
||||
let wide_company = column_header(&fixture, "Company");
|
||||
let wide_last = column_header(&fixture, "Lines +/\u{2212}");
|
||||
assert!(wide_last.right() <= wide_table.right() + 1.0, "the table opens fitted to the dialog: {wide_last:?} in {wide_table:?}");
|
||||
|
||||
fixture.room(narrow).settle();
|
||||
let slim_table = table_rect(&fixture);
|
||||
let slim_company = column_header(&fixture, "Company");
|
||||
let slim_last = column_header(&fixture, "Lines +/\u{2212}");
|
||||
assert!(slim_table.width() < wide_table.width() - 1.0, "hosted About shrinks with window: {slim_table:?} vs {wide_table:?}");
|
||||
assert!(slim_company.width() < wide_company.width() - 1.0, "hosted About refits its Company column: {slim_company:?} vs {wide_company:?}");
|
||||
assert!(slim_last.right() <= slim_table.right() + 1.0, "the narrower table still fits its last column: {slim_last:?} in {slim_table:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use serde_json::Value;
|
||||
use crate::WordApp;
|
||||
|
||||
mod bookmarks;
|
||||
pub(crate) mod chrome;
|
||||
mod customize_keyboard;
|
||||
mod enclose;
|
||||
mod find;
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
//! Modal dialog chrome: modal nudge/shake animations and decorations (#3859, #4076, #7321).
|
||||
|
||||
use craft::ui::runtime::env::Env;
|
||||
use craft::ui::style::rgba_color;
|
||||
use egui::emath::TSTransform;
|
||||
use egui::{Context, CornerRadius, Id, LayerId, Order, Stroke, StrokeKind, Ui, vec2};
|
||||
|
||||
use crate::WordApp;
|
||||
|
||||
/// How long a modal window shakes or flashes after a press beside it, in seconds.
|
||||
pub(crate) const NUDGE_SECS: f64 = 0.4;
|
||||
|
||||
/// The `ctx.data` key for when the window `id` was last nudged, in this document window: the data
|
||||
/// is shared by all of them.
|
||||
pub(crate) fn nudge_id(ctx: &Context, id: Id) -> Id {
|
||||
id.with(("nudge", ctx.viewport_id()))
|
||||
}
|
||||
|
||||
/// Forgets a nudge of the window `id` as it closes, so it doesn't go on when the window reopens.
|
||||
pub(crate) fn forget_nudge(ctx: &Context, id: Id) {
|
||||
let key = nudge_id(ctx, id);
|
||||
ctx.data_mut(|d| {
|
||||
d.remove::<f64>(key);
|
||||
});
|
||||
}
|
||||
|
||||
/// The shake's sideways offset at `t` (0 to 1) through it: three swings either way of up to 6
|
||||
/// points, dying away.
|
||||
pub(crate) fn shake_offset(t: f32) -> f32 {
|
||||
6.0 * (t * 3.0 * std::f32::consts::TAU).sin() * (1.0 - t)
|
||||
}
|
||||
|
||||
/// Triggers a shake/nudge animation on dialog `id` if not already running.
|
||||
pub(crate) fn trigger_prompt_nudge(ctx: &Context, id: Id) {
|
||||
let key = nudge_id(ctx, id);
|
||||
let now = ctx.input(|i| i.time);
|
||||
let running = ctx.data(|d| d.get_temp::<f64>(key)).is_some_and(|s| (0.0..NUDGE_SECS).contains(&(now - s)));
|
||||
if !running {
|
||||
ctx.data_mut(|d| d.insert_temp(key, now));
|
||||
}
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
/// Applies modal shake / nudge animation (or accent border flashes under reduced motion) to the
|
||||
/// active modal dialog. Also detects presses beside the dialog (on the backdrop or outside) to
|
||||
/// trigger the nudge.
|
||||
pub(crate) fn apply_modal_nudge(app: &mut WordApp, ui: &mut Ui) {
|
||||
let ctx = ui.ctx().clone();
|
||||
if craft::ui::runtime::measure::active(&ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Forget nudge on every dialog close, so reopening within NUDGE_SECS opens still.
|
||||
// Tracking the host-provided open_serial distinguishes successive opens sharing the same ID.
|
||||
let prev_open_key = Id::NULL.with("modal_dialogs_open_last_pass").with(ctx.viewport_id());
|
||||
let prev_open: Vec<(Id, u64)> = ctx.data(|d| d.get_temp(prev_open_key)).unwrap_or_default();
|
||||
let current_open: Vec<(Id, u64)> =
|
||||
app.dialog_host.open_dialogs().into_iter().filter_map(|d| app.dialog_host.open_serial(d.id).map(|s| (d.id, s))).collect();
|
||||
for (closed_id, prev_serial) in &prev_open {
|
||||
if !current_open.iter().any(|(id, serial)| id == closed_id && serial == prev_serial) {
|
||||
forget_nudge(&ctx, *closed_id);
|
||||
}
|
||||
}
|
||||
ctx.data_mut(|d| d.insert_temp(prev_open_key, current_open));
|
||||
|
||||
let prompt_id = app.closing.as_ref().and_then(|c| c.prompt).filter(|&id| app.dialog_host.get_dyn(id).is_some());
|
||||
let target_id =
|
||||
prompt_id.or_else(|| app.dialog_host.shows_modal().then(|| app.dialog_host.open_dialogs().into_iter().next_back().map(|d| d.id)).flatten());
|
||||
let Some(id) = target_id else {
|
||||
return;
|
||||
};
|
||||
|
||||
let hosted = app.dialog_host.get_dyn(id).is_some();
|
||||
if !hosted {
|
||||
return;
|
||||
}
|
||||
|
||||
// When popups/menus are open inside a modal dialog, overlay::top points to the popup.
|
||||
// Walk up .parent to locate the target modal dialog's own overlay entry so clicking
|
||||
// inside the dialog (outside the popup) does not falsely trigger a shake.
|
||||
let top_id = craft::ui::runtime::overlay::top(&ctx);
|
||||
let mut modal_entry = top_id.and_then(|tid| craft::ui::runtime::overlay::entry(&ctx, tid));
|
||||
while let Some(entry) = modal_entry.as_ref() {
|
||||
if entry.rank.is_modal() {
|
||||
break;
|
||||
}
|
||||
modal_entry = entry.parent.and_then(|pid| craft::ui::runtime::overlay::entry(&ctx, pid));
|
||||
}
|
||||
let modal_entry = modal_entry.filter(|e| e.rank.is_modal());
|
||||
let modal_layer_id = ctx.memory(|m| m.top_modal_layer());
|
||||
|
||||
let (dialog_rect, area_layer_id) = if let Some(ref entry) = modal_entry {
|
||||
(Some(entry.rect), Some(LayerId::new(Order::Foreground, craft::ui::runtime::memory::sub(entry.id, "area"))))
|
||||
} else if let Some(layer) = modal_layer_id {
|
||||
(ctx.memory(|m| m.area_rect(layer.id)), Some(layer))
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
|
||||
let Some(rect) = dialog_rect else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Include the modal dialog's rectangle and all open overlays in its family
|
||||
// (such as dropdown popups or submenus) so presses on popup extensions are inside.
|
||||
let mut inside_rects = vec![rect];
|
||||
if let Some(ref entry) = modal_entry {
|
||||
for family_id in craft::ui::runtime::overlay::family(&ctx, entry.id) {
|
||||
if let Some(e) = craft::ui::runtime::overlay::entry(&ctx, family_id) {
|
||||
inside_rects.push(e.rect);
|
||||
if let Some(anchor) = e.anchor {
|
||||
inside_rects.push(anchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let is_inside = |pos: egui::Pos2| inside_rects.iter().any(|r| r.contains(pos));
|
||||
|
||||
let beside = ctx.input(|i| {
|
||||
let event_pressed = i.events.iter().any(|e| match e {
|
||||
egui::Event::PointerButton { pos, pressed: true, button: egui::PointerButton::Primary, .. } => !is_inside(*pos),
|
||||
_ => false,
|
||||
});
|
||||
let held_pressed = i.pointer.any_pressed() && i.pointer.press_origin().is_some_and(|p| !is_inside(p));
|
||||
event_pressed || held_pressed
|
||||
});
|
||||
if beside {
|
||||
trigger_prompt_nudge(&ctx, id);
|
||||
}
|
||||
|
||||
let key = nudge_id(&ctx, id);
|
||||
let now = ctx.input(|i| i.time);
|
||||
let start = match ctx.data(|d| d.get_temp::<f64>(key)).filter(|s| (0.0..NUDGE_SECS).contains(&(now - s))) {
|
||||
Some(s) => s,
|
||||
None => return,
|
||||
};
|
||||
|
||||
ctx.request_repaint();
|
||||
let t = ((now - start) / NUDGE_SECS).clamp(0.0, 1.0) as f32;
|
||||
let animate = app.animations_on() && app.system_animations();
|
||||
|
||||
if animate {
|
||||
let offset = shake_offset(t);
|
||||
let transform = TSTransform::from_translation(vec2(offset, 0.0));
|
||||
if let Some(area_layer) = area_layer_id {
|
||||
ctx.transform_layer_shapes(area_layer, transform);
|
||||
}
|
||||
if let Some(modal_layer) = modal_layer_id
|
||||
&& Some(modal_layer) != area_layer_id
|
||||
{
|
||||
ctx.transform_layer_shapes(modal_layer, transform);
|
||||
}
|
||||
} else if ((t * 4.0) as u32).is_multiple_of(2) {
|
||||
let env = Env::of(ui);
|
||||
let radius = CornerRadius::from(env.tokens.shape.radius.window);
|
||||
let stroke = Stroke::new(2.0, rgba_color(env.tokens.color.accent.solid));
|
||||
if let Some(area_layer) = area_layer_id {
|
||||
ctx.layer_painter(area_layer).rect_stroke(rect, radius, stroke, StrokeKind::Inside);
|
||||
}
|
||||
if let Some(modal_layer) = modal_layer_id
|
||||
&& Some(modal_layer) != area_layer_id
|
||||
{
|
||||
ctx.layer_painter(modal_layer).rect_stroke(rect, radius, stroke, StrokeKind::Inside);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,12 +291,12 @@ fn chart_grid(ui: &mut Ui, colors: [Color32; 3], form: &mut ChartTypeForm) -> bo
|
||||
let mut activated = false;
|
||||
for event in out.response.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
|
||||
if let Some(kind) = keys.last().and_then(|k| kinds.get(*k)) {
|
||||
form.kind = *kind;
|
||||
}
|
||||
}
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(key), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(key)) => {
|
||||
if let Some(kind) = kinds.get(key) {
|
||||
form.kind = *kind;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ pub(super) fn list_index(ui: &mut Ui, label: &Label, rows: &[String], current: O
|
||||
let mut picked = Picked { selected: None, activated: None };
|
||||
for event in events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(set), .. } => picked.selected = set.last().copied(),
|
||||
CollectionEvent::Selection(SelectionChange::Set(set)) => picked.selected = set.last().copied(),
|
||||
CollectionEvent::Activate(row) => {
|
||||
picked.selected = Some(row);
|
||||
picked.activated = Some(row);
|
||||
|
||||
@@ -501,7 +501,7 @@ fn symbol_body(
|
||||
&mut |t, _| Tab::new(word(if *t == 0 { "Symbols" } else { "Special Characters" })),
|
||||
);
|
||||
for event in out.response.events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event
|
||||
&& let Some(t) = keys.last()
|
||||
{
|
||||
form.tab = *t;
|
||||
@@ -570,7 +570,7 @@ fn special_table(ui: &mut Ui, form: &mut SymbolForm) -> bool {
|
||||
let mut activated = false;
|
||||
for event in events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(set), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(set)) => {
|
||||
if let Some(at) = set.last() {
|
||||
form.special = *at;
|
||||
}
|
||||
@@ -655,7 +655,7 @@ fn recent_row(ui: &mut Ui, form: &mut SymbolForm, dark: bool) {
|
||||
.events
|
||||
};
|
||||
for event in events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(rows), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(rows)) = event
|
||||
&& let Some(r) = rows.last().and_then(|i| form.recent.get(*i)).cloned()
|
||||
&& let Some(c) = r.ch.chars().next()
|
||||
{
|
||||
@@ -702,7 +702,7 @@ fn glyph_grid(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().copied().or(picked),
|
||||
CollectionEvent::Selection(SelectionChange::Set(rows)) => picked = rows.last().copied().or(picked),
|
||||
CollectionEvent::Activate(row) => {
|
||||
picked = Some(row);
|
||||
activated = true;
|
||||
|
||||
@@ -375,21 +375,3 @@ fn date_time_dialog_keeps_open_and_displays_invalid_picture_error() {
|
||||
assert!(a.dialog_host.get_dyn(id).is_some(), "the dialog stays open");
|
||||
assert_eq!(a.session.doc.plain_text(wordcraft_doc::StoryRef::Body), "");
|
||||
}
|
||||
|
||||
/// #4832: Document Information fields are offered and format instructions match the chosen
|
||||
/// format.
|
||||
#[test]
|
||||
fn field_dialog_lists_the_document_information_fields() {
|
||||
let listed: Vec<&str> = FIELDS.iter().filter(|(_, cat, _)| *cat == "Document Information").map(|(n, _, _)| *n).collect();
|
||||
for name in ["COMMENTS", "KEYWORDS", "LASTSAVEDBY", "NUMCHARS", "REVNUM", "SUBJECT"] {
|
||||
assert!(listed.contains(&name), "{name} in {listed:?}");
|
||||
}
|
||||
let a = app();
|
||||
let mut f = FieldForm::new(&a);
|
||||
f.select("REVNUM");
|
||||
f.number_format = "ROMAN".into();
|
||||
f.preserve = false;
|
||||
assert_eq!(f.instruction(), r"REVNUM \* ROMAN");
|
||||
f.select("SUBJECT");
|
||||
assert_eq!(f.instruction(), "SUBJECT");
|
||||
}
|
||||
|
||||
@@ -452,8 +452,8 @@ impl WordForm for LanguageForm {
|
||||
.show_items(ui, &source, &mut |i, _| ListRow::new(Label::from(list.get(*i).map(|(_, n)| n.clone()).unwrap_or_default())));
|
||||
// A language is always chosen: a Clear leaves it, and a Toggle of the chosen row picks it again.
|
||||
let picked = shown.events.into_iter().find_map(|event| match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => keys.last().copied(),
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(key), .. } => Some(key),
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => keys.last().copied(),
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(key)) => Some(key),
|
||||
_ => None,
|
||||
});
|
||||
if let Some((tag, _)) = picked.and_then(|i| list.get(i)) {
|
||||
|
||||
@@ -272,7 +272,7 @@ impl ListForm {
|
||||
.show_items(ui, &source, &mut |at, _| ListRow::new((*at + 1).to_string()))
|
||||
.events;
|
||||
for event in events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event
|
||||
&& let Some(chosen) = keys.last()
|
||||
{
|
||||
self.level = *chosen;
|
||||
|
||||
@@ -446,7 +446,7 @@ impl BordersForm {
|
||||
let out = strip
|
||||
.show_items(ui, &source, &mut |key, _| Tab::new(tabs.iter().find(|tab| tab.0 == *key).map_or_else(String::new, |tab| tab.1.clone())));
|
||||
for event in out.response.events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event
|
||||
&& let Some(chosen) = keys.last()
|
||||
{
|
||||
self.tab = *chosen;
|
||||
|
||||
@@ -313,11 +313,11 @@ impl WordForm for SourceManagerForm {
|
||||
.show_items(ui, &source, &mut |i, _| ListRow::new(Label::from(rows.get(*i).cloned().unwrap_or_default())));
|
||||
for event in shown.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => self.selected = keys.last().copied(),
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(key), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => self.selected = keys.last().copied(),
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(key)) => {
|
||||
self.selected = if self.selected == Some(key) { None } else { Some(key) };
|
||||
}
|
||||
CollectionEvent::Selection { change: SelectionChange::Clear, .. } => self.selected = None,
|
||||
CollectionEvent::Selection(SelectionChange::Clear) => self.selected = None,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,8 +322,8 @@ impl WordForm for TocStylesForm {
|
||||
// A level is always picked: Clear and a Toggle off keep the current one.
|
||||
for event in shown.events {
|
||||
let picked = match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => keys.last().copied(),
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(key), .. } => Some(key),
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => keys.last().copied(),
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(key)) => Some(key),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(at) = picked {
|
||||
|
||||
@@ -401,7 +401,7 @@ fn list_table(ui: &mut Ui, name: &str, rows: &[(String, String)], second: bool,
|
||||
});
|
||||
let mut picked = None;
|
||||
for event in out.events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event
|
||||
&& let Some(key) = keys.into_iter().last()
|
||||
{
|
||||
picked = Some(key);
|
||||
@@ -560,7 +560,7 @@ impl WordForm for AutoCorrectForm {
|
||||
.natural_height(true)
|
||||
.show_items(ui, &source, &mut |key, _| Tab::new(tab_name(*key)));
|
||||
for event in strip.response.events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event
|
||||
&& let Some(key) = keys.into_iter().last()
|
||||
{
|
||||
self.tab = key.min(2);
|
||||
@@ -632,7 +632,7 @@ mod tests {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut app = app("");
|
||||
app.run("tools.autocorrect", json!({})).unwrap();
|
||||
let mut h = crate::test_harness::builder().allow_missing_glyphs().with_size(vec2(1440.0, 900.0)).build_ui_state(
|
||||
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);
|
||||
@@ -665,85 +665,4 @@ mod tests {
|
||||
}
|
||||
assert_eq!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body), "Hello. world");
|
||||
}
|
||||
|
||||
/// #3036: the Replace list says so when the filter matches nothing instead of going blank.
|
||||
#[test]
|
||||
fn the_autocorrect_list_says_when_the_filter_matches_nothing() {
|
||||
let mut app = app("");
|
||||
app.session.prefs.autocorrect.entries.push(("brb".to_string(), "be right back".to_string()));
|
||||
app.run("tools.autocorrect", json!({})).unwrap();
|
||||
fn texts(h: &egui_kittest::Harness<'_, WordApp>) -> Vec<String> {
|
||||
fn extract(shape: &egui::Shape, out: &mut Vec<String>) {
|
||||
match shape {
|
||||
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
|
||||
egui::Shape::Vec(v) => v.iter().for_each(|s| extract(s, out)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for clipped in &h.output().shapes {
|
||||
extract(&clipped.shape, &mut out);
|
||||
}
|
||||
out
|
||||
}
|
||||
let mut h = crate::test_harness::builder().allow_missing_glyphs().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);
|
||||
},
|
||||
app,
|
||||
);
|
||||
for _ in 0..4 {
|
||||
h.step();
|
||||
}
|
||||
assert!(!texts(&h).iter().any(|t| t.contains("(none)")), "entries show, no hint");
|
||||
if let Some(host) = h.state_mut().dialog_host.get_mut::<FormHost<AutoCorrectForm>>() {
|
||||
host.form_mut().from = "zzz".to_string();
|
||||
} else {
|
||||
panic!("the AutoCorrect form is open");
|
||||
}
|
||||
for _ in 0..2 {
|
||||
h.step();
|
||||
}
|
||||
assert!(texts(&h).iter().any(|t| t.contains("(none)")), "no matches: the hint shows");
|
||||
}
|
||||
|
||||
/// #6046: Compare › More shows "Show changes at:" and its two choices each on one line. The
|
||||
/// column is not the grid's last, so it first gets the grid's minimum cell width; wrapped to
|
||||
/// that, its text broke after every few letters and the column stayed that narrow.
|
||||
#[test]
|
||||
fn compare_more_keeps_the_show_changes_at_column_on_one_line() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut app = app("Original text.");
|
||||
app.run("review.compare", json!({})).unwrap();
|
||||
let mut h = crate::test_harness::builder().allow_missing_glyphs().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);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(4);
|
||||
h.get_by_label("More >>").click();
|
||||
h.run_steps(4);
|
||||
let one_line = h.get_by_label("New document").rect().height();
|
||||
for label in ["Word level", "Character level"] {
|
||||
let r = h.get_by_label(label).rect();
|
||||
assert!(r.height() <= one_line + 1.0, "{label} wraps: {r:?}, one line is {one_line}");
|
||||
}
|
||||
fn find_galley<'a>(shape: &'a egui::Shape, text: &str) -> Option<&'a std::sync::Arc<egui::Galley>> {
|
||||
match shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == text => Some(&t.galley),
|
||||
egui::Shape::Vec(v) => v.iter().find_map(|s| find_galley(s, text)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
let galley = h.output().shapes.iter().find_map(|s| find_galley(&s.shape, "Show changes at:")).expect("Show changes at: text galley");
|
||||
assert_eq!(galley.rows.len(), 1, "Show changes at: must be on one line, but has {} rows", galley.rows.len());
|
||||
// The next column starts after the widest of them.
|
||||
let (left, right) = (h.get_by_label("Character level").rect(), h.get_by_label("Show changes in:").rect());
|
||||
assert!(right.left() >= left.right(), "the columns overlap: {left:?} {right:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ impl RibbonDialog {
|
||||
&mut |page, _| Tab::new(tabs.iter().find(|tab| tab.0 == *page).map_or_else(String::new, |tab| tab.1.clone())),
|
||||
);
|
||||
for event in out.response.events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(pages), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(pages)) = event
|
||||
&& let Some(page) = pages.last()
|
||||
&& *page != self.page
|
||||
{
|
||||
@@ -788,7 +788,6 @@ pub(crate) fn open(app: &mut WordApp, name: &str, _params: &Value, parent: Optio
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use serde_json::json;
|
||||
use wordcraft_engine::Session;
|
||||
@@ -860,42 +859,4 @@ mod tests {
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
assert_ne!(h.state().session.view.ruler, ruler, "the custom group's button runs its command");
|
||||
}
|
||||
|
||||
/// #1845: typing in the command filter searches across all commands regardless of category,
|
||||
/// and Add >> places the selected command on the Quick Access Toolbar.
|
||||
#[test]
|
||||
fn command_filter_narrows_the_picker_and_add_works() {
|
||||
let mut a = app();
|
||||
a.run("tools.customizeRibbon", json!({})).unwrap();
|
||||
let id = craft::ui::dialog::dialog_id("customizeRibbon");
|
||||
assert!(a.dialog_host.open_dialogs().iter().any(|d| d.id == id), "the dialog is open");
|
||||
|
||||
let (category, current) = {
|
||||
let d = a.dialog_host.get_by_id::<RibbonDialog>(id).expect("dialog exists");
|
||||
(d.category.clone(), d.command.clone())
|
||||
};
|
||||
|
||||
// Empty filter keeps the category scope.
|
||||
let unfiltered = matching_commands(&a, &category, "");
|
||||
assert!(!unfiltered.is_empty());
|
||||
|
||||
// Typing searches every command, ignoring the category.
|
||||
let filter = "bold";
|
||||
let cmds = matching_commands(&a, &category, filter);
|
||||
assert!(cmds.iter().any(|(cmd_id, _)| cmd_id == "format.bold"));
|
||||
assert!(cmds.len() < a.session.registry.all().len());
|
||||
|
||||
let ctx = egui::Context::default();
|
||||
a.dialog_host.set_json_field(&ctx, id, "filter", json!(filter)).unwrap();
|
||||
prepare(&mut a, id);
|
||||
|
||||
let picked = select_in(&cmds, ¤t);
|
||||
assert!(!picked.is_empty());
|
||||
a.dialog_host.set_json_field(&ctx, id, "command", json!(picked)).unwrap();
|
||||
|
||||
// The dialog's Add >> adds the filtered pick to the Quick Access Toolbar.
|
||||
a.run("tools.customizeRibbon", json!({"qatAdd": picked})).unwrap();
|
||||
assert!(a.session.ribbon.qat().contains(&picked.as_str()));
|
||||
assert!(a.session.ribbon.qat().contains(&"format.bold"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,8 +300,8 @@ fn category_list(ui: &mut Ui, form: &mut SmartArtForm) {
|
||||
.show_items(ui, &keyed(&positions, |i| *i), &mut |key, _| ListRow::new(tl!(CATEGORIES.get(*key).copied().unwrap_or("All")).to_string()));
|
||||
for event in out.events {
|
||||
let picked = match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => keys.last().copied(),
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(key), .. } => Some(key),
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => keys.last().copied(),
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(key)) => Some(key),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(category) = picked.and_then(|k| CATEGORIES.get(k)) {
|
||||
@@ -333,12 +333,12 @@ fn layout_tiles(ui: &mut Ui, theme: &[Rgb], form: &mut SmartArtForm) -> bool {
|
||||
let mut activated = false;
|
||||
for event in out.response.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
|
||||
if let Some(layout) = keys.last().and_then(|k| shown.get(*k)) {
|
||||
form.layout = *layout;
|
||||
}
|
||||
}
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(key), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(key)) => {
|
||||
if let Some(layout) = shown.get(key) {
|
||||
form.layout = *layout;
|
||||
}
|
||||
@@ -429,7 +429,7 @@ pub fn frame_button(app: &mut WordApp, ui: &mut Ui, pages: &[PlacedPage], layout
|
||||
];
|
||||
let area = ui.max_rect();
|
||||
let shown = TaskBar::selection(tl!("Text Pane").to_string(), &corners)
|
||||
.side(Side::Start, craft::behavior::overlay::Align::Center)
|
||||
.side(Side::Start)
|
||||
.dismiss(TaskBarDismiss::Keep)
|
||||
.show(ui, area, |ui, _| IconButton::new(IconId::new("textPane")).label(tl!("Text Pane").to_string()).show(ui).clicked());
|
||||
if shown.inner == Some(true) {
|
||||
|
||||
@@ -6,18 +6,15 @@
|
||||
use craft::behavior::Anchor9;
|
||||
use craft::color_ui::ui::ColorPickerTab;
|
||||
use craft::font_manager::picker::FontPickerSettings;
|
||||
use craft::ui::buttons::{Button, ControlPlace, GroupLevel, ToggleButton};
|
||||
use craft::ui::contract::{Bind, Entry, Gap, Props as _, Show as _, ShowContainer as _, Sizing, Trigger};
|
||||
use craft::ui::controls::disclosure::DisclosureGlyph;
|
||||
use craft::ui::buttons::{Button, ToggleButton};
|
||||
use craft::ui::contract::{Bind, Entry, Show as _, ShowContainer as _, Trigger};
|
||||
use craft::ui::dialog::DialogId;
|
||||
use craft::ui::display::{Picture, PictureSize, Text};
|
||||
use craft::ui::display::Picture;
|
||||
use craft::ui::form::{Field, FieldGroup};
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::list::{ThumbAspect, ThumbSize};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::Menu;
|
||||
use craft::ui::patterns::form_dialogs::FormCx;
|
||||
use craft::ui::pickers::{ComboBox, ReferencePoint, ReferencePointKind, Select};
|
||||
use craft::ui::popover::Popover;
|
||||
use craft::ui::pickers::{ReferencePoint, ReferencePointKind, Select};
|
||||
use craft::ui::primitives::{ContentPainterCx, Glyph, IconSpec};
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::sections::Section;
|
||||
@@ -125,15 +122,6 @@ const ANCHORS: [Anchor9; 9] = [
|
||||
Anchor9::BottomRight,
|
||||
];
|
||||
|
||||
/// The alignment labels shown on the closed Alignment button, in [`CELL_ALIGNS`] order.
|
||||
const ALIGN_LABELS: [&str; 9] = ["Top left", "Top", "Top right", "Left", "Center", "Right", "Bottom left", "Bottom", "Bottom right"];
|
||||
|
||||
/// The closed Alignment button's visible label for `align` (`"Auto"` when inherited).
|
||||
fn align_label(align: &str) -> Label {
|
||||
let text = CELL_ALIGNS.iter().position(|(n, _, _)| *n == align).and_then(|i| ALIGN_LABELS.get(i).copied()).unwrap_or("Auto");
|
||||
lab(text)
|
||||
}
|
||||
|
||||
/// The `cellAlign` name for a part's alignments, empty when it sets neither.
|
||||
fn align_name(h: Option<Align>, v: Option<VAlign>) -> String {
|
||||
if h.is_none() && v.is_none() {
|
||||
@@ -179,10 +167,7 @@ fn region_of(st: &TableStyleProps, part: TablePart) -> TableRegion {
|
||||
/// The params `table.newStyle` / `table.modifyStyle` take for the dialog's state: only what
|
||||
/// changed from `basis`, part by part, so the rest stays inherited.
|
||||
pub fn table_style_params(id: Option<&str>, name: &str, based_on: &str, regions: &[TableRegion; 13], basis: &[TableRegion; 13]) -> Value {
|
||||
let mut v = json!({"name": name.trim()});
|
||||
if !based_on.trim().is_empty() {
|
||||
v["basedOn"] = json!(based_on.trim());
|
||||
}
|
||||
let mut v = json!({"name": name.trim(), "basedOn": based_on});
|
||||
for (((part, _), r), b) in PARTS.iter().zip(regions.iter()).zip(basis.iter()) {
|
||||
let ch = region_changes(r, b);
|
||||
if ch.as_object().is_some_and(|o| !o.is_empty()) {
|
||||
@@ -374,9 +359,7 @@ fn paint_preview(cx: &ContentPainterCx<'_>, rect: Rect, style: Option<&TableStyl
|
||||
let Some(st) = style else { return };
|
||||
let mut shapes: Vec<Shape> = Vec::new();
|
||||
let formats: Vec<PartFormat> = TablePart::ALL.iter().map(|p| st.part(*p)).collect();
|
||||
let pad_x = (rect.width() * 0.035).clamp(6.0, 14.0);
|
||||
let pad_y = (rect.height() * 0.06).clamp(4.0, 10.0);
|
||||
let table = rect.shrink2(vec2(pad_x, pad_y));
|
||||
let table = rect.shrink2(vec2(14.0, 10.0));
|
||||
let (cw, rh) = (table.width() / COLS as f32, table.height() / ROWS as f32);
|
||||
let rgb = |c: Rgb| Color32::from_rgb(c.0, c.1, c.2);
|
||||
let tb = st.parts.borders.unwrap_or_default();
|
||||
@@ -443,18 +426,16 @@ fn paint_preview(cx: &ContentPainterCx<'_>, rect: Rect, style: Option<&TableStyl
|
||||
Some(TextColor::Rgb(c)) => rgb(c),
|
||||
_ => Color32::BLACK,
|
||||
};
|
||||
let font = egui::FontId::proportional((rh * 0.65).clamp(8.5, 11.0));
|
||||
let inset_x = (cw * 0.06).clamp(2.0, 4.0);
|
||||
let inset_y = (rh * 0.1).clamp(1.0, 2.0);
|
||||
let font = egui::FontId::proportional(11.0);
|
||||
let (ax, x) = match h {
|
||||
Some(Align::Center) => (egui::Align::Center, cell.center().x),
|
||||
Some(Align::Right) => (egui::Align::Max, cell.right() - inset_x),
|
||||
_ => (egui::Align::Min, cell.left() + inset_x),
|
||||
Some(Align::Right) => (egui::Align::Max, cell.right() - 4.0),
|
||||
_ => (egui::Align::Min, cell.left() + 4.0),
|
||||
};
|
||||
let (ay, y) = match v {
|
||||
Some(VAlign::Center) => (egui::Align::Center, cell.center().y),
|
||||
Some(VAlign::Bottom) => (egui::Align::Max, cell.bottom() - inset_y),
|
||||
_ => (egui::Align::Min, cell.top() + inset_y),
|
||||
Some(VAlign::Bottom) => (egui::Align::Max, cell.bottom() - 2.0),
|
||||
_ => (egui::Align::Min, cell.top() + 2.0),
|
||||
};
|
||||
let galley = cx.painter.layout_no_wrap(txt.to_string(), font, color);
|
||||
let r = egui::Align2([ax, ay]).anchor_size(pos2(x, y), galley.size());
|
||||
@@ -538,7 +519,7 @@ impl TableStyleForm {
|
||||
FieldGroup::new(lab("Table style")).show(ui, |ui, _| {
|
||||
let name_label = lab("Name:");
|
||||
Field::new(name_label.clone()).show(ui, |ui, _| {
|
||||
TextField::new(name_label.clone(), Bind::bound(&mut self.name)).width_chars(30).show(ui);
|
||||
TextField::new(name_label.clone(), Bind::bound(&mut self.name)).show(ui);
|
||||
});
|
||||
let entries: Vec<Entry<usize>> = self.bases.iter().enumerate().map(|(i, b)| Entry::new(i, b.name.clone())).collect();
|
||||
let current = self.bases.iter().position(|b| b.id == self.based_on).unwrap_or(usize::MAX);
|
||||
@@ -564,172 +545,72 @@ impl TableStyleForm {
|
||||
let Self { region, regions, pen, palette, catalog, font_settings, .. } = self;
|
||||
let Some(r) = regions.get_mut(*region) else { return };
|
||||
Section::fixed(lab("Formatting")).show(ui, |ui, _| {
|
||||
// Row 1: Font, size, and B / I / U toggles.
|
||||
Row::new().gap(Gap::Inline).wrap(true).show(ui, |ui, _| {
|
||||
let sizes: Vec<Entry<String>> = wordcraft_engine::cmd::format::SIZES
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let s = size_text(*s);
|
||||
Entry::new(s.clone(), s)
|
||||
})
|
||||
.collect();
|
||||
FieldGroup::new(lab("Formatting")).show(ui, |ui, _| {
|
||||
if let Some(catalog) = catalog.get() {
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
let font_label = lab("Font:");
|
||||
Text::new(font_label.clone()).show(ui);
|
||||
craft::ui::runtime::env::with_env(
|
||||
ui,
|
||||
|overrides| {
|
||||
overrides.values.set(ControlPlace::Ribbon);
|
||||
},
|
||||
|ui| {
|
||||
font_picker(font_label, Bind::bound(&mut r.font), catalog, Bind::bound(&mut *font_settings), &[], None).show(ui);
|
||||
},
|
||||
);
|
||||
let font_label = lab("Font:");
|
||||
Field::new(font_label.clone()).show(ui, |ui, _| {
|
||||
font_picker(font_label.clone(), Bind::bound(&mut r.font), catalog, Bind::bound(&mut *font_settings), &[], None).show(ui);
|
||||
});
|
||||
}
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
let size_label = lab("Size:");
|
||||
Text::new(size_label.clone()).show(ui);
|
||||
craft::ui::runtime::env::with_env(
|
||||
ui,
|
||||
|overrides| {
|
||||
overrides.values.set(ControlPlace::Ribbon);
|
||||
},
|
||||
|ui| {
|
||||
ComboBox::new(size_label, Bind::bound(&mut r.size), &sizes).show(ui);
|
||||
},
|
||||
);
|
||||
// Text, so an empty box means the size is inherited.
|
||||
let size_label = lab("Size:");
|
||||
Field::new(size_label.clone()).show(ui, |ui, _| {
|
||||
TextField::new(size_label.clone(), Bind::bound(&mut r.size)).show(ui);
|
||||
});
|
||||
|
||||
// Compact icon-only labels inside standard secondary (framed) toggle buttons so B / I / U
|
||||
// keep full icon size and visible button outlines.
|
||||
craft::ui::runtime::env::with_env(
|
||||
ui,
|
||||
|overrides| {
|
||||
overrides.values.set(GroupLevel::Compact);
|
||||
},
|
||||
|ui| {
|
||||
Row::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
ToggleButton::new(lab("Bold"), Bind::bound(&mut r.bold)).icon(crate::icons::id("bold")).tooltip(lab("Bold")).show(ui);
|
||||
ToggleButton::new(lab("Italic"), Bind::bound(&mut r.italic))
|
||||
.icon(crate::icons::id("italic"))
|
||||
.tooltip(lab("Italic"))
|
||||
.show(ui);
|
||||
ToggleButton::new(lab("Underline"), Bind::bound(&mut r.underline))
|
||||
.icon(crate::icons::id("underline"))
|
||||
.tooltip(lab("Underline"))
|
||||
.show(ui);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
// Row 2: Font color and Fill color.
|
||||
Row::new().gap(Gap::Section).wrap(true).show(ui, |ui, _| {
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
Text::new(lab("Font color:")).show(ui);
|
||||
if color_field(ui, &lab("Font color:"), &mut r.color, &ColorFieldEmpty::NoColor, palette).more_colors {
|
||||
asks.push(Asks::Color { field: "color", current: Rgb::parse(&r.color), tab: ColorPickerTab::Standard });
|
||||
}
|
||||
Field::new(lab("Font style:")).show(ui, |ui, _| {
|
||||
ui.horizontal(|ui| {
|
||||
ToggleButton::new(lab("Bold"), Bind::bound(&mut r.bold)).show(ui);
|
||||
ToggleButton::new(lab("Italic"), Bind::bound(&mut r.italic)).show(ui);
|
||||
ToggleButton::new(lab("Underline"), Bind::bound(&mut r.underline)).show(ui);
|
||||
});
|
||||
});
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
Text::new(lab("Fill color:")).show(ui);
|
||||
if color_field(ui, &lab("Fill color:"), &mut r.fill, &ColorFieldEmpty::NoColor, palette).more_colors {
|
||||
asks.push(Asks::Color { field: "fill", current: Rgb::parse(&r.fill), tab: ColorPickerTab::Standard });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Row 3: Border pen style, width, and color.
|
||||
Row::new().gap(Gap::Inline).wrap(true).show(ui, |ui, _| {
|
||||
if color_field(ui, &lab("Font color:"), &mut r.color, &ColorFieldEmpty::NoColor, palette).more_colors {
|
||||
asks.push(Asks::Color { field: "color", current: Rgb::parse(&r.color), tab: ColorPickerTab::Standard });
|
||||
}
|
||||
let styles: Vec<Entry<usize>> = LINE_STYLES.iter().enumerate().map(|(i, (_, n))| Entry::new(i, lab(n))).collect();
|
||||
let current = LINE_STYLES.iter().position(|(s, _)| *s == pen.style).unwrap_or(0);
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
Text::new(lab("Style:")).show(ui);
|
||||
if let Some((s, _)) = Select::new(lab("Style:"), Bind::given(current), &styles)
|
||||
.sizing(Sizing::Content)
|
||||
.show(ui)
|
||||
.value()
|
||||
.copied()
|
||||
.and_then(|i| LINE_STYLES.get(i))
|
||||
{
|
||||
pen.style = *s;
|
||||
}
|
||||
});
|
||||
|
||||
if let Some((s, _)) = pick_index(ui, "Style:", &styles, current).and_then(|i| LINE_STYLES.get(i)) {
|
||||
pen.style = *s;
|
||||
}
|
||||
let widths: Vec<Entry<usize>> =
|
||||
WIDTHS.iter().enumerate().map(|(i, w)| Entry::new(i, crate::i18n::fmt(tl!("{n} pt"), &[("n", &w.to_string())]))).collect();
|
||||
let current = WIDTHS.iter().position(|w| *w == pen.width).unwrap_or(usize::MAX);
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
Text::new(lab("Width:")).show(ui);
|
||||
if let Some(w) = Select::new(lab("Width:"), Bind::given(current), &widths)
|
||||
.sizing(Sizing::Content)
|
||||
.show(ui)
|
||||
.value()
|
||||
.copied()
|
||||
.and_then(|i| WIDTHS.get(i))
|
||||
{
|
||||
pen.width = *w;
|
||||
}
|
||||
});
|
||||
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
Text::new(lab("Color:")).show(ui);
|
||||
if color_field(ui, &lab("Color:"), &mut pen.color, &ColorFieldEmpty::NoColor, palette).more_colors {
|
||||
asks.push(Asks::Color { field: "pen", current: Rgb::parse(&pen.color), tab: ColorPickerTab::Standard });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Row 4: Borders menu and compact Alignment dropdown opening the 3×3 alignment grid.
|
||||
Row::new().gap(Gap::Section).wrap(true).show(ui, |ui, _| {
|
||||
let button = Button::new(lab("Borders:")).painted(lab("Borders")).trailing_icon(DisclosureGlyph::menu_button()).show(ui);
|
||||
let entries: Vec<Entry<usize>> = EDGES
|
||||
.iter()
|
||||
.zip(EDGE_GLYPHS.iter())
|
||||
.enumerate()
|
||||
.map(|(i, ((label, edges), glyph))| Entry::new(i, lab(label)).icon(IconSpec::glyph(glyph)).checked(edges_on(&r.borders, edges)))
|
||||
.collect();
|
||||
let picked = Menu::new(lab("Borders")).opened_by(&button, Trigger::Press).pick(ui, &entries).picked;
|
||||
if let Some((_, edges)) = picked.and_then(|i| EDGES.get(i)) {
|
||||
pick_edges(&mut r.borders, edges, pen);
|
||||
if let Some(w) = pick_index(ui, "Width:", &widths, current).and_then(|i| WIDTHS.get(i)) {
|
||||
pen.width = *w;
|
||||
}
|
||||
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, _| {
|
||||
Text::new(lab("Alignment:")).show(ui);
|
||||
let open_id = ui.make_persistent_id("tstyle_align_open");
|
||||
let mut open = ui.ctx().data(|d| d.get_temp::<bool>(open_id)).unwrap_or(false);
|
||||
let align_text = align_label(&r.align);
|
||||
let align_spoken = Label::from(format!("{} {}", tl!("Alignment:"), align_text.as_str()));
|
||||
let button = Button::new(align_spoken)
|
||||
.painted(align_text)
|
||||
.icon(crate::icons::id("cellAlign"))
|
||||
.trailing_icon(DisclosureGlyph::menu_button())
|
||||
.show(ui);
|
||||
if button.clicked() {
|
||||
open = !open;
|
||||
if color_field(ui, &lab("Color:"), &mut pen.color, &ColorFieldEmpty::NoColor, palette).more_colors {
|
||||
asks.push(Asks::Color { field: "pen", current: Rgb::parse(&pen.color), tab: ColorPickerTab::Standard });
|
||||
}
|
||||
Field::new(lab("Borders:")).show(ui, |ui, _| {
|
||||
let button = Button::new(lab("Borders")).show(ui);
|
||||
let entries: Vec<Entry<usize>> = EDGES
|
||||
.iter()
|
||||
.zip(EDGE_GLYPHS.iter())
|
||||
.enumerate()
|
||||
.map(|(i, ((label, edges), glyph))| {
|
||||
Entry::new(i, lab(label)).icon(IconSpec::glyph(glyph)).checked(edges_on(&r.borders, edges))
|
||||
})
|
||||
.collect();
|
||||
let picked = Menu::new(lab("Borders")).opened_by(&button, Trigger::Press).pick(ui, &entries).picked;
|
||||
if let Some((_, edges)) = picked.and_then(|i| EDGES.get(i)) {
|
||||
pick_edges(&mut r.borders, edges, pen);
|
||||
}
|
||||
Popover::new(lab("Alignment"), Bind::bound(&mut open)).opened_by(&button).show(ui, |ui, cx| {
|
||||
// The grid is row by row from the top left, as `CELL_ALIGNS` is.
|
||||
let current = CELL_ALIGNS.iter().position(|(n, _, _)| *n == r.align).and_then(|i| ANCHORS.get(i)).copied();
|
||||
let picked = ReferencePoint::new(lab("Alignment:"), Bind::given(current))
|
||||
.kind(ReferencePointKind::Alignment)
|
||||
.show(ui)
|
||||
.value()
|
||||
.copied();
|
||||
if let Some(anchor) = picked {
|
||||
// Picking the selected cell again clears the alignment.
|
||||
r.align = anchor
|
||||
.and_then(|a| ANCHORS.iter().position(|x| *x == a))
|
||||
.and_then(|i| CELL_ALIGNS.get(i))
|
||||
.map(|(n, _, _)| n.to_string())
|
||||
.unwrap_or_default();
|
||||
cx.request_close();
|
||||
}
|
||||
});
|
||||
ui.ctx().data_mut(|d| d.insert_temp(open_id, open));
|
||||
});
|
||||
if color_field(ui, &lab("Fill color:"), &mut r.fill, &ColorFieldEmpty::NoColor, palette).more_colors {
|
||||
asks.push(Asks::Color { field: "fill", current: Rgb::parse(&r.fill), tab: ColorPickerTab::Standard });
|
||||
}
|
||||
// The grid is row by row from the top left, as `CELL_ALIGNS` is.
|
||||
let current = CELL_ALIGNS.iter().position(|(n, _, _)| *n == r.align).and_then(|i| ANCHORS.get(i)).copied();
|
||||
let picked =
|
||||
ReferencePoint::new(lab("Alignment:"), Bind::given(current)).kind(ReferencePointKind::Alignment).show(ui).value().copied();
|
||||
if let Some(anchor) = picked {
|
||||
// Picking the selected cell again clears the alignment.
|
||||
r.align = anchor
|
||||
.and_then(|a| ANCHORS.iter().position(|x| *x == a))
|
||||
.and_then(|i| CELL_ALIGNS.get(i))
|
||||
.map(|(n, _, _)| n.to_string())
|
||||
.unwrap_or_default();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -771,9 +652,7 @@ impl WordForm for TableStyleForm {
|
||||
let look = look_for(self.look, self.part());
|
||||
let preview = self.preview.as_ref();
|
||||
Section::fixed(lab("Preview")).show(ui, |ui, _| {
|
||||
Picture::painter(lab("Table style preview"), ThumbAspect::new(36, 13), |cx, rect| paint_preview(cx, rect, preview, &look))
|
||||
.extent(PictureSize::Sample(ThumbSize::Large))
|
||||
.show(ui);
|
||||
Picture::painter(lab("Table style preview"), ThumbAspect::new(36, 13), |cx, rect| paint_preview(cx, rect, preview, &look)).show(ui);
|
||||
});
|
||||
true
|
||||
}
|
||||
@@ -898,191 +777,6 @@ mod tests {
|
||||
)
|
||||
}
|
||||
|
||||
/// Alignment choices expose their names and current selection, and can be toggled through the dialog.
|
||||
#[test]
|
||||
fn alignment_buttons_expose_names_selection_and_clicks() {
|
||||
use crate::dialogs::host::FormHost;
|
||||
use egui::accesskit::{Role, Toggled};
|
||||
use egui_kittest::kittest::NodeT;
|
||||
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.run("insert.table", json!({"rows": 4, "cols": 3})).unwrap();
|
||||
app.run("table.newStyle", json!({"name": "AlignTest"})).unwrap();
|
||||
let dialog_id = crate::dialogs::open(&mut app, "modifyTableStyle", &json!({})).expect("dialog opened");
|
||||
// Keep the background ribbon's character controls out of the dialog's label queries.
|
||||
app.ui.tab = "Insert".into();
|
||||
let mut h = harness(app);
|
||||
steps(&mut h);
|
||||
|
||||
// Open the Alignment popover, verify labels and unchecked state, then pick "Bottom right".
|
||||
h.get_by_role_and_label(Role::Button, "Alignment: Auto").click();
|
||||
steps(&mut h);
|
||||
assert_eq!(h.get_by_role_and_label(Role::RadioButton, "Bottom right").accesskit_node().toggled(), Some(Toggled::False));
|
||||
assert!(!h.get_by_role_and_label(Role::RadioButton, "Center").accesskit_node().is_disabled());
|
||||
|
||||
// Click "Bottom right", check align == "bottomRight" and button exposes the value.
|
||||
h.get_by_role_and_label(Role::RadioButton, "Bottom right").click();
|
||||
steps(&mut h);
|
||||
{
|
||||
let host = h.state().dialog_host.get_by_id::<FormHost<TableStyleForm>>(dialog_id).expect("form is hosted");
|
||||
let r = &host.form().regions[host.form().region];
|
||||
assert_eq!(r.align, "bottomRight");
|
||||
}
|
||||
|
||||
// Reopen Alignment via its updated accessible name, verify "Bottom right" is checked, click again to clear it.
|
||||
h.get_by_role_and_label(Role::Button, "Alignment: Bottom right").click();
|
||||
steps(&mut h);
|
||||
assert_eq!(h.get_by_role_and_label(Role::RadioButton, "Bottom right").accesskit_node().toggled(), Some(Toggled::True));
|
||||
h.get_by_role_and_label(Role::RadioButton, "Bottom right").click();
|
||||
steps(&mut h);
|
||||
{
|
||||
let host = h.state().dialog_host.get_by_id::<FormHost<TableStyleForm>>(dialog_id).expect("form is hosted");
|
||||
let r = &host.form().regions[host.form().region];
|
||||
assert_eq!(r.align, "");
|
||||
}
|
||||
assert!(h.query_by_role_and_label(Role::Button, "Alignment: Auto").is_some());
|
||||
}
|
||||
|
||||
/// #7692: empty or whitespace basedOn must be omitted so build_modified does not reject unbased styles.
|
||||
#[test]
|
||||
fn table_style_params_omits_empty_based_on() {
|
||||
let regions: [TableRegion; 13] = std::array::from_fn(|_| TableRegion::default());
|
||||
let basis: [TableRegion; 13] = std::array::from_fn(|_| TableRegion::default());
|
||||
let params = table_style_params(Some("tableGrid"), "Table Grid", "", ®ions, &basis);
|
||||
assert!(!params.as_object().unwrap().contains_key("basedOn"));
|
||||
|
||||
let params_whitespace = table_style_params(Some("tableGrid"), "Table Grid", " ", ®ions, &basis);
|
||||
assert!(!params_whitespace.as_object().unwrap().contains_key("basedOn"));
|
||||
|
||||
let params_with_base = table_style_params(None, "New Style", "tableGrid", ®ions, &basis);
|
||||
assert_eq!(params_with_base.get("basedOn").and_then(|v| v.as_str()), Some("tableGrid"));
|
||||
}
|
||||
|
||||
/// Choosing the document default font or size on a sub-part after changing Whole Table must
|
||||
/// still emit that part's explicit override instead of treating the default as unchanged.
|
||||
#[test]
|
||||
fn choosing_default_font_and_size_on_sub_part_overrides_whole_table() {
|
||||
use crate::dialogs::host::FormHost;
|
||||
use egui::accesskit::Role;
|
||||
use wordcraft_doc::CharProps;
|
||||
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let default_chr = app.session.doc.styles.resolve_char(None, &CharProps::default());
|
||||
let default_size = size_text(default_chr.size);
|
||||
let other_size = if (default_chr.size - 9.0).abs() < 0.1 { "14".to_string() } else { "9".to_string() };
|
||||
let other_font = "Georgia".to_string();
|
||||
|
||||
let dialog_id = crate::dialogs::open(&mut app, "modifyTableStyle", &json!({})).expect("dialog opened");
|
||||
app.ui.tab = "Insert".into();
|
||||
let mut h = harness(app);
|
||||
steps(&mut h);
|
||||
|
||||
// Set Whole Table font and size to non-default values, then switch to Header Row and pick
|
||||
// the document's own default font and size explicitly.
|
||||
{
|
||||
let host = h.state_mut().dialog_host.get_mut_by_id::<FormHost<TableStyleForm>>(dialog_id).expect("form is hosted");
|
||||
host.form_mut().regions[part_index(TablePart::WholeTable)].font = other_font.clone();
|
||||
host.form_mut().regions[part_index(TablePart::WholeTable)].size = other_size.clone();
|
||||
}
|
||||
steps(&mut h);
|
||||
h.get_by_label("Apply formatting to:").click();
|
||||
steps(&mut h);
|
||||
h.get_by_label("Header Row").click();
|
||||
steps(&mut h);
|
||||
h.get_by_role_and_label(Role::ComboBox, "Size:").click();
|
||||
steps(&mut h);
|
||||
for _ in 0..default_size.len().max(4) {
|
||||
h.key_press(egui::Key::Backspace);
|
||||
}
|
||||
h.event(egui::Event::Text(default_size));
|
||||
h.key_press(egui::Key::Enter);
|
||||
steps(&mut h);
|
||||
{
|
||||
let host = h.state_mut().dialog_host.get_mut_by_id::<FormHost<TableStyleForm>>(dialog_id).expect("form is hosted");
|
||||
host.form_mut().regions[part_index(TablePart::FirstRow)].font = default_chr.font.clone();
|
||||
}
|
||||
steps(&mut h);
|
||||
|
||||
h.get_by_label("OK").click();
|
||||
steps(&mut h);
|
||||
assert!(h.state().dialog_host.open_dialogs().is_empty(), "OK closes the dialog");
|
||||
|
||||
let st = h.state().session.doc.styles.get("TableGrid").cloned().unwrap();
|
||||
assert_eq!(st.table_part(TablePart::WholeTable).chr.font.as_deref(), Some(other_font.as_str()));
|
||||
assert_eq!(st.table_part(TablePart::FirstRow).chr.font.as_deref(), Some(default_chr.font.as_str()));
|
||||
assert_eq!(st.table_part(TablePart::FirstRow).chr.size, Some(default_chr.size));
|
||||
}
|
||||
|
||||
/// #7692: modifying the default Table Grid style (which has no base style) sends no empty basedOn
|
||||
/// and OK closes successfully without a blank preview or command rejection.
|
||||
#[test]
|
||||
fn modify_table_grid_style_omits_empty_based_on_and_does_not_fail() {
|
||||
use crate::dialogs::host::FormHost;
|
||||
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.run("insert.table", json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let dialog_id = crate::dialogs::open(&mut app, "modifyTableStyle", &json!({})).expect("dialog opened");
|
||||
app.ui.tab = "Insert".into();
|
||||
let mut h = harness(app);
|
||||
steps(&mut h);
|
||||
{
|
||||
let host = h.state().dialog_host.get_by_id::<FormHost<TableStyleForm>>(dialog_id).expect("form is hosted");
|
||||
assert!(host.form().based_on.is_empty(), "Table Grid has no base style");
|
||||
assert!(host.form().preview.is_some(), "Table Grid preview must build without a base style");
|
||||
let r = &host.form().regions[host.form().region];
|
||||
assert!(r.font.is_empty(), "unset font stays empty (inherited) until edited");
|
||||
assert!(r.size.is_empty(), "unset size stays empty (inherited) until edited");
|
||||
let params = host.form().params();
|
||||
let obj = params.as_object().unwrap();
|
||||
assert!(!obj.contains_key("basedOn"), "empty basedOn must be omitted");
|
||||
assert!(!obj.contains_key("wholeTable"), "untouched style sends no region changes");
|
||||
}
|
||||
{
|
||||
use egui::accesskit::Role;
|
||||
|
||||
let dialog = h.get_by_role_and_label(Role::Dialog, "Modify Table Style").rect();
|
||||
assert!(h.query_by_role_and_label(Role::Heading, "Formatting").is_some(), "Formatting section heading is exposed");
|
||||
assert!(h.query_by_role_and_label(Role::Label, "Font:").is_some(), "Font visible label is exposed");
|
||||
assert!(h.query_by_role_and_label(Role::Label, "Size:").is_some(), "Size visible label is exposed");
|
||||
let font = h.get_by_role_and_label(Role::ComboBox, "Font:").rect();
|
||||
let size = h.get_by_role_and_label(Role::ComboBox, "Size:").rect();
|
||||
let underline = h.get_by_role_and_label(Role::Button, "Underline").rect();
|
||||
let font_color = h.query_all_by_label("Font color: No Color").next().expect("font color field").rect();
|
||||
let fill = h.query_all_by_label("Fill color: No Color").next().expect("fill color field").rect();
|
||||
let borders = h.get_by_role_and_label(Role::Button, "Borders:").rect();
|
||||
let align = h.get_by_role_and_label(Role::Button, "Alignment: Auto").rect();
|
||||
assert!(size.width() < font.width(), "Size box should be narrower than Font box: size={size:?} font={font:?}");
|
||||
for (name, rect) in
|
||||
[("Underline", underline), ("Font color", font_color), ("Fill color", fill), ("Borders", borders), ("Alignment", align)]
|
||||
{
|
||||
assert!(rect.right() <= dialog.right(), "{name} must fit inside the dialog without overflowing: rect={rect:?} dialog={dialog:?}");
|
||||
}
|
||||
assert!(
|
||||
(borders.center().y - align.center().y).abs() < (borders.height() + align.height()) * 0.25
|
||||
&& (borders.height() - align.height()).abs() < borders.height() * 0.25,
|
||||
"Borders and Alignment should line up compactly on one row: borders={borders:?} align={align:?}"
|
||||
);
|
||||
assert!(
|
||||
(font_color.center().y - fill.center().y).abs() < (font_color.height() + fill.height()) * 0.25,
|
||||
"Font color and Fill color should share one row: font_color={font_color:?} fill={fill:?}"
|
||||
);
|
||||
let preview = h.get_by_role_and_label(Role::Image, "Table style preview").rect();
|
||||
let controls_height = align.bottom() - font.top();
|
||||
assert!(
|
||||
preview.height() > font.height() * 2.0 && preview.height() < controls_height && preview.width() > preview.height() * 2.0,
|
||||
"preview should be a landscape compact sample taller than a control row and shorter than the formatting controls: preview={preview:?} font={font:?} controls_height={controls_height}"
|
||||
);
|
||||
assert!(
|
||||
preview.right() <= dialog.right() && preview.bottom() <= dialog.bottom(),
|
||||
"preview must stay inside the dialog: preview={preview:?} dialog={dialog:?}"
|
||||
);
|
||||
}
|
||||
h.get_by_label("OK").click();
|
||||
steps(&mut h);
|
||||
assert!(h.state().dialog_host.open_dialogs().is_empty(), "OK closes the dialog");
|
||||
}
|
||||
|
||||
/// #714: picking a part under "Apply formatting to" and changing it edits that part (here the
|
||||
/// even banded rows) and no other.
|
||||
#[test]
|
||||
@@ -1103,14 +797,10 @@ mod tests {
|
||||
steps(&mut h);
|
||||
for label in ["Bold", "Italic", "Underline"] {
|
||||
// An off toggle button reports no toggled state; only an on one says `True`.
|
||||
assert_ne!(
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, label).accesskit_node().toggled(),
|
||||
Some(Toggled::True),
|
||||
"{label} starts off"
|
||||
);
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, label).click();
|
||||
assert_ne!(h.get_by_label(label).accesskit_node().toggled(), Some(Toggled::True), "{label} starts off");
|
||||
h.get_by_label(label).click();
|
||||
steps(&mut h);
|
||||
assert_eq!(h.get_by_role_and_label(egui::accesskit::Role::Button, label).accesskit_node().toggled(), Some(Toggled::True));
|
||||
assert_eq!(h.get_by_label(label).accesskit_node().toggled(), Some(Toggled::True));
|
||||
}
|
||||
h.get_by_label("OK").click();
|
||||
steps(&mut h);
|
||||
|
||||
@@ -254,7 +254,7 @@ impl OrganizerDialog {
|
||||
});
|
||||
for event in out.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
|
||||
if let Some(key) = keys.last() {
|
||||
self.left = key.clone();
|
||||
}
|
||||
@@ -285,7 +285,7 @@ impl OrganizerDialog {
|
||||
ListRow::new(label(n)).lead_text(label(glyph(ty)), label("¶"))
|
||||
});
|
||||
for event in out.events {
|
||||
if let CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } = event
|
||||
if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event
|
||||
&& let Some(key) = keys.last()
|
||||
{
|
||||
self.right = key.clone();
|
||||
|
||||
@@ -108,19 +108,12 @@ pub(crate) fn settle(app: &mut WordApp, ctx: &Context) {
|
||||
/// More Colors targets, so none outlives its dialog.
|
||||
pub(crate) fn close_all(app: &mut WordApp, ctx: &Context) {
|
||||
let ids: Vec<DialogId> = app.dialog_host.open_dialogs().into_iter().rev().map(|dialog| dialog.id).collect();
|
||||
let had_dialogs = !ids.is_empty();
|
||||
for id in ids {
|
||||
app.dialog_host.cancel_by_id(ctx, id);
|
||||
}
|
||||
settle(app, ctx);
|
||||
// PLAN: assumed `WordApp::more_colors` with `clear()` (ribbon-w11, rb.A4's target map)
|
||||
app.more_colors.clear();
|
||||
if had_dialogs && !app.file_dialog_open() && !app.ui.backstage {
|
||||
app.canvas.focus_page(ctx);
|
||||
app.canvas.focus_pending = true;
|
||||
app.canvas.focus_page_after_pass();
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
/// Opens the About dialog on `tab`. A second About while one is open opens nothing: the first keeps the input.
|
||||
|
||||
@@ -62,12 +62,12 @@ fn pick_name(ui: &mut egui::Ui, label: &str, names: &[String], current: &str) ->
|
||||
let mut activated = false;
|
||||
for e in response.events {
|
||||
match e {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
|
||||
if let Some(n) = keys.first().and_then(|k| names.get(*k)) {
|
||||
picked = Some(n.clone());
|
||||
}
|
||||
}
|
||||
CollectionEvent::Selection { change: SelectionChange::Toggle(k), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Toggle(k)) => {
|
||||
if let Some(n) = names.get(k) {
|
||||
picked = Some(n.clone());
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::ui::contract::Bind;
|
||||
use craft::ui::dialog::{DialogId, DialogResult, DialogStack, StackDialog, dialog_id};
|
||||
use craft::ui::menu::search::{HelpEntry, SearchIndex, SearchWords, Synonyms};
|
||||
use craft::ui::menu::HelpEntry;
|
||||
use craft::ui::patterns::panels::CommandPalette;
|
||||
use craft::ui::runtime::env::{Env, Label, WordTemplate};
|
||||
use craft::ui::runtime::env::{Label, WordTemplate};
|
||||
use serde_json::Value;
|
||||
|
||||
use super::find::{SEARCH_SUGGESTIONS, find_in_navigation_pane};
|
||||
@@ -46,10 +46,7 @@ impl StackDialog for SearchCommandsDialog {
|
||||
}
|
||||
|
||||
fn show(&mut self, ui: &mut egui::Ui, _: &DialogStack) -> Option<DialogResult<Option<String>>> {
|
||||
let env = Env::of(ui);
|
||||
let view = env.view();
|
||||
let index = SearchIndex::new(&view, &self.entries, &Synonyms::of(&view.words::<SearchWords>()));
|
||||
let out = CommandPalette::new(tl!("Search Commands"), &self.entries, &index, Bind::bound(&mut self.open))
|
||||
let out = CommandPalette::new(tl!("Search Commands"), &self.entries, Bind::bound(&mut self.open))
|
||||
.suggested((Label::from(tl!("Suggested")), self.suggested.clone()))
|
||||
.fallback(self.fallback.clone())
|
||||
.show(ui);
|
||||
|
||||
@@ -161,7 +161,7 @@ impl ManageStylesDialog {
|
||||
});
|
||||
for event in out.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
|
||||
if let Some(key) = keys.last() {
|
||||
self.selected = key.clone();
|
||||
}
|
||||
|
||||
@@ -898,8 +898,8 @@ fn replace_all_with_regex_groups_from_the_dialog() {
|
||||
h.run_steps(2);
|
||||
h.state_mut().run("ui.dialog", json!({"name": "replace"})).unwrap();
|
||||
h.run_steps(2);
|
||||
set_field(&mut h, "find", "find", json!(r"(?<last>\w+), (\w+)")); // PLAN: assumed key `find` for the Find and Replace dialog
|
||||
set_field(&mut h, "find", "replace", json!(with));
|
||||
set_field(&mut h, "find", "query", json!(r"(?<last>\w+), (\w+)")); // PLAN: assumed key `find` for the Find and Replace dialog
|
||||
set_field(&mut h, "find", "with", json!(with));
|
||||
set_field(&mut h, "find", "regex", json!(true));
|
||||
h.get_by_label("Replace All").click();
|
||||
h.run_steps(2);
|
||||
@@ -1577,56 +1577,6 @@ fn modal_dialogs_block_the_window_behind_them() {
|
||||
assert!(h.state().ui.backstage, "File opens beside Find");
|
||||
}
|
||||
|
||||
/// Dismissing a dialog opened from a non-canvas command or control returns keyboard focus to the page (#7458).
|
||||
#[test]
|
||||
fn dismissing_a_dialog_from_non_canvas_control_returns_keyboard_focus_to_page() {
|
||||
let mut h = app_harness(WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default()));
|
||||
h.run_steps(6);
|
||||
|
||||
// 1. Move focus to a control outside the canvas (Navigation pane search box)
|
||||
h.state_mut().run("view.navigationPane", json!({"value": true})).unwrap();
|
||||
h.run_steps(3);
|
||||
h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Search document").click();
|
||||
h.run_steps(2);
|
||||
assert!(h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Search document").is_focused());
|
||||
assert!(!h.state().canvas.focused(&h.ctx), "canvas does not have focus");
|
||||
|
||||
// Open a dialog via command while Navigation pane has focus
|
||||
h.state_mut().run("ui.dialog", json!({"name": "font"})).unwrap();
|
||||
h.run_steps(3);
|
||||
assert!(is_open(h.state(), "font"), "font dialog is open");
|
||||
|
||||
// Dismiss with Escape
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(3);
|
||||
assert!(!is_open(h.state(), "font"), "font dialog closed");
|
||||
|
||||
// Canvas must have regained keyboard focus
|
||||
assert!(h.state().canvas.focused(&h.ctx), "the document canvas took keyboard focus back");
|
||||
h.event(egui::Event::Text("!".into()));
|
||||
h.run_steps(2);
|
||||
assert_eq!(body_of(h.state()), "!", "typing reached the document canvas");
|
||||
|
||||
// 2. Focus Navigation pane search box again, open dialog, and dismiss via Cancel button
|
||||
h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Search document").click();
|
||||
h.run_steps(2);
|
||||
assert!(h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Search document").is_focused());
|
||||
assert!(!h.state().canvas.focused(&h.ctx), "canvas does not have focus");
|
||||
|
||||
h.state_mut().run("ui.dialog", json!({"name": "font"})).unwrap();
|
||||
h.run_steps(3);
|
||||
assert!(is_open(h.state(), "font"), "font dialog is open");
|
||||
|
||||
press(&mut h, "Cancel");
|
||||
h.run_steps(3);
|
||||
assert!(!is_open(h.state(), "font"), "font dialog closed");
|
||||
|
||||
assert!(h.state().canvas.focused(&h.ctx), "the document canvas took keyboard focus back after Cancel");
|
||||
h.event(egui::Event::Text("?".into()));
|
||||
h.run_steps(2);
|
||||
assert_eq!(body_of(h.state()), "!?", "typing reached the document canvas after Cancel");
|
||||
}
|
||||
|
||||
/// Which dialogs leave the window working (#3859, Word for Mac 16.114.1): `shows_modal` and
|
||||
/// `modal_open` agree with it for each.
|
||||
#[test]
|
||||
@@ -1663,71 +1613,6 @@ fn find_symbol_mark_entry_cross_reference_and_merge_fields_are_modeless() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #3859: Escape in the fallback file chooser over a modal dialog (`templates`) cancels only the
|
||||
/// chooser; the dialog under it, drawn first on `dialog_host`, stays open and regains the top
|
||||
/// of the stack.
|
||||
#[test]
|
||||
fn escape_in_the_browser_leaves_the_dialog_under_it_open() {
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::browse::places::{FakeDirectories, FolderCache};
|
||||
use craft::dialogs::ui::FileChooser;
|
||||
use craft::host::{ManualJobs, PickRequest, Wake};
|
||||
use craft::ui::dialog::DialogResult;
|
||||
|
||||
let mut h = app_harness(app_with(""));
|
||||
h.run_steps(6);
|
||||
// A new window's page takes the keyboard from the first click or command; establish focus so
|
||||
// the later blocked-input check actually tests modal blocking.
|
||||
let ctx = h.ctx.clone();
|
||||
h.state_mut().canvas.focus_page(&ctx);
|
||||
h.run_steps(2);
|
||||
h.event(egui::Event::Text("a".into()));
|
||||
h.run_steps(2);
|
||||
assert_eq!(body_of(h.state()), "a", "the page takes typing while no modal is open");
|
||||
|
||||
open_named(&mut h, "templates", json!({}));
|
||||
assert_eq!(open_keys(h.state()), ["templates"]);
|
||||
|
||||
let jobs = Arc::new(ManualJobs::new());
|
||||
let folders = FolderCache::new(Arc::new(FakeDirectories::new().folder("/d/drafts").file("/d/House.dotx")), jobs.clone(), Wake::none());
|
||||
let req = PickRequest::open("template").directory("/d").fallback(true);
|
||||
h.state_mut().dialog_host.open(FileChooser::new(req, None, folders));
|
||||
for _ in 0..4 {
|
||||
jobs.run_all();
|
||||
h.step();
|
||||
}
|
||||
|
||||
assert!(h.state().dialog_host.is_open::<FileChooser>(), "browser is open");
|
||||
let open = h.state().dialog_host.open_dialogs();
|
||||
assert_eq!(open.len(), 2, "browser is stacked over templates");
|
||||
let ids: Vec<_> = open.iter().map(|d| d.id).collect();
|
||||
assert_eq!(
|
||||
ids,
|
||||
[craft::ui::dialog::dialog_id("templates"), craft::ui::dialog::dialog_id("fileChooser")],
|
||||
"browser is stacked on top of templates"
|
||||
);
|
||||
let listed = open.into_iter().find_map(|d| d.fields.and_then(|f| f.get("listed").cloned()));
|
||||
assert_eq!(listed, Some(json!(true)), "the chooser finished listing its folder");
|
||||
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(3);
|
||||
|
||||
assert!(!h.state().dialog_host.is_open::<FileChooser>(), "Escape closes the browser");
|
||||
assert_eq!(h.state_mut().dialog_host.take::<FileChooser>(), Some(DialogResult::Cancel), "Escape cancels the browser");
|
||||
assert_eq!(open_keys(h.state()), ["templates"], "and leaves the dialog under it open");
|
||||
|
||||
h.event(egui::Event::Text("x".into()));
|
||||
h.run_steps(2);
|
||||
assert_eq!(body_of(h.state()), "a", "the document behind templates stays blocked");
|
||||
assert!(is_open(h.state(), "templates"), "templates stays open");
|
||||
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(3);
|
||||
assert!(!is_open(h.state(), "templates"), "a second Escape closes templates once it is back on top");
|
||||
assert!(h.state().dialog_host.is_empty(), "all dialogs are closed");
|
||||
}
|
||||
|
||||
/// Every dialog name the name table knows opens its dialog under the key the host reports, or
|
||||
/// nothing where its condition isn't met; scripts and every command use this table (dg.A2).
|
||||
#[test]
|
||||
@@ -2055,205 +1940,3 @@ fn insert_chart_tiles_render_within_compact_bounds() {
|
||||
let grid = h.get_by_role_and_label(Role::ListBox, "Chart types").rect();
|
||||
assert!(grid.width() <= 380.0, "3-column chart types grid should not exceed comfortable dialog proportions (~360 pt), got {:?}", grid.size());
|
||||
}
|
||||
|
||||
/// The shake starts and ends where the dialog is and swings at most 6 points either way (#3859, #4076, #7321).
|
||||
#[test]
|
||||
fn the_shake_comes_back_to_rest() {
|
||||
assert_eq!(chrome::shake_offset(0.0), 0.0);
|
||||
assert!(chrome::shake_offset(1.0).abs() < 1e-4);
|
||||
assert!((0..=100).map(|i| chrome::shake_offset(i as f32 / 100.0).abs()).all(|x| x <= 6.0));
|
||||
assert!((0..=100).any(|i| chrome::shake_offset(i as f32 / 100.0).abs() > 3.0), "it does move");
|
||||
}
|
||||
|
||||
/// #7321: clicking beside the Save Changes modal dialog nudges it (or flashes its edge under reduced motion),
|
||||
/// repeat clicks mid-nudge leave the animation running without restarting, and closing clears the nudge state.
|
||||
#[test]
|
||||
fn unsaved_changes_dialog_shakes_on_outside_click_and_clears_on_close() {
|
||||
for animations in ["on", "off"] {
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.run("text.insert", json!({"text": "Unsaved"})).unwrap();
|
||||
app.run("ui.animations", json!({"value": animations})).unwrap();
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_eframe(|_| app);
|
||||
h.run_steps(6);
|
||||
|
||||
// Attempt window close while dirty. Prompt opens peacefully without shaking.
|
||||
h.input_mut().viewports.entry(egui::ViewportId::ROOT).or_default().events.push(egui::ViewportEvent::Close);
|
||||
h.step();
|
||||
h.step();
|
||||
|
||||
let prompt_id = h.state().closing.as_ref().and_then(|c| c.prompt).expect("Save Changes prompt is open");
|
||||
let key = chrome::nudge_id(&h.ctx, prompt_id);
|
||||
let started = |h: &egui_kittest::Harness<'_, WordApp>| h.ctx.data(|d| d.get_temp::<f64>(key));
|
||||
|
||||
assert_eq!(started(&h), None, "{animations:?}: prompt opens peacefully without shaking");
|
||||
|
||||
let look = |h: &egui_kittest::Harness<'_, WordApp>| {
|
||||
let shapes = &h.output().shapes;
|
||||
let mut flat = Vec::new();
|
||||
fn walk<'a>(s: &'a egui::Shape, out: &mut Vec<&'a egui::Shape>) {
|
||||
match s {
|
||||
egui::Shape::Vec(children) => {
|
||||
for c in children {
|
||||
walk(c, out);
|
||||
}
|
||||
}
|
||||
other => out.push(other),
|
||||
}
|
||||
}
|
||||
for c in shapes {
|
||||
walk(&c.shape, &mut flat);
|
||||
}
|
||||
let save_x = flat.iter().find_map(|s| match s {
|
||||
egui::Shape::Text(t) if t.galley.text() == "Save" || t.galley.text() == "Don't Save" || t.galley.text() == "Cancel" => Some(t.pos.x),
|
||||
_ => None,
|
||||
});
|
||||
let border_flashes =
|
||||
flat.iter().filter(|s| matches!(s, egui::Shape::Rect(r) if r.stroke.width > 0.0 && r.fill == egui::Color32::TRANSPARENT)).count();
|
||||
(save_x, border_flashes)
|
||||
};
|
||||
|
||||
let rest_pos = look(&h).0;
|
||||
let baseline_flashes = look(&h).1;
|
||||
|
||||
// Clicking beside the dialog triggers the nudge
|
||||
let rect = craft::ui::runtime::overlay::top(&h.ctx)
|
||||
.and_then(|id| craft::ui::runtime::overlay::entry(&h.ctx, id))
|
||||
.map(|e| e.rect)
|
||||
.or_else(|| h.ctx.memory(|m| m.top_modal_layer().and_then(|l| m.area_rect(l.id))))
|
||||
.expect("dialog rect exists");
|
||||
let beside = egui::pos2(rect.min.x - 20.0, rect.min.y - 20.0);
|
||||
assert!(!rect.contains(beside));
|
||||
|
||||
h.event(egui::Event::PointerMoved(beside));
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
|
||||
let first = started(&h).expect("clicking outside nudges the dialog");
|
||||
let mut looks = vec![look(&h)];
|
||||
|
||||
// Repeat outside click while it runs does not restart it
|
||||
h.event(egui::Event::PointerMoved(beside));
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
h.event(egui::Event::PointerButton { pos: beside, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
assert_eq!(started(&h), Some(first), "{animations:?}: repeat click does not reset start time mid-nudge");
|
||||
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
looks.push(look(&h));
|
||||
}
|
||||
|
||||
if animations == "on" {
|
||||
assert!(looks.iter().any(|l| l.0 != rest_pos), "it shakes horizontally under full animations");
|
||||
} else {
|
||||
assert!(looks.iter().any(|l| l.1 > baseline_flashes), "it flashes accent border under reduced motion");
|
||||
assert!(looks.iter().all(|l| l.0 == rest_pos), "it does not translate horizontally under reduced motion");
|
||||
}
|
||||
|
||||
// Run until shake completes
|
||||
h.run_steps(30);
|
||||
let final_look = look(&h);
|
||||
assert_eq!(final_look.0, rest_pos, "it comes back to rest");
|
||||
assert_eq!(final_look.1, baseline_flashes, "border flash ends at rest");
|
||||
|
||||
// Cancel closes the dialog and forgets nudge
|
||||
h.state_mut().run("ui.saveChanges", json!({"answer": "cancel"})).unwrap();
|
||||
h.step();
|
||||
assert_eq!(started(&h), None, "{animations:?}: closing the dialog clears nudge state");
|
||||
}
|
||||
}
|
||||
|
||||
/// #7321: ordinary click inside a dialog with a popup open does not shake it;
|
||||
/// clicking outside the dialog shakes it; closing clears nudge so reopening within 0.4s opens still.
|
||||
#[test]
|
||||
fn modal_dialog_with_open_popup_does_not_shake_on_inside_click_but_shakes_on_outside_click() {
|
||||
let app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_eframe(|_| app);
|
||||
h.run_steps(6);
|
||||
let id = super::open(h.state_mut(), "font", &json!({})).expect("font dialog opens");
|
||||
h.run_steps(4);
|
||||
|
||||
// Open a dropdown popup inside the Font dialog
|
||||
let buttons: Vec<_> =
|
||||
h.query_all_by_role_and_label(egui::accesskit::Role::Button, "Font color: Automatic").filter(|n| !n.accesskit_node().is_hidden()).collect();
|
||||
assert!(!buttons.is_empty(), "Font color button exists");
|
||||
buttons.last().unwrap().click();
|
||||
h.run_steps(3);
|
||||
|
||||
// Verify a popup is open on top of the overlay stack
|
||||
let top = craft::ui::runtime::overlay::top(&h.ctx).expect("top overlay entry exists");
|
||||
let top_entry = craft::ui::runtime::overlay::entry(&h.ctx, top).expect("top entry exists");
|
||||
assert_eq!(top_entry.rank, craft::ui::runtime::overlay::Rank::Popup, "top entry is popup");
|
||||
|
||||
// Resolve the target modal dialog's own overlay entry by traversing parents
|
||||
let mut cur = top_entry.clone();
|
||||
while let Some(parent) = cur.parent.and_then(|p| craft::ui::runtime::overlay::entry(&h.ctx, p)) {
|
||||
if cur.rank.is_modal() {
|
||||
break;
|
||||
}
|
||||
cur = parent;
|
||||
}
|
||||
assert!(cur.rank.is_modal(), "found modal dialog overlay entry");
|
||||
let modal_rect = cur.rect;
|
||||
let popup_rect = top_entry.rect;
|
||||
|
||||
// A click inside the modal dialog (on body padding, outside the popup) must NOT nudge
|
||||
let inside_point = egui::pos2(modal_rect.min.x + 40.0, modal_rect.min.y + 40.0);
|
||||
assert!(modal_rect.contains(inside_point), "point is inside dialog");
|
||||
assert!(!popup_rect.contains(inside_point), "point is outside popup");
|
||||
|
||||
h.event(egui::Event::PointerMoved(inside_point));
|
||||
h.event(egui::Event::PointerButton { pos: inside_point, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
h.event(egui::Event::PointerButton { pos: inside_point, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
|
||||
let key = chrome::nudge_id(&h.ctx, id);
|
||||
assert!(h.ctx.data(|d| d.get_temp::<f64>(key)).is_none(), "click inside dialog with popup open does not nudge");
|
||||
assert!(h.state().dialog_host.get_dyn(id).is_some(), "dialog remains open after inside click");
|
||||
|
||||
// A click inside the popup itself (or an extension of the popup) must also NOT nudge
|
||||
let popup_point = popup_rect.center();
|
||||
h.event(egui::Event::PointerMoved(popup_point));
|
||||
h.event(egui::Event::PointerButton { pos: popup_point, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
h.event(egui::Event::PointerButton { pos: popup_point, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
assert!(h.ctx.data(|d| d.get_temp::<f64>(key)).is_none(), "click inside popup does not nudge");
|
||||
|
||||
// Dismiss the open dropdown popup
|
||||
h.event(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
h.event(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: false, repeat: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
|
||||
// A click outside the modal dialog (even completed within a single frame) MUST nudge it
|
||||
let beside_point = egui::pos2(modal_rect.min.x - 20.0, modal_rect.min.y - 20.0);
|
||||
assert!(!modal_rect.contains(beside_point), "point is outside dialog");
|
||||
|
||||
h.event(egui::Event::PointerMoved(beside_point));
|
||||
h.event(egui::Event::PointerButton { pos: beside_point, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.event(egui::Event::PointerButton { pos: beside_point, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.step();
|
||||
|
||||
assert!(h.ctx.data(|d| d.get_temp::<f64>(key)).is_some(), "click outside dialog nudges it");
|
||||
|
||||
let serial1 = h.state().dialog_host.open_serial(id).expect("dialog has open serial");
|
||||
|
||||
// Closing the dialog clears the nudge
|
||||
let ctx = h.ctx.clone();
|
||||
h.state_mut().dialog_host.cancel_by_id(&ctx, id);
|
||||
h.run_steps(3);
|
||||
assert!(h.ctx.data(|d| d.get_temp::<f64>(key)).is_none(), "closing dialog clears nudge");
|
||||
|
||||
// Reopening the dialog gets a new open serial and starts still
|
||||
let id2 = super::open(h.state_mut(), "font", &json!({})).expect("font dialog reopens");
|
||||
let serial2 = h.state().dialog_host.open_serial(id2).expect("reopened dialog has open serial");
|
||||
assert_ne!(serial1, serial2, "successive opens have distinct open serials");
|
||||
h.run_steps(2);
|
||||
let key2 = chrome::nudge_id(&h.ctx, id2);
|
||||
assert!(h.ctx.data(|d| d.get_temp::<f64>(key2)).is_none(), "reopened dialog starts still");
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
//! In-app file browser trials and interaction regressions (#576, #3037, #3859).
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests;
|
||||
@@ -1,47 +0,0 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::browse::places::{FakeDirectories, FolderCache};
|
||||
use craft::dialogs::ui::FileChooser;
|
||||
use craft::host::{ManualJobs, PickRequest, Wake};
|
||||
use egui::vec2;
|
||||
use serde_json::json;
|
||||
use wordcraft_engine::Session;
|
||||
|
||||
use crate::{Services, WordApp};
|
||||
|
||||
/// #3859: a modal dialog that closes as it opens the browser (Save in "Save changes?" as a new
|
||||
/// document closes, with no system dialog) leaves the keyboard in the browser's name box: the
|
||||
/// document doesn't take it back on the next frame.
|
||||
#[test]
|
||||
fn a_dialog_closing_into_the_browser_leaves_it_the_keyboard() {
|
||||
let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default());
|
||||
a.run("text.insert", json!({"text": "Unsaved"})).unwrap();
|
||||
let _ = a.run("file.close", json!({}));
|
||||
assert!(a.dialog_host.shows_modal(), "Save Changes prompt opens");
|
||||
|
||||
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();
|
||||
crate::test_harness::logic(&ctx, app);
|
||||
app.ui(ui);
|
||||
},
|
||||
a,
|
||||
);
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
|
||||
let _ = h.state_mut().run("ui.saveChanges", json!({"answer": "save"}));
|
||||
let folders = FolderCache::new(Arc::new(FakeDirectories::new().folder("/d/drafts")), Arc::new(ManualJobs::new()), Wake::none());
|
||||
let req = PickRequest::save("document").file_name("Unsaved.docx").fallback(true);
|
||||
h.state_mut().dialog_host.open(FileChooser::new(req, None, folders));
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
|
||||
assert!(h.state().dialog_host.is_open::<FileChooser>(), "Save As goes on in the browser");
|
||||
assert!(!h.state().canvas.focused(&h.ctx), "document does not take the keyboard back");
|
||||
|
||||
let before_doc = h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body);
|
||||
h.event(egui::Event::Text("x".into()));
|
||||
crate::test_harness::frames(&mut h, 2);
|
||||
|
||||
let after_doc = h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body);
|
||||
assert_eq!(after_doc, before_doc, "typing does not leak into the document behind the browser");
|
||||
}
|
||||
@@ -162,7 +162,6 @@ impl WordApp {
|
||||
let paths = paths.iter().map(|p| p.to_string_lossy().into_owned()).collect();
|
||||
Some(self.finish_picks(d.after, paths))
|
||||
}
|
||||
Picked::Saved { path, .. } => Some(self.finish_picks(d.after, vec![path.to_string_lossy().into_owned()])),
|
||||
Picked::Contents(files) => Some(self.finish_contents(d.after, files)),
|
||||
// The page handed the save over as a download: the save finishes under that name, which
|
||||
// the engine answers with `downloaded`, and the document keeps the file it had.
|
||||
@@ -538,7 +537,7 @@ mod picture_dispatch_tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::host::{AppInfo, Host, Picked, ScriptedFiles};
|
||||
use craft::platform::open::{DroppedFile, FileIntake};
|
||||
use craft::platform::open::{DropTarget, DroppedFile, FileIntake};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -569,7 +568,7 @@ mod picture_dispatch_tests {
|
||||
let services = crate::Services { intake: Some(intake), ..Default::default() };
|
||||
let mut dropped = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), services);
|
||||
let document = dropped.session.document_id();
|
||||
sender.dropped(vec![DroppedFile { path: None, name, bytes: Some(bytes.into()) }]);
|
||||
sender.dropped(vec![DroppedFile { path: None, name, bytes: Some(bytes.into()) }], DropTarget::Elsewhere);
|
||||
dropped.drain_inbox();
|
||||
assert_eq!(dropped.session.document_id(), document, "drop inserts into the current document: {ext}");
|
||||
let pictures = dropped.session.run("arrange.selectionPane", &json!({})).unwrap();
|
||||
|
||||
@@ -455,7 +455,7 @@ fn failed_web_saves_restore_the_save_stamps() {
|
||||
assert_eq!(a.session.path, path_before, "{id}: {name}");
|
||||
}
|
||||
// The browser takes the download: the scripted host files its bytes under the name it answers with.
|
||||
let files = Arc::new(ScriptedFiles::answering([Picked::Saved { path: PathBuf::from("draft.docx"), file_type: None }]).in_browser());
|
||||
let files = Arc::new(ScriptedFiles::answering([Picked::Paths(vec![PathBuf::from("draft.docx")])]).in_browser());
|
||||
let mut a = app_over(&files, wordcraft_doc::Document::from_text(UNSAVED));
|
||||
a.session.dirty = true;
|
||||
let revision_before = a.session.doc.core.revision;
|
||||
@@ -488,7 +488,7 @@ fn web_pdf_export_keeps_an_existing_suffix_in_any_case() {
|
||||
("Report", "Report.pdf"),
|
||||
] {
|
||||
// The browser takes the download: the scripted host files its bytes under the name it answers with.
|
||||
files.queue(Picked::Saved { path: PathBuf::from(expected), file_type: None });
|
||||
files.queue(Picked::Paths(vec![PathBuf::from(expected)]));
|
||||
let result = a.execute("file.exportPdf", json!({"path": name})).unwrap();
|
||||
assert_eq!(result["downloaded"], expected, "{name}");
|
||||
assert!(files.file(std::path::Path::new(expected)).is_some_and(|b| b.starts_with(b"%PDF")), "{name}");
|
||||
@@ -923,73 +923,3 @@ fn many_failed_fonts_end_with_a_count() {
|
||||
a.add_fonts(fonts).unwrap();
|
||||
assert_eq!(status_text(&a), "Added 0 fonts; 5 couldn't be read: f0.ttf, f1.ttf, f2.ttf and 2 more");
|
||||
}
|
||||
|
||||
/// Drawn entries have names and selection state, and choosing one still picks its path (#576, #6790).
|
||||
#[test]
|
||||
fn entries_expose_names_selection_and_picking() {
|
||||
use craft::browse::places::{FakeDirectories, FolderCache};
|
||||
use craft::dialogs::Answer;
|
||||
use craft::dialogs::ui::FileChooser;
|
||||
use craft::host::{ManualJobs, Wake};
|
||||
use craft::ui::dialog::DialogResult;
|
||||
use egui::accesskit::Role;
|
||||
use egui::vec2;
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
|
||||
let fake = Arc::new(FakeDirectories::new().folder("/d/Drafts").file("/d/chapter.docx"));
|
||||
let jobs = Arc::new(ManualJobs::new());
|
||||
let folders = FolderCache::new(fake, jobs.clone(), Wake::none());
|
||||
|
||||
let a = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default());
|
||||
let mut h = crate::test_harness::builder().with_size(vec2(760.0, 520.0)).build_eframe(|_| a);
|
||||
|
||||
let req = PickRequest::open("document").directory("/d").fallback(true);
|
||||
h.state_mut().dialog_host.open(FileChooser::new(req, None, folders));
|
||||
|
||||
let step = |h: &mut egui_kittest::Harness<'_, WordApp>, count: usize| {
|
||||
for _ in 0..count {
|
||||
jobs.run_all();
|
||||
h.step();
|
||||
}
|
||||
};
|
||||
let chooser_fields = |h: &egui_kittest::Harness<'_, WordApp>| {
|
||||
h.state()
|
||||
.dialog_host
|
||||
.open_dialogs()
|
||||
.into_iter()
|
||||
.find_map(|d| d.fields.filter(|f| f.get("listed").is_some()))
|
||||
.expect("FileChooser fields are exposed")
|
||||
};
|
||||
|
||||
step(&mut h, 6);
|
||||
assert_eq!(chooser_fields(&h)["listed"], json!(true), "folder finished listing");
|
||||
|
||||
// Both entries are exposed with ListItem role and start unselected.
|
||||
for name in ["Drafts", "chapter.docx"] {
|
||||
assert_eq!(h.get_by_role_and_label(Role::ListItem, name).accesskit_node().is_selected(), Some(false), "{name} starts unselected");
|
||||
}
|
||||
|
||||
// Selecting the folder marks Drafts selected, leaves chapter.docx unselected, and leaves the name box empty.
|
||||
h.get_by_role_and_label(Role::ListItem, "Drafts").click();
|
||||
step(&mut h, 3);
|
||||
assert_eq!(h.get_by_role_and_label(Role::ListItem, "Drafts").accesskit_node().is_selected(), Some(true));
|
||||
assert_eq!(h.get_by_role_and_label(Role::ListItem, "chapter.docx").accesskit_node().is_selected(), Some(false));
|
||||
assert_eq!(chooser_fields(&h)["selection"], json!(["Drafts"]));
|
||||
assert_eq!(chooser_fields(&h)["name"], json!(""));
|
||||
|
||||
// Selecting chapter.docx moves selection from Drafts to chapter.docx and fills the File name box.
|
||||
h.get_by_role_and_label(Role::ListItem, "chapter.docx").click();
|
||||
step(&mut h, 3);
|
||||
assert_eq!(h.get_by_role_and_label(Role::ListItem, "Drafts").accesskit_node().is_selected(), Some(false));
|
||||
assert_eq!(h.get_by_role_and_label(Role::ListItem, "chapter.docx").accesskit_node().is_selected(), Some(true));
|
||||
assert_eq!(chooser_fields(&h)["selection"], json!(["chapter.docx"]));
|
||||
assert_eq!(chooser_fields(&h)["name"], json!("chapter.docx"));
|
||||
assert_eq!(h.get_by_role_and_label(Role::TextInput, "File name").accesskit_node().value().as_deref(), Some("chapter.docx"));
|
||||
|
||||
// Open button confirms the pick.
|
||||
h.get_by_role_and_label(Role::Button, "Open").click();
|
||||
step(&mut h, 3);
|
||||
|
||||
let answer = h.state_mut().dialog_host.take::<FileChooser>();
|
||||
assert_eq!(answer, Some(DialogResult::Ok(Answer::Paths(vec![PathBuf::from("/d/chapter.docx")]))));
|
||||
}
|
||||
|
||||
@@ -207,37 +207,6 @@ fn fonts_of_one_download_are_listed_together() {
|
||||
assert_eq!((g[1].fonts.as_slice(), g[1].url), (["Cascadia Code"].as_slice(), "https://c"));
|
||||
}
|
||||
|
||||
/// As many downloads as the box lists, in a short window and a very short one: what is above
|
||||
/// the row with Close scrolls, so the opt-out and Close stay on screen and the box in the window.
|
||||
#[test]
|
||||
fn many_downloads_in_a_short_window_leave_the_opt_out_and_close_on_screen() {
|
||||
for height in [600.0, 400.0] {
|
||||
let mut a = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Lanterns")), crate::Services::default());
|
||||
let fonts: Vec<Row> = (0..LISTED)
|
||||
.map(|i| Row {
|
||||
font: format!("Harbour Face {i}"),
|
||||
shown_as: vec!["Carlito".into()],
|
||||
download: format!("Harbour Face {i}"),
|
||||
publisher: "Lantern Works".into(),
|
||||
url: format!("https://example.org/{i}"),
|
||||
restricted: false,
|
||||
})
|
||||
.collect();
|
||||
open_with(&mut a, None, FontBox::new(fonts, false), DialogHooks { prepare: None, settle });
|
||||
let h = harness_sized(a, egui::vec2(1000.0, height));
|
||||
// The steps are still there, to scroll to.
|
||||
assert!(h.query_by_label("Add Font…").is_some());
|
||||
for label in ["Don't show this again", "Close"] {
|
||||
// Close is also the window's close box: every match is on screen.
|
||||
let rects: Vec<egui::Rect> = h.query_all_by_label(label).map(|n| n.rect()).collect();
|
||||
assert!(!rects.is_empty(), "no {label}");
|
||||
for r in rects {
|
||||
assert!(r.min.y >= 0.0 && r.max.y <= height, "{label} is at {r:?}, outside the {height} pt window");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A font whose publisher limits its use says so on its card, and has a card of its own.
|
||||
#[test]
|
||||
fn a_font_with_a_limited_licence_says_so() {
|
||||
|
||||
@@ -512,27 +512,4 @@ mod tests {
|
||||
assert!((x - ex).abs() < 0.05 && (y - ey).abs() < 0.05, "({x}, {y}) vs ({ex}, {ey})");
|
||||
}
|
||||
}
|
||||
|
||||
/// #7317: the `fitOnePage` app icon is a document the registry resolves and the rasteriser draws.
|
||||
/// A document the engine fails to parse or draw gives no texture, and so no shape: the tile would
|
||||
/// be blank. The pre-#7101 test painted the hand-written vector path; this checks the same icon
|
||||
/// through the SVG set that replaced it.
|
||||
#[test]
|
||||
fn fit_one_page_icon_paints_without_panic() {
|
||||
const KEY: &str = "fitOnePage";
|
||||
use craft::theme::{Contrast, Mode};
|
||||
use craft::ui::primitives::{Draw, DrawEnv, PaintRecord};
|
||||
use craft::ui::testing::{Frames, style};
|
||||
|
||||
register();
|
||||
let tokens = style::tokens(Mode::Light, Contrast::Standard);
|
||||
let record = std::cell::RefCell::new(PaintRecord::default());
|
||||
let mut frames = Frames::new();
|
||||
let shapes = frames.frame_shapes(|ui| {
|
||||
let env = DrawEnv { tokens: &tokens, direction: craft::i18n::Direction::Ltr, ink: craft::ui::style::Ink::OnPanel };
|
||||
let icon = IconSpec::svg(IconId::new(KEY));
|
||||
Draw::new(ui.painter(), &record, env).icon(Rect::from_min_size(Pos2::ZERO, egui::vec2(20.0, 20.0)), &icon);
|
||||
});
|
||||
assert!(!shapes.is_empty(), "{KEY} icon must paint");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ pub fn page_input(app: &mut WordApp, inputs: &[EditorInput], pass: &ToolPass, ct
|
||||
// Enter and Escape leave crop mode keeping the crop (`crop` docs). The canvas takes the page's
|
||||
// keys as editor input before the crop overlay's own pass reads its Submit and Cancel, so they
|
||||
// end it here, and neither types a paragraph over the selected picture.
|
||||
if matches!(e, EditorInput::Newline { .. } | EditorInput::Cancel) && crate::crop::active(app).is_some() {
|
||||
if matches!(e, EditorInput::Newline | EditorInput::Cancel) && crate::crop::active(app).is_some() {
|
||||
crate::crop::leave(app);
|
||||
continue;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ fn is_key_input(e: &EditorInput) -> bool {
|
||||
EditorInput::Move(..)
|
||||
| EditorInput::Delete { .. }
|
||||
| EditorInput::Edit(_)
|
||||
| EditorInput::Newline { .. }
|
||||
| EditorInput::Newline
|
||||
| EditorInput::Tab
|
||||
| EditorInput::BackTab
|
||||
| EditorInput::Cancel
|
||||
@@ -306,7 +306,7 @@ fn equation_input(app: &mut WordApp, ctx: &egui::Context, pass: &ToolPass, e: &E
|
||||
let _ = app.run(if *forward { "equation.delete" } else { "equation.backspace" }, json!({}));
|
||||
true
|
||||
}
|
||||
EditorInput::Newline { .. } => {
|
||||
EditorInput::Newline => {
|
||||
let _ = app.run("equation.enter", json!({}));
|
||||
true
|
||||
}
|
||||
@@ -518,7 +518,7 @@ fn handle_input(app: &mut WordApp, ctx: &egui::Context, pass: &ToolPass, e: &Edi
|
||||
};
|
||||
let _ = app.run(id, json!({}));
|
||||
}
|
||||
EditorInput::Newline { .. } => {
|
||||
EditorInput::Newline => {
|
||||
if !crate::objects::key(app, Key::Enter, Modifiers::NONE) {
|
||||
let _ = app.run("text.newParagraph", json!({}));
|
||||
}
|
||||
|
||||
@@ -284,31 +284,6 @@ fn copied_bold_app() -> WordApp {
|
||||
a
|
||||
}
|
||||
|
||||
/// #5616: after Mod+Shift+V (Paste Formatting) and a paired browser paste event, a later
|
||||
/// menu-bar paste (`Event::Paste`) with no key or pointer press in between still keeps source
|
||||
/// formatting instead of reading the earlier Mod+Shift as Keep Text Only.
|
||||
#[test]
|
||||
fn the_ignored_paste_uses_up_its_paste_modifiers() {
|
||||
let mut h = app_harness(copied_bold_app());
|
||||
let chord = Modifiers { shift: true, ..mod_held() };
|
||||
batch_frame(&mut h, vec![egui::Event::ModifiersChanged(chord), key_event(Key::V, true, chord), egui::Event::Paste("x".into())]);
|
||||
batch_frame(&mut h, vec![key_event(Key::V, false, Modifiers::NONE), egui::Event::ModifiersChanged(Modifiers::NONE)]);
|
||||
assert_eq!(body(h.state()), "source target");
|
||||
assert!(is_bold(&mut h));
|
||||
run(&mut h, "select.text", json!({"text": "target"}));
|
||||
offer(&h, vec![ClipItem::Html("<p><i>menu</i></p>".into()), ClipItem::Text("menu".into())]);
|
||||
batch_frame(&mut h, vec![egui::Event::Paste("menu".into())]);
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert_eq!(body(h.state()), "source menu");
|
||||
let state = run(&mut h, "format.state", json!({}));
|
||||
assert_ne!(
|
||||
state.get("bold").and_then(serde_json::Value::as_bool),
|
||||
Some(true),
|
||||
"a later menu-bar paste does not inherit target's bold via Keep Text Only: {state}"
|
||||
);
|
||||
assert_eq!(state.get("italic").and_then(serde_json::Value::as_bool), Some(true), "a later menu-bar paste keeps clipboard formatting: {state}");
|
||||
}
|
||||
|
||||
/// Paste Formatting on a chord the user bound pastes the copied formatting once.
|
||||
#[test]
|
||||
fn paste_formatting_on_another_key_pastes_the_copied_formatting() {
|
||||
|
||||
+61
-161
@@ -3,8 +3,7 @@
|
||||
//! machine, badges, claimed keys) is the framework's `Keytips`; this module gives it WordCraft's
|
||||
//! tabs, controls, legacy sequences and regions.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::behavior::overlay::MinWidth;
|
||||
use craft::keymap::CommandRef;
|
||||
@@ -35,60 +34,6 @@ pub(crate) fn backstage_region() -> egui::Id {
|
||||
egui::Id::unique("wc_keytips_backstage_region")
|
||||
}
|
||||
|
||||
/// Per-context map of ribbon `menu_button` widget ids to the command id each opens a menu for,
|
||||
/// so [`Keytips`] places badges on menu buttons without binding them to fire on pointer click.
|
||||
fn menu_buttons_id() -> egui::Id {
|
||||
egui::Id::unique("wc_keytips_menu_buttons")
|
||||
}
|
||||
|
||||
/// Records (or clears) the command id associated with a ribbon `menu_button` widget id so
|
||||
/// [`show`] can attach `CommandRef` to its inspected element for language-independent badge placement.
|
||||
pub(crate) fn note_menu_button(ctx: &egui::Context, widget_id: egui::Id, command_id: Option<&str>) {
|
||||
let existing = ctx.data(|d| d.get_temp::<Arc<HashMap<egui::Id, CommandRef>>>(menu_buttons_id()));
|
||||
let unchanged = match (&existing, command_id) {
|
||||
(Some(map), Some(id)) => map.get(&widget_id).is_some_and(|cmd| cmd.id == id && cmd.params.is_null()),
|
||||
(Some(map), None) => !map.contains_key(&widget_id),
|
||||
(None, None) => true,
|
||||
(None, Some(_)) => false,
|
||||
};
|
||||
if unchanged {
|
||||
return;
|
||||
}
|
||||
ctx.data_mut(|d| {
|
||||
let mut map = d.get_temp::<Arc<HashMap<egui::Id, CommandRef>>>(menu_buttons_id()).map(|a| (*a).clone()).unwrap_or_default();
|
||||
match command_id {
|
||||
Some(id) => {
|
||||
map.insert(widget_id, CommandRef::new(id));
|
||||
}
|
||||
None => {
|
||||
map.remove(&widget_id);
|
||||
}
|
||||
}
|
||||
d.insert_temp(menu_buttons_id(), Arc::new(map));
|
||||
});
|
||||
}
|
||||
|
||||
/// Attaches noted `menu_button` commands to uncommanded root elements of a ribbon `Recorded`
|
||||
/// snapshot so `craft::menu::Keytips` places badges on menu buttons regardless of translation.
|
||||
fn with_menu_commands(ctx: &egui::Context, recorded: Arc<Recorded>) -> Arc<Recorded> {
|
||||
let Some(commands) = ctx.data(|d| d.get_temp::<Arc<HashMap<egui::Id, CommandRef>>>(menu_buttons_id())) else {
|
||||
return recorded;
|
||||
};
|
||||
if commands.is_empty() || !recorded.elements.iter().any(|e| e.part.is_none() && e.command.is_none() && commands.contains_key(&e.id)) {
|
||||
return recorded;
|
||||
}
|
||||
let mut patched = (*recorded).clone();
|
||||
for element in &mut patched.elements {
|
||||
if element.part.is_none()
|
||||
&& element.command.is_none()
|
||||
&& let Some(cmd) = commands.get(&element.id)
|
||||
{
|
||||
element.command = Some(cmd.clone());
|
||||
}
|
||||
}
|
||||
Arc::new(patched)
|
||||
}
|
||||
|
||||
/// Word's tab letters, as Word for Windows shows them after Alt (File F, Design G, References S,
|
||||
/// Review R, View W, Help Y). File opens the Backstage.
|
||||
const TAB_LETTERS: [(&str, &str); 11] = [
|
||||
@@ -114,32 +59,29 @@ pub const SEARCH_LETTER: &str = "Q";
|
||||
/// Legacy menu keys (#1697): Word 2003 menu sequences Word for Windows still takes after Alt,
|
||||
/// observed there. Hidden, as in Word: no badges, not in Customize Keyboard. They start only on
|
||||
/// letters no tab keytip or Search uses (see the test).
|
||||
fn legacy() -> &'static [(&'static str, CommandRef)] {
|
||||
static LEGACY: OnceLock<Vec<(&'static str, CommandRef)>> = OnceLock::new();
|
||||
LEGACY.get_or_init(|| {
|
||||
let cmd = CommandRef::new;
|
||||
let dialog = |name: &str| CommandRef::with_params("ui.dialog", serde_json::json!({ "name": name }));
|
||||
vec![
|
||||
("VU", cmd("view.fullScreenView")),
|
||||
("VP", cmd("view.printLayout")),
|
||||
("VW", cmd("view.webLayout")),
|
||||
("VO", cmd("view.outline")),
|
||||
("VN", cmd("view.draft")),
|
||||
("VD", cmd("view.navigationPane")),
|
||||
("VL", cmd("view.ruler")),
|
||||
("VZ", dialog("zoom")),
|
||||
("EL", cmd("select.all")),
|
||||
("EF", dialog("find")),
|
||||
("EE", dialog("replace")),
|
||||
("EG", dialog("goto")),
|
||||
("IS", dialog("symbol")),
|
||||
("IPF", cmd("insert.picture")),
|
||||
("OF", dialog("font")),
|
||||
("OP", dialog("paragraph")),
|
||||
("TW", cmd("review.wordCount")),
|
||||
("AIT", dialog("insertTable")),
|
||||
]
|
||||
})
|
||||
fn legacy() -> Vec<(&'static str, CommandRef)> {
|
||||
let cmd = CommandRef::new;
|
||||
let dialog = |name: &str| CommandRef::with_params("ui.dialog", serde_json::json!({ "name": name }));
|
||||
vec![
|
||||
("VU", cmd("view.fullScreenView")),
|
||||
("VP", cmd("view.printLayout")),
|
||||
("VW", cmd("view.webLayout")),
|
||||
("VO", cmd("view.outline")),
|
||||
("VN", cmd("view.draft")),
|
||||
("VD", cmd("view.navigationPane")),
|
||||
("VL", cmd("view.ruler")),
|
||||
("VZ", dialog("zoom")),
|
||||
("EL", cmd("select.all")),
|
||||
("EF", dialog("find")),
|
||||
("EE", dialog("replace")),
|
||||
("EG", dialog("goto")),
|
||||
("IS", dialog("symbol")),
|
||||
("IPF", cmd("insert.picture")),
|
||||
("OF", dialog("font")),
|
||||
("OP", dialog("paragraph")),
|
||||
("TW", cmd("review.wordCount")),
|
||||
("AIT", dialog("insertTable")),
|
||||
]
|
||||
}
|
||||
|
||||
/// The letter badge for a tab (empty when it has none).
|
||||
@@ -437,71 +379,37 @@ fn controls(tab: &str) -> Vec<Control> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps an ASCII alphanumeric keytip letter to a static single-character `&'static str`, avoiding
|
||||
/// per-control `String` allocations when caching [`KeytipControl`].
|
||||
fn ascii_upper_str(c: char) -> Option<&'static str> {
|
||||
const CHARS: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
let idx = CHARS.find(c.to_ascii_uppercase())?;
|
||||
CHARS.get(idx..idx + 1)
|
||||
/// A control with the letters it asks for.
|
||||
struct Row {
|
||||
control: Control,
|
||||
letters: Option<String>,
|
||||
}
|
||||
|
||||
/// Cached keytip controls and reserved shortcut letters per engine registry and active ribbon tab,
|
||||
/// avoiding per-frame `registry.all()` scans and `KeytipControl` / `CommandRef` allocations while
|
||||
/// idle.
|
||||
pub(crate) struct KeytipCache {
|
||||
registry: Arc<wordcraft_engine::Registry>,
|
||||
reserved: Vec<char>,
|
||||
tab: String,
|
||||
tab_controls: Vec<KeytipControl<'static>>,
|
||||
/// A tab's controls with the shortcut letter each keeps, when its command has an Alt+letter shortcut.
|
||||
fn rows(app: &WordApp, tab: &str) -> Vec<Row> {
|
||||
controls(tab)
|
||||
.into_iter()
|
||||
.map(|control| {
|
||||
let letters = shortcut_letter(app, &control.command.id).map(String::from);
|
||||
Row { control, letters }
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
impl KeytipCache {
|
||||
fn build_tab_controls(app: &WordApp, tab: &str) -> Vec<KeytipControl<'static>> {
|
||||
let mut out: Vec<KeytipControl<'static>> = controls(tab)
|
||||
.into_iter()
|
||||
.map(|control| {
|
||||
let letters = shortcut_letter(app, &control.command.id).and_then(ascii_upper_str);
|
||||
KeytipControl::new(control.command, control.tip, letters)
|
||||
})
|
||||
.collect();
|
||||
out.push(KeytipControl::new(CommandRef::new("tools.search"), "Search", Some(SEARCH_LETTER)));
|
||||
out
|
||||
}
|
||||
|
||||
fn new(app: &WordApp, tab: &str) -> Self {
|
||||
KeytipCache {
|
||||
registry: app.session.registry.clone(),
|
||||
reserved: reserved_letters(app),
|
||||
tab: tab.to_owned(),
|
||||
tab_controls: Self::build_tab_controls(app, tab),
|
||||
}
|
||||
}
|
||||
|
||||
fn sync(&mut self, app: &WordApp, tab: &str) {
|
||||
let reg_changed = !Arc::ptr_eq(&self.registry, &app.session.registry);
|
||||
if reg_changed {
|
||||
self.registry = app.session.registry.clone();
|
||||
self.reserved = reserved_letters(app);
|
||||
}
|
||||
if reg_changed || self.tab != tab {
|
||||
self.tab.clear();
|
||||
self.tab.push_str(tab);
|
||||
self.tab_controls = Self::build_tab_controls(app, tab);
|
||||
}
|
||||
}
|
||||
/// The Search box: its badge is Alt, Q on every tab.
|
||||
fn search_row() -> Row {
|
||||
Row { control: Control { tip: "Search", command: CommandRef::new("tools.search") }, letters: Some(SEARCH_LETTER.to_string()) }
|
||||
}
|
||||
|
||||
/// The Backstage's pages as cached static keytip controls.
|
||||
fn backstage_controls() -> &'static [KeytipControl<'static>] {
|
||||
static CONTROLS: OnceLock<Vec<KeytipControl<'static>>> = OnceLock::new();
|
||||
CONTROLS.get_or_init(|| {
|
||||
crate::backstage::KEYTIPS
|
||||
.iter()
|
||||
.map(|(page, letter)| {
|
||||
KeytipControl::new(CommandRef::with_params("ui.backstage", serde_json::json!({ "page": page })), page, Some(letter))
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
/// The Backstage's pages, one badge each: the first letter its page has in `KEYTIPS`.
|
||||
fn backstage_rows() -> Vec<Row> {
|
||||
crate::backstage::KEYTIPS
|
||||
.iter()
|
||||
.map(|(page, letter)| Row {
|
||||
control: Control { tip: page, command: CommandRef::with_params("ui.backstage", serde_json::json!({ "page": page })) },
|
||||
letters: Some(letter.to_string()),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Shows the keytips after the shell and the regions they place badges on, and acts on what the keys chose.
|
||||
@@ -518,15 +426,14 @@ pub(crate) fn show(ui: &mut Ui, app: &mut WordApp, ribbon: &RibbonOutput<String>
|
||||
.filter_map(|t| ribbon.tab_ids.iter().find(|(name, _)| name == t).map(|(_, id)| (Label::from(t), tab_letter(t), *id)))
|
||||
.collect();
|
||||
|
||||
let cache = match app.keytip_cache.take() {
|
||||
Some(mut cache) => {
|
||||
cache.sync(app, &app.ui.tab);
|
||||
cache
|
||||
}
|
||||
None => KeytipCache::new(app, &app.ui.tab),
|
||||
};
|
||||
let controls: &[KeytipControl<'_>] = if app.ui.backstage { backstage_controls() } else { &cache.tab_controls };
|
||||
let sequences: &[(&str, CommandRef)] = if cfg!(target_os = "macos") { &[] } else { legacy() };
|
||||
let mut rows = if app.ui.backstage { backstage_rows() } else { rows(app, &app.ui.tab) };
|
||||
if !app.ui.backstage {
|
||||
rows.push(search_row());
|
||||
}
|
||||
let controls: Vec<KeytipControl<'_>> =
|
||||
rows.iter().map(|r| KeytipControl::new(r.control.command.clone(), r.control.tip, r.letters.as_deref())).collect();
|
||||
|
||||
let sequences = if cfg!(target_os = "macos") { Vec::new() } else { legacy() };
|
||||
// A hidden toolbar has no badges, and a disabled command's button has none to press.
|
||||
let digits: Vec<CommandRef> = if app.ui.quick_access_toolbar {
|
||||
app.session
|
||||
@@ -540,25 +447,18 @@ pub(crate) fn show(ui: &mut Ui, app: &mut WordApp, ribbon: &RibbonOutput<String>
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
let reserved = reserved_letters(app);
|
||||
|
||||
let mut places: Vec<Arc<Recorded>> = Vec::new();
|
||||
let patch_menu_places = enabled && (app.keytips_active || !ctx.input(|i| i.events.is_empty()));
|
||||
places.extend(ribbon.controls.clone().map(|recorded| if patch_menu_places { with_menu_commands(&ctx, recorded) } else { recorded }));
|
||||
places.extend(ribbon.controls.clone());
|
||||
places.extend(inspect::recorded(&ctx, qat_region()));
|
||||
places.extend(inspect::recorded(&ctx, search_region()));
|
||||
if app.ui.backstage {
|
||||
places.extend(inspect::recorded(&ctx, backstage_region()));
|
||||
}
|
||||
|
||||
let out = Keytips::new(enabled)
|
||||
.tabs(&tabs)
|
||||
.controls(controls)
|
||||
.sequences(sequences)
|
||||
.digits(&digits)
|
||||
.reserved(&cache.reserved)
|
||||
.places(&places)
|
||||
.show_over(ui);
|
||||
app.keytip_cache = Some(cache);
|
||||
let out =
|
||||
Keytips::new(enabled).tabs(&tabs).controls(&controls).sequences(&sequences).digits(&digits).reserved(&reserved).places(&places).show_over(ui);
|
||||
// PLAN: `WordApp::keytips_active` is app-hub's (rb.A11).
|
||||
app.keytips_active = out.active;
|
||||
if let Some(tab) = out.tab.as_deref().and_then(tab_of_badge) {
|
||||
|
||||
@@ -30,25 +30,6 @@ fn bold(h: &mut egui_kittest::Harness<'static, WordApp>) -> bool {
|
||||
h.state_mut().session.run("format.state", &serde_json::json!({})).unwrap()["bold"] == true
|
||||
}
|
||||
|
||||
fn painted_text_rects(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Rect)> {
|
||||
fn walk(shape: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) {
|
||||
match shape {
|
||||
egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())),
|
||||
egui::Shape::Vec(children) => {
|
||||
for child in children {
|
||||
walk(child, out);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for clipped in shapes {
|
||||
walk(&clipped.shape, &mut out);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_keytip_command_is_registered() {
|
||||
// The keytip tables name commands by id; a renamed or removed command must fail here,
|
||||
@@ -75,14 +56,13 @@ fn keytips_never_reuse_another_commands_shortcut_letter() {
|
||||
let reserved = reserved_letters(&a);
|
||||
let folder = craft::i18n::Folder::new("en");
|
||||
for (tab, _) in TAB_LETTERS.iter().chain(&TABLE_TAB_LETTERS) {
|
||||
let tab_controls = KeytipCache::build_tab_controls(&a, tab);
|
||||
let labels: Vec<(&str, Option<&str>)> = tab_controls.iter().map(|c| (c.label, c.letters)).collect();
|
||||
let rows = rows(&a, tab);
|
||||
let labels: Vec<(&str, Option<&str>)> = rows.iter().map(|r| (r.control.tip, r.letters.as_deref())).collect();
|
||||
let badges = craft::keymap::mnemonic::assign_keytips(&labels, &reserved, &folder);
|
||||
assert_eq!(badges.len(), tab_controls.len(), "{tab}: one badge per control");
|
||||
for (control, badge) in tab_controls.iter().zip(&badges) {
|
||||
let id = &control.command.id;
|
||||
assert!(!badge.is_empty(), "{tab}: {id} must receive a non-empty keytip badge");
|
||||
if let Some(own) = control.letters {
|
||||
assert_eq!(badges.len(), rows.len(), "{tab}: one badge per control");
|
||||
for (row, badge) in rows.iter().zip(&badges) {
|
||||
let id = &row.control.command.id;
|
||||
if let Some(own) = &row.letters {
|
||||
assert_eq!(badge, own, "{tab}: {id} should keep its shortcut letter {own}");
|
||||
} else {
|
||||
let first = badge.chars().next().unwrap_or('?');
|
||||
@@ -92,61 +72,6 @@ fn keytips_never_reuse_another_commands_shortcut_letter() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Home's Paste, a menu button, shows its keytip whatever the interface language. The keytips
|
||||
/// table holds the English tips, and `menu_button` previously matched it with its translated one,
|
||||
/// which no other language's "Paste" equals or begins with. Pseudo-localization stands in for one.
|
||||
#[test]
|
||||
fn a_menu_buttons_keytip_does_not_depend_on_the_language() {
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::Queryable as _;
|
||||
|
||||
let a = app();
|
||||
let reserved = reserved_letters(&a);
|
||||
let cache = KeytipCache::new(&a, "Home");
|
||||
let paste_idx = cache.tab_controls.iter().position(|c| c.command.id == "edit.paste").expect("Home tab has Paste");
|
||||
let labels: Vec<(&str, Option<&str>)> = cache.tab_controls.iter().map(|c| (c.label, c.letters)).collect();
|
||||
|
||||
let english_folder = craft::i18n::Folder::new("en");
|
||||
let english_badges = craft::keymap::mnemonic::assign_keytips(&labels, &reserved, &english_folder);
|
||||
let paste_badge = &english_badges[paste_idx];
|
||||
assert!(!paste_badge.is_empty(), "Paste receives a keytip badge");
|
||||
|
||||
for lang in ["de", "fr", "es", "tr", "pseudo", "ja", "zh", "pt-BR"] {
|
||||
let folder = craft::i18n::Folder::new(lang);
|
||||
let badges = craft::keymap::mnemonic::assign_keytips(&labels, &reserved, &folder);
|
||||
assert_eq!(&badges[paste_idx], paste_badge, "language={lang}: Paste badge must stay {paste_badge} regardless of language");
|
||||
}
|
||||
|
||||
let mut h = harness(app());
|
||||
h.ctx.add_glyph_rasterizer(egui::GlyphRasterizer::new("wordcraft::keytips::pseudo_markers", |request| {
|
||||
matches!(request.cluster, "⟦" | "⟧").then(|| egui::RasterizedGlyph {
|
||||
bitmap: egui::GlyphBitmap {
|
||||
image: egui::ColorImage::new([1, 1], vec![egui::Color32::WHITE]),
|
||||
offset_px: egui::Vec2::ZERO,
|
||||
is_color: false,
|
||||
},
|
||||
advance_px: request.font_size_px.max(1.0),
|
||||
})
|
||||
}));
|
||||
h.state_mut().ui.language = "pseudo".into();
|
||||
crate::test_harness::frames(&mut h, 2);
|
||||
|
||||
let paste_rect = h.get_by_role_and_label(Role::Button, "⟦Paste⟧").rect();
|
||||
h.input_mut().events.push(key_event(egui::Key::F10, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
h.input_mut().events.extend([key_event(egui::Key::H, true, egui::Modifiers::NONE), egui::Event::Text("h".into())]);
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
let painted = painted_text_rects(&h.output().shapes);
|
||||
crate::i18n::apply_language(crate::i18n::Lang::EN);
|
||||
|
||||
assert_eq!(h.state().ui.tab.as_str(), "Home");
|
||||
assert!(h.state().keytips_active, "F10, H activates Home command keytips");
|
||||
assert!(
|
||||
painted.iter().any(|(text, rect)| text == paste_badge && paste_rect.expand(8.0).contains(rect.center())),
|
||||
"Paste's {paste_badge:?} badge is drawn over Paste {paste_rect:?} under pseudo-localization: {painted:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// #1697: legacy sequences never start on a tab keytip (table tabs included) or Search, and
|
||||
/// every one reaches a command or dialog that exists.
|
||||
#[test]
|
||||
@@ -158,7 +83,7 @@ fn legacy_menu_keys_stay_off_the_ribbon_letters_and_all_resolve() {
|
||||
for (keys, command) in legacy() {
|
||||
let first = &keys[..1];
|
||||
assert!(!taken.iter().any(|l| l.starts_with(first)), "{keys} starts on a ribbon letter");
|
||||
assert!(!legacy().iter().any(|(k, _)| *k != *keys && k.starts_with(*keys)), "{keys} hides a longer sequence");
|
||||
assert!(!legacy().iter().any(|(k, _)| *k != keys && k.starts_with(keys)), "{keys} hides a longer sequence");
|
||||
let mut b = app();
|
||||
// The hosted parameter dialogs open nothing before the window's context is known.
|
||||
b.ctx = Some(egui::Context::default());
|
||||
@@ -253,150 +178,6 @@ fn the_legacy_hint_hangs_under_the_slim_bar_without_a_ribbon() {
|
||||
assert!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).is_empty(), "no letter typed into the document");
|
||||
}
|
||||
|
||||
fn painted_texts(shapes: &[egui::epaint::ClippedShape]) -> Vec<String> {
|
||||
fn walk(shape: &egui::Shape, out: &mut Vec<String>) {
|
||||
match shape {
|
||||
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
|
||||
egui::Shape::Vec(children) => {
|
||||
for child in children {
|
||||
walk(child, out);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::new();
|
||||
for clipped in shapes {
|
||||
walk(&clipped.shape, &mut out);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_qat_badges_wait_for_the_complete_number_and_escape_cancels() {
|
||||
// Collect genuinely enabled commands from a live harness context (where `frame_input` has
|
||||
// published command states) so all 20 QAT buttons remain active during the test.
|
||||
let mut h = harness(app());
|
||||
let commands: Vec<String> = {
|
||||
let ctx = h.ctx.clone();
|
||||
let a = h.state();
|
||||
let mut ids: Vec<String> = a
|
||||
.session
|
||||
.registry
|
||||
.all()
|
||||
.iter()
|
||||
.filter(|s| s.id != "format.bold" && s.id != "format.italic" && crate::chrome::qat_enabled(&ctx, a, s.id))
|
||||
.take(18)
|
||||
.map(|s| s.id.to_string())
|
||||
.collect();
|
||||
ids.insert(0, "format.italic".into());
|
||||
ids.insert(9, "format.bold".into());
|
||||
ids
|
||||
};
|
||||
assert_eq!(commands.len(), 20, "expected 20 enabled QAT commands");
|
||||
h.state_mut().session.ribbon.qat = Some(commands);
|
||||
crate::test_harness::frames(&mut h, 2);
|
||||
{
|
||||
let ctx = h.ctx.clone();
|
||||
let a = h.state();
|
||||
let enabled_count = a.session.ribbon.qat().iter().filter(|id| crate::chrome::qat_enabled(&ctx, a, id)).count();
|
||||
assert_eq!(enabled_count, 20, "all 20 QAT commands stay enabled");
|
||||
}
|
||||
|
||||
let digit = |key, ch: &str| [key_event(key, true, egui::Modifiers::NONE), egui::Event::Text(ch.into())];
|
||||
|
||||
h.input_mut().events.push(key_event(egui::Key::F10, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(h.state().keytips_active);
|
||||
let shown = painted_texts(&h.output().shapes);
|
||||
assert!(shown.iter().any(|t| t == "001"), "20-button QAT paints 001 for the 10th button: {shown:?}");
|
||||
|
||||
h.input_mut().events.extend(digit(egui::Key::Num0, "0"));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(h.state().keytips_active, "first 0 waits for the rest of the multi-digit badge");
|
||||
h.input_mut().events.extend(digit(egui::Key::Num0, "0"));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(h.state().keytips_active, "second 0 still waits for the final digit of 001");
|
||||
assert!(!bold(&mut h), "incomplete prefix 00 must not fire Bold");
|
||||
let narrowed = painted_texts(&h.output().shapes);
|
||||
assert!(narrowed.iter().any(|t| t == "001"), "001 remains painted while waiting on prefix 00");
|
||||
assert!(!narrowed.iter().any(|t| t == "010"), "non-matching multi-digit badges are hidden under prefix 00");
|
||||
|
||||
h.input_mut().events.extend(digit(egui::Key::Num1, "1")); // 001: first button after the first nine.
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
assert!(bold(&mut h), "001 runs Bold");
|
||||
assert!(!h.state().keytips_active, "completing 001 ends keytips");
|
||||
assert!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).is_empty(), "QAT digits never type into the document");
|
||||
|
||||
h.input_mut().events.push(key_event(egui::Key::F10, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(h.state().keytips_active);
|
||||
h.input_mut().events.extend(digit(egui::Key::Num0, "0"));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(h.state().keytips_active);
|
||||
h.input_mut().events.push(key_event(egui::Key::Escape, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(!h.state().keytips_active, "Escape cancels a partial multi-digit prefix");
|
||||
|
||||
// Reopening keytips and pressing 1 fires button 1 (Italic), proving the cancelled "0" prefix was cleared.
|
||||
h.input_mut().events.push(key_event(egui::Key::F10, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
assert!(h.state().keytips_active);
|
||||
h.input_mut().events.extend(digit(egui::Key::Num1, "1"));
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
assert!(!h.state().keytips_active);
|
||||
assert_eq!(
|
||||
h.state_mut().session.run("format.state", &serde_json::json!({})).unwrap()["italic"],
|
||||
true,
|
||||
"after Escape, F10 then 1 runs the first button"
|
||||
);
|
||||
assert!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).is_empty(), "no keytip digit typed into the document");
|
||||
|
||||
// Verify production `craft::menu::Keytips` assigns distinct, prefix-free digit badges across
|
||||
// single- and multi-digit QAT lengths without any test-only label helper.
|
||||
for count in [9, 10, 18, 19, 100, 200] {
|
||||
let digits: Vec<CommandRef> = (0..count).map(|i| CommandRef::new(format!("test.qat.{i}"))).collect();
|
||||
let region_id = egui::Id::unique(("test_qat_digit_badges", count));
|
||||
let ctx = crate::test_harness::context();
|
||||
let run_pass = |events: Vec<egui::Event>| {
|
||||
craft::ui::shell::embed::before_input(&ctx, |_| craft::ui::runtime::frame::FrameInput::new(craft::ui::runtime::env::RootEnv::default()));
|
||||
ctx.run_ui(
|
||||
egui::RawInput {
|
||||
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(2000.0, 2000.0))),
|
||||
focused: true,
|
||||
events,
|
||||
..Default::default()
|
||||
},
|
||||
|ui| {
|
||||
let (_, recorded) = inspect::record(ui, region_id, |ui| {
|
||||
for row in digits.chunks(20) {
|
||||
ui.horizontal(|ui| {
|
||||
for cmd in row {
|
||||
craft::ui::buttons::IconButton::command(craft::behavior::IconId::new("bold"), cmd.clone()).show(ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
let places: Vec<Arc<Recorded>> = recorded.into_iter().collect();
|
||||
let _ = Keytips::new(true).digits(&digits).places(&places).show_over(ui);
|
||||
},
|
||||
)
|
||||
};
|
||||
run_pass(Vec::new()).drop_without_applying_deltas();
|
||||
let shown = run_pass(vec![key_event(egui::Key::F10, true, egui::Modifiers::NONE)]);
|
||||
let labels = painted_texts(&shown.shapes);
|
||||
shown.drop_without_applying_deltas();
|
||||
assert_eq!(labels.len(), count, "expected one painted digit badge per QAT command for count={count}: {labels:?}");
|
||||
for (i, label) in labels.iter().enumerate() {
|
||||
assert!(!label.is_empty() && label.chars().all(|c| c.is_ascii_digit()), "non-digit badge {label:?} at {i} for count={count}");
|
||||
assert!(
|
||||
!labels.iter().enumerate().any(|(j, other)| i != j && other.starts_with(label.as_str())),
|
||||
"ambiguous label {label} in {count} buttons"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn qat_keytips_follow_custom_order_and_skip_disabled_commands() {
|
||||
let mut a = app();
|
||||
@@ -472,60 +253,3 @@ fn keytips_option_persists() {
|
||||
b.apply_prefs(serde_json::from_str("{}").unwrap());
|
||||
assert!(b.ui.keytips_enabled, "older preferences retain enabled KeyTips");
|
||||
}
|
||||
|
||||
/// After idle frames populate the keytip cache on Home, switching tabs updates the active tab's
|
||||
/// keytips so Insert badges run Insert commands and switching back to Home runs Home commands.
|
||||
#[test]
|
||||
fn keytips_update_controls_when_switching_tabs() {
|
||||
let badge_for = |a: &WordApp, tab: &str, command_id: &str| -> String {
|
||||
let reserved = reserved_letters(a);
|
||||
let folder = craft::i18n::Folder::new("en");
|
||||
let tab_controls = KeytipCache::build_tab_controls(a, tab);
|
||||
let labels: Vec<(&str, Option<&str>)> = tab_controls.iter().map(|c| (c.label, c.letters)).collect();
|
||||
let badges = craft::keymap::mnemonic::assign_keytips(&labels, &reserved, &folder);
|
||||
tab_controls
|
||||
.iter()
|
||||
.zip(badges)
|
||||
.find(|(c, _)| c.command.id == command_id)
|
||||
.map(|(_, badge)| badge)
|
||||
.expect("command has a keytip badge on its tab")
|
||||
};
|
||||
let press_keytip_seq = |h: &mut egui_kittest::Harness<'static, WordApp>, seq: &str| {
|
||||
for ch in seq.chars() {
|
||||
let name = ch.to_ascii_uppercase().to_string();
|
||||
let key = egui::Key::from_name(&name).unwrap();
|
||||
let text = ch.to_ascii_lowercase().to_string();
|
||||
h.input_mut().events.extend([key_event(key, true, egui::Modifiers::NONE), egui::Event::Text(text)]);
|
||||
crate::test_harness::frame(h);
|
||||
}
|
||||
};
|
||||
|
||||
let mut h = harness(app());
|
||||
// Let idle frames populate the keytip cache on the initial Home tab.
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
assert_eq!(h.state().ui.tab, "Home");
|
||||
|
||||
// Switch to Insert via keytips (F10, N) and fire Page Break through its Insert keytip badge.
|
||||
let page_break_badge = badge_for(h.state(), "Insert", "insert.pageBreak");
|
||||
h.input_mut().events.push(key_event(egui::Key::F10, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
press_keytip_seq(&mut h, tab_letter("Insert"));
|
||||
assert_eq!(h.state().ui.tab, "Insert", "F10 and the Insert tab badge switch to Insert");
|
||||
press_keytip_seq(&mut h, &page_break_badge);
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
assert!(
|
||||
h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body).contains('\u{000C}'),
|
||||
"Insert keytip badge {page_break_badge} runs insert.pageBreak after switching from Home"
|
||||
);
|
||||
assert!(!bold(&mut h), "switching to Insert does not fire Home's Bold command");
|
||||
|
||||
// Switch back to Home via keytips (F10, H) and fire Bold through its Home keytip badge.
|
||||
let bold_badge = badge_for(h.state(), "Home", "format.bold");
|
||||
h.input_mut().events.push(key_event(egui::Key::F10, true, egui::Modifiers::NONE));
|
||||
crate::test_harness::frame(&mut h);
|
||||
press_keytip_seq(&mut h, tab_letter("Home"));
|
||||
assert_eq!(h.state().ui.tab, "Home", "F10 and the Home tab badge switch back to Home");
|
||||
press_keytip_seq(&mut h, &bold_badge);
|
||||
crate::test_harness::frames(&mut h, 3);
|
||||
assert!(bold(&mut h), "Home keytip badge {bold_badge} runs format.bold after switching back from Insert");
|
||||
}
|
||||
|
||||
@@ -402,11 +402,6 @@ pub struct WordApp {
|
||||
/// The app-scope command states handed to the runtime, edited only when they change: the runtime resolves
|
||||
/// commands again only when their revision moves ([`WordApp::command_input`]).
|
||||
pub(crate) command_states: craft::ui::contract::Tracked<craft::ui::runtime::commands::CommandStates>,
|
||||
/// Precomputed command metadata, translated hints, and last gate results for [`WordApp::command_input`],
|
||||
/// avoiding per-frame allocations and catalog reparsing while idle.
|
||||
pub(crate) command_states_cache: Option<app::command_board::CommandStatesCache>,
|
||||
/// Cached keytip control lists and reserved shortcut letters per registry and active ribbon tab.
|
||||
pub(crate) keytip_cache: Option<keytips::KeytipCache>,
|
||||
/// Frames drawn so far, counted to 2: the control channel's queued requests wait until the
|
||||
/// fonts are warm.
|
||||
pub(crate) fonts_frames: u8,
|
||||
@@ -578,8 +573,6 @@ pub(crate) fn rust_sources(dir: &std::path::Path) -> Vec<std::path::PathBuf> {
|
||||
files
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod file_browser;
|
||||
#[cfg(test)]
|
||||
mod test_harness;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -352,26 +352,10 @@ fn hovering_a_bar_member_previews_its_command() {
|
||||
h.get_by_label("20").rect().center()
|
||||
}
|
||||
Member::Font => {
|
||||
// `FontPicker` scans `Catalog::global()` on a background thread; wait until ready so the
|
||||
// chevron click isn't ignored while the picker is still disabled in a fresh test process.
|
||||
let catalog = craft::font_manager::Catalog::global();
|
||||
catalog.scan_in_background();
|
||||
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10);
|
||||
while !catalog.is_ready() && std::time::Instant::now() < deadline {
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
}
|
||||
assert!(catalog.is_ready(), "font catalog finished scanning");
|
||||
steps(&mut h);
|
||||
let b = font_box(&h);
|
||||
let c = canvas(&h);
|
||||
// A click on a Plain picker's name only selects it (craft-libs #3103); the chevron opens the list.
|
||||
let chevron = h
|
||||
.query_all_by_label("Fonts")
|
||||
.map(|n| n.rect())
|
||||
.filter(|r| c.contains_rect(*r))
|
||||
.min_by(|a, z| a.center().distance(b.center()).total_cmp(&z.center().distance(b.center())))
|
||||
.expect("the font box's chevron");
|
||||
click_at(&mut h, chevron.center());
|
||||
// The font picker's chevron is an adornment inside the field and a click on the name opens the list
|
||||
// too, so click the field itself (the size box's chevron lies beside it).
|
||||
click_at(&mut h, b.center());
|
||||
// The framework's font list is a tree of families (depth rows), so its rows are tree items.
|
||||
h.query_all_by_role(Role::TreeItem)
|
||||
.filter(|n| {
|
||||
|
||||
@@ -110,9 +110,6 @@ pub(crate) struct ObjectGesture {
|
||||
/// copy's axis lock). Alt is not part of it: letting Alt go just before the release must not snap an
|
||||
/// object that was placed freely while Alt was held.
|
||||
last_mods: (bool, bool),
|
||||
/// The pointer position and Alt state at the last move: releasing Alt with the pointer still
|
||||
/// must not re-snap the object when a modifier change stirs the pass.
|
||||
last_at: (Pos2, bool),
|
||||
/// Moving an In Line with Text object: where it lands.
|
||||
drop_at: Option<Drop>,
|
||||
preview: Option<Preview>,
|
||||
@@ -475,7 +472,6 @@ impl ObjectGesture {
|
||||
pending_behind: false,
|
||||
copy: false,
|
||||
last_mods: (false, false),
|
||||
last_at: (Pos2::ZERO, false),
|
||||
drop_at: None,
|
||||
preview: None,
|
||||
}
|
||||
@@ -609,11 +605,6 @@ impl ObjectGesture {
|
||||
app.canvas.cancel_text_drag();
|
||||
self.pending_behind = false;
|
||||
}
|
||||
let alt_released = self.moved && self.last_at == (p.pos, true) && !p.mods.alt && self.last_mods == (p.mods.shift, p.mods.cmd);
|
||||
self.last_at = (p.pos, p.mods.alt);
|
||||
if alt_released {
|
||||
return;
|
||||
}
|
||||
self.moved = true;
|
||||
self.last_mods = (p.mods.shift, p.mods.cmd);
|
||||
self.copy = p.mods.cmd && object.member.is_none();
|
||||
@@ -652,28 +643,21 @@ impl ObjectGesture {
|
||||
/// it's over. `lock` (`Some(horizontal)`) keeps an aligned copy on its axis.
|
||||
fn snap_move(&mut self, body: &PageBody, cx: &mut ToolContext, object: &ObjectHit, lock: Option<bool>) {
|
||||
let Some(pp) = placed(body, self.to_page) else { return };
|
||||
let Some(b) = finite_spin_bounds(self.rect, object.spin) else { return };
|
||||
let b = object.spin.bounds(self.rect);
|
||||
let a = pp.to_doc(&body.view, pt(b.x, b.y));
|
||||
let c = pp.to_doc(&body.view, pt(b.right(), b.bottom()));
|
||||
if !a.x.is_finite() || !a.y.is_finite() || !c.x.is_finite() || !c.y.is_finite() {
|
||||
return;
|
||||
}
|
||||
let off = cx.snap_rect(DocRect::from_points(a, c));
|
||||
let off = match lock {
|
||||
Some(true) => Vec2::new(off.x, 0.0),
|
||||
Some(false) => Vec2::new(0.0, off.y),
|
||||
None => off,
|
||||
};
|
||||
if !off.x.is_finite() || !off.y.is_finite() || off == Vec2::ZERO {
|
||||
if off == Vec2::ZERO {
|
||||
return;
|
||||
}
|
||||
let at = pp.from_doc(&body.view, a + off);
|
||||
let dx = (at.x - f64::from(b.x)) as f32;
|
||||
let dy = (at.y - f64::from(b.y)) as f32;
|
||||
if dx.is_finite() && dy.is_finite() {
|
||||
self.rect.x += dx;
|
||||
self.rect.y += dy;
|
||||
}
|
||||
self.rect.x += (at.x - f64::from(b.x)) as f32;
|
||||
self.rect.y += (at.y - f64::from(b.y)) as f32;
|
||||
}
|
||||
|
||||
/// The button went up. Commits a move as one command; false for a press on a Behind Text
|
||||
@@ -805,32 +789,15 @@ pub(crate) fn snap(app: &WordApp, layout: &DocLayout) -> Option<PageSnap> {
|
||||
Some(pages.into_iter().enumerate().fold(PageSnap::new(options), |snap, (page, targets)| snap.page(page, targets)))
|
||||
}
|
||||
|
||||
/// Axis-aligned bounds of `rect` turned by `spin`, or `None` when any input or bound is non-finite.
|
||||
fn finite_spin_bounds(rect: wordcraft_geom::Rect, spin: wordcraft_geom::Spin) -> Option<wordcraft_geom::Rect> {
|
||||
if !rect.x.is_finite() || !rect.y.is_finite() || !rect.w.is_finite() || !rect.h.is_finite() || !spin.deg.is_finite() {
|
||||
return None;
|
||||
}
|
||||
let (bw, bh) = spin.extent(rect.w, rect.h);
|
||||
let x = rect.x + (rect.w - bw) / 2.0;
|
||||
let y = rect.y + (rect.h - bh) / 2.0;
|
||||
(x.is_finite() && y.is_finite() && bw.is_finite() && bh.is_finite()).then(|| wordcraft_geom::Rect::new(x, y, bw, bh))
|
||||
}
|
||||
|
||||
/// The snap targets of `pg` in its own page points, each spanning the page's own range:
|
||||
/// its edges and centre, its margins, and the floating objects on it that `me` can snap to (all but
|
||||
/// itself and, for a text box, the objects in its text: they move with it). The page's own width
|
||||
/// leaves out the comment balloons' markup area.
|
||||
fn snap_targets(pg: &wordcraft_layout::Page, me: Option<&ObjectHit>) -> Vec<SnapTarget> {
|
||||
if !pg.w.is_finite() || !pg.h.is_finite() || !pg.markup.is_finite() {
|
||||
return Vec::new();
|
||||
}
|
||||
let w = (f64::from(pg.w) - f64::from(pg.markup)).max(0.0);
|
||||
let h = f64::from(pg.h).max(0.0);
|
||||
let w = f64::from((pg.w - pg.markup).max(0.0));
|
||||
let h = f64::from(pg.h);
|
||||
let mut targets = Vec::new();
|
||||
let vertical = |targets: &mut Vec<SnapTarget>, x: f64, kind: SnapKind| {
|
||||
if !x.is_finite() {
|
||||
return;
|
||||
}
|
||||
let mut t = SnapTarget::new(Axis::Y, x, kind);
|
||||
t.span = Some((0.0, h));
|
||||
targets.push(t);
|
||||
@@ -838,14 +805,9 @@ fn snap_targets(pg: &wordcraft_layout::Page, me: Option<&ObjectHit>) -> Vec<Snap
|
||||
for (x, kind) in [(0.0, SnapKind::Bounds), (w / 2.0, SnapKind::Center), (w, SnapKind::Bounds)] {
|
||||
vertical(&mut targets, x, kind);
|
||||
}
|
||||
if pg.body.x.is_finite() && pg.body.w.is_finite() {
|
||||
vertical(&mut targets, f64::from(pg.body.x), SnapKind::Guide);
|
||||
vertical(&mut targets, f64::from(pg.body.x) + f64::from(pg.body.w), SnapKind::Guide);
|
||||
}
|
||||
vertical(&mut targets, f64::from(pg.body.x), SnapKind::Guide);
|
||||
vertical(&mut targets, f64::from(pg.body.right()), SnapKind::Guide);
|
||||
let horizontal = |targets: &mut Vec<SnapTarget>, y: f64, kind: SnapKind| {
|
||||
if !y.is_finite() {
|
||||
return;
|
||||
}
|
||||
let mut t = SnapTarget::new(Axis::X, y, kind);
|
||||
t.span = Some((0.0, w));
|
||||
targets.push(t);
|
||||
@@ -853,10 +815,8 @@ fn snap_targets(pg: &wordcraft_layout::Page, me: Option<&ObjectHit>) -> Vec<Snap
|
||||
for (y, kind) in [(0.0, SnapKind::Bounds), (h / 2.0, SnapKind::Center), (h, SnapKind::Bounds)] {
|
||||
horizontal(&mut targets, y, kind);
|
||||
}
|
||||
if pg.body.y.is_finite() && pg.body.h.is_finite() {
|
||||
horizontal(&mut targets, f64::from(pg.body.y), SnapKind::Guide);
|
||||
horizontal(&mut targets, f64::from(pg.body.y) + f64::from(pg.body.h), SnapKind::Guide);
|
||||
}
|
||||
horizontal(&mut targets, f64::from(pg.body.y), SnapKind::Guide);
|
||||
horizontal(&mut targets, f64::from(pg.body.bottom()), SnapKind::Guide);
|
||||
let pos = me.map(ObjectHit::pos);
|
||||
let own = me.and_then(|m| m.text_box).map(StoryRef::Part);
|
||||
for it in pg.items.iter().chain(&pg.header).chain(&pg.footer) {
|
||||
@@ -865,18 +825,12 @@ fn snap_targets(pg: &wordcraft_layout::Page, me: Option<&ObjectHit>) -> Vec<Snap
|
||||
if *wrap == Wrap::Inline || is_me || Some(*story) == own {
|
||||
continue;
|
||||
}
|
||||
let Some(b) = finite_spin_bounds(*rect, *spin) else {
|
||||
continue;
|
||||
};
|
||||
let x0 = f64::from(b.x);
|
||||
let x1 = x0 + f64::from(b.w);
|
||||
for (x, kind) in [(x0, SnapKind::LayerEdge), ((x0 + x1) / 2.0, SnapKind::LayerCenter), (x1, SnapKind::LayerEdge)] {
|
||||
vertical(&mut targets, x, kind);
|
||||
let b = spin.bounds(*rect);
|
||||
for (x, kind) in [(b.x, SnapKind::LayerEdge), (b.x + b.w / 2.0, SnapKind::LayerCenter), (b.right(), SnapKind::LayerEdge)] {
|
||||
vertical(&mut targets, f64::from(x), kind);
|
||||
}
|
||||
let y0 = f64::from(b.y);
|
||||
let y1 = y0 + f64::from(b.h);
|
||||
for (y, kind) in [(y0, SnapKind::LayerEdge), ((y0 + y1) / 2.0, SnapKind::LayerCenter), (y1, SnapKind::LayerEdge)] {
|
||||
horizontal(&mut targets, y, kind);
|
||||
for (y, kind) in [(b.y, SnapKind::LayerEdge), (b.y + b.h / 2.0, SnapKind::LayerCenter), (b.bottom(), SnapKind::LayerEdge)] {
|
||||
horizontal(&mut targets, f64::from(y), kind);
|
||||
}
|
||||
}
|
||||
targets
|
||||
|
||||
@@ -1053,287 +1053,6 @@ fn a_dragged_objects_snap_lines_include_the_page_margins_and_a_neighbouring_obje
|
||||
assert!(!has_target(&targets, Axis::Y, SnapKind::LayerEdge, me.rect.x), "the dragged object is no target of its own drag: {targets:?}");
|
||||
}
|
||||
|
||||
/// #7749: empty targets, negative tolerance, disabled alignment guides, and hostile non-finite
|
||||
/// page/margin/object/moving geometry never produce non-finite snap targets, emit snap lines, or
|
||||
/// move a dragged object.
|
||||
#[test]
|
||||
fn nothing_to_snap_to() {
|
||||
use craft::behavior::geometry::SnapTargets;
|
||||
use egui::{Event, PointerButton};
|
||||
use wordcraft_geom::{Point as GeomPoint, Rect as GeomRect, Spin};
|
||||
use wordcraft_layout::{Page, Placed};
|
||||
|
||||
let moving = DocRect::new(100.0, 200.0, 150.0, 220.0);
|
||||
// Empty target set and negative tolerance never move anything.
|
||||
assert_eq!(SnapTargets::new().snap_rect(moving, 6.0), (Vec2::ZERO, Vec::new()));
|
||||
let mut single = SnapTargets::new();
|
||||
single.add(SnapTarget::new(Axis::Y, 99.0, SnapKind::Guide));
|
||||
assert_eq!(single.snap_rect(moving, -1.0), (Vec2::ZERO, Vec::new()));
|
||||
|
||||
// Non-finite page dimensions or markup yield no targets.
|
||||
for (w, h, markup) in [
|
||||
(f32::NAN, 792.0, 0.0),
|
||||
(f32::INFINITY, 792.0, 0.0),
|
||||
(612.0, f32::NAN, 0.0),
|
||||
(612.0, f32::INFINITY, 0.0),
|
||||
(612.0, 792.0, f32::NAN),
|
||||
(612.0, 792.0, f32::NEG_INFINITY),
|
||||
] {
|
||||
let pg = Page { w, h, markup, body: GeomRect::new(72.0, 72.0, 468.0, 648.0), ..Page::default() };
|
||||
assert!(snap_targets(&pg, None).is_empty(), "non-finite page ({w}, {h}, {markup}) must yield no targets");
|
||||
}
|
||||
|
||||
// Non-finite margins or floating objects on an otherwise valid page are dropped so they cannot
|
||||
// poison snapping onto valid targets on the same page.
|
||||
let placed_obj = |rect: GeomRect, spin: Spin, off: usize| Placed::Object {
|
||||
rect,
|
||||
spin,
|
||||
story: StoryRef::Body,
|
||||
path: wordcraft_doc::Path::top(0),
|
||||
off,
|
||||
text_box: None,
|
||||
wrap: Wrap::InFrontOfText,
|
||||
origin: GeomPoint::default(),
|
||||
group_boxes: Vec::new(),
|
||||
};
|
||||
let mut pg = Page { w: 612.0, h: 792.0, markup: 0.0, body: GeomRect { x: f32::NAN, y: 72.0, w: 468.0, h: f32::INFINITY }, ..Page::default() };
|
||||
pg.items.push(placed_obj(GeomRect { x: f32::NAN, y: 200.0, w: 50.0, h: 20.0 }, Spin::default(), 0));
|
||||
pg.items.push(placed_obj(GeomRect { x: 100.0, y: f32::INFINITY, w: 50.0, h: 20.0 }, Spin::default(), 1));
|
||||
pg.header.push(placed_obj(GeomRect::new(100.0, 200.0, 50.0, 20.0), Spin { deg: f32::NAN, ..Spin::default() }, 2));
|
||||
pg.footer.push(placed_obj(GeomRect::new(10.0, 20.0, 3e38, 3e38), Spin::new(45.0, false, false), 3));
|
||||
// Valid neighbouring floating object at x = 300..380, y = 400..440.
|
||||
pg.items.push(placed_obj(GeomRect::new(300.0, 400.0, 80.0, 40.0), Spin::default(), 4));
|
||||
|
||||
let targets = snap_targets(&pg, None);
|
||||
assert!(!targets.is_empty(), "valid page and neighbour targets remain");
|
||||
assert!(!has_target(&targets, Axis::X, SnapKind::Guide, 72.0), "non-finite body margin dropped: {targets:?}");
|
||||
assert!(!has_target(&targets, Axis::Y, SnapKind::LayerEdge, 100.0), "non-finite objects dropped: {targets:?}");
|
||||
assert!(!has_target(&targets, Axis::X, SnapKind::LayerEdge, 200.0), "non-finite objects dropped: {targets:?}");
|
||||
assert!(!has_target(&targets, Axis::Y, SnapKind::LayerEdge, 0.0), "rotated-bounds overflow dropped: {targets:?}");
|
||||
assert!(!has_target(&targets, Axis::X, SnapKind::LayerEdge, 0.0), "rotated-bounds overflow dropped: {targets:?}");
|
||||
assert!(
|
||||
targets.iter().all(|t| t.position.is_finite() && t.span.is_none_or(|(a, b)| a.is_finite() && b.is_finite() && a <= b)),
|
||||
"all emitted snap targets and spans must be finite: {targets:?}"
|
||||
);
|
||||
let mut snap_set = SnapTargets::new();
|
||||
for t in targets {
|
||||
snap_set.add(t);
|
||||
}
|
||||
let (delta, lines) = snap_set.snap_rect(DocRect::new(297.0, 402.0, 347.0, 422.0), 6.0);
|
||||
assert!(delta.x.is_finite() && delta.y.is_finite(), "snap delta must stay finite: {delta:?}");
|
||||
assert!((delta.x - 3.0).abs() < 1e-6 && (delta.y + 2.0).abs() < 1e-6, "valid neighbour still snaps: {delta:?}");
|
||||
assert!(lines.iter().all(|l| l.position.is_finite()), "snap lines must be finite: {lines:?}");
|
||||
|
||||
// Turning alignment guides off via `ui.alignmentGuides` disables snapping on a live drag.
|
||||
let mut app = WordApp::new(wordcraft_engine::Session::new(Document::new()), crate::Services::default());
|
||||
app.run("view.commentsPane", json!({"value": false})).unwrap();
|
||||
app.run("ui.alignmentGuides", json!({"value": false})).unwrap();
|
||||
app.run("insert.shape", json!({"kind": "rectangle", "width": 100, "height": 50})).unwrap();
|
||||
app.run("arrange.bounds", json!({"page": 0, "x": 100, "y": 250})).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);
|
||||
},
|
||||
app,
|
||||
);
|
||||
h.run_steps(6);
|
||||
let page = h.state_mut().session.layout().pages.first().map(|p| p.w - p.markup).unwrap();
|
||||
let centre = page / 2.0;
|
||||
let r = h.state_mut().session.layout().object(&Pos::body(0, 0), 0).unwrap().rect;
|
||||
let (cx, cy) = (r.x + r.w / 2.0, r.y + r.h / 2.0);
|
||||
let from = crate::canvas::page_to_screen(h.state_mut(), 0, cx, cy).unwrap();
|
||||
let to = crate::canvas::page_to_screen(h.state_mut(), 0, centre + 1.5, cy).unwrap();
|
||||
let button = |at: Pos2, pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
h.event(Event::PointerMoved(from));
|
||||
h.event(button(from, true));
|
||||
h.run_steps(1);
|
||||
for at in [from + egui::vec2(0.0, 40.0), to + egui::vec2(0.0, 40.0), to] {
|
||||
h.event(Event::PointerMoved(at));
|
||||
h.run_steps(1);
|
||||
}
|
||||
assert!(h.state().canvas.object_gesture().is_some(), "dragging");
|
||||
h.event(button(to, false));
|
||||
h.run_steps(3);
|
||||
let landed = h.state_mut().session.layout().object(&Pos::body(0, 0), 0).unwrap().rect;
|
||||
assert!((landed.x + landed.w / 2.0 - (centre + 1.5)).abs() < 0.01, "disabled guides leave drop unsnapped: {landed:?}");
|
||||
|
||||
assert_snap_move_guards_non_finite_moving_bounds();
|
||||
}
|
||||
|
||||
/// #7749: `ObjectGesture::snap_move` leaves `self.rect` unchanged and emits no snap lines when the
|
||||
/// moving object's bounds or mapped corners are non-finite, while snapping finite bounds onto the
|
||||
/// same page targets.
|
||||
fn assert_snap_move_guards_non_finite_moving_bounds() {
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use craft::behavior::geometry::SnapLine;
|
||||
use craft::behavior::kurbo::Size;
|
||||
use craft::behavior::value::CancelReason;
|
||||
use craft::pages::ui::{PageSnap, PageSource, PageView, PageViewState};
|
||||
use craft::ui::canvas::{CanvasTool, ToolAction, ToolHost, ToolPath};
|
||||
use craft::ui::primitives::textures::{Revision, ThumbRender, ThumbRequest, ThumbSource};
|
||||
use craft::ui::style::DataColor;
|
||||
use egui::{Color32, Event, PointerButton};
|
||||
use wordcraft_geom::{Point as GeomPoint, Rect as GeomRect, Spin};
|
||||
|
||||
struct BlankPage;
|
||||
impl ThumbSource<usize> for BlankPage {
|
||||
fn revision(&self, _: &usize, _: &ThumbRequest) -> Revision {
|
||||
Revision::new(0)
|
||||
}
|
||||
fn render(&self, _: &usize, _: &ThumbRequest) -> ThumbRender {
|
||||
ThumbRender::Blank
|
||||
}
|
||||
}
|
||||
impl PageSource for BlankPage {
|
||||
fn page_count(&self) -> usize {
|
||||
1
|
||||
}
|
||||
fn page_size(&self, _: usize) -> Size {
|
||||
Size::new(612.0, 792.0)
|
||||
}
|
||||
}
|
||||
|
||||
struct Case {
|
||||
label: &'static str,
|
||||
rect: GeomRect,
|
||||
spin: Spin,
|
||||
should_snap: bool,
|
||||
}
|
||||
struct Outcome {
|
||||
label: &'static str,
|
||||
before: GeomRect,
|
||||
after: GeomRect,
|
||||
snapped: Vec<SnapLine>,
|
||||
should_snap: bool,
|
||||
}
|
||||
struct ProbeState {
|
||||
view: PageViewState,
|
||||
page_center: Option<Pos2>,
|
||||
pending: VecDeque<Case>,
|
||||
outcomes: Vec<Outcome>,
|
||||
}
|
||||
|
||||
struct SnapMoveProbe<'a, 'b> {
|
||||
body: &'b PageBody<'b>,
|
||||
pending: &'a mut VecDeque<Case>,
|
||||
ran: Option<(&'static str, GeomRect, GeomRect, bool)>,
|
||||
}
|
||||
impl CanvasTool for SnapMoveProbe<'_, '_> {
|
||||
fn press(&mut self, _: &ToolPointer, cx: &mut ToolContext<'_>) -> ToolAction {
|
||||
if let Some(case) = self.pending.pop_front() {
|
||||
let mut gesture = ObjectGesture { to_page: 0, rect: case.rect, ..ObjectGesture::inert() };
|
||||
let hit = ObjectHit {
|
||||
page: 0,
|
||||
rect: case.rect,
|
||||
spin: case.spin,
|
||||
story: StoryRef::Body,
|
||||
path: wordcraft_doc::Path::top(0),
|
||||
off: 0,
|
||||
text_box: None,
|
||||
wrap: Wrap::InFrontOfText,
|
||||
origin: GeomPoint::default(),
|
||||
member: None,
|
||||
};
|
||||
gesture.snap_move(self.body, cx, &hit, None);
|
||||
self.ran = Some((case.label, case.rect, gesture.rect, case.should_snap));
|
||||
}
|
||||
ToolAction::Done
|
||||
}
|
||||
fn drag(&mut self, _: &ToolPointer, _: &mut ToolContext<'_>) {}
|
||||
fn release(&mut self, _: &ToolPointer, _: &mut ToolContext<'_>) {}
|
||||
fn cancel(&mut self, _: CancelReason, _: &mut ToolContext<'_>) {}
|
||||
fn paint(&self, _: &Draw<'_>, _: &ToolContext<'_>) {}
|
||||
fn command_form(&self) -> ToolPath {
|
||||
ToolPath::Command("snap_move probe")
|
||||
}
|
||||
}
|
||||
|
||||
let cases = VecDeque::from([
|
||||
Case { label: "finite control snaps", rect: GeomRect::new(297.0, 402.0, 50.0, 20.0), spin: Spin::default(), should_snap: true },
|
||||
Case {
|
||||
label: "nan spin",
|
||||
rect: GeomRect::new(297.0, 402.0, 50.0, 20.0),
|
||||
spin: Spin { deg: f32::NAN, ..Spin::default() },
|
||||
should_snap: false,
|
||||
},
|
||||
Case { label: "nan x", rect: GeomRect { x: f32::NAN, y: 402.0, w: 50.0, h: 20.0 }, spin: Spin::default(), should_snap: false },
|
||||
Case { label: "inf y", rect: GeomRect { x: 297.0, y: f32::INFINITY, w: 50.0, h: 20.0 }, spin: Spin::default(), should_snap: false },
|
||||
Case { label: "nan w", rect: GeomRect { x: 297.0, y: 402.0, w: f32::NAN, h: 20.0 }, spin: Spin::default(), should_snap: false },
|
||||
Case { label: "neg inf h", rect: GeomRect { x: 297.0, y: 402.0, w: 50.0, h: f32::NEG_INFINITY }, spin: Spin::default(), should_snap: false },
|
||||
Case { label: "overflow right", rect: GeomRect::new(2e38, 402.0, 2e38, 20.0), spin: Spin::default(), should_snap: false },
|
||||
Case {
|
||||
label: "rotated extent overflow",
|
||||
rect: GeomRect::new(10.0, 20.0, 3e38, 3e38),
|
||||
spin: Spin::new(45.0, false, false),
|
||||
should_snap: false,
|
||||
},
|
||||
Case {
|
||||
label: "rotated origin overflow",
|
||||
rect: GeomRect::new(-3e38, 0.0, 0.0, 3e38),
|
||||
spin: Spin::new(90.0, false, false),
|
||||
should_snap: false,
|
||||
},
|
||||
]);
|
||||
let case_count = cases.len();
|
||||
let state = ProbeState { view: PageViewState::default(), page_center: None, pending: cases, outcomes: Vec::new() };
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(800.0, 600.0)).build_ui_state(
|
||||
|ui, state: &mut ProbeState| {
|
||||
let snap = PageSnap::new(SnapOptions::default()).page(
|
||||
0,
|
||||
vec![
|
||||
SnapTarget::new(Axis::Y, 0.0, SnapKind::Bounds),
|
||||
SnapTarget::new(Axis::X, 0.0, SnapKind::Bounds),
|
||||
SnapTarget::new(Axis::Y, 300.0, SnapKind::LayerEdge),
|
||||
SnapTarget::new(Axis::X, 400.0, SnapKind::LayerEdge),
|
||||
],
|
||||
);
|
||||
PageView::new("SnapProbe", &BlankPage, &mut state.view, DataColor::new(Color32::WHITE)).snap(Some(snap)).show(ui, |ui, body| {
|
||||
if state.page_center.is_none() {
|
||||
state.page_center = body.pages.first().map(|p| p.rect.center());
|
||||
}
|
||||
if let Some(pass) = body.pass {
|
||||
let mut probe = SnapMoveProbe { body, pending: &mut state.pending, ran: None };
|
||||
let reply = ToolHost::new().run(ui, pass, &mut probe);
|
||||
if let Some((label, before, after, should_snap)) = probe.ran {
|
||||
state.outcomes.push(Outcome { label, before, after, snapped: reply.snapped, should_snap });
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
state,
|
||||
);
|
||||
h.run_steps(3);
|
||||
let at = h.state().page_center.expect("probe page placed");
|
||||
let button = |pressed: bool| Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
h.event(Event::PointerMoved(at));
|
||||
for _ in 0..case_count {
|
||||
h.event(button(true));
|
||||
h.run_steps(1);
|
||||
h.event(button(false));
|
||||
h.run_steps(1);
|
||||
}
|
||||
assert_eq!(h.state().outcomes.len(), case_count, "all snap_move probe cases ran");
|
||||
for o in &h.state().outcomes {
|
||||
if o.should_snap {
|
||||
assert!(!o.snapped.is_empty(), "{}: expected snap lines on finite control", o.label);
|
||||
assert!((o.after.x - 300.0).abs() < 1e-4 && (o.after.y - 400.0).abs() < 1e-4, "{}: snapped to target, got {:?}", o.label, o.after);
|
||||
} else {
|
||||
assert!(o.snapped.is_empty(), "{}: expected no snap lines, got {:?}", o.label, o.snapped);
|
||||
assert_eq!(
|
||||
[o.after.x.to_bits(), o.after.y.to_bits(), o.after.w.to_bits(), o.after.h.to_bits()],
|
||||
[o.before.x.to_bits(), o.before.y.to_bits(), o.before.w.to_bits(), o.before.h.to_bits()],
|
||||
"{}: moving rect must stay unchanged ({:?} -> {:?})",
|
||||
o.label,
|
||||
o.before,
|
||||
o.after,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// #2277: the actual picture pixels follow the rotation handle before release, including
|
||||
/// pictures whose cached preview already contains a rotation and either reflection.
|
||||
#[test]
|
||||
|
||||
@@ -94,7 +94,7 @@ fn tabs(app: &mut WordApp, ui: &mut Ui) {
|
||||
/// The key a selection event picked, if it picked one row.
|
||||
fn picked_row(event: &CollectionEvent<usize, RowEvent>) -> Option<usize> {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => keys.first().copied(),
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => keys.first().copied(),
|
||||
CollectionEvent::Activate(key) => Some(*key),
|
||||
_ => None,
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ pub(super) fn styles(app: &mut WordApp, ui: &mut Ui) {
|
||||
let mut asked = None;
|
||||
for event in &out.events {
|
||||
match event {
|
||||
CollectionEvent::Selection { change: SelectionChange::Set(keys), .. } => {
|
||||
CollectionEvent::Selection(SelectionChange::Set(keys)) => {
|
||||
if let Some((id, ..)) = keys.first().and_then(|k| list.get(*k)) {
|
||||
let _ = app.run("para.style", json!({"style": id}));
|
||||
app.canvas.focus_page(&ctx);
|
||||
|
||||
@@ -137,7 +137,7 @@ pub(crate) fn paste_named_files(app: &mut WordApp, text: &str) -> bool {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::system_clipboard::testing::{app_holding, rgba8};
|
||||
use craft::platform::clipboard::{Flavor, RGBA8, URI_LIST};
|
||||
use craft::platform::clipboard::{Flavor, URI_LIST};
|
||||
|
||||
fn pictures(a: &mut WordApp) -> usize {
|
||||
a.session.run("arrange.selectionPane", &json!({})).unwrap().as_array().map(|x| x.len()).unwrap_or(0)
|
||||
@@ -148,29 +148,6 @@ mod tests {
|
||||
Flavor::new(URI_LIST, lines.concat().into_bytes())
|
||||
}
|
||||
|
||||
/// Hostile or damaged clipboard pictures and non-picture files are refused without panicking.
|
||||
#[test]
|
||||
fn hostile_clipboard_pictures_are_refused() {
|
||||
assert!(png_from_rgba(usize::MAX, 2, Vec::new()).is_err());
|
||||
assert!(png_from_rgba(10_000, 10_000, Vec::new()).is_err());
|
||||
assert!(png_from_rgba(4, 4, vec![0; 63]).is_err());
|
||||
assert!(png_from_rgba(0, 4, Vec::new()).is_err());
|
||||
|
||||
// Damaged RGBA8 pixels buffer on the clipboard.
|
||||
let mut damaged = Vec::new();
|
||||
damaged.extend_from_slice(&(4u32).to_le_bytes());
|
||||
damaged.extend_from_slice(&(4u32).to_le_bytes());
|
||||
damaged.extend_from_slice(&[0u8; 10]);
|
||||
let mut a = app_holding(&[Flavor::new(RGBA8, damaged)]);
|
||||
assert!(a.run("edit.paste", json!({})).is_err());
|
||||
assert_eq!(pictures(&mut a), 0);
|
||||
|
||||
// Copied files that aren't pictures leave Paste to the usual clipboard.
|
||||
let mut a = app_holding(&[uri_list(&[PathBuf::from("/tmp/notes.txt")])]);
|
||||
assert_eq!(a.run("edit.paste", json!({})).unwrap_err(), system_clipboard::nothing_to_paste(&a));
|
||||
assert_eq!(pictures(&mut a), 0);
|
||||
}
|
||||
|
||||
/// Paste with only a picture on the clipboard inserts it at its natural size, one undo step.
|
||||
#[test]
|
||||
fn paste_inserts_clipboard_pixels() {
|
||||
|
||||
@@ -177,35 +177,3 @@ pub(crate) fn show(app: &mut WordApp, ui: &mut Ui) {
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::{By, Queryable};
|
||||
|
||||
fn harness(app: WordApp) -> egui_kittest::Harness<'static, WordApp> {
|
||||
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);
|
||||
},
|
||||
app,
|
||||
)
|
||||
}
|
||||
|
||||
/// #1885: The Read Aloud player opens as a modeless dialog and closes from its title bar close action.
|
||||
#[test]
|
||||
fn read_aloud_player_closes_from_title_bar() {
|
||||
let mut app = WordApp::new(wordcraft_engine::Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.session.read_aloud.open = true;
|
||||
let mut h = harness(app);
|
||||
h.run_steps(4);
|
||||
assert!(h.state().session.read_aloud.open, "the player is open");
|
||||
let close = h.query_all(By::new().role(Role::Button).label("Close")).next().expect("close button on player");
|
||||
close.click();
|
||||
h.run_steps(3);
|
||||
assert!(!h.state().session.read_aloud.open, "the player stops and closes");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ use craft::ui::contract::{Gap, Props as _, Show as _, ShowContainer as _};
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::MenuItem;
|
||||
use craft::ui::primitives::FacePaint;
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile};
|
||||
|
||||
use super::common::{menu_button, size_field};
|
||||
@@ -78,24 +77,18 @@ pub(super) fn smart_art_design(row: &mut RibbonRow<'_>, app: &mut WordApp) {
|
||||
let face = Button::new(tl!("Change\nColors").to_string()).icon(IconId::new("smartArtColors")).arrangement(Arrangement::Stacked);
|
||||
let _ = menu_button(ui, face, tl!("Change\nColors").to_string(), None, |ui, _| {
|
||||
let custom = g.has_custom_colors();
|
||||
for (idx, colors) in SmartArtColors::ALL.into_iter().enumerate() {
|
||||
let theme = theme.clone();
|
||||
for colors in SmartArtColors::ALL {
|
||||
MenuItem::command(CommandRef::with_params("smartArt.colors", json!({"variant": colors.id()})))
|
||||
.label(crate::dialogs_smart_art::colors_label(colors))
|
||||
.radio_mark(g.colors == colors && !custom)
|
||||
.sample(
|
||||
ThumbAspect::new(2, 1),
|
||||
FacePaint::new(idx as u64, move |cx, r| crate::dialogs_smart_art::swatches(cx, r, colors, &theme)),
|
||||
)
|
||||
.sample(move |cx, r| crate::dialogs_smart_art::swatches(cx, r, colors, theme))
|
||||
.show(ui);
|
||||
}
|
||||
// Active while items carry their own colours; set in the Text Pane.
|
||||
let theme = theme.clone();
|
||||
let g = g.clone();
|
||||
let mut row = MenuItem::new(tl!("Custom").to_string())
|
||||
.enabled(custom)
|
||||
.radio_mark(custom)
|
||||
.sample(ThumbAspect::new(2, 1), FacePaint::new(0x100, move |cx, r| crate::dialogs_smart_art::custom_swatches(cx, r, &g, &theme)));
|
||||
.sample(move |cx, r| crate::dialogs_smart_art::custom_swatches(cx, r, g, theme));
|
||||
if !custom {
|
||||
row = row.tooltip(tl!("Set the colors in the Text Pane to use custom colors.").to_string());
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ 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::layout_components::{Row, Stack};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::{Menu, MenuItem, MenuOutput};
|
||||
use craft::ui::primitives::{FacePaint, IconSpec};
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::runtime::env::Label;
|
||||
use craft::ui::text::NumberField;
|
||||
|
||||
@@ -37,9 +36,6 @@ pub(crate) fn menu_button(
|
||||
face = face.tooltip(TooltipSpec::new(hint.clone()).disabled_text(hint));
|
||||
}
|
||||
let opener = face.trailing_icon(IconSpec::glyph(&MENU_ARROW)).enabled(enabled).show(ui);
|
||||
if !ui.is_sizing_pass() {
|
||||
crate::keytips::note_menu_button(ui.ctx(), opener.response.id, about.filter(|id| !id.is_empty()));
|
||||
}
|
||||
Menu::new(name).opened_by(&opener.response, Trigger::Click).show(ui, body).output
|
||||
}
|
||||
|
||||
@@ -134,13 +130,10 @@ pub(crate) fn weight_menu(ui: &mut Ui, _app: &mut WordApp, id: &str, current: Op
|
||||
MenuItem::command(CommandRef::with_params(id, params(w)))
|
||||
.label(label)
|
||||
.check(checked)
|
||||
.sample(
|
||||
ThumbAspect::new(3, 1),
|
||||
FacePaint::new(u64::from(w.to_bits()), move |cx, rect| {
|
||||
let y = rect.center().y;
|
||||
cx.painter.line_segment([egui::pos2(rect.left(), y), egui::pos2(rect.right(), y)], egui::Stroke::new(w.max(pixel), cx.ink()));
|
||||
}),
|
||||
)
|
||||
.sample(move |cx, rect| {
|
||||
let y = rect.center().y;
|
||||
cx.painter.line_segment([egui::pos2(rect.left(), y), egui::pos2(rect.right(), y)], egui::Stroke::new(w.max(pixel), cx.ink()));
|
||||
})
|
||||
.show(ui);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,20 +342,6 @@ fn language_names_resolve_aliases_and_tags() {
|
||||
assert!(c.extra.is_some() && !c.listed.contains(&true));
|
||||
}
|
||||
|
||||
/// #1110: the strip's drawn buttons have names for screen readers: Share, and the "»" that
|
||||
/// holds the tabs that don't fit ("More tabs", not a glyph).
|
||||
#[test]
|
||||
fn the_tab_strip_buttons_have_names() {
|
||||
let app = WordApp::new(Session::new(wordcraft_doc::Document::from_text("Text")), crate::Services::default());
|
||||
let mut h = app_harness(app, vec2(760.0, 700.0));
|
||||
h.get_by_role_and_label(egui::accesskit::Role::Button, tl!("Share"));
|
||||
let more = h.get_by_role_and_label(egui::accesskit::Role::Button, tl!("More tabs"));
|
||||
more.click();
|
||||
crate::test_harness::frames(&mut h, 2);
|
||||
// The menu lists a tab that didn't fit (View is among the last on a narrow strip).
|
||||
assert!(h.query(By::new().role(egui::accesskit::Role::MenuItem).label(tl!("View"))).is_some(), "the » menu lists the tabs left out");
|
||||
}
|
||||
|
||||
/// Each contextual tab shows on the tab strip while its object is selected and leaves with the
|
||||
/// selection.
|
||||
#[test]
|
||||
@@ -1071,163 +1057,3 @@ fn table_style_options_align_in_two_columns() {
|
||||
let caption = text_rect("Table Style Options");
|
||||
assert!(banded.bottom() <= caption.top(), "checkboxes collide with group caption: {banded:?} vs {caption:?}");
|
||||
}
|
||||
|
||||
struct StylesGalleryLayout {
|
||||
gallery: egui::Rect,
|
||||
tiles: Vec<(String, egui::Rect, Option<egui::accesskit::Toggled>)>,
|
||||
up: egui::Rect,
|
||||
down: egui::Rect,
|
||||
more: egui::Rect,
|
||||
}
|
||||
|
||||
/// Lay out the Home tab in LTR (`rtl == false`) or Arabic RTL (`rtl == true`) using `fixture_lang`
|
||||
/// so the test never skips when `CRAFT_I18N_DIR` is unset, and collect the Styles gallery's
|
||||
/// container, visible tiles, and stepper/More buttons.
|
||||
fn styles_gallery_layout(rtl: bool) -> StylesGalleryLayout {
|
||||
use egui::accesskit::Role;
|
||||
|
||||
struct ResetLang;
|
||||
impl Drop for ResetLang {
|
||||
fn drop(&mut self) {
|
||||
crate::i18n::apply_language(crate::i18n::Lang::EN);
|
||||
}
|
||||
}
|
||||
let _reset = ResetLang;
|
||||
|
||||
let lang = if rtl {
|
||||
crate::i18n::fixture_lang("ar", "\tHome\tالرئيسية\n\tStyles\tالأنماط\n\tNormal\tعادي\n")
|
||||
} else {
|
||||
crate::i18n::Lang::EN
|
||||
};
|
||||
|
||||
let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), crate::Services::default());
|
||||
app.ui.language = "en".into();
|
||||
app.run("ui.tab", json!({"tab": "Home"})).unwrap();
|
||||
|
||||
let mut h = crate::test_harness::builder().with_size(vec2(2560.0, 900.0)).build_ui_state(
|
||||
move |ui, app: &mut WordApp| {
|
||||
let ctx = ui.ctx().clone();
|
||||
app.logic(&ctx);
|
||||
if rtl {
|
||||
ctx.set_missing_glyph_policy(egui::MissingGlyphPolicy::Tofu);
|
||||
crate::i18n::apply_language(lang);
|
||||
ctx.global_style_mut(|s| s.right_to_left = true);
|
||||
craft::ui::runtime::env::with_env(ui, |o| o.direction = Some(craft::i18n::Direction::Rtl), |ui| app.ui(ui));
|
||||
ctx.global_style_mut(|s| s.right_to_left = false);
|
||||
crate::i18n::apply_language(crate::i18n::Lang::EN);
|
||||
} else {
|
||||
app.ui(ui);
|
||||
}
|
||||
},
|
||||
app,
|
||||
);
|
||||
crate::test_harness::frames(&mut h, 4);
|
||||
|
||||
crate::i18n::apply_language(lang);
|
||||
let gallery_label = crate::i18n::t("Styles").to_string();
|
||||
let names: Vec<String> = h.state().session.doc.styles.gallery().iter().take(6).map(|s| crate::i18n::style_name(s)).collect();
|
||||
crate::i18n::apply_language(crate::i18n::Lang::EN);
|
||||
|
||||
let gallery = h
|
||||
.query_all(By::new().role(Role::RadioGroup).label(gallery_label.as_str()))
|
||||
.next()
|
||||
.unwrap_or_else(|| panic!("Styles radio group '{gallery_label}' not found"))
|
||||
.rect();
|
||||
assert!(gallery.is_positive(), "Styles gallery rect must be positive: {gallery:?}");
|
||||
|
||||
let in_gallery = |rect: egui::Rect| gallery.contains_rect(rect);
|
||||
let tiles: Vec<_> = names
|
||||
.iter()
|
||||
.filter_map(|name| {
|
||||
h.query_all(By::new().role(Role::RadioButton).label(name.as_str()))
|
||||
.find(|node| in_gallery(node.rect()))
|
||||
.map(|node| (name.clone(), node.rect(), node.accesskit_node().toggled()))
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(tiles.len(), names.len(), "expected all {} visible Styles tiles inside {gallery:?}: {tiles:?} vs {names:?}", names.len());
|
||||
|
||||
let button = |label: &str| {
|
||||
h.query_all(By::new().role(Role::Button).label(label))
|
||||
.find(|node| in_gallery(node.rect()))
|
||||
.unwrap_or_else(|| panic!("gallery button '{label}' not found inside {gallery:?}"))
|
||||
.rect()
|
||||
};
|
||||
|
||||
StylesGalleryLayout { gallery, tiles, up: button("Previous row"), down: button("Next row"), more: button("More") }
|
||||
}
|
||||
|
||||
/// #5566, #7753: in a right-to-left interface the Styles gallery starts at the right, as the rest
|
||||
/// of the ribbon does: the first style (Normal) is the rightmost tile, and the scroll arrows and
|
||||
/// More button sit in a column at the gallery's left end. Left to right is unchanged.
|
||||
#[test]
|
||||
fn the_styles_gallery_reads_from_the_right_in_a_right_to_left_interface() {
|
||||
use egui::accesskit::Toggled;
|
||||
|
||||
let assert_common = |layout: &StylesGalleryLayout, expected_first: &str, dir: &str| {
|
||||
assert_eq!(layout.tiles.len(), 6, "{dir}: expected 6 visible gallery tiles: {:?}", layout.tiles);
|
||||
let (first_name, first_rect, first_toggled) = &layout.tiles[0];
|
||||
assert_eq!(first_name, expected_first, "{dir}: first tile should be localized Normal");
|
||||
assert_eq!(*first_toggled, Some(Toggled::True), "{dir}: active Normal style should be checked");
|
||||
assert!(
|
||||
layout
|
||||
.tiles
|
||||
.iter()
|
||||
.all(|(_, r, _)| r.is_positive() && layout.gallery.contains_rect(*r) && (r.center().y - first_rect.center().y).abs() <= 1.0),
|
||||
"{dir}: gallery tiles must sit on one horizontal row inside {:?}: {:?}",
|
||||
layout.gallery,
|
||||
layout.tiles
|
||||
);
|
||||
|
||||
let controls = [("Previous row", layout.up), ("Next row", layout.down), ("More", layout.more)];
|
||||
for (name, rect) in controls {
|
||||
assert!(rect.is_positive(), "{dir}: {name} rect must be positive: {rect:?}");
|
||||
assert!(layout.gallery.contains_rect(rect), "{dir}: {name} {rect:?} must sit inside gallery {:?}", layout.gallery);
|
||||
}
|
||||
assert!(
|
||||
(layout.up.center().x - layout.down.center().x).abs() <= 1.0 && (layout.down.center().x - layout.more.center().x).abs() <= 1.0,
|
||||
"{dir}: up, down, and More buttons must align in one column: up={:?}, down={:?}, more={:?}",
|
||||
layout.up,
|
||||
layout.down,
|
||||
layout.more
|
||||
);
|
||||
assert!(
|
||||
layout.up.max.y <= layout.down.min.y + 1.0 && layout.down.max.y <= layout.more.min.y + 1.0,
|
||||
"{dir}: buttons must stack top-to-bottom (up -> down -> More): up={:?}, down={:?}, more={:?}",
|
||||
layout.up,
|
||||
layout.down,
|
||||
layout.more
|
||||
);
|
||||
};
|
||||
|
||||
// 1. Left-to-right (English)
|
||||
let ltr = styles_gallery_layout(false);
|
||||
assert_common(<r, "Normal", "LTR");
|
||||
assert!(
|
||||
ltr.tiles.windows(2).all(|w| w[0].1.center().x < w[1].1.center().x && w[0].1.max.x <= w[1].1.min.x + 1.0),
|
||||
"LTR: tiles must run left to right: {:?}",
|
||||
ltr.tiles
|
||||
);
|
||||
for (name, ctrl) in [("Previous row", ltr.up), ("Next row", ltr.down), ("More", ltr.more)] {
|
||||
assert!(
|
||||
ltr.tiles.iter().all(|(_, tile, _)| ctrl.min.x >= tile.max.x),
|
||||
"LTR: {name} ({ctrl:?}) must sit to the right of every tile: {:?}",
|
||||
ltr.tiles
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Right-to-left (Arabic)
|
||||
let rtl = styles_gallery_layout(true);
|
||||
assert_common(&rtl, "عادي", "RTL");
|
||||
assert!(
|
||||
rtl.tiles.windows(2).all(|w| w[0].1.center().x > w[1].1.center().x && w[0].1.min.x + 1.0 >= w[1].1.max.x),
|
||||
"RTL: tiles must run right to left from the rightmost Normal tile: {:?}",
|
||||
rtl.tiles
|
||||
);
|
||||
for (name, ctrl) in [("Previous row", rtl.up), ("Next row", rtl.down), ("More", rtl.more)] {
|
||||
assert!(
|
||||
rtl.tiles.iter().all(|(_, tile, _)| ctrl.max.x <= tile.min.x),
|
||||
"RTL: {name} ({ctrl:?}) must sit to the left of every tile: {:?}",
|
||||
rtl.tiles
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use craft::menu::CommandRef;
|
||||
use craft::ui::contract::{Props as _, Show as _};
|
||||
use craft::ui::display::Divider;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::primitives::FacePaint;
|
||||
|
||||
use egui::{Rect, Stroke, pos2};
|
||||
|
||||
@@ -25,12 +23,12 @@ pub(super) const UNDERLINE_STYLES: [(&str, &str); 8] = [
|
||||
/// Home › Font › Underline's drop-down (#2738): a sample of each line, Words only, None, More
|
||||
/// Underlines… (the Font dialog) and Underline Color.
|
||||
pub(super) fn underline_menu(ui: &mut Ui, app: &mut WordApp) {
|
||||
for (idx, (style, name)) in UNDERLINE_STYLES.into_iter().enumerate() {
|
||||
for (style, name) in UNDERLINE_STYLES {
|
||||
// The sample stands for the label; the name is the tooltip and what assistive technology reads.
|
||||
MenuItem::command(CommandRef::with_params("format.underline", json!({"style": style})))
|
||||
.label(tl!(name).to_string())
|
||||
.tooltip(tl!(name).to_string())
|
||||
.sample(ThumbAspect::new(4, 1), FacePaint::new(idx as u64, move |cx, r| paint_underline(&cx.painter, r, style, cx.ink())))
|
||||
.sample(move |cx, r| paint_underline(&cx.painter, r, style, cx.ink()))
|
||||
.sample_only()
|
||||
.hide_shortcut()
|
||||
.show(ui);
|
||||
|
||||
@@ -459,32 +459,4 @@ mod tests {
|
||||
a.run("edit.paste", params).unwrap();
|
||||
assert!(!a.session.doc.media.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_copy_does_not_publish_or_overwrite_clipboard_state() {
|
||||
let mut a = app_with_copied_picture();
|
||||
assert!(a.clipboard_published);
|
||||
let clip = handle(&a).unwrap();
|
||||
let image = clip.read_image().unwrap().unwrap();
|
||||
assert_eq!((image.width, image.height), (2, 2));
|
||||
|
||||
a.run("caret.docEnd", json!({})).unwrap();
|
||||
assert!(a.session.sel.is_collapsed());
|
||||
|
||||
let ctx = a.ctx.clone().unwrap();
|
||||
let empty_r = a.run("edit.copy", json!({})).unwrap();
|
||||
put_result(&mut a, &ctx, &empty_r);
|
||||
|
||||
assert!(a.clipboard_published, "empty copy must not change published-copy state");
|
||||
let clip = handle(&a).unwrap();
|
||||
let image2 = clip.read_image().unwrap().unwrap();
|
||||
assert_eq!((image2.width, image2.height), (2, 2), "empty copy must not overwrite clipboard image");
|
||||
|
||||
let mut a2 = app_holding(&[]);
|
||||
assert!(!a2.clipboard_published);
|
||||
let ctx2 = a2.ctx.clone().unwrap();
|
||||
let empty_r2 = a2.run("edit.copy", json!({})).unwrap();
|
||||
put_result(&mut a2, &ctx2, &empty_r2);
|
||||
assert!(!a2.clipboard_published, "empty copy must not change published-copy state when false");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,24 +231,6 @@ fn dragging_across_cells_selects_their_rectangle() {
|
||||
assert!(!crate::mini_toolbar::visible(h.state()));
|
||||
}
|
||||
|
||||
/// The "+" left of a row border adds a row there and selects it, in one undo step; over it
|
||||
/// the pointer is the plain arrow.
|
||||
#[test]
|
||||
fn the_plus_button_adds_a_row() {
|
||||
let mut h = table_window();
|
||||
let a = cell(&mut h, 0, 0);
|
||||
let depth = h.state().session.undo_depth();
|
||||
let at = screen(&mut h, a.x - 10.0, a.bottom());
|
||||
h.event(egui::Event::PointerMoved(at));
|
||||
steps(&mut h, 2);
|
||||
assert_eq!(arrow_toward(&h), None, "over the insert button the pointer is the plain arrow");
|
||||
click(&mut h, at);
|
||||
let rows = h.state().session.doc.body.iter().find_map(|b| b.as_table()).map(|t| t.rows.len());
|
||||
assert_eq!(rows, Some(3));
|
||||
assert_eq!(h.state().session.cell_range().map(|r| (r.rows, r.cols)), Some(((1, 1), (0, 2))), "the new row is selected");
|
||||
assert_eq!(h.state().session.undo_depth(), depth + 1);
|
||||
}
|
||||
|
||||
/// A double-click along a cell's left edge selects its row, as in Word.
|
||||
#[test]
|
||||
fn a_double_click_by_a_cells_edge_selects_its_row() {
|
||||
|
||||
+12
-130
@@ -5,7 +5,7 @@ use craft::automation::control::{ControlRequest, Reply};
|
||||
use craft::host::{PickId, PickKind, PickRequest, Picked, ScriptedFiles};
|
||||
use craft::platform::clock::monotonic_ms;
|
||||
use craft::platform::default_app::{DefaultApp, DefaultAppError};
|
||||
use craft::platform::open::{DroppedFile, FileIntake};
|
||||
use craft::platform::open::{DropTarget, DroppedFile, FileIntake};
|
||||
use craft::ui::shell::ScreenMode;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -55,24 +55,6 @@ fn save_as_suggests_the_first_words_of_a_new_document() {
|
||||
assert_eq!(app.default_save_name(), "kept.docm", "a saved file keeps its name and format");
|
||||
}
|
||||
|
||||
/// #3634: every source of the title (path, file name, document title) drops NUL.
|
||||
#[test]
|
||||
fn title_stem_omits_nul_from_each_title_source() {
|
||||
let mut app = app();
|
||||
let fallback = app.title_stem();
|
||||
for title in ["Résumé\u{0} notes", "\u{0}"] {
|
||||
let expected = if title == "\u{0}" { fallback.as_str() } else { "Résumé notes" };
|
||||
app.session.doc.core.title = title.into();
|
||||
assert_eq!(app.title_stem(), expected);
|
||||
app.session.file_name = Some(title.into());
|
||||
assert_eq!(app.title_stem(), expected);
|
||||
app.session.path = Some(std::path::PathBuf::from(format!("{title}.docx")));
|
||||
assert_eq!(app.title_stem(), expected);
|
||||
app.session.path = None;
|
||||
app.session.file_name = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// A harness on a document with text whose page has the keyboard.
|
||||
fn canvas_harness() -> egui_kittest::Harness<'static, WordApp> {
|
||||
let mut a = app();
|
||||
@@ -102,7 +84,6 @@ type Rig = egui_kittest::Harness<'static, WordApp>;
|
||||
/// runs it before the second (`raw_input_hook`), as on the desktop.
|
||||
fn press(h: &mut Rig, key: egui::Key, modifiers: egui::Modifiers) {
|
||||
h.event(egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers });
|
||||
h.event(egui::Event::Key { key, physical_key: None, pressed: false, repeat: false, modifiers });
|
||||
h.step();
|
||||
h.step();
|
||||
}
|
||||
@@ -284,12 +265,10 @@ fn row_mod_shift_0_resets_the_interface_size_unless_bound() {
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: None, pressed: true, repeat: false, modifiers: altgr });
|
||||
h.event(egui::Event::ModifiersChanged(altgr));
|
||||
h.event(egui::Event::Text("}".into()));
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: None, pressed: false, repeat: false, modifiers: altgr });
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.interface_size.percent(), Some(300), "AltGr+0 doesn't reset");
|
||||
assert_eq!(body_text(h.state()), "}", "AltGr+0 types the character");
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: Some(egui::Key::Num0), pressed: true, repeat: false, modifiers: chord });
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: Some(egui::Key::Num0), pressed: false, repeat: false, modifiers: chord });
|
||||
h.step();
|
||||
h.step();
|
||||
assert!(h.state().ui.interface_size.is_auto(), "Ctrl+Shift+0 returns to Auto");
|
||||
@@ -298,7 +277,6 @@ fn row_mod_shift_0_resets_the_interface_size_unless_bound() {
|
||||
// PLAN(shell-w7): sh.A11 `Session::keymap_mut` over `Overrides::insert`.
|
||||
h.state_mut().session.keymap_mut().insert("view.focus", vec!["Mod+Shift+0".into()]);
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: Some(egui::Key::Num0), pressed: true, repeat: false, modifiers: chord });
|
||||
h.event(egui::Event::Key { key: egui::Key::Num0, physical_key: Some(egui::Key::Num0), pressed: false, repeat: false, modifiers: chord });
|
||||
h.step();
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.interface_size.percent(), Some(300), "the size stays");
|
||||
@@ -616,7 +594,7 @@ impl craft::platform::clipboard::ClipboardBackend for LatePaste {
|
||||
fn drop_files(a: &mut WordApp, files: Vec<DroppedFile>) {
|
||||
let (intake, sender) = FileIntake::new(craft::host::Wake::none());
|
||||
a.services.intake = Some(intake);
|
||||
sender.dropped(files);
|
||||
sender.dropped(files, DropTarget::Elsewhere);
|
||||
}
|
||||
|
||||
/// An in-memory dropped file.
|
||||
@@ -1954,21 +1932,6 @@ fn save_prompt_shows_why_the_save_failed() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// #3172: the ribbon's combo boxes name themselves: a screen reader reads their label (Font,
|
||||
/// Font Size), and the drop-down arrows say what they drop down.
|
||||
#[test]
|
||||
fn the_ribbon_boxes_name_themselves_for_a_screen_reader() {
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut a = app();
|
||||
a.run("file.new", json!({"template": "sample"})).unwrap();
|
||||
let mut h = harness(a);
|
||||
h.run_steps(6);
|
||||
for (role, name) in [(Role::ComboBox, "Font"), (Role::ComboBox, "Font Size"), (Role::Button, "Font Color")] {
|
||||
assert!(h.query_by_role_and_label(role, name).is_some(), "nothing on the ribbon is called {name:?} with {role:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #3172: the Paste button is named "Paste": its tooltip adds the key as the platform writes it,
|
||||
/// so its name no longer carries macOS's "⌘V", which screen readers read on Windows as "Paste (⌘V)".
|
||||
#[test]
|
||||
@@ -2578,7 +2541,7 @@ impl WebSaves {
|
||||
let answered = self.0.answer_to(
|
||||
id,
|
||||
match ended {
|
||||
Ended::Saved => Picked::Saved { path: std::path::PathBuf::from("novel.docx"), file_type: None },
|
||||
Ended::Saved => Picked::Paths(vec![std::path::PathBuf::from("novel.docx")]),
|
||||
Ended::Cancelled => Picked::Cancelled,
|
||||
Ended::Failed(why) => Picked::Failed(why),
|
||||
},
|
||||
@@ -3385,6 +3348,7 @@ fn f11_and_escape_toggle_full_screen() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let key = |key| egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
|
||||
// Run frames and return the full-screen requests the window got.
|
||||
let sent = |h: &mut egui_kittest::Harness<WordApp>| {
|
||||
let mut out = Vec::new();
|
||||
@@ -3395,86 +3359,30 @@ fn f11_and_escape_toggle_full_screen() {
|
||||
out
|
||||
};
|
||||
assert_eq!(sent(&mut h), vec![], "a normal window to start with");
|
||||
h.key_press(egui::Key::F11);
|
||||
h.event(key(egui::Key::F11));
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(true)], "F11");
|
||||
assert!(h.state().session.view.full_screen);
|
||||
h.key_press(egui::Key::F11);
|
||||
h.event(key(egui::Key::F11));
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(false)], "F11 again");
|
||||
assert!(!h.state().session.view.full_screen);
|
||||
// The command (ribbon, command search, agents), then Escape.
|
||||
assert_eq!(h.state_mut().run("view.fullScreen", json!({})).unwrap(), json!({"value": true}));
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(true)], "the command");
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(key(egui::Key::Escape));
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(false)], "Escape");
|
||||
// Escape in a normal window doesn't touch the window.
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(key(egui::Key::Escape));
|
||||
assert_eq!(sent(&mut h), vec![]);
|
||||
// Escape closing a dialog leaves full screen alone.
|
||||
h.state_mut().run("view.fullScreen", json!({"value": true})).unwrap();
|
||||
h.state_mut().run("ui.dialog", json!({"name": "zoom"})).unwrap();
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(true)]);
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(key(egui::Key::Escape));
|
||||
assert_eq!(sent(&mut h), vec![]);
|
||||
assert!(open_dialog(h.state()).is_none(), "Escape closed the dialog");
|
||||
assert!(h.state().session.view.full_screen, "and only that");
|
||||
}
|
||||
|
||||
/// The Full Screen button tells assistive technology what the command can do: it is enabled
|
||||
/// exactly when the command is, so the browser build (which keeps full screen to itself)
|
||||
/// does not announce a control that cannot be activated.
|
||||
#[test]
|
||||
fn the_full_screen_button_reports_the_commands_own_enabled_state() {
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
use wordcraft_engine::{CommandSpec, Registry};
|
||||
|
||||
// The browser build's reason for refusing full screen, forced here so the test says
|
||||
/// something on every platform.
|
||||
fn unavailable(_: &wordcraft_engine::Session) -> Option<&'static str> {
|
||||
Some("Use the browser's full screen (F11)")
|
||||
}
|
||||
|
||||
let mut a = app();
|
||||
let specs: Vec<CommandSpec> = a
|
||||
.session
|
||||
.registry
|
||||
.all()
|
||||
.iter()
|
||||
.map(|s| {
|
||||
if s.id == "view.fullScreen" {
|
||||
CommandSpec {
|
||||
id: s.id,
|
||||
label: s.label,
|
||||
location: s.location,
|
||||
shortcut: s.shortcut,
|
||||
params: s.params,
|
||||
mutates: s.mutates,
|
||||
enabled: unavailable,
|
||||
run: s.run,
|
||||
}
|
||||
} else {
|
||||
s.clone()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
a.session.registry = std::sync::Arc::new(Registry::new(specs));
|
||||
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1920.0, 900.0)).build_eframe(|_| a);
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
h.state_mut().run("ui.tab", json!({ "tab": "View" })).unwrap();
|
||||
for _ in 0..3 {
|
||||
h.step();
|
||||
}
|
||||
let node = h
|
||||
.query_all(egui_kittest::kittest::By::new().role(egui::accesskit::Role::Button))
|
||||
.into_iter()
|
||||
.find(|n| n.accesskit_node().label().as_deref().is_some_and(|l| l.replace('\n', " ").contains("Full Screen")))
|
||||
.expect("the Full Screen button is on the View tab");
|
||||
assert!(!crate::app::command_board::command_enabled(h.state(), "view.fullScreen"), "the command is unavailable, as the test arranged it",);
|
||||
assert!(node.accesskit_node().is_disabled(), "a control the command refuses is announced as disabled",);
|
||||
}
|
||||
|
||||
/// #980: in full screen, Escape with text selected collapses the selection (as in a normal
|
||||
/// window) and leaves full screen alone; the next Escape, with nothing selected, leaves it.
|
||||
#[test]
|
||||
@@ -3484,6 +3392,7 @@ fn escape_collapses_a_selection_before_leaving_full_screen() {
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let esc = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE };
|
||||
let sent = |h: &mut egui_kittest::Harness<WordApp>| {
|
||||
let mut out = Vec::new();
|
||||
for _ in 0..2 {
|
||||
@@ -3499,11 +3408,11 @@ fn escape_collapses_a_selection_before_leaving_full_screen() {
|
||||
h.state_mut().run("view.fullScreen", json!({"value": true})).unwrap();
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(true)]);
|
||||
assert!(!h.state().session.sel.is_collapsed());
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(esc.clone());
|
||||
assert_eq!(sent(&mut h), vec![], "Escape with a selection stays in full screen");
|
||||
assert!(h.state().session.sel.is_collapsed(), "and collapses the selection");
|
||||
assert!(h.state().session.view.full_screen);
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(esc);
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(false)], "Escape with nothing selected leaves");
|
||||
assert!(!h.state().session.view.full_screen);
|
||||
}
|
||||
@@ -3526,33 +3435,6 @@ fn full_screen_follows_the_window() {
|
||||
assert!(!a.session.view.full_screen);
|
||||
}
|
||||
|
||||
/// #1678: Focus and Full Screen View put the window in full screen, asked of the system once
|
||||
/// per change (switching between the two keeps it), and the usual window comes back after.
|
||||
#[test]
|
||||
fn focus_and_full_screen_view_ask_for_full_screen_once_per_change() {
|
||||
use egui::ViewportCommand::Fullscreen;
|
||||
let mut h = crate::test_harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_eframe(|_| app());
|
||||
for _ in 0..6 {
|
||||
h.step();
|
||||
}
|
||||
let sent = |h: &mut egui_kittest::Harness<WordApp>| {
|
||||
let mut out = Vec::new();
|
||||
for _ in 0..2 {
|
||||
h.step();
|
||||
out.extend(h.output().viewport_output.values().flat_map(|v| v.commands.iter()).filter(|c| matches!(c, Fullscreen(_))).cloned());
|
||||
}
|
||||
out
|
||||
};
|
||||
assert_eq!(sent(&mut h), vec![], "a normal window to start with");
|
||||
h.state_mut().run("view.focus", json!({})).unwrap();
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(true)]);
|
||||
assert_eq!(sent(&mut h), vec![]);
|
||||
h.state_mut().run("view.fullScreenView", json!({})).unwrap();
|
||||
assert_eq!(sent(&mut h), vec![], "Focus to Full Screen View stays full screen");
|
||||
h.state_mut().run("view.fullScreenView", json!({})).unwrap();
|
||||
assert_eq!(sent(&mut h), vec![Fullscreen(false)]);
|
||||
}
|
||||
|
||||
/// #312: Dark page darkens only the pages; the interface keeps following its own setting.
|
||||
#[test]
|
||||
fn dark_page_leaves_the_interface_theme_alone() {
|
||||
|
||||
@@ -34,7 +34,6 @@ struct Recorder {
|
||||
held: Arc<Mutex<Vec<mpsc::Sender<()>>>>,
|
||||
never_sent: bool,
|
||||
names: Vec<&'static str>,
|
||||
chooses: bool,
|
||||
}
|
||||
|
||||
impl Recorder {
|
||||
@@ -46,7 +45,6 @@ impl Recorder {
|
||||
held: Arc::default(),
|
||||
never_sent: true,
|
||||
names: vec!["Test queue"],
|
||||
chooses: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +54,6 @@ impl Recorder {
|
||||
self
|
||||
}
|
||||
|
||||
/// A spooler where the user does not choose a printer (e.g. system print dialog).
|
||||
fn without_choosing(mut self) -> Self {
|
||||
self.chooses = false;
|
||||
self
|
||||
}
|
||||
|
||||
/// A recorder whose cancel answers `never_sent`.
|
||||
fn cancelling(reply: Reply, never_sent: bool) -> Self {
|
||||
Recorder { never_sent, ..Recorder::new(reply) }
|
||||
@@ -84,14 +76,7 @@ impl Recorder {
|
||||
}
|
||||
|
||||
impl SpoolBackend for Recorder {
|
||||
fn chooses_printer(&self) -> bool {
|
||||
self.chooses
|
||||
}
|
||||
|
||||
fn printers(&self) -> Option<Vec<craft::print::Printer>> {
|
||||
if !self.chooses {
|
||||
return None;
|
||||
}
|
||||
Some(
|
||||
self.names
|
||||
.iter()
|
||||
@@ -645,50 +630,6 @@ fn return_on_the_print_page_prints() {
|
||||
assert_eq!(rec.sent_count(), 2, "Return in the chooser prints nothing");
|
||||
}
|
||||
|
||||
/// #2958: the Print button leads the settings, above the printer and the settings it prints
|
||||
/// with (as in Word), and it wears the accent the app gives a dialog's primary button, so the
|
||||
/// page's one action is found first and reads as one rather than as another setting.
|
||||
#[test]
|
||||
fn the_print_button_leads_the_settings_and_is_the_primary_action() {
|
||||
use egui::accesskit::Role;
|
||||
use egui_kittest::kittest::{By, Queryable};
|
||||
|
||||
fn collect_shapes<'a>(shapes: &'a [egui::epaint::ClippedShape], out: &mut Vec<&'a egui::Shape>) {
|
||||
for clipped in shapes {
|
||||
fn walk<'a>(shape: &'a egui::Shape, out: &mut Vec<&'a egui::Shape>) {
|
||||
match shape {
|
||||
egui::Shape::Vec(children) => {
|
||||
for child in children {
|
||||
walk(child, out);
|
||||
}
|
||||
}
|
||||
other => out.push(other),
|
||||
}
|
||||
}
|
||||
walk(&clipped.shape, out);
|
||||
}
|
||||
}
|
||||
|
||||
const BLURB: &str = "Send the document straight to the system print dialog, or save a copy in another format below.";
|
||||
let mut a = app();
|
||||
a.services.print = Some(Recorder::new(Reply::Sent).without_choosing().spool());
|
||||
a.run("file.print", json!({})).unwrap();
|
||||
let mut h = harness(a);
|
||||
h.run_steps(4);
|
||||
// The page's own Print button (the backstage list has a Print entry too): the last.
|
||||
let print = h.query_all(By::new().role(Role::Button).label("Print")).last().expect("a Print button").rect();
|
||||
let blurb = h.get_by_label(BLURB).rect();
|
||||
assert!(print.min.y < blurb.min.y, "the Print button leads the settings: {print:?} above {blurb:?}");
|
||||
let env = craft::ui::runtime::env::Env::of_root(&h.ctx);
|
||||
let accent = egui::Color32::from(craft::theme::Srgba::from(env.tokens.color.accent.strong));
|
||||
let mut shapes = Vec::new();
|
||||
collect_shapes(&h.output().shapes, &mut shapes);
|
||||
assert!(
|
||||
shapes.iter().any(|s| matches!(s, egui::Shape::Rect(r) if (r.rect.min.distance(print.min) < 1.0) && r.fill == accent)),
|
||||
"the Print button is the primary (accent) button"
|
||||
);
|
||||
}
|
||||
|
||||
/// #3210: a successful native print submission returns to the document, the same as Word —
|
||||
/// previously the Print page stayed up until the user clicked Back, even though the job had
|
||||
/// already gone to the spooler. A failed submission stays up instead, so the error (and the
|
||||
@@ -793,16 +734,8 @@ fn alt_q_opens_search_and_typing_goes_there() {
|
||||
let Some(open) = chord_event(&chord) else {
|
||||
panic!("the chord {chord} names a key egui knows");
|
||||
};
|
||||
let release = |key, modifiers| egui::Event::Key { key, physical_key: None, pressed: false, repeat: false, modifiers };
|
||||
let open_release = chord_event(&chord).map(|e| match e {
|
||||
egui::Event::Key { key, physical_key, modifiers, .. } => egui::Event::Key { key, physical_key, pressed: false, repeat: false, modifiers },
|
||||
other => other,
|
||||
});
|
||||
// Both in one frame's input, as the platform sends them: kittest's `event` runs a frame for each queued event.
|
||||
h.input_mut().events.extend([open.clone(), egui::Event::Text("q".into())]);
|
||||
if let Some(rel) = open_release.clone() {
|
||||
h.input_mut().events.push(rel);
|
||||
}
|
||||
h.step();
|
||||
// The chord fires the command in that pass; the app runs it before the next pass (`raw_input_hook`).
|
||||
h.step();
|
||||
@@ -816,30 +749,25 @@ fn alt_q_opens_search_and_typing_goes_there() {
|
||||
h.step();
|
||||
assert_eq!(search_text(&h).as_deref(), Some("bold"), "typing goes into the search box");
|
||||
assert_eq!(h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body), "Kilns");
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(key(egui::Key::Escape, egui::Modifiers::NONE));
|
||||
h.step();
|
||||
h.step();
|
||||
// The framework gives Escape to a field holding a draft first (`overlay/dismissal.rs`): the typed "bold" takes the
|
||||
// first one, and the second closes Search. The old app closed on one.
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.event(key(egui::Key::Escape, egui::Modifiers::NONE));
|
||||
h.step();
|
||||
h.step();
|
||||
assert!(!crate::chrome::search::is_open(h.state()), "Escape closes Search");
|
||||
assert!(!h.state().session.view.full_screen_view);
|
||||
// Words that name no command: Enter finds them in the document, in the Navigation pane.
|
||||
h.event(open);
|
||||
if let Some(rel) = open_release {
|
||||
h.event(rel);
|
||||
}
|
||||
h.step();
|
||||
h.step();
|
||||
// Typing sends each key's press before its text.
|
||||
h.event(key(egui::Key::K, egui::Modifiers::SHIFT));
|
||||
h.event(egui::Event::Text("Kilns".into()));
|
||||
h.event(release(egui::Key::K, egui::Modifiers::SHIFT));
|
||||
h.step();
|
||||
h.event(key(egui::Key::Enter, egui::Modifiers::NONE));
|
||||
h.event(release(egui::Key::Enter, egui::Modifiers::NONE));
|
||||
h.step();
|
||||
h.step();
|
||||
assert!(!crate::chrome::search::is_open(h.state()), "Enter ran the search");
|
||||
|
||||
@@ -430,17 +430,14 @@ fn find_replace_and_go_to_keys_like_word() {
|
||||
h.event(egui::Event::Text("Kilns fire clay. Kilns cool.".into()));
|
||||
h.step();
|
||||
let nav_query = |h: &egui_kittest::Harness<WordApp>| h.ctx.data(|d| d.get_temp::<String>(h.state().window_id("nav_query"))).unwrap_or_default();
|
||||
let release = |key, modifiers| egui::Event::Key { key, physical_key: None, pressed: false, repeat: false, modifiers };
|
||||
// Ctrl+F: the pane, and typing goes into its search box.
|
||||
h.event(key(egui::Key::F, egui::Modifiers::COMMAND));
|
||||
h.event(release(egui::Key::F, egui::Modifiers::COMMAND));
|
||||
h.step();
|
||||
h.step();
|
||||
assert!(h.state().session.view.nav_pane, "the Navigation pane opened");
|
||||
assert_eq!(h.state().ui.nav_tab, "results", "Find exposes its results (#2096)");
|
||||
assert!(h.state().dialog_host.open_dialogs().is_empty(), "no dialog: {:?}", open_key(h.state()));
|
||||
h.event(key(egui::Key::C, egui::Modifiers::NONE));
|
||||
h.event(release(egui::Key::C, egui::Modifiers::NONE));
|
||||
h.event(egui::Event::Text("cool".into()));
|
||||
h.step();
|
||||
h.step();
|
||||
@@ -463,7 +460,6 @@ fn find_replace_and_go_to_keys_like_word() {
|
||||
h.state_mut().canvas.focus_page(&ctx);
|
||||
h.step();
|
||||
h.event(key(egui::Key::F, egui::Modifiers::COMMAND));
|
||||
h.event(release(egui::Key::F, egui::Modifiers::COMMAND));
|
||||
h.step();
|
||||
h.step();
|
||||
assert_eq!(nav_query(&h), "Kilns");
|
||||
|
||||
@@ -783,12 +783,6 @@ mod tests {
|
||||
},
|
||||
false,
|
||||
);
|
||||
// Give the craft runtime the test's mode (#3589 keeps the curve `super::apply` set on that mode's style).
|
||||
let mode = if dark { craft::theme::ModeChoice::Dark } else { craft::theme::ModeChoice::Light };
|
||||
craft::ui::shell::embed::before_input(&h.ctx, |_| {
|
||||
craft::ui::runtime::frame::FrameInput::new(craft::ui::runtime::env::RootEnv::new().mode(mode))
|
||||
});
|
||||
h.step();
|
||||
h.run();
|
||||
let img = h.render().unwrap();
|
||||
// Ink: how far each pixel, laid over the background (the window outside the frame is
|
||||
|
||||
@@ -76,27 +76,4 @@ mod tests {
|
||||
// Scales above 150% (e.g. 175% where half width is ~548.5 pt) clamp up to the 600 pt minimum width.
|
||||
assert_eq!(requested_size(egui::vec2(548.0, 480.0), 8192.0), Some(egui::vec2(600.0, 480.0)));
|
||||
}
|
||||
|
||||
/// #7317: insane values in requested window geometry are clamped or dropped.
|
||||
#[test]
|
||||
fn insane_values_are_clamped_or_dropped() {
|
||||
// Zero or non-positive width/height are dropped.
|
||||
assert_eq!(requested_size(egui::vec2(0.0, 800.0), 16384.0), None);
|
||||
assert_eq!(requested_size(egui::vec2(800.0, 0.0), 16384.0), None);
|
||||
assert_eq!(requested_size(egui::vec2(-5.0, 800.0), 16384.0), None);
|
||||
|
||||
// NaN and infinite values are dropped.
|
||||
assert_eq!(requested_size(egui::vec2(f32::NAN, 800.0), 16384.0), None);
|
||||
assert_eq!(requested_size(egui::vec2(800.0, f32::NAN), 16384.0), None);
|
||||
assert_eq!(requested_size(egui::vec2(f32::INFINITY, 800.0), 16384.0), None);
|
||||
assert_eq!(requested_size(egui::vec2(800.0, f32::NEG_INFINITY), 16384.0), None);
|
||||
|
||||
// Tiny side clamps up to MIN_SIZE, huge side clamps down to MAX_SIZE (16384.0).
|
||||
let tiny_and_huge = requested_size(egui::vec2(10.0, 1.0e9), 16384.0);
|
||||
assert_eq!(tiny_and_huge, Some(egui::vec2(MIN_SIZE.x, 16384.0)));
|
||||
|
||||
// Sane values within bounds are preserved as-is.
|
||||
let sane = egui::vec2(1200.0, 800.0);
|
||||
assert_eq!(requested_size(sane, 16384.0), Some(sane));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +146,6 @@ impl WordApp {
|
||||
command_catalog_lang: _,
|
||||
key_overrides: _,
|
||||
command_states: _,
|
||||
command_states_cache: _,
|
||||
keytip_cache: _,
|
||||
fonts_frames: _,
|
||||
printing: _,
|
||||
print_feedback_seen: _,
|
||||
|
||||
@@ -544,70 +544,3 @@ fn nul_in_the_document_title_never_reaches_an_os_window_title() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Issue #117: a viewport command schedules a repaint, so resending an unchanged window title every
|
||||
/// frame would keep the app redrawing at the monitor's refresh rate while idle. WordCraft supplies
|
||||
/// a stable `window_title()` to `AppShell` every frame so `craft-libs` (`ui-contract` windows
|
||||
/// `native.rs`) deduplicates `SetTitle` per viewport and idle frames emit no
|
||||
/// `ViewportCommand::Title`.
|
||||
#[test]
|
||||
fn window_title_is_sent_only_when_it_changes() {
|
||||
let mut rig = Rig::new();
|
||||
let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default());
|
||||
let titles = |rig: &mut Rig, a: &mut WordApp| -> Vec<(ViewportId, String)> {
|
||||
rig.frame(a);
|
||||
rig.commands
|
||||
.iter()
|
||||
.filter_map(|(v, c)| match c {
|
||||
ViewportCommand::Title(t) => Some((*v, t.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
let initial_title = a.window_title();
|
||||
// The title goes out on the first frame that sets it.
|
||||
assert_eq!(titles(&mut rig, &mut a), vec![(ViewportId::ROOT, initial_title.clone())], "first frame sends the window title");
|
||||
assert!(titles(&mut rig, &mut a).is_empty(), "subsequent idle frame sends no title");
|
||||
assert!(titles(&mut rig, &mut a).is_empty(), "steady idle sends no title");
|
||||
a.run("text.insert", json!({"text": "edit"})).unwrap();
|
||||
let dirty_title = a.window_title();
|
||||
assert_ne!(dirty_title, initial_title, "editing the document changes the window title");
|
||||
assert_eq!(titles(&mut rig, &mut a), vec![(ViewportId::ROOT, dirty_title)], "dirty document changes the title stem, sending it once");
|
||||
assert!(titles(&mut rig, &mut a).is_empty(), "steady state after edit sends no title");
|
||||
}
|
||||
|
||||
/// When the root window closes and WordCraft promotes another open window into the root viewport,
|
||||
/// `WordApp::paint_window` supplies the promoted window's `window_title()` every frame so
|
||||
/// `ViewportId::ROOT` receives the new title once and emits no further `ViewportCommand::Title`
|
||||
/// while idle (per-viewport deduplication lives in `craft-libs` `ui-contract` windows `native.rs`).
|
||||
#[test]
|
||||
fn root_viewport_receives_promoted_windows_title_after_root_closes() {
|
||||
let mut rig = Rig::new();
|
||||
let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default());
|
||||
rig.frames(&mut a, 2);
|
||||
assert_eq!(a.window_title(), super::title("Document1", false));
|
||||
|
||||
a.run("file.new", json!({})).unwrap();
|
||||
let promoted = a.windows.shown();
|
||||
let promoted_title = a.window_title();
|
||||
assert_eq!(promoted_title, super::title("Document2", false));
|
||||
rig.frames(&mut a, 2);
|
||||
assert_eq!(a.window_count(), 2);
|
||||
|
||||
rig.close(ViewportId::ROOT);
|
||||
rig.frame(&mut a);
|
||||
assert_eq!((a.window_count(), a.windows.root.get()), (1, promoted), "the remaining window moves into the root viewport");
|
||||
let root_titles: Vec<&str> = rig
|
||||
.commands
|
||||
.iter()
|
||||
.filter_map(|(v, c)| match c {
|
||||
ViewportCommand::Title(t) if *v == ViewportId::ROOT => Some(t.as_str()),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(root_titles, [promoted_title.as_str()], "root viewport receives the promoted window's title");
|
||||
|
||||
rig.frame(&mut a);
|
||||
let idle_titles = rig.commands.iter().filter(|(v, c)| *v == ViewportId::ROOT && matches!(c, ViewportCommand::Title(_))).count();
|
||||
assert_eq!(idle_titles, 0, "idle frame after promotion sends no duplicate title");
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# The root window hides instead of taking over another document
|
||||
|
||||
The first window an app opens is the framework's root window, and the app ends when it closes. WordCraft
|
||||
used to keep it open when the user closed it with other document windows open: it switched to another
|
||||
window's document and that window disappeared, so the window the user closed stayed and a different one
|
||||
vanished (#7752). We decided instead that the root window hides (storytold/craft-libs#584) and adopts
|
||||
nothing, so the window the user closes is always the one that goes, and the app ends only when the last
|
||||
document window closes or the user quits.
|
||||
|
||||
## Considered options
|
||||
|
||||
- **Root takes over another document** (the old behaviour): no framework change, but it is the reported bug,
|
||||
and the moved window loses its position and size.
|
||||
- **Root shows no document and stays visible**: leaves an empty window the user did not ask for.
|
||||
File diff suppressed because one or more lines are too long
@@ -1,12 +1,11 @@
|
||||
# Windows, Linux and macOS release-ref nightly: supervised manual go-live
|
||||
|
||||
**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and
|
||||
the signer (`nightly-sign.yml`, on the dedicated `nightly-signer` branch) keep only their exact
|
||||
context guards and run when one of the reviewed manual actors dispatches them.
|
||||
`nightly-dispatch.yml` stays literally off: it only forwards scheduled producers. There is no
|
||||
schedule. The installed policy
|
||||
**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and the
|
||||
signer (`nightly-sign.yml`, release) keep only their exact context guards and run when one of the reviewed
|
||||
manual actors dispatches them. There is no schedule yet. The installed policy
|
||||
[`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the v3 policy.
|
||||
Its `producer_workflow_id` is the registration of `nightly.yml` on main, read with:
|
||||
Once `nightly.yml` lands on `main`, populate `producer_workflow_id` before promoting the policy to
|
||||
`release` by reading:
|
||||
|
||||
```bash
|
||||
gh api repos/storytold/wordcraft/actions/workflows/nightly.yml --jq .id
|
||||
@@ -15,57 +14,31 @@ gh api repos/storytold/wordcraft/actions/workflows/nightly.yml --jq .id
|
||||
The callers pass no platform secrets. The unsigned reusable caller's maximum OIDC/attestation
|
||||
permissions are for its isolated attester; its compiler narrows to contents and Actions read
|
||||
only, with no OIDC, attestation write, release environment or platform signing secrets.
|
||||
Shared tooling is pinned to `be00e5ccd18b68e950c8a08532f2230e7c3d0cba`, the craft-common-actions
|
||||
main commit that merged [#371](https://github.com/storytold/craft-common-actions/pull/371) (the
|
||||
candidate is admitted on the built commit's own Sonar analysis, not main's latest) after
|
||||
[#370](https://github.com/storytold/craft-common-actions/pull/370) (the Windows and macOS nightly
|
||||
registry rows for the 14 apps) and
|
||||
[#369](https://github.com/storytold/craft-common-actions/pull/369) (shared helper checkouts kept out
|
||||
of the app's clean-source check, and macOS on `macos-15`), following
|
||||
[#364](https://github.com/storytold/craft-common-actions/pull/364) (the signer may run on the
|
||||
policy's signer branch) and [#363](https://github.com/storytold/craft-common-actions/pull/363) (the
|
||||
multi-app pipeline, which makes the signer's `app-name` input required and admits any reviewed
|
||||
registry app), with #342 (`a4f6fd51`, policy v3 and the `platforms` input) and #339 (`605d5876`)
|
||||
earlier. Both callers name it in `uses` and `tooling-revision`. A pin is reviewed source
|
||||
availability, not provider, queue, native signing or crypto qualification.
|
||||
Shared tooling is pinned to `605d58766e8f536564da8fc81d3676ac86816dea`, the craft-common-actions
|
||||
main commit that merged [#339](https://github.com/storytold/craft-common-actions/pull/339) (bounded
|
||||
lineage compares and an issue reread at the end of candidate admission) on top of
|
||||
[#342](https://github.com/storytold/craft-common-actions/pull/342) (policy v3, the `platforms` input
|
||||
and the Linux and macOS legs). Both callers name it in `uses` and `tooling-revision`. A pin is reviewed
|
||||
source availability, not provider, queue, native signing or crypto qualification.
|
||||
Existing stable workflows are unchanged.
|
||||
|
||||
**Registry admission.** Craft-common-actions #363 ("run the shared nightly pipeline for any reviewed
|
||||
registry app") is in the pin, and `nightly-apps.json` admits `storytold/wordcraft`. Both callers'
|
||||
`uses`, `tooling-revision` and the policy pins move together to the same reviewed revision. The
|
||||
signer also requires the policy's `platforms` map to equal the app's admitted targets, so
|
||||
WordCraft's `windows-x86_64` and `macos-aarch64` rows need the targets and entrypoints that a
|
||||
craft-common-actions follow-up adds; until it merges, the first signer run stops at admission.
|
||||
**The shared-workflow port is a prerequisite.** At this pin both reusable workflows admit only
|
||||
PhotoCraft: `nightly-unsigned.yml` requires `inputs.app-name == 'photocraft'` and
|
||||
`github.repository == 'storytold/photocraft'` on its build jobs, and `nightly-release.yml` requires the
|
||||
same repository in `validate` and every signing job (its concurrency group is
|
||||
`craft-release-ref-signer-photocraft`). A WordCraft dispatch therefore builds and signs nothing until
|
||||
`storytold/craft-common-actions` admits `storytold/wordcraft`. No dispatch can produce a release before
|
||||
that port, and both callers' `uses`, `tooling-revision` and the policy pins must move to the same
|
||||
reviewed revision together. The port is craft-common-actions #363 ("run the shared nightly pipeline for any
|
||||
reviewed registry app"); until it merges these callers are inert.
|
||||
|
||||
**First runs.** The first runs are manual dispatches in this order: `nightly.yml` on main (only a
|
||||
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `nightly-signer`
|
||||
with that producer run ID and attempt, by a listed manual actor. `nightly-dispatch.yml` only matters
|
||||
once a schedule is approved.
|
||||
|
||||
**Signer branch.** The signer runs on `refs/heads/nightly-signer`, not on the stable `release`
|
||||
branch, so nightly signer files never need a stable release sync. The policy's `release_branch`
|
||||
names it, the signer's guard requires it and the dispatcher targets it. The branch only
|
||||
fast-forwards to reviewed main commits, through the settings script's `advance` (no queued signer
|
||||
run, a trust-closure scan, then the full diff of `.github/` and `packaging/`), and the existing
|
||||
`release` environment trusts it alongside `release`. Its trust closure is all of `.github/` and
|
||||
`packaging/`, including `packaging/env.sh`, which `packaging/macos/import-cert.sh` sources with
|
||||
the Apple keys. On that branch only the pinned `nightly-sign.yml` caller may reach an environment:
|
||||
no app workflow binds one, nothing else calls `nightly-release.yml`, and the only caller of the
|
||||
shared stable `release.yml` is `release.yml`, whose callee must carry the stable-only environment
|
||||
guard. The contract tests check the in-repo part on every main PR; the settings scan also resolves
|
||||
the callee. Stable releases still come only from `refs/heads/release`. History does not carry over
|
||||
a switch between `release` and `nightly-signer`, so the switch happens before the first
|
||||
publication.
|
||||
|
||||
**Registry admission.** The signer requires the protected policy's `platforms` map to equal the
|
||||
run app's admitted targets in craft-common-actions' `nightly-apps.json`, and it refuses rather
|
||||
than sign a subset. WordCraft's row admits `linux-x86_64`; the matching `windows-x86_64` and
|
||||
`macos-aarch64` targets and entrypoints are a craft-common-actions follow-up, and the first
|
||||
signer run stops at admission until they merge.
|
||||
listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `release` with that
|
||||
producer run ID and attempt, by a listed manual actor.
|
||||
|
||||
**Manual actors.** `bflatastic`, `dylanmtaylor`, `echelon`, `FredApps` and `skylartaylor`, in the
|
||||
producer's `manual-actors` and the policy's `manual_actors`. The list mirrors the release-managers
|
||||
team (id 19837241), leaving out `echelon-robot`; update it by PR in both places when the team
|
||||
changes.
|
||||
team (id 19837241), leaving out `echelon-robot`; update it by PR in both places when the team changes.
|
||||
|
||||
**Admission timing.** The candidate check reads the newest CI run on the candidate commit and
|
||||
main's latest finished Sonar analysis, so pick a quiet main, wait for its CI and SonarCloud analysis
|
||||
@@ -75,45 +48,41 @@ push lands a newer analysis.
|
||||
**Platform rows.** The producer caller lists
|
||||
`platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'` on its single job: one producer
|
||||
run builds every listed platform for one all-or-nothing release (one failed or skipped platform stops
|
||||
that night's release), and the signer admits platforms only from the protected policy, so
|
||||
that night's release), and the release-ref signer admits platforms only from the protected policy, so
|
||||
there is no separate Linux or macOS caller job and the signer caller has no platform input.
|
||||
|
||||
## Installed policy values and their sources
|
||||
|
||||
Read on 2026-11-24; re-read anything that may have moved (and fill in `producer_workflow_id` after
|
||||
`nightly.yml` lands on `main`) before `nightly-signer` is advanced to it.
|
||||
`nightly.yml` lands on `main`) before the policy is promoted to `release`.
|
||||
|
||||
| Field | Value | Source |
|
||||
|---|---|---|
|
||||
| `repository_id` | `1408489772` | `gh api repos/storytold/wordcraft --jq .id` |
|
||||
| `producer_workflow_id` | `429734489` | `gh api repos/storytold/wordcraft/actions/workflows/nightly.yml --jq .id` |
|
||||
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `be00e5cc…` (craft-common-actions #371 after #370, #369 and #364) | The callers' pin |
|
||||
| `producer_workflow_id` | `null` (pending `main` registration) | Read via `gh api repos/storytold/wordcraft/actions/workflows/nightly.yml --jq .id` once `nightly.yml` reaches `main` |
|
||||
| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `605d5876…` (craft-common-actions #339) | The callers' pin |
|
||||
| `manual_actors` / `automatic_signer_actors` | the five release managers / `[]` | release-managers team (id 19837241) members; equals the producer caller's `manual-actors` |
|
||||
| `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist |
|
||||
| `platforms` | three rows | Storytold stable signing identities (Windows Authenticode subject, Linux OpenPGP fingerprint, macOS Apple Team ID `DJ6XS33FX8`) |
|
||||
| `candidate_policy.required_workflows` | CI (`ci.yml`, workflow `380135788`), `gate / gate (ubuntu-24.04)` | Workflow list API; always-run main push gate job |
|
||||
| `candidate_policy.sonar` | `storytold` / `storytold_wordcraft`, app `12526` | `sonar-project.properties` |
|
||||
| Sonar conditions | `new_security_rating` accepted (max 5); the other five required | Standard Storytold SonarCloud quality gate |
|
||||
| Sonar `issue_types` / `debt` | `VULNERABILITY`; `[]` | Refresh from SonarCloud before `nightly-signer` is advanced to it |
|
||||
| Sonar `issue_types` / `debt` | `VULNERABILITY`; `[]` | Refresh from SonarCloud before promoting policy to `release` |
|
||||
|
||||
The candidate check refuses whenever main's unresolved vulnerability set differs from `debt`, whether
|
||||
an issue is new or fixed, and whenever a required condition fails or a listed CI job is renamed. Refresh
|
||||
those values in the same reviewed change that `nightly-signer` is then advanced to.
|
||||
those values in the same reviewed change that promotes the policy to `release`.
|
||||
|
||||
## Ownership and interface
|
||||
|
||||
- `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named
|
||||
`WordCraft unsigned nightly`, enabled for manual dispatch by `manual-actors`; no signing secrets
|
||||
may be passed or inherited.
|
||||
- `.github/workflows/nightly-sign.yml`: top-level registration on `nightly-signer`, enabled for manual dispatch,
|
||||
and only ever fast-forwards to reviewed main commits. It rejects wrong repository/event/actual
|
||||
- `.github/workflows/nightly-sign.yml`: top-level release registration, enabled for manual dispatch,
|
||||
and identical on main and release after reviewed promotion. It rejects wrong repository/event/actual
|
||||
branch, including same-name tags. Its constant whole-run concurrency (`wordcraft-nightly-release`,
|
||||
`queue: max`, `cancel-in-progress: false`) is distinct from stable. The caller itself passes no
|
||||
credentials; only the shared callee's sign jobs bind the `release` environment, which trusts `release` and
|
||||
`nightly-signer`.
|
||||
- `.github/workflows/nightly-dispatch.yml`: transport only, never authorization. It is literally
|
||||
off (`false &&`) and forwards only a first-attempt scheduled producer to `nightly-sign.yml` on
|
||||
`nightly-signer`. No schedule is registered until activation is reviewed.
|
||||
credentials; only the shared callee's sign jobs bind the `release` environment.
|
||||
- Shared reusable entrypoints are `nightly-unsigned.yml` and `nightly-release.yml` in
|
||||
`storytold/craft-common-actions`. Both must resolve to a **real reviewed public immutable commit**;
|
||||
the defining workflow SHA and tooling input must match.
|
||||
@@ -132,10 +101,3 @@ those values in the same reviewed change that `nightly-signer` is then advanced
|
||||
identical and equal to the reviewed release managers list, with `automatic_signer_actors` empty.
|
||||
- `.github/nightly-signing-policy.json` matches the `craft-nightly-release-policy/v3` schema,
|
||||
repository identity, platform trust anchors, CI workflow trigger, and `sonar-project.properties`.
|
||||
- The signer guards `refs/heads/nightly-signer`, passes `app-name: wordcraft`, and the policy's
|
||||
`release_branch` names it.
|
||||
- A trust-closure scan reads every workflow: nothing binds an `environment`, only `nightly-sign.yml`
|
||||
calls `nightly-release.yml` (at a full SHA), and the only caller of the shared stable `release.yml`
|
||||
is `release.yml`.
|
||||
- `nightly-dispatch.yml` keeps a literal-off guard, a `workflow_run`-only trigger and a
|
||||
`refs/heads/nightly-signer` request.
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# Implementation plan: closing document windows
|
||||
|
||||
For [the specification](../specs/multi-window-close.md) (#7822, part of #7671). Steps run in order; each is
|
||||
its own PR.
|
||||
|
||||
## 1. craft-libs prerequisites (base `next`)
|
||||
|
||||
- **Hidden root window** (storytold/craft-libs#584, [ADR 0001](../adr/0001-hidden-root-window.md)): the root
|
||||
OS window can close or hide while document windows stay open, and adopts nothing.
|
||||
- **Test kit with any number of windows** (C5-8): `craft_ui_test_kit::windows::Windows` keeps focus and close
|
||||
events per child, so three-window tests can target one child.
|
||||
- Not in scope: the cursor on non-root windows (C5-5, `cursor::image_target`) gets its own issue.
|
||||
|
||||
## 2. Repin craft-libs in WordCraft
|
||||
|
||||
Brings storytold/craft-libs#3290 (one modal stack across windows) and the two changes above. Stage 3 of
|
||||
#7671 does this repin.
|
||||
|
||||
## 3. WordCraft PR (Fixes #7822)
|
||||
|
||||
Code is in `crates/ui-egui/src/` unless noted.
|
||||
|
||||
| Spec rule | Change |
|
||||
|---|---|
|
||||
| 1 | Drop the root taking over another document (`settle_windows` in `windows.rs`); closing the root window closes it through step 1's hidden root. Rewrite `closing_a_window_asks_first_and_the_root_adopts_another`. |
|
||||
| 2 | `other_window_on_document` filters windows by document (C5-6). |
|
||||
| 3, 9 | `app::Closing` records the window that owns the prompt. Pumping, cancelling and closing the prompt use that window's dialog host, not the active one. |
|
||||
| 4, 9 | `run` and `close_decision` check `closing` first: a close while one is running raises the prompt and returns, never calls `begin_closing` again. |
|
||||
| 9 | Clearing `closing.prompt` in `sync_document` and `apply_close_answer` either continues the close or ends it, so no `Hold` is left with no prompt. `apply_close_answer` matches the guard's document, not the active one. |
|
||||
| 5 | Cancelling Save As during a close cancels the close or quit (`continue_after_save`). |
|
||||
| 7 | On one-document-at-a-time hosts, the root close acts on the active entry, not `root_key()`; the fallback layer keeps its close button (C5-1..3). |
|
||||
| 8 | `file.close` takes `save`; `close_refused` names both options. `ui.closeWindow` takes `window` and defaults to `active_viewport()` (`control/handler.rs`). Update `docs/control-protocol.md` and `docs/mcp.md`. |
|
||||
| — | `queue_for_window` repaints the target window (C5-7). |
|
||||
|
||||
Tests: the table in the specification, in `windows/tests.rs` and `documents.rs`.
|
||||
|
||||
Checks: `cargo fmt --all --check`, `cargo clippy -p wordcraft-ui-egui --all-targets -- -D warnings`,
|
||||
`cargo test -p wordcraft-ui-egui`, `cargo xtask layers`, `cargo xtask wasm`.
|
||||
+5
-14
@@ -22,12 +22,6 @@ synced from the release manager's machine. On the release branch, the shared wor
|
||||
macOS and Windows jobs if their signing credentials are missing. Local packaging can still
|
||||
produce unsigned builds with a warning.
|
||||
|
||||
The supervised nightly signer does not sign from `release`: it runs on `refs/heads/nightly-signer`,
|
||||
which only ever fast-forwards to reviewed main commits, and the `release` environment trusts both
|
||||
branches. Everything that can reach it is the trust closure: all of `.github/` and `packaging/`,
|
||||
including `packaging/env.sh`, which `packaging/macos/import-cert.sh` sources with the Apple keys.
|
||||
Stable releases still come only from `refs/heads/release`.
|
||||
|
||||
Local packaging: `packaging/macos/package.sh --arch universal`, `packaging/windows/package.ps1`,
|
||||
`packaging/linux/package.sh` (then `packaging/linux/flatpak-bundle.sh` for the Flatpak), `packaging/web/package.sh`.
|
||||
|
||||
@@ -60,18 +54,15 @@ What the channel is:
|
||||
archives on the `full-ci` label or on dispatch, with no secrets;
|
||||
`packaging/nightly-tests.py` runs the synthetic suites in Packaging lint.
|
||||
|
||||
Every packaged Linux format ships one launcher (`packaging/linux/nightly-launcher.sh`) that starts
|
||||
the binary the channel's way, because a Nightly build refuses to run without a profile:
|
||||
Every Linux format ships one launcher (`packaging/linux/nightly-launcher.sh`) that starts the
|
||||
binary the channel's way, because a Nightly build refuses to run without a profile:
|
||||
`wordcraft --launch-profile nightly-v1 --profile-root "${XDG_DATA_HOME:-$HOME/.local/share}/wordcraft-nightly" -- "$@"`.
|
||||
That launcher is the deb/rpm `/usr/bin/wordcraft-nightly` wrapper (real binary in
|
||||
`/usr/lib/wordcraft-nightly/`), the AppImage `AppRun` (a script, not a symlink, calling
|
||||
`usr/bin/wordcraft`), the Arch `bin/wordcraft-nightly` launcher (real binary in
|
||||
`bin/.wordcraft-nightly/`), the plain tar's `bin/wordcraft` (real binary in `lib/wordcraft-nightly/`), which the Flatpak
|
||||
bundle also installs. The app-owned Nightly tar's `wordcraft` is craft-common-actions' shared
|
||||
template instead (`packaging/linux/nightly-tar-launch.sh`, #363 rendered for this app), starting
|
||||
`wordcraft-bin` beside it with
|
||||
`--profile-root ${XDG_DATA_HOME:-$HOME/.local/share}/ai.storyteller.wordcraft.nightly`, and asking a
|
||||
bare `--version`/`-V` in the Launcher's form. `XDG_DATA_HOME` keeps the profile on the app's own data directory inside the
|
||||
`bin/.wordcraft-nightly/`), the app-owned Nightly tar's `wordcraft` (real binary `wordcraft-bin`)
|
||||
and the plain tar's `bin/wordcraft` (real binary in `lib/wordcraft-nightly/`), which the Flatpak
|
||||
bundle also installs. `XDG_DATA_HOME` keeps the profile on the app's own data directory inside the
|
||||
Flatpak sandbox (`~/.var/app/ai.storyteller.wordcraft.nightly/data/wordcraft-nightly`), which
|
||||
persists; the sandbox's home is discarded. Redirecting `XDG_*` alone is refused: the build's root
|
||||
validator derives the stable boundary from it, so the profile would sit inside it. The launcher
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user