diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7df74a9b27..ffcc6efa00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,8 +36,10 @@ jobs: - name: Verify published recipe fragments run: python3 script/check-ai docs - uses: oven-sh/setup-bun@v2 - - name: gpui-pre is pinned exactly - run: bun script/check-gpui-pin.ts + - name: GPUI CE is pinned exactly + run: | + bun test script/check-gpui-pin.test.ts + bun script/check-gpui-pin.ts - uses: taiki-e/install-action@v2 with: tool: cargo-machete@0.9.1 @@ -56,7 +58,7 @@ jobs: # Lints every member and, as a side effect, type-checks the example # crates that the `test` job leaves out. - name: Lint - run: cargo clippy --workspace --exclude gpui-shell --locked -- --deny warnings + run: cargo clippy --workspace --locked -- --deny warnings no-default-features: name: No default features @@ -71,7 +73,7 @@ jobs: - name: Install system dependencies run: script/bootstrap - name: Check without default features (tree-sitter disabled) - run: cargo check -p gpui-component --no-default-features --locked + run: cargo check -p gpui_ce_components --no-default-features --locked # Control callback, legacy alias, and Form contract tests on the same # feature set, so they reuse the build above. - name: Test without default features @@ -124,13 +126,13 @@ jobs: # `crates/kit/tests`. - name: Test run: >- - cargo test --workspace --exclude gpui-shell + cargo test --workspace --features gpui-component-story/test-support --locked $TEST_EXCLUDES - name: Doc tests if: ${{ matrix.run_on == 'macos-latest' }} run: >- - cargo test --workspace --exclude gpui-shell + cargo test --workspace --features gpui-component-story/test-support --locked $TEST_EXCLUDES --doc # `crates/kit/tests/rendering.rs` needs a real Metal device and is opted @@ -139,98 +141,6 @@ jobs: - name: Metal UI rendering tests if: ${{ matrix.run_on == 'macos-latest' }} run: >- - cargo test --workspace --exclude gpui-shell + cargo test --workspace --features gpui-component-story/test-support --locked $TEST_EXCLUDES --test rendering - - gpui-shell-core: - name: GPUI Shell Core - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy - cache-save-if: ${{ github.ref == 'refs/heads/main' }} - cache-shared-key: gpui-shell-release - # Replaces the system `ld` on Linux and is a no-op elsewhere. - - uses: rui314/setup-mold@v1 - - name: Install system dependencies - run: script/bootstrap - - name: Test runtime core without standard-library integration cases - run: | - cargo test -p gpui-shell --release --lib -- \ - --skip tests::standard_runtime \ - --skip tests::network \ - --skip tests::fs \ - --skip tests::process \ - --skip tests::benchmark - cargo test -p gpui-shell --release tests::benchmark - cargo test -p gpui-shell --release --doc - - name: Lint GPUI Shell - run: cargo clippy -p gpui-shell --all-targets -- -D warnings - - gpui-component-shell: - name: GPUI Component Shell - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy - cache-save-if: ${{ github.ref == 'refs/heads/main' }} - - uses: actions/setup-node@v4 - with: - node-version: 22 - # Replaces the system `ld` on Linux and is a no-op elsewhere. - - uses: rui314/setup-mold@v1 - - name: Install system dependencies - run: script/bootstrap - - name: Test component bindings - run: cargo test -p gpui-component-shell --all-targets - - name: Verify generated TypeScript contracts - run: | - npm --prefix crates/component-shell/tests/types ci - npm --prefix crates/component-shell/tests/types test - - name: Lint component bindings - run: cargo clippy -p gpui-component-shell --all-targets -- -D warnings - # The inventory test proves every public component is registered or - # explicitly deferred; this proves the JavaScript gallery covers what the - # inventory claims. Without it the two drift silently. - - name: Verify story coverage against the component inventory - run: node examples/js_story/fixtures/verify-coverage.mjs - - gpui-shell-standard-runtime: - name: GPUI Shell Standard Runtime (${{ matrix.target }}) - strategy: - fail-fast: false - matrix: - include: - - target: aarch64-apple-darwin - run_on: macos-latest - - target: x86_64-linux-gnu - run_on: ubuntu-latest - - target: x86_64-windows-msvc - run_on: windows-latest - runs-on: ${{ matrix.run_on }} - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - cache-save-if: ${{ github.ref == 'refs/heads/main' }} - cache-shared-key: gpui-shell-release - # Replaces the system `ld` on Linux and is a no-op elsewhere. - - uses: rui314/setup-mold@v1 - - name: Install system dependencies - if: ${{ matrix.run_on != 'windows-latest' }} - run: script/bootstrap - - name: Test LLRT module integration - run: | - cargo test -p gpui-shell --release tests::standard_runtime - cargo test -p gpui-shell --release tests::fs - cargo test -p gpui-shell --release tests::process - cargo test -p gpui-shell --release tests::network - cargo test -p gpui-shell --release tests::render - cargo test -p gpui-shell --release tests::snapshot - cargo test -p gpui-shell --release tests::host_api - cargo test -p gpui-shell --release tests::http_request diff --git a/Cargo.lock b/Cargo.lock index 39c0620630..dce4960959 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,18 @@ dependencies = [ "uuid", ] +[[package]] +name = "accesskit_android" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e27dedd5e1932e1f52fedcde681bc2ae4213df53bad5b295103aa36b1d0ffb6" +dependencies = [ + "accesskit", + "accesskit_consumer", + "jni 0.21.1", + "log", +] + [[package]] name = "accesskit_atspi_common" version = "0.19.1" @@ -19,7 +31,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "023da0e5097f46df7092d5280b02efb9bbf8d93298daeced42652463e357d636" dependencies = [ "accesskit", - "accesskit_consumer 0.38.0", + "accesskit_consumer", "atspi-common", "phf 0.13.1", "serde", @@ -28,22 +40,26 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950720ce064757a1b629caad3a408e8d2c63bb01f29b8a3ff8daa331053ffeb" +checksum = "5d10a236f96f87d70732e44520046785431ef01d5bcd6b041317bfadd2f88245" dependencies = [ "accesskit", "hashbrown 0.16.1", ] [[package]] -name = "accesskit_consumer" -version = "0.38.0" +name = "accesskit_ios" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d10a236f96f87d70732e44520046785431ef01d5bcd6b041317bfadd2f88245" +checksum = "750c4e9f6ce888dfe8a10c0f1b5ceb646a7854fd46579d74919219d1bb314083" dependencies = [ "accesskit", + "accesskit_consumer", "hashbrown 0.16.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit 0.2.2", ] [[package]] @@ -53,7 +69,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce02dc63b43f0c9296af9ac946312a2dc8814427d7a64d2d600971dac55b6076" dependencies = [ "accesskit", - "accesskit_consumer 0.38.0", + "accesskit_consumer", "hashbrown 0.16.1", "objc2 0.5.2", "objc2-app-kit 0.2.2", @@ -80,12 +96,12 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.33.1" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e93ac7bf50b964f1cbb75f741629a4e950571baa1ef1274457ab5a80d9bcc2" +checksum = "106c2b961215864d1c2e703ee63269c25c4e80a577ffb2c1017b9c17dcdf83a1" dependencies = [ "accesskit", - "accesskit_consumer 0.37.0", + "accesskit_consumer", "hashbrown 0.16.1", "static_assertions", "windows 0.62.2", @@ -165,6 +181,48 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +[[package]] +name = "android-activity" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags 2.13.2", + "cc", + "jni 0.22.4", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror 2.0.21", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "android_log-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" + +[[package]] +name = "android_logger" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb4e440d04be07da1f1bf44fb4495ebd58669372fe0cffa6e48595ac5bd88a3" +dependencies = [ + "android_log-sys", + "env_filter", + "log", +] + [[package]] name = "android_system_properties" version = "0.1.6" @@ -188,7 +246,7 @@ checksum = "f211a51805bc641f3ad5b7664c77d2547af685cc33b4cd8d31964027a46f13f1" dependencies = [ "anstyle", "memchr", - "unicode-width", + "unicode-width 0.2.2", ] [[package]] @@ -221,15 +279,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "ar_archive_writer" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73cd58deff2140a0a8eae87e417bd01db68a33e148aa93d1e8cd837e55e312b6" -dependencies = [ - "object 0.39.1", -] - [[package]] name = "arbitrary" version = "1.4.2" @@ -617,7 +666,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom 8.0.0", + "nom", "num-rational", "v_frame", ] @@ -641,7 +690,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide 0.8.9", - "object 0.37.3", + "object", "rustc-demangle", "windows-link 0.2.1", ] @@ -673,26 +722,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bindgen" -version = "0.71.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" -dependencies = [ - "bitflags 2.13.2", - "cexpr", - "clang-sys", - "itertools 0.13.0", - "log", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash 2.1.3", - "shlex 1.3.0", - "syn 2.0.119", -] - [[package]] name = "bit-set" version = "0.8.0" @@ -969,24 +998,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "cbindgen" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadd868a2ce9ca38de7eeafdcec9c7065ef89b42b32f0839278d55f35c54d1ff" -dependencies = [ - "heck 0.4.1", - "indexmap", - "log", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn 2.0.119", - "tempfile", - "toml 0.8.23", -] - [[package]] name = "cc" version = "1.2.67" @@ -996,7 +1007,7 @@ dependencies = [ "find-msvc-tools", "jobserver", "libc", - "shlex 2.0.1", + "shlex", ] [[package]] @@ -1005,15 +1016,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom 7.1.3", -] - [[package]] name = "cfg-expr" version = "0.15.8" @@ -1036,15 +1038,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" -[[package]] -name = "cgl" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" -dependencies = [ - "libc", -] - [[package]] name = "chacha20" version = "0.10.2" @@ -1108,17 +1101,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "clang-sys" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "4.6.7" @@ -1204,6 +1186,16 @@ dependencies = [ "objc", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width 0.1.14", +] + [[package]] name = "codespan-reporting" version = "0.13.1" @@ -1212,7 +1204,7 @@ checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" dependencies = [ "serde", "termcolor", - "unicode-width", + "unicode-width 0.2.2", ] [[package]] @@ -1419,19 +1411,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-graphics2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4416167a69126e617f8d0a214af0e3c1dbdeffcb100ddf72dcd1a1ac9893c146" -dependencies = [ - "bitflags 2.13.2", - "block", - "cfg-if", - "core-foundation 0.10.0", - "libc", -] - [[package]] name = "core-text" version = "21.0.0" @@ -1444,59 +1423,12 @@ dependencies = [ "libc", ] -[[package]] -name = "core-video" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "139679cc63eb9504bdbe37e37874b0247136177655f0008588781e90863afa62" -dependencies = [ - "block", - "core-foundation 0.10.0", - "core-graphics2", - "io-surface", - "libc", - "metal", -] - [[package]] name = "core_detect" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" -[[package]] -name = "core_maths" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" -dependencies = [ - "libm", -] - -[[package]] -name = "cosmic-text" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be17b688510d934ce13f48a2beba700e11583e281e0fda99c22bb256a14eda73" -dependencies = [ - "bitflags 2.13.2", - "fontdb 0.23.0", - "harfrust 0.5.2", - "linebender_resource_handle", - "log", - "rangemap", - "rustc-hash 2.1.3", - "self_cell", - "skrifa 0.40.0", - "smol_str", - "swash", - "sys-locale", - "unicode-bidi", - "unicode-linebreak", - "unicode-script", - "unicode-segmentation", -] - [[package]] name = "cpufeatures" version = "0.2.17" @@ -1701,8 +1633,18 @@ version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.20.11", + "darling_macro 0.20.11", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core 0.21.3", + "darling_macro 0.21.3", ] [[package]] @@ -1718,13 +1660,38 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.119", +] + [[package]] name = "darling_macro" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ - "darling_core", + "darling_core 0.20.11", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core 0.21.3", "quote", "syn 2.0.119", ] @@ -1790,6 +1757,18 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "derive_setters" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e6f6fa1f03c14ae082120b84b3c7fbd7b8588d924cf2d7c3daf9afd49df8b9" +dependencies = [ + "darling 0.21.3", + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "deunicode" version = "1.6.2" @@ -1888,7 +1867,6 @@ checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", - "libc", "objc2 0.6.4", ] @@ -1954,7 +1932,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cac124e13ae9aa56acc4241f8c8207501d93afdd8d8e62f0c1f2e12f6508c65" dependencies = [ - "darling", + "darling 0.20.11", "proc-macro2", "quote", "syn 2.0.119", @@ -2085,6 +2063,16 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "env_filter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" +dependencies = [ + "log", + "regex", +] + [[package]] name = "equator" version = "0.4.2" @@ -2254,7 +2242,6 @@ dependencies = [ "miniz_oxide 0.8.9", "num-complex", "pulp", - "rayon-core", "smallvec", "zune-inflate", ] @@ -2286,6 +2273,9 @@ name = "fastrand" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" +dependencies = [ + "getrandom 0.4.3", +] [[package]] name = "fax" @@ -2385,6 +2375,18 @@ dependencies = [ "spin 0.9.9", ] +[[package]] +name = "flume" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" +dependencies = [ + "fastrand", + "futures-core", + "futures-sink", + "spin 0.9.9", +] + [[package]] name = "fnv" version = "1.0.7" @@ -2411,15 +2413,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" -[[package]] -name = "font-types" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b38ad915f6dadd993ced50848a8291a543bd41ca62bc10740d5e64e2ab4cfd7" -dependencies = [ - "bytemuck", -] - [[package]] name = "font-types" version = "0.12.5" @@ -2440,29 +2433,37 @@ dependencies = [ [[package]] name = "fontdb" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" +checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f" dependencies = [ "fontconfig-parser", "log", "memmap2", "slotmap", "tinyvec", - "ttf-parser", ] [[package]] -name = "fontdb" -version = "0.24.0" +name = "fontique" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2660c5e9157bf76d2db1294e4a9feba604ef610819a3b591088d0d8392a3290f" +checksum = "6688bc1294fe7117d788937b6c53480169b29c566954af490830d4c09da9516a" dependencies = [ - "fontconfig-parser", - "log", + "hashbrown 0.17.1", + "linebender_resource_handle", "memmap2", - "slotmap", - "tinyvec", + "objc2 0.6.4", + "objc2-core-foundation", + "objc2-core-text", + "objc2-foundation 0.3.2", + "parlance", + "read-fonts", + "roxmltree 0.21.1", + "smallvec", + "windows 0.62.2", + "windows-core 0.62.2", + "yeslogic-fontconfig-sys", ] [[package]] @@ -2878,6 +2879,12 @@ dependencies = [ "xml-rs", ] +[[package]] +name = "glam" +version = "0.30.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9" + [[package]] name = "glib" version = "0.18.5" @@ -3055,58 +3062,48 @@ dependencies = [ [[package]] name = "gpui-ce" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0af79c6659e0fea67773cfbd751fc5c8e51be00139827f365d7d1237a468a4d" +checksum = "7691a905fc9b283228c14b9b5ca93d002be88e203aa5878746152210b33c8dbf" dependencies = [ "accesskit", "anyhow", "async-channel", "async-task", "backtrace", - "bindgen", "bitflags 2.13.2", - "block", - "cbindgen", "chrono", - "cocoa 0.26.0", - "cocoa-foundation 0.2.0", - "core-foundation 0.10.0", - "core-foundation-sys", - "core-graphics 0.24.0", - "core-text", - "core-video", "ctor", "derive_more 2.1.1", + "derive_setters", "embed-resource", "etagere", - "foreign-types", "futures", "futures-concurrency", "getrandom 0.3.4", "gpui_ce_collections", "gpui_ce_macros", - "gpui_ce_media", "gpui_ce_refineable", "gpui_ce_scheduler", "gpui_ce_shared_string", "gpui_ce_sum_tree", "gpui_ce_util", + "hdrhistogram", "heapless", "http", "image", "inventory", "itertools 0.14.0", + "libc", "log", "lyon", - "mach2", - "metal", "num_cpus", - "objc", - "palette", + "objc2-core-foundation", + "objc2-core-video", + "palette", "parking", "parking_lot", - "pathfinder_geometry", + "phf 0.13.1", "pin-project", "pollster 0.4.0", "postage", @@ -3120,23 +3117,24 @@ dependencies = [ "seahash", "serde", "serde_json", - "skrifa 0.46.2", + "skrifa", "slotmap", "smallvec", "spin 0.10.1", - "stacksafe", - "strum", + "strum 0.28.0", "taffy", "thiserror 2.0.21", + "tracing", + "ttf-parser", + "unicode-bidi", "unicode-segmentation", "url", "usvg", "uuid", "waker-fn", "web-time", + "windows 0.61.3", "windows 0.62.2", - "zed-font-kit", - "zed-scap", ] [[package]] @@ -3189,11 +3187,55 @@ dependencies = [ "gpui_ce_kit", ] +[[package]] +name = "gpui_ce_apple" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa083d7db19daf89b46955f73b86712790f5b29658e83636344f12ec218031e2" +dependencies = [ + "anyhow", + "async-task", + "block2 0.6.2", + "core-foundation 0.10.0", + "core-foundation-sys", + "core-graphics 0.24.0", + "core-text", + "derive_more 2.1.1", + "dispatch2", + "etagere", + "foreign-types", + "futures", + "gpui-ce", + "gpui_ce_collections", + "gpui_ce_parley", + "gpui_ce_render", + "gpui_ce_util", + "image", + "libc", + "log", + "mach2", + "metal", + "objc2 0.6.4", + "objc2-core-foundation", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-security", + "parking_lot", + "pathfinder_geometry", + "skrifa", + "smallvec", + "thiserror 2.0.21", + "wgsl-rs", + "zed-font-kit", +] + [[package]] name = "gpui_ce_collections" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f707750f990017957611d0909c1a53c6bd7b7c6cfb2fd8095141c99afa2a49" +checksum = "9a50a4b92bb986496158b619d9b0bc730dc5dcdb27f6cbc84359227e0b70894b" dependencies = [ "gpui_ce_util", "indexmap", @@ -3213,13 +3255,12 @@ dependencies = [ "gpui_ce_components_base", "gpui_ce_components_macros", "gpui_ce_macros", - "html5ever 0.27.0", + "gpui_ce_parley", "indoc", "itertools 0.13.0", "log", "lsp-types 0.97.0", "markdown", - "markup5ever_rcdom", "notify", "num-traits", "objc2 0.6.4", @@ -3309,6 +3350,7 @@ dependencies = [ "futures", "gpui-ce", "gpui_ce_macros", + "gpui_ce_parley", "gpui_ce_platform", "html5ever 0.27.0", "indoc", @@ -3330,7 +3372,6 @@ dependencies = [ "serde_json", "smallvec", "smol", - "syntect", "tracing", "unicode-segmentation", "web-time", @@ -3375,15 +3416,38 @@ dependencies = [ [[package]] name = "gpui_ce_derive_refineable" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a399d81b69ae3cec57ab87c3e2f2a415b443481195dd091256abca771c377d2b" +checksum = "f2093181860ea347ba22f9645aac164becd52ce5ac157a1f9ccce5a07b01cea9" dependencies = [ "proc-macro2", "quote", "syn 2.0.119", ] +[[package]] +name = "gpui_ce_ios" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380935ab92414a1c1c054e3a217b032a0012d1128c662e94005785cfd8cf7086" +dependencies = [ + "accesskit_ios", + "anyhow", + "block2 0.6.2", + "futures", + "gpui-ce", + "gpui_ce_apple", + "log", + "objc2 0.6.4", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", + "objc2-ui-kit 0.3.2", + "parking_lot", + "raw-window-handle", + "uuid", +] + [[package]] name = "gpui_ce_kit" version = "0.2.0" @@ -3400,9 +3464,9 @@ dependencies = [ [[package]] name = "gpui_ce_linux" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab947c84c6460f6431c99bd6a8b0954591bfa511c0006515ecc3897e7a903c84" +checksum = "e471c10455ec436ba6d9a41f2e08db60576283ccd1f51a844e4d72810a297e28" dependencies = [ "accesskit", "accesskit_unix", @@ -3417,24 +3481,22 @@ dependencies = [ "futures", "gpui-ce", "gpui_ce_collections", + "gpui_ce_parley", "gpui_ce_util", "gpui_ce_wgpu", "image", "itertools 0.14.0", "libc", "log", + "memfd", "notify-rust", "oo7", "open", "parking_lot", - "pathfinder_geometry", - "pollster 0.4.0", - "profiling", "raw-window-handle", "smallvec", "smol", - "strum", - "swash", + "strum 0.28.0", "url", "uuid", "wayland-backend", @@ -3452,60 +3514,58 @@ dependencies = [ [[package]] name = "gpui_ce_macos" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af0fe6b615e579ce0180198417815547c1c9ae654dc1e2382299f0c3f3564f79" +checksum = "3956b3383e204f0455aea6129da9676c4ffbf09351bf685df5ec8c2bb8572d36" dependencies = [ "accesskit", "accesskit_macos", "anyhow", - "async-task", - "block", "block2 0.6.2", - "cbindgen", "cocoa 0.26.0", "core-foundation 0.10.0", "core-foundation-sys", "core-graphics 0.24.0", "core-text", - "core-video", "ctor", - "derive_more 2.1.1", "dispatch2", "etagere", "foreign-types", "futures", "gpui-ce", + "gpui_ce_apple", "gpui_ce_collections", - "gpui_ce_media", + "gpui_ce_parley", + "gpui_ce_scheduler", "gpui_ce_util", + "gpui_ce_wgpu", "image", "itertools 0.14.0", - "libc", "log", - "mach2", "metal", "objc", "objc2 0.6.4", "objc2-app-kit 0.3.2", + "objc2-core-video", "objc2-foundation 0.3.2", - "objc2-user-notifications", + "objc2-user-notifications 0.3.2", "palette", "parking_lot", - "pathfinder_geometry", "raw-window-handle", "semver", + "skrifa", "smallvec", - "strum", + "strum 0.28.0", + "url", "uuid", "zed-font-kit", ] [[package]] name = "gpui_ce_macros" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b8dc0ee902563235e47809c403e1d59b1beb53a7dc916e66f2f7864ac41483" +checksum = "3b28e8c6c9f75c3cc2c3d07918572ff9d8f78bd61a72b1a545bea88daefbb978" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3514,65 +3574,114 @@ dependencies = [ ] [[package]] -name = "gpui_ce_media" -version = "0.2.2" +name = "gpui_ce_mobile" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c67e75d8c59ca24f95df41dd102aa7b4c93d306046ec0f2aa15c7f16022283c" +checksum = "7a1d3851dba337d09aa5e0a0ba1f0a68459f87b0948280addf2544bab3c869c2" dependencies = [ + "accesskit", + "accesskit_android", + "android-activity", + "android_logger", "anyhow", - "bindgen", - "core-foundation 0.10.0", - "core-video", - "ctor", - "foreign-types", - "metal", - "objc", + "futures", + "gpui-ce", + "gpui_ce_parley", + "gpui_ce_wgpu", + "jni 0.22.4", + "libc", + "log", + "memmap2", + "ndk", + "ndk-context", + "ndk-sys", + "parking_lot", + "raw-window-handle", + "rustc-hash 2.1.3", + "smallvec", + "uuid", +] + +[[package]] +name = "gpui_ce_parley" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2254b91da65d1e8823708275347e88a83141dbb9cb58d3ab0736168ea4d9673c" +dependencies = [ + "anyhow", + "fontique", + "gpui-ce", + "parking_lot", + "parley", + "skrifa", + "swash", + "unicode-segmentation", ] [[package]] name = "gpui_ce_platform" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42fc3ad60af3e375b224e701a3e5db31f4def8e3a1099899882e937a9e9c12e9" +checksum = "9e195209c604737d67a1d9ae56345209cd1a6d74abe45f8f3f16c31e278440b3" dependencies = [ + "anyhow", "console_error_panic_hook", "gpui-ce", + "gpui_ce_apple", + "gpui_ce_ios", "gpui_ce_linux", "gpui_ce_macos", + "gpui_ce_mobile", "gpui_ce_web", + "gpui_ce_wgpu", "gpui_ce_windows", ] [[package]] name = "gpui_ce_refineable" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "536a08dd1678cede87b6f91d58fc7dcfcb37c4d46075954d55db0b120b28dc28" +checksum = "bc760d0665a16cd3058a4076a02ed7b7422102bac4c8551ec13943599f586a98" dependencies = [ "gpui_ce_derive_refineable", ] +[[package]] +name = "gpui_ce_render" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b326f0a39d3ca9c3e40efa3156bf4d371158e1c2281258bb6dafd97a6f321ca" +dependencies = [ + "gpui-ce", + "naga 24.0.0", + "naga 29.0.4", + "smallvec", + "wgsl-rs", + "windows 0.62.2", +] + [[package]] name = "gpui_ce_scheduler" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ba0e1b5482fa9bc8ee71117c981e4d9afc5511624bedd9454040c95aca26091" +checksum = "09be7fb293688e06a2ea871715fbb57fdb9e17f88d8629ed53c9ee1a60e69515" dependencies = [ "async-task", "backtrace", "chrono", - "flume", + "flume 0.12.0", "futures", "parking_lot", "rand 0.9.5", + "wasm_thread", "web-time", ] [[package]] name = "gpui_ce_shared_string" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadabf028fc7322e74aa5d823defca7441d335cfd3592fb0ba3af1b0532e39da" +checksum = "5310ad372bd963a7fb527fda31bfb75e6ed86b7f44e2e076ced47d0e28d655eb" dependencies = [ "schemars", "serde", @@ -3581,9 +3690,9 @@ dependencies = [ [[package]] name = "gpui_ce_sum_tree" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5462a23e7ff0d4ca09f585b6de33d9ef6c302d57106fac5f6a3cc35bdf9e8f" +checksum = "56017a4f9a24251a1ef38715b1e9a415be7066410a7e6002bb3267544740736f" dependencies = [ "heapless", "log", @@ -3593,9 +3702,9 @@ dependencies = [ [[package]] name = "gpui_ce_util" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3214d3b3693a92cc8caf5547cedeb2f0bd5498be5475261e48dd0482bf9514a0" +checksum = "89433e8e93ee8684fc076dab4b8fc1085ca2fadbe4f42c28311940afae61ef1d" dependencies = [ "anyhow", "log", @@ -3604,14 +3713,16 @@ dependencies = [ [[package]] name = "gpui_ce_web" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac03c593fc6ee1957a7a55594b506ff6218662ea4a20523407252c2b5d570c01" +checksum = "f887b0a426caf694fcc7ef204c5bf344236b8ff6bddf354e35426506073da29c" dependencies = [ "anyhow", "console_error_panic_hook", "futures", "gpui-ce", + "gpui_ce_parley", + "gpui_ce_scheduler", "gpui_ce_wgpu", "http", "js-sys", @@ -3621,46 +3732,51 @@ dependencies = [ "uuid", "wasm-bindgen", "wasm-bindgen-futures", + "wasm_thread", "web-sys", "web-time", ] [[package]] name = "gpui_ce_wgpu" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d986e05a9106ac0ecf048f9b5a4a6b030d6b538836dc3ad0a0686da01d4a830" +checksum = "d3168d4877f63a3e4a36dce067dd3c19d6df5604be3ac0d357da2aedc9e44db0" dependencies = [ "anyhow", - "bytemuck", - "cosmic-text", "etagere", "gpui-ce", "gpui_ce_collections", + "gpui_ce_render", "gpui_ce_util", - "itertools 0.14.0", + "image", "js-sys", "log", + "metal", + "objc2 0.6.4", + "objc2-core-foundation", + "objc2-core-video", + "objc2-io-surface", + "objc2-metal 0.3.2", "parking_lot", "pollster 0.4.0", "profiling", "raw-window-handle", "smallvec", - "swash", - "unicode-bidi", - "unicode-segmentation", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", "wgpu", - "zed-font-kit", + "wgsl-rs", + "windows 0.61.3", + "windows 0.62.2", ] [[package]] name = "gpui_ce_windows" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063326fe043ef3f51b0b36877e8d9f9af0e20d6dfe51efcb275a3cd380128e02" +checksum = "2bd1d66220d98bb604541c74c4922ca27576008d03e6266b241d91bc0e17e6f0" dependencies = [ "accesskit", "accesskit_windows", @@ -3670,6 +3786,9 @@ dependencies = [ "futures", "gpui-ce", "gpui_ce_collections", + "gpui_ce_parley", + "gpui_ce_render", + "gpui_ce_scheduler", "gpui_ce_util", "image", "itertools 0.14.0", @@ -3679,6 +3798,8 @@ dependencies = [ "raw-window-handle", "smallvec", "uuid", + "wgsl-rs", + "windows 0.61.3", "windows 0.62.2", "windows-core 0.62.2", "windows-numerics 0.3.1", @@ -3695,12 +3816,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "grid" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40ca9252762c466af32d0b1002e91e4e1bc5398f77455e55474deb466355ff5" - [[package]] name = "gtk" version = "0.18.2" @@ -3784,19 +3899,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "harfrust" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9da2e5ae821f6e96664977bf974d6d6a2d6682f9ccee23e62ec1d134246845f9" -dependencies = [ - "bitflags 2.13.2", - "bytemuck", - "core_maths", - "read-fonts 0.37.0", - "smallvec", -] - [[package]] name = "harfrust" version = "0.12.0" @@ -3805,7 +3907,7 @@ checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" dependencies = [ "bitflags 2.13.2", "bytemuck", - "read-fonts 0.41.0", + "read-fonts", "smallvec", ] @@ -3849,6 +3951,23 @@ name = "hashbrown" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash 0.2.0", +] + +[[package]] +name = "hdrhistogram" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49d1053f4708f0af3cf9fc5bffc7e68a914a3c45becb231c80068c9c3f78bea" +dependencies = [ + "base64 0.22.1", + "byteorder", + "crossbeam-channel", + "flate2", + "nom", + "num-traits", +] [[package]] name = "heapless" @@ -4106,11 +4225,32 @@ checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb" dependencies = [ "displaydoc", "litemap", + "serde", "tinystr", "writeable", "zerovec", ] +[[package]] +name = "icu_locale_fallback" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "251af8e57c9400e3eb58242fe5b8b1152b2a64fdf4cf632f923c38ccee6f2fa9" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "decf2a22ec8fa68f1a0c1129a3f8583f8f8bc24e8b9ccbe98ead99f62a4dc3a8" + [[package]] name = "icu_normalizer" version = "2.3.0" @@ -4160,6 +4300,8 @@ checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73" dependencies = [ "displaydoc", "icu_locale_core", + "serde", + "stable_deref_trait", "writeable", "yoke", "zerofrom", @@ -4167,6 +4309,28 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_segmenter" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d07aafccd67af15d02512a6adf5896fbc5ed00f2e99b471d2efa14016db3db" +dependencies = [ + "icu_collections", + "icu_locale_fallback", + "icu_provider", + "icu_segmenter_data", + "potential_utf", + "smallvec", + "utf8_iter", + "zerovec", +] + +[[package]] +name = "icu_segmenter_data" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae293c039020f9ec10710af98d29ce6aa2051486638b49c9a6409f3b4a9e98ad" + [[package]] name = "ident_case" version = "1.0.1" @@ -4227,7 +4391,6 @@ dependencies = [ "png", "qoi", "ravif", - "rayon", "rgb", "tiff", "zune-core", @@ -4335,18 +4498,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "io-surface" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "554b8c5d64ec09a3a520fe58e4d48a73e00ff32899cdcbe32a4877afd4968b8e" -dependencies = [ - "cgl", - "core-foundation 0.10.0", - "core-foundation-sys", - "leaky-cow", -] - [[package]] name = "ipnet" version = "2.12.2" @@ -4464,6 +4615,36 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link 0.2.1", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + [[package]] name = "jni-sys" version = "0.3.1" @@ -4594,13 +4775,13 @@ dependencies = [ "dirs 6.0.0", "dpi", "dunce", - "flume", + "flume 0.11.1", "gdkx11", "gtk", "html5ever 0.29.1", "http", "javascriptcore-rs", - "jni", + "jni 0.21.1", "kuchikiki", "libc", "ndk", @@ -4608,7 +4789,7 @@ dependencies = [ "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-foundation 0.3.2", - "objc2-ui-kit", + "objc2-ui-kit 0.3.2", "objc2-web-kit", "once_cell", "percent-encoding", @@ -4627,21 +4808,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "leak" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd100e01f1154f2908dfa7d02219aeab25d0b9c7fa955164192e3245255a0c73" - -[[package]] -name = "leaky-cow" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a8225d44241fd324a8af2806ba635fc7c8a7e9a7de4d5cf3ef54e71f5926fc" -dependencies = [ - "leak", -] - [[package]] name = "lebe" version = "0.5.3" @@ -4865,12 +5031,9 @@ dependencies = [ [[package]] name = "mach2" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1b95cd5421ec55b445b5ae102f5ea0e768de1f82bd3001e11f426c269c3aea" -dependencies = [ - "libc", -] +checksum = "dae608c151f68243f2b000364e1f7b186d9c29845f7d2d85bd31b9ad77ad552b" [[package]] name = "malloc_buf" @@ -4971,7 +5134,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" dependencies = [ "cfg-if", - "rayon", ] [[package]] @@ -4990,6 +5152,15 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "memfd" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57804b2c9b69967f1536a56f86297e367a33b19e98852ed624b84551cdbc0d90" +dependencies = [ + "rustix 1.1.5", +] + [[package]] name = "memmap2" version = "0.9.11" @@ -5039,12 +5210,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -5093,6 +5258,27 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" +[[package]] +name = "naga" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e380993072e52eef724eddfcde0ed013b0c023c3f0417336ed041aa9f076994e" +dependencies = [ + "arrayvec", + "bit-set 0.8.0", + "bitflags 2.13.2", + "cfg_aliases", + "codespan-reporting 0.11.1", + "hexf-parse", + "indexmap", + "log", + "rustc-hash 1.1.0", + "strum 0.26.3", + "termcolor", + "thiserror 2.0.21", + "unicode-xid", +] + [[package]] name = "naga" version = "29.0.4" @@ -5104,7 +5290,7 @@ dependencies = [ "bitflags 2.13.2", "cfg-if", "cfg_aliases", - "codespan-reporting", + "codespan-reporting 0.13.1", "half", "hashbrown 0.16.1", "hexf-parse", @@ -5143,6 +5329,12 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + [[package]] name = "ndk-sys" version = "0.6.0+11769913" @@ -5179,16 +5371,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "nom" version = "8.0.0" @@ -5476,7 +5658,7 @@ dependencies = [ "block2 0.6.2", "libc", "objc2 0.6.4", - "objc2-cloud-kit", + "objc2-cloud-kit 0.3.2", "objc2-core-data 0.3.2", "objc2-core-foundation", "objc2-core-graphics", @@ -5487,6 +5669,19 @@ dependencies = [ "objc2-quartz-core 0.3.2", ] +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-core-location 0.2.2", + "objc2-foundation 0.2.2", +] + [[package]] name = "objc2-cloud-kit" version = "0.3.2" @@ -5498,6 +5693,17 @@ dependencies = [ "objc2-foundation 0.3.2", ] +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + [[package]] name = "objc2-core-data" version = "0.2.2" @@ -5528,7 +5734,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", + "libc", "objc2 0.6.4", ] @@ -5567,6 +5775,18 @@ dependencies = [ "objc2-foundation 0.3.2", ] +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-contacts", + "objc2-foundation 0.2.2", +] + [[package]] name = "objc2-core-location" version = "0.3.2" @@ -5600,6 +5820,7 @@ dependencies = [ "objc2-core-foundation", "objc2-core-graphics", "objc2-io-surface", + "objc2-metal 0.3.2", ] [[package]] @@ -5663,6 +5884,18 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + [[package]] name = "objc2-metal" version = "0.2.2" @@ -5683,46 +5916,114 @@ checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", + "dispatch2", + "objc2 0.6.4", + "objc2-core-foundation", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", + "objc2-metal 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.13.2", "objc2 0.6.4", + "objc2-core-foundation", "objc2-foundation 0.3.2", + "objc2-metal 0.3.2", +] + +[[package]] +name = "objc2-security" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" +dependencies = [ + "objc2-core-foundation", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.2", + "objc2-foundation 0.2.2", ] [[package]] -name = "objc2-quartz-core" +name = "objc2-ui-kit" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ "bitflags 2.13.2", "block2 0.5.1", "objc2 0.5.2", + "objc2-cloud-kit 0.2.2", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", + "objc2-core-location 0.2.2", "objc2-foundation 0.2.2", - "objc2-metal 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core 0.2.2", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications 0.2.2", ] [[package]] -name = "objc2-quartz-core" +name = "objc2-ui-kit" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "objc2 0.6.4", "objc2-core-foundation", "objc2-foundation 0.3.2", - "objc2-metal 0.3.2", + "objc2-quartz-core 0.3.2", ] [[package]] -name = "objc2-ui-kit" -version = "0.3.2" +name = "objc2-uniform-type-identifiers" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ "bitflags 2.13.2", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.2", + "block2 0.5.1", + "objc2 0.5.2", + "objc2-core-location 0.2.2", + "objc2-foundation 0.2.2", ] [[package]] @@ -5734,7 +6035,7 @@ dependencies = [ "bitflags 2.13.2", "block2 0.6.2", "objc2 0.6.4", - "objc2-core-location", + "objc2-core-location 0.3.2", "objc2-foundation 0.3.2", ] @@ -5779,15 +6080,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "object" -version = "0.39.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -5967,6 +6259,39 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "parlance" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73072a9470554c8e794778acece2312661218aaabb635600957d952cf01c716e" + +[[package]] +name = "parley" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22d2ff88bd3f7d68d1d9b09c7e6209f9a8e8c05088295140a2bcf2e9b17038c5" +dependencies = [ + "fontique", + "harfrust", + "hashbrown 0.17.1", + "icu_normalizer", + "icu_properties", + "icu_segmenter", + "linebender_resource_handle", + "parlance", + "parley_data", + "skrifa", +] + +[[package]] +name = "parley_data" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1567535334d6ba2d3cde19221ba9a7bd0fabb3cbd99046ddfb10ae061cfcc889" +dependencies = [ + "icu_properties", +] + [[package]] name = "paste" version = "1.0.15" @@ -6402,6 +6727,8 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" dependencies = [ + "serde_core", + "writeable", "zerovec", ] @@ -6432,16 +6759,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.119", -] - [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -6560,16 +6877,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "psm" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd034599e63b970727f70d79e02d62390a4a84f7c6b827c27c46d5ac3fa622" -dependencies = [ - "ar_archive_writer", - "cc", -] - [[package]] name = "pulp" version = "0.22.3" @@ -6857,12 +7164,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" -[[package]] -name = "rangemap" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" - [[package]] name = "rav1e" version = "0.8.1" @@ -6909,7 +7210,6 @@ dependencies = [ "loop9", "quick-error 2.0.1", "rav1e", - "rayon", "rgb", ] @@ -6960,17 +7260,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "read-fonts" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b634fabf032fab15307ffd272149b622260f55974d9fad689292a5d33df02e5" -dependencies = [ - "bytemuck", - "core_maths", - "font-types 0.11.3", -] - [[package]] name = "read-fonts" version = "0.41.0" @@ -6978,18 +7267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" dependencies = [ "bytemuck", - "font-types 0.12.5", - "once_cell", -] - -[[package]] -name = "read-fonts" -version = "0.43.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005c8acf251756c478b0bf402885bfd88a1476020c4c7e6060edc1aa68da38ea" -dependencies = [ - "bytemuck", - "font-types 0.12.5", + "font-types", "once_cell", ] @@ -7539,12 +7817,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "self_cell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" - [[package]] name = "semver" version = "1.0.28" @@ -7756,12 +8028,6 @@ dependencies = [ "dirs 6.0.0", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "shlex" version = "2.0.1" @@ -7792,6 +8058,16 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + [[package]] name = "simd_helpers" version = "0.1.0" @@ -7828,16 +8104,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" -[[package]] -name = "skrifa" -version = "0.40.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fbdfe3d2475fbd7ddd1f3e5cf8288a30eb3e5f95832829570cd88115a7434ac" -dependencies = [ - "bytemuck", - "read-fonts 0.37.0", -] - [[package]] name = "skrifa" version = "0.44.0" @@ -7845,17 +8111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" dependencies = [ "bytemuck", - "read-fonts 0.41.0", -] - -[[package]] -name = "skrifa" -version = "0.46.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4febebda507fb889c545a37a135517769d1391941013561292897961d1887d6" -dependencies = [ - "bytemuck", - "read-fonts 0.43.3", + "read-fonts", ] [[package]] @@ -7902,10 +8158,30 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4aaa7368fcf4852a4c2dd92df0cace6a71f2091ca0a23391ce7f3a31833f1523" dependencies = [ - "borsh", "serde_core", ] +[[package]] +name = "snafu" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e84b3f4eacbf3a1ce05eac6763b4d629d60cbc94d632e4092c54ade71f1e1a2" +dependencies = [ + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c97747dbf44bb1ca44a561ece23508e99cb592e862f22222dcf42f51d1e451" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "socket2" version = "0.6.5" @@ -7975,40 +8251,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "stacker" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707f49d46706bacf8a2b00d51dace3f9de527c13eec3778f570c411f89e69967" -dependencies = [ - "cc", - "cfg-if", - "libc", - "psm", - "windows-sys 0.61.2", -] - -[[package]] -name = "stacksafe" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f9c34983ac74195c710c473db6fdf1085f64a47dbaa0090d1bea03be70da66" -dependencies = [ - "stacker", - "stacksafe-macro", -] - -[[package]] -name = "stacksafe-macro" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6feeae42a2d6b0dcb8aeb2f08d9e48cdac600239cf8a20fc59f9e252e86bdfe1" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.6", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -8061,20 +8303,48 @@ dependencies = [ "quote", ] +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros 0.26.4", +] + [[package]] name = "strum" -version = "0.27.2" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd" +dependencies = [ + "strum_macros 0.28.0", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "strum_macros", + "heck 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.119", ] [[package]] name = "strum_macros" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" +checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -8189,7 +8459,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c2499c2d826531388872b2268718aed907a39bd785ab0dcfe57fab26283f92e" dependencies = [ - "skrifa 0.44.0", + "skrifa", "yazi", "zeno", ] @@ -8265,15 +8535,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "sys-locale" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4" -dependencies = [ - "libc", -] - [[package]] name = "sysinfo" version = "0.31.4" @@ -8358,14 +8619,14 @@ dependencies = [ [[package]] name = "taffy" -version = "0.12.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "340a09581f29809fc0df82a3955501dc7f2a21f887e5d1c13dbe288fe1c0bef4" +checksum = "639627c87f43b9181c811f40a6296409e093a17bc761214cba3c15df74f86b99" dependencies = [ "arrayvec", - "grid", "serde", "slotmap", + "smallvec", ] [[package]] @@ -8592,6 +8853,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", + "serde_core", "zerovec", ] @@ -9339,9 +9601,6 @@ name = "ttf-parser" version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" -dependencies = [ - "core_maths", -] [[package]] name = "typeid" @@ -9402,12 +9661,6 @@ version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" -[[package]] -name = "unicode-linebreak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" - [[package]] name = "unicode-script" version = "0.5.8" @@ -9426,6 +9679,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode-width" version = "0.2.2" @@ -9478,8 +9737,8 @@ dependencies = [ "base64 0.23.1", "data-url", "flate2", - "fontdb 0.24.0", - "harfrust 0.12.0", + "fontdb", + "harfrust", "imagesize", "kurbo", "log", @@ -9487,7 +9746,7 @@ dependencies = [ "roxmltree 0.21.1", "simplecss", "siphasher 1.0.4", - "skrifa 0.44.0", + "skrifa", "strict-num", "svgtypes", "tiny-skia-path", @@ -9725,6 +9984,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasm_thread" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7516db7f32decdadb1c3b8deb1b7d78b9df7606c5cc2f6241737c2ab3a0258e" +dependencies = [ + "futures", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wayland-backend" version = "0.3.17" @@ -9733,6 +10004,7 @@ checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" dependencies = [ "cc", "downcast-rs", + "log", "rustix 1.1.5", "scoped-tls", "smallvec", @@ -9956,7 +10228,7 @@ dependencies = [ "hashbrown 0.16.1", "js-sys", "log", - "naga", + "naga 29.0.4", "parking_lot", "portable-atomic", "profiling", @@ -9987,7 +10259,7 @@ dependencies = [ "hashbrown 0.16.1", "indexmap", "log", - "naga", + "naga 29.0.4", "once_cell", "parking_lot", "portable-atomic", @@ -9998,6 +10270,7 @@ dependencies = [ "thiserror 2.0.21", "wgpu-core-deps-apple", "wgpu-core-deps-emscripten", + "wgpu-core-deps-wasm", "wgpu-core-deps-windows-linux-android", "wgpu-hal", "wgpu-naga-bridge", @@ -10022,6 +10295,15 @@ dependencies = [ "wgpu-hal", ] +[[package]] +name = "wgpu-core-deps-wasm" +version = "29.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1fb1798be2a912497d4c224f72d39bb0cb34af50e8bcc29865bc339c943059" +dependencies = [ + "wgpu-hal", +] + [[package]] name = "wgpu-core-deps-windows-linux-android" version = "29.0.4" @@ -10056,7 +10338,7 @@ dependencies = [ "libc", "libloading", "log", - "naga", + "naga 29.0.4", "ndk-sys", "objc2 0.6.4", "objc2-core-foundation", @@ -10091,7 +10373,7 @@ version = "29.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95226013f547544b223281cd16a4fb549aa9dcb562adbda0faae4c73ffbbc161" dependencies = [ - "naga", + "naga 29.0.4", "wgpu-types", ] @@ -10109,6 +10391,41 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wgsl-rs" +version = "0.1.0-beta.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20205e0ed5ccc5543652a6e5699455da154d9dc722c74e9e33f8514260d710e1" +dependencies = [ + "glam", + "half", + "naga 29.0.4", + "paste", + "snafu", + "wgsl-rs-ir", + "wgsl-rs-macros", +] + +[[package]] +name = "wgsl-rs-ir" +version = "0.1.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291227cb39d86fd08dd66d1d967dd4d03ef0058688c36edd1215134f198d8007" + +[[package]] +name = "wgsl-rs-macros" +version = "0.1.0-beta.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b381fbc656986e2551e0bfe1152e112aaceecbafeb5a1ca0314cc40e08c045c0" +dependencies = [ + "itertools 0.14.0", + "proc-macro2", + "quote", + "snafu", + "syn 2.0.119", + "wgsl-rs-ir", +] + [[package]] name = "which" version = "6.0.3" @@ -11375,6 +11692,7 @@ dependencies = [ "displaydoc", "yoke", "zerofrom", + "zerovec", ] [[package]] @@ -11383,6 +11701,7 @@ version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" dependencies = [ + "serde", "yoke", "zerofrom", "zerovec-derive", diff --git a/Cargo.toml b/Cargo.toml index 10fe59fedd..62bded9cfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,14 +58,14 @@ story = { path = "crates/story" } # GPUI CE is published to crates.io as `gpui-ce` with its platform, web and # macros split into sibling crates. -gpui = { package = "gpui-ce", version = "0.2.2" } -gpui_platform = { package = "gpui_ce_platform", version = "0.1.0", features = [ +gpui = { package = "gpui-ce", version = "=0.3.0" } +gpui_platform = { package = "gpui_ce_platform", version = "=0.3.0", features = [ "font-kit", "x11", "wayland", ] } -gpui_web = { package = "gpui_ce_web", version = "0.1.0" } -gpui_macros = { package = "gpui_ce_macros", version = "0.1.0" } +gpui_web = { package = "gpui_ce_web", version = "=0.3.0" } +gpui_macros = { package = "gpui_ce_macros", version = "=0.3.0" } sum-tree = { version = "0.2.0", package = "zed-sum-tree" } reqwest = { version = "0.12.15-zed", package = "zed-reqwest", default-features = false, features = [ "charset", diff --git a/crates/base/Cargo.toml b/crates/base/Cargo.toml index e4fe9fa204..4c4c5664ea 100644 --- a/crates/base/Cargo.toml +++ b/crates/base/Cargo.toml @@ -48,7 +48,6 @@ smallvec.workspace = true sum-tree.workspace = true tracing.workspace = true unicode-segmentation = "1.12.0" -syntect.workspace = true [target.'cfg(not(target_family = "wasm"))'.dependencies] smol.workspace = true @@ -72,6 +71,7 @@ windows = { workspace = true, features = ["Win32_Foundation", "Win32_UI_WindowsA ashpd = { version = "0.13", default-features = false, features = ["async-io", "settings"] } [dev-dependencies] +gpui_ce_parley = { version = "0.3.0", default-features = false } criterion = "0.5" gpui = { workspace = true, features = ["test-support"] } gpui_platform = { workspace = true, features = ["test-support"] } diff --git a/crates/base/examples/native/Cargo.toml b/crates/base/examples/native/Cargo.toml index 06186d2045..3661340f61 100644 --- a/crates/base/examples/native/Cargo.toml +++ b/crates/base/examples/native/Cargo.toml @@ -23,7 +23,7 @@ gpui = { workspace = true, features = ["test-support"] } [lints] workspace = true -# The shared showcase is included with `#[path]`, which cargo-machete cannot -# follow when detecting its `chrono`, `gpui`, `gpui_base`, and `syntect` imports. +# Shared showcase and HTTP modules are included with `#[path]`, which +# cargo-machete cannot follow when detecting these imports. [package.metadata.cargo-machete] -ignored = ["chrono", "gpui", "gpui-base", "syntect"] +ignored = ["chrono", "futures", "reqwest", "syntect"] diff --git a/crates/base/src/accordion.rs b/crates/base/src/accordion.rs index 8652276b98..200ec3ea3f 100644 --- a/crates/base/src/accordion.rs +++ b/crates/base/src/accordion.rs @@ -8,8 +8,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; - type ChangeHandler = Rc; /// An unstyled accordion root for application-owned items. diff --git a/crates/base/src/alert_dialog.rs b/crates/base/src/alert_dialog.rs index f85f51b9cf..00dc965b87 100644 --- a/crates/base/src/alert_dialog.rs +++ b/crates/base/src/alert_dialog.rs @@ -6,7 +6,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; use crate::{Dialog, DialogChangeReason, DialogHandle}; macro_rules! alert_part { diff --git a/crates/base/src/avatar.rs b/crates/base/src/avatar.rs index f36205d7e9..b6e6fe0681 100644 --- a/crates/base/src/avatar.rs +++ b/crates/base/src/avatar.rs @@ -4,8 +4,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; - /// An unstyled avatar root that renders its image slot or fallback slot. #[derive(IntoElement)] pub struct Avatar { diff --git a/crates/base/src/button.rs b/crates/base/src/button.rs index 55cf9108a3..4ac564aafc 100644 --- a/crates/base/src/button.rs +++ b/crates/base/src/button.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{RoleOverride, Selectable, StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{RoleOverride, Selectable, StateStyle, TestSupportExt as _}; type ClickHandler = Rc; diff --git a/crates/base/src/checkbox.rs b/crates/base/src/checkbox.rs index 670f22516f..9187bffef1 100644 --- a/crates/base/src/checkbox.rs +++ b/crates/base/src/checkbox.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{RoleOverride, StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{RoleOverride, StateStyle, TestSupportExt as _}; type ChangeHandler = Rc; @@ -433,13 +433,13 @@ mod tests { indicator(CheckboxState::Checked, false) .resolved_style() .border_color, - Some(checked_color) + Some(checked_color.into()) ); assert_eq!( indicator(CheckboxState::Checked, true) .resolved_style() .border_color, - Some(disabled_color) + Some(disabled_color.into()) ); assert_eq!( indicator(CheckboxState::Indeterminate, false) @@ -452,7 +452,7 @@ mod tests { .border_color(checked_color) .resolved_style() .border_color, - Some(disabled_color) + Some(disabled_color.into()) ); } @@ -627,7 +627,7 @@ mod tests { .disabled(|style| style.opacity(0.5)) }) .resolved_style(); - assert_eq!(combined.border_color, Some(checked_color)); + assert_eq!(combined.border_color, Some(checked_color.into())); assert_eq!(combined.opacity, Some(0.5)); let state_over_instance = styles( diff --git a/crates/base/src/color_picker.rs b/crates/base/src/color_picker.rs index 28d3c5d6c3..d872359d45 100644 --- a/crates/base/src/color_picker.rs +++ b/crates/base/src/color_picker.rs @@ -12,7 +12,7 @@ use palette::IntoColor as _; use smallvec::SmallVec; use crate::{ - RoleOverride, StyledExt as _, + RoleOverride, actions::{Cancel, Confirm}, input::InputEvent, slider::{SliderEvent, SliderState}, diff --git a/crates/base/src/combobox.rs b/crates/base/src/combobox.rs index f72ae7577c..bc45102d57 100644 --- a/crates/base/src/combobox.rs +++ b/crates/base/src/combobox.rs @@ -8,7 +8,6 @@ use gpui::{ use crate::{ Select, actions::{Cancel, Confirm, SelectDown, SelectUp}, - styled::StyledExt as _, }; const CONTEXT: &str = "Combobox"; diff --git a/crates/base/src/date_picker.rs b/crates/base/src/date_picker.rs index 9b2433b91a..a8ebe01600 100644 --- a/crates/base/src/date_picker.rs +++ b/crates/base/src/date_picker.rs @@ -7,10 +7,7 @@ use gpui::{ div, }; -use crate::{ - StyledExt as _, - actions::{Cancel, Confirm}, -}; +use crate::actions::{Cancel, Confirm}; type OpenChange = Rc; diff --git a/crates/base/src/dialog.rs b/crates/base/src/dialog.rs index 041bd42ab1..de80aee088 100644 --- a/crates/base/src/dialog.rs +++ b/crates/base/src/dialog.rs @@ -12,8 +12,8 @@ use gpui::{ }; use smallvec::SmallVec; +use crate::FocusTrapElement as _; use crate::actions::{Cancel, Confirm}; -use crate::{FocusTrapElement as _, StyledExt as _}; const CONTEXT: &str = "Dialog"; type Decision = Rc bool>; diff --git a/crates/base/src/dock/tab_group.rs b/crates/base/src/dock/tab_group.rs index bb759813a6..8242398611 100644 --- a/crates/base/src/dock/tab_group.rs +++ b/crates/base/src/dock/tab_group.rs @@ -1737,7 +1737,11 @@ mod tests { fn the_renderer_composes_frame_then_tab_bar_then_content(cx: &mut TestAppContext) { let (_group, calls, cx) = build_skinned_group(&["a"], cx); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( *calls.borrow(), @@ -1752,7 +1756,11 @@ mod tests { fn an_empty_group_asks_the_renderer_for_its_empty_state(cx: &mut TestAppContext) { let (_group, calls, cx) = build_skinned_group(&[], cx); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( *calls.borrow(), diff --git a/crates/base/src/input/base/element.rs b/crates/base/src/input/base/element.rs index 6091cc0ef1..32713167b2 100644 --- a/crates/base/src/input/base/element.rs +++ b/crates/base/src/input/base/element.rs @@ -1,15 +1,16 @@ use crate::input::{InputExtras as _, InputModeKind}; +use crate::text_compat::ShapedLineExt as _; use gpui::Corners; use gpui::Half; use gpui::{ - AnyElement, App, Bounds, Edges, Element, ElementId, ElementInputHandler, Entity, - GlobalElementId, + AnyElement, App, AppContext as _, Bounds, Edges, Element, ElementId, ElementInputHandler, + Entity, GlobalElementId, }; use gpui::{ ColorExt as _, HighlightStyle, Hitbox, HitboxBehavior, Hsla, InteractiveElement, IntoElement, LayoutId, MouseButton, MouseMoveEvent, MouseUpEvent, ParentElement as _, Path, Pixels, Point, Position, ShapedLine, SharedString, Size, Style, Styled as _, TextAlign, TextRun, TextStyle, - UnderlineStyle, Window, fill, point, px, relative, size, + UnderlineStyle, Window, point, px, relative, size, }; use ropey::Rope; use smallvec::SmallVec; @@ -566,8 +567,8 @@ impl TextElement { // For Right alignment use 0 margin: cursor is clamped to bounds separately, // so we never scroll the text for cursor-at-edge, avoiding a first-click jump. let safety_margin = match last_layout.text_align { - TextAlign::Left => RIGHT_MARGIN, - TextAlign::Right => px(0.), + TextAlign::Start | TextAlign::Left => RIGHT_MARGIN, + TextAlign::End | TextAlign::Right => px(0.), TextAlign::Center => CURSOR_WIDTH, }; @@ -1058,7 +1059,6 @@ impl TextElement { strikethrough: None, letter_spacing: None, }], - None, ); empty_line_number.width + LINE_NUMBER_RIGHT_MARGIN @@ -1111,7 +1111,6 @@ impl TextElement { strikethrough: None, letter_spacing: None, }], - None, ); let tab_text = SharedString::new_static("→"); @@ -1127,7 +1126,6 @@ impl TextElement { strikethrough: None, letter_spacing: None, }], - None, ); Some(WhitespaceIndicators { space, tab }) @@ -1188,7 +1186,7 @@ impl TextElement { Some( window .text_system() - .shape_line(first_text, font_size, &[first_run], None), + .shape_line(first_text, font_size, &[first_run]), ) } else { None @@ -1213,7 +1211,7 @@ impl TextElement { let shaped_text = if text.is_empty() { " ".into() } else { text }; window .text_system() - .shape_line(shaped_text, font_size, &[run], None) + .shape_line(shaped_text, font_size, &[run]) }) .collect(); @@ -1664,7 +1662,6 @@ impl TextElement { part.to_owned().into(), style.font_size.to_pixels(window.rem_size()), &[style.to_run(part.len())], - None, ) .width; width += @@ -1679,7 +1676,6 @@ impl TextElement { part.to_owned().into(), style.font_size.to_pixels(window.rem_size()), &[style.to_run(part.len())], - None, ) .width }) @@ -1749,7 +1745,6 @@ impl TextElement { text[part.clone()].to_owned().into(), font_size, &runs_for_range(runs, run_offset, &part), - None, ); let width = shaped.width; fragments.push(InlineFragment { @@ -1776,7 +1771,6 @@ impl TextElement { text[part.clone()].to_owned().into(), font_size, &runs_for_range(runs, run_offset, &part), - None, ); let width = shaped.width; fragments.push(InlineFragment { @@ -1883,9 +1877,7 @@ impl TextElement { let text: SharedString = display_text.to_string().into(); let aligned_runs = align_runs_to_char_boundaries(&text, runs); let line_runs = aligned_runs.as_deref().unwrap_or(runs); - let shaped_line = window - .text_system() - .shape_line(text, font_size, line_runs, None); + let shaped_line = window.text_system().shape_line(text, font_size, line_runs); let line_layout = LineLayout::new() .lines(smallvec::smallvec![shaped_line]) @@ -1901,12 +1893,10 @@ impl TextElement { let mut line_has_background = false; for (line, line_runs) in placeholder_line_runs(&placeholder_text, runs) { - let shaped_line = window.text_system().shape_line( - line.to_string().into(), - font_size, - &line_runs, - None, - ); + let shaped_line = + window + .text_system() + .shape_line(line.to_string().into(), font_size, &line_runs); line_has_background |= has_background(&line_runs); placeholder_lines.push(shaped_line); } @@ -1954,7 +1944,7 @@ impl TextElement { align_runs_to_char_boundaries(&sub_line, &line_runs).unwrap_or(line_runs); let shaped_line = window .text_system() - .shape_line(sub_line, font_size, &line_runs, None); + .shape_line(sub_line, font_size, &line_runs); line_has_background |= has_background(&line_runs); wrapped_lines.push(shaped_line); @@ -2394,7 +2384,11 @@ impl Element for TextElement { // out there is measured in spaces instead. let space_width = { let font_id = window.text_system().resolve_font(&font); - window.text_system().layout_width(font_id, text_size, ' ') + window + .text_system() + .advance(font_id, text_size, ' ') + .map(|size| size.width) + .unwrap_or_default() }; self.state.update(cx, |state, cx| { @@ -2633,7 +2627,6 @@ impl Element for TextElement { strikethrough: None, letter_spacing: None, }], - wrap_width, ) .width } @@ -2792,13 +2785,9 @@ impl Element for TextElement { }; let mut sub_lines: SmallVec<[ShapedLine; 1]> = SmallVec::new(); - sub_lines.push( - window - .text_system() - .shape_line(line_no, text_size, &runs, None), - ); + sub_lines.push(window.text_system().shape_line(line_no, text_size, &runs)); for _ in 0..line.wrapped_lines.len().saturating_sub(1) { - sub_lines.push(ShapedLine::default()); + sub_lines.push(window.text_system().shape_line("".into(), text_size, &[])); } line_numbers.push(sub_lines); } @@ -2910,10 +2899,10 @@ impl Element for TextElement { // Paint the current line background if is_active { if let Some(bg_color) = active_line_color { - window.paint_quad(fill( - Bounds::new(p, size(bounds.size.width, height)), - bg_color, - )); + window.paint_quad( + gpui::PaintQuad::new(Bounds::new(p, size(bounds.size.width, height))) + .background(bg_color), + ); } } offset_y += height; @@ -3057,7 +3046,9 @@ impl Element for TextElement { line_height, ), ); - window.paint_quad(fill(ghost_bounds, editor_background)); + window.paint_quad( + gpui::PaintQuad::new(ghost_bounds).background(editor_background), + ); // Paint ghost line text _ = ghost_line.paint( @@ -3080,7 +3071,9 @@ impl Element for TextElement { // Paint blinking cursors (shared blink state for all carets) if focused && show_cursor { for cursor_info in prepaint.cursor_infos_with_scroll() { - window.paint_quad(fill(cursor_info.bounds, editor_style.caret)); + window.paint_quad( + gpui::PaintQuad::new(cursor_info.bounds).background(editor_style.caret), + ); } } @@ -3102,7 +3095,7 @@ impl Element for TextElement { prepaint.ghost_lines_height, editor_paddings, ); - window.paint_quad(fill(gutter_bounds, gutter_bg)); + window.paint_quad(gpui::PaintQuad::new(gutter_bounds).background(gutter_bg)); // Each item is the normal lines. for (lines, &buffer_line) in line_numbers @@ -3116,13 +3109,13 @@ impl Element for TextElement { // paint active line number background if is_active { if let Some(bg_color) = active_line_color { - window.paint_quad(fill( - Bounds::new( + window.paint_quad( + gpui::PaintQuad::new(Bounds::new( point(gutter_bounds.origin.x, p.y), size(gutter_bounds.size.width, height), - ), - bg_color, - )); + )) + .background(bg_color), + ); } } @@ -3190,7 +3183,8 @@ impl Element for TextElement { // Paint background to cover any existing text let bg_bounds = Bounds::new(p, size(first_line.width + px(4.), line_height)); - window.paint_quad(fill(bg_bounds, editor_background)); + window + .paint_quad(gpui::PaintQuad::new(bg_bounds).background(editor_background)); // Paint first line completion text _ = first_line.paint(p, line_height, text_align, None, window, cx); @@ -3440,10 +3434,7 @@ fn split_runs_by_bg_segments( mod tests { use super::*; use crate::input::{EditorMode, EditorState, FoldRange, RangeDecoration, Redo, Undo}; - use gpui::{ - AppContext as _, Context, EntityInputHandler as _, Render, TestAppContext, - VisualTestContext, div, - }; + use gpui::{Context, EntityInputHandler as _, Render, TestAppContext, VisualTestContext, div}; #[test] fn line_number_column_stays_at_three_digits_then_grows_up_to_seven() { diff --git a/crates/base/src/input/base/layout.rs b/crates/base/src/input/base/layout.rs index 779b1f2cf9..eb02407b39 100644 --- a/crates/base/src/input/base/layout.rs +++ b/crates/base/src/input/base/layout.rs @@ -4,7 +4,7 @@ use gpui::{Bounds, Half, Pixels, ShapedLine, TextAlign, px}; use super::{WrappingIndent, display_map::LineLayout}; -#[derive(Clone, Default)] +#[derive(Clone)] pub(crate) struct WhitespaceIndicators { pub(crate) space: ShapedLine, pub(crate) tab: ShapedLine, @@ -40,9 +40,9 @@ impl LastLayout { pub(super) fn alignment_offset(&self, line_width: Pixels) -> Pixels { match self.text_align { - TextAlign::Left => px(0.), + TextAlign::Start | TextAlign::Left => px(0.), TextAlign::Center => (self.content_width - line_width).half().max(px(0.)), - TextAlign::Right => (self.content_width - line_width).max(px(0.)), + TextAlign::End | TextAlign::Right => (self.content_width - line_width).max(px(0.)), } } } diff --git a/crates/base/src/input/base/mod.rs b/crates/base/src/input/base/mod.rs index 605501189f..bd699af8e5 100644 --- a/crates/base/src/input/base/mod.rs +++ b/crates/base/src/input/base/mod.rs @@ -1,4 +1,4 @@ -use crate::{StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{StateStyle, TestSupportExt as _}; use gpui::{ AnyElement, App, Div, ElementId, InteractiveElement, Interactivity, IntoElement, ParentElement, Refineable as _, RenderOnce, Role, SharedString, StatefulInteractiveElement, StyleRefinement, @@ -265,7 +265,10 @@ mod tests { .focused(true) .border_color(gpui::red()) .styles(|styles| styles.focused(|style| style.border_color(gpui::blue()))); - assert_eq!(focused.resolved_style().border_color, Some(gpui::blue())); + assert_eq!( + focused.resolved_style().border_color, + Some(gpui::blue().into()) + ); let disabled = InputBase::new("disabled") .focused(true) diff --git a/crates/base/src/input/base/state.rs b/crates/base/src/input/base/state.rs index c7ff7fc732..c8c491a56f 100644 --- a/crates/base/src/input/base/state.rs +++ b/crates/base/src/input/base/state.rs @@ -2546,8 +2546,8 @@ impl InputBaseState { // For Right alignment use 0 margin: the cursor indicator is clamped inside bounds // in layout_cursors, so shifting the text here would cause a first-click visual jump. let safety_margin = match last_layout.text_align { - TextAlign::Left => RIGHT_MARGIN, - TextAlign::Right => px(0.), + TextAlign::Start | TextAlign::Left => RIGHT_MARGIN, + TextAlign::End | TextAlign::Right => px(0.), TextAlign::Center => CURSOR_WIDTH, }; if let Some(vi) = last_layout diff --git a/crates/base/src/input/editor/display_map/inline_line.rs b/crates/base/src/input/editor/display_map/inline_line.rs index b45fd3bab7..b3e99ab75d 100644 --- a/crates/base/src/input/editor/display_map/inline_line.rs +++ b/crates/base/src/input/editor/display_map/inline_line.rs @@ -1,4 +1,5 @@ //! A visual row whose offsets remain in source UTF-8 bytes. +use crate::text_compat::ShapedLineExt as _; use gpui::{App, Pixels, Point, ShapedLine, SharedString, TextAlign, Window, point, px}; use std::ops::Range; @@ -134,7 +135,7 @@ impl InputLine { Content::Inline(fragments) => { let remaining = (width.unwrap_or(self.width) - self.width).max(px(0.)); let offset = match align { - TextAlign::Right => remaining, + TextAlign::End | TextAlign::Right => remaining, TextAlign::Center => remaining / 2., _ => px(0.), }; diff --git a/crates/base/src/input/editor/display_map/text_wrapper.rs b/crates/base/src/input/editor/display_map/text_wrapper.rs index 99388fac36..e3c522da34 100644 --- a/crates/base/src/input/editor/display_map/text_wrapper.rs +++ b/crates/base/src/input/editor/display_map/text_wrapper.rs @@ -1,12 +1,11 @@ use super::inline_line::InputLine; +use crate::text_compat::{LineFragment, LineWrapperExt as _}; use gpui::Half; use std::borrow::Cow; use std::ops::Range; use std::rc::Rc; -use gpui::{ - App, Font, LineFragment, Pixels, Point, ShapedLine, Size, TextAlign, Window, point, px, size, -}; +use gpui::{App, Font, Pixels, Point, ShapedLine, Size, TextAlign, Window, point, px, size}; use ropey::Rope; use smallvec::SmallVec; use sum_tree::{Bias, Dimensions, SumTree}; @@ -421,7 +420,7 @@ impl TextWrapper { new_text: &Rope, wrap_line: &mut F, ) where - F: FnMut(&str, Pixels, usize) -> Vec, + F: FnMut(&str, Pixels, usize) -> Vec, { // Remove the old changed lines. let buffer_line_count = self.lines_count(); @@ -991,11 +990,27 @@ mod tests { use super::*; use std::rc::Rc; - use gpui::{Boundary, FontFeatures, FontStyle, FontWeight, px}; + use crate::text_compat::Boundary; + use gpui::{FontFeatures, FontStyle, FontWeight, px}; + + fn test_line(len: usize) -> ShapedLine { + let text_system = gpui::WindowTextSystem::new(std::sync::Arc::new(gpui::TextSystem::new( + std::sync::Arc::new(gpui::TestTextSystem), + ))); + text_system.shape_line( + "a".repeat(len).into(), + px(0.), + &[gpui::TextRun { + len, + ..Default::default() + }], + ) + } #[test] fn test_update() { let font = gpui::Font { + width: Default::default(), family: "Arial".into(), weight: FontWeight::default(), style: FontStyle::Normal, @@ -1192,6 +1207,7 @@ mod tests { fn test_font() -> gpui::Font { gpui::Font { + width: Default::default(), family: "Arial".into(), weight: FontWeight::default(), style: FontStyle::Normal, @@ -1332,8 +1348,8 @@ mod tests { fn test_line_layout() { let mut line_layout = LineLayout::new(); - let line1 = ShapedLine::default().with_len(100); - let line2 = ShapedLine::default().with_len(50); + let line1 = test_line(100); + let line2 = test_line(50); let wrapped_lines = smallvec::smallvec![line1, line2]; line_layout.set_wrapped_lines(wrapped_lines); assert_eq!(line_layout.len(), 150); @@ -1364,9 +1380,9 @@ mod tests { fn test_position_for_index_prefers_first_leading_empty_visual_line() { let mut line_layout = LineLayout::new(); line_layout.set_wrapped_lines(smallvec::smallvec![ - ShapedLine::default(), - ShapedLine::default(), - ShapedLine::default().with_len(3), + test_line(0), + test_line(0), + test_line(3), ]); assert_eq!( @@ -1379,10 +1395,7 @@ mod tests { fn clicking_past_a_wrapped_row_keeps_the_caret_on_that_row() { // One buffer line wrapped into two visual rows, splitting at byte 10. let mut line_layout = LineLayout::new(); - line_layout.set_wrapped_lines(smallvec::smallvec![ - ShapedLine::default().with_len(10), - ShapedLine::default().with_len(5), - ]); + line_layout.set_wrapped_lines(smallvec::smallvec![test_line(10), test_line(5),]); let last_layout = test_last_layout(px(20.)); // Clicking past the last glyph of the first row resolves to the wrap boundary, which is @@ -1464,6 +1477,7 @@ mod tests { #[test] fn test_offset_to_display_point() { let font = gpui::Font { + width: Default::default(), family: "Arial".into(), weight: FontWeight::default(), style: FontStyle::Normal, @@ -1636,10 +1650,7 @@ mod tests { #[test] fn test_wrap_indent_offsets_continuation_lines() { let mut line_layout = LineLayout::new(); - line_layout.set_wrapped_lines(smallvec::smallvec![ - ShapedLine::default().with_len(5), - ShapedLine::default().with_len(10), - ]); + line_layout.set_wrapped_lines(smallvec::smallvec![test_line(5), test_line(10),]); line_layout = line_layout.wrap_indent(px(20.0)); diff --git a/crates/base/src/input/editor/indent.rs b/crates/base/src/input/editor/indent.rs index b642c2df84..95d346a01d 100644 --- a/crates/base/src/input/editor/indent.rs +++ b/crates/base/src/input/editor/indent.rs @@ -96,7 +96,6 @@ impl TextElement { underline: None, letter_spacing: None, }], - None, ); layout.width diff --git a/crates/base/src/lib.rs b/crates/base/src/lib.rs index 5b4d5bf3ed..45dc8fdb7e 100644 --- a/crates/base/src/lib.rs +++ b/crates/base/src/lib.rs @@ -67,6 +67,7 @@ mod table; mod tabs; pub mod text; mod text_boundary; +mod text_compat; mod text_selection; mod theme; pub mod theme_tokens; @@ -246,3 +247,6 @@ pub fn init(cx: &mut App) { #[cfg(feature = "test-support")] pub mod test_support; + +#[cfg(test)] +mod test_text_system; diff --git a/crates/base/src/link.rs b/crates/base/src/link.rs index bbcfe13804..d308ac9fd6 100644 --- a/crates/base/src/link.rs +++ b/crates/base/src/link.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{StateStyle, StyledExt as _}; +use crate::StateStyle; type ActivationHandler = Rc; type OpenHandler = Rc; diff --git a/crates/base/src/motion/reveal.rs b/crates/base/src/motion/reveal.rs index b09ad3be8d..7f171411e7 100644 --- a/crates/base/src/motion/reveal.rs +++ b/crates/base/src/motion/reveal.rs @@ -98,7 +98,11 @@ impl Element for MotionReveal { if changed { window.request_animation_frame(); } - window.with_content_mask(Some(ContentMask { bounds }), |window| { + let mask = ContentMask { + bounds, + fade_out: Default::default(), + }; + window.with_content_mask(Some(mask), |window| { self.child.prepaint_at(bounds.origin, window, cx); }); } @@ -113,7 +117,11 @@ impl Element for MotionReveal { window: &mut Window, cx: &mut App, ) { - window.with_content_mask(Some(ContentMask { bounds }), |window| { + let mask = ContentMask { + bounds, + fade_out: Default::default(), + }; + window.with_content_mask(Some(mask), |window| { self.child.paint(window, cx); }); } diff --git a/crates/base/src/nav_stack.rs b/crates/base/src/nav_stack.rs index 698332fdec..846d1259d1 100644 --- a/crates/base/src/nav_stack.rs +++ b/crates/base/src/nav_stack.rs @@ -7,7 +7,7 @@ use gpui::{ }; use crate::{ - History, StyledExt as _, + History, motion::{Presence, PresencePhase, Transition}, }; diff --git a/crates/base/src/number_input.rs b/crates/base/src/number_input.rs index b3c53dc19a..57100a8aeb 100644 --- a/crates/base/src/number_input.rs +++ b/crates/base/src/number_input.rs @@ -8,7 +8,7 @@ use gpui::{ Window, actions, div, prelude::FluentBuilder as _, }; -use crate::{Button, InputBase, StyledExt as _}; +use crate::{Button, InputBase}; actions!(number_input, [Increment, Decrement]); diff --git a/crates/base/src/otp_input.rs b/crates/base/src/otp_input.rs index 633dddabb2..00e17d04c3 100644 --- a/crates/base/src/otp_input.rs +++ b/crates/base/src/otp_input.rs @@ -1,4 +1,4 @@ -use crate::{StyledExt as _, input::blink_cursor::BlinkCursor}; +use crate::input::blink_cursor::BlinkCursor; use gpui::{ AnyElement, App, AppContext as _, Context, Empty, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement as _, IntoElement, KeyDownEvent, ParentElement, Render, RenderOnce, diff --git a/crates/base/src/pagination.rs b/crates/base/src/pagination.rs index 76971e0a2a..ddb46fe6bd 100644 --- a/crates/base/src/pagination.rs +++ b/crates/base/src/pagination.rs @@ -5,8 +5,6 @@ use gpui::{ SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Window, div, }; -use crate::StyledExt as _; - type PageChangeHandler = Rc; /// A visible destination in a pagination control. diff --git a/crates/base/src/plot/element.rs b/crates/base/src/plot/element.rs index 4123ddbeac..db89fcea49 100644 --- a/crates/base/src/plot/element.rs +++ b/crates/base/src/plot/element.rs @@ -3,8 +3,9 @@ use std::{cell::Cell, rc::Rc}; use gpui::{ - AnyElement, App, Bounds, Element, ElementId, GlobalElementId, Hitbox, HitboxBehavior, - InspectorElementId, IntoElement, LayoutId, MouseMoveEvent, Pixels, Point, Size, Style, Window, + AnyElement, App, AppContext as _, Bounds, Element, ElementId, GlobalElementId, Hitbox, + HitboxBehavior, InspectorElementId, IntoElement, LayoutId, MouseMoveEvent, Pixels, Point, Size, + Style, Window, }; use super::{Plot, PlotAppear, appear::track_appear, hover::track_hover}; diff --git a/crates/base/src/plot/grid.rs b/crates/base/src/plot/grid.rs index e4a347da4b..3c8a2c4637 100644 --- a/crates/base/src/plot/grid.rs +++ b/crates/base/src/plot/grid.rs @@ -1,4 +1,4 @@ -use gpui::{Background, Bounds, Pixels, Point, Window, fill, point, px, size}; +use gpui::{Background, Bounds, Pixels, Point, Window, point, px, size}; use super::origin_point; @@ -80,7 +80,9 @@ impl Grid { pub fn paint(&self, bounds: &Bounds, window: &mut Window) { for (start, end) in self.points(bounds) { for (start, end) in dash_segments(start, end, self.dash_array.as_deref()) { - window.paint_quad(fill(line_bounds(start, end), self.stroke)); + window.paint_quad( + gpui::PaintQuad::new(line_bounds(start, end)).background(self.stroke), + ); } } } diff --git a/crates/base/src/plot/label.rs b/crates/base/src/plot/label.rs index c7170d4581..8b4d6d6cdc 100644 --- a/crates/base/src/plot/label.rs +++ b/crates/base/src/plot/label.rs @@ -37,7 +37,7 @@ fn shape_label( }; window .text_system() - .shape_line(text.clone(), font_size, &[text_run], None) + .shape_line(text.clone(), font_size, &[text_run]) } /// Returns the rendered width of `text` at `font_size` using the window's diff --git a/crates/base/src/plot/shape/bar.rs b/crates/base/src/plot/shape/bar.rs index f851958182..ea571dedbb 100644 --- a/crates/base/src/plot/shape/bar.rs +++ b/crates/base/src/plot/shape/bar.rs @@ -1,6 +1,4 @@ -use gpui::{ - App, Background, Bounds, Corners, PaintQuad, Pixels, Point, Size, Window, fill, point, px, -}; +use gpui::{App, Background, Bounds, Corners, PaintQuad, Pixels, Point, Size, Window, point, px}; use crate::plot::{ label::{PlotLabel, TEXT_GAP, TEXT_HEIGHT, TEXT_SIZE, Text}, @@ -217,7 +215,11 @@ impl Bar { }; let bg = (self.fill)(v, frame, self.alignment); - graph.push(fill(Bounds::from_corners(p1, p2), bg).corner_radii(self.corner_radii)); + graph.push( + gpui::PaintQuad::new(Bounds::from_corners(p1, p2)) + .background(bg) + .corner_radii(self.corner_radii), + ); if let Some(label) = &self.label { let label_origin = label_origin(self.alignment, cross, base, value, bw); diff --git a/crates/base/src/plot/shape/line.rs b/crates/base/src/plot/shape/line.rs index af5a1f71da..05d5280bd8 100644 --- a/crates/base/src/plot/shape/line.rs +++ b/crates/base/src/plot/shape/line.rs @@ -2,7 +2,7 @@ use gpui::{ Background, BorderStyle, Bounds, Hsla, PaintQuad, Path, PathBuilder, Pixels, Point, Window, px, - quad, size, + size, }; use crate::plot::{Curve, PathCache, ShapeKey, origin_point}; @@ -125,16 +125,16 @@ impl Line { /// Paint the dots on the Line. fn paint_dot(&self, dot: Point) -> PaintQuad { - quad( - gpui::bounds(dot, size(self.dot_size, self.dot_size)), - self.dot_size / 2., - self.dot_fill, - px(1.), - self.dot_stroke - .or_else(|| self.dot_fill.as_solid()) - .unwrap_or_default(), - BorderStyle::default(), - ) + gpui::PaintQuad::new(gpui::bounds(dot, size(self.dot_size, self.dot_size))) + .corner_radii(self.dot_size / 2.) + .background(self.dot_fill) + .border_widths(px(1.)) + .border_color( + self.dot_stroke + .or_else(|| self.dot_fill.as_solid()) + .unwrap_or_default(), + ) + .border_style(BorderStyle::default()) } /// The projected points relative to `origin`, and the dot quads to paint. diff --git a/crates/base/src/plot/shape/radial_line.rs b/crates/base/src/plot/shape/radial_line.rs index 8d834f71a0..6a6b2b3db1 100644 --- a/crates/base/src/plot/shape/radial_line.rs +++ b/crates/base/src/plot/shape/radial_line.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use gpui::{ Background, BorderStyle, Bounds, Hsla, PaintQuad, Path, PathBuilder, Pixels, Point, Window, - point, px, quad, size, + point, px, size, }; const HALF_PI: f32 = PI / 2.; @@ -158,16 +158,16 @@ impl RadialLine { /// Paint a dot on the RadialLine. fn paint_dot(&self, dot: Point) -> PaintQuad { - quad( - gpui::bounds(dot, size(self.dot_size, self.dot_size)), - self.dot_size / 2., - self.dot_fill, - px(1.), - self.dot_stroke - .or_else(|| self.dot_fill.as_solid()) - .unwrap_or_default(), - BorderStyle::default(), - ) + gpui::PaintQuad::new(gpui::bounds(dot, size(self.dot_size, self.dot_size))) + .corner_radii(self.dot_size / 2.) + .background(self.dot_fill) + .border_widths(px(1.)) + .border_color( + self.dot_stroke + .or_else(|| self.dot_fill.as_solid()) + .unwrap_or_default(), + ) + .border_style(BorderStyle::default()) } /// Resolve the data to points around the center of the bounds. diff --git a/crates/base/src/popover.rs b/crates/base/src/popover.rs index a9c35c054d..6bbb9a23e1 100644 --- a/crates/base/src/popover.rs +++ b/crates/base/src/popover.rs @@ -1,14 +1,14 @@ use std::rc::Rc; use gpui::{ - Anchor, AnyElement, App, Context, DismissEvent, ElementId, EventEmitter, FocusHandle, - Focusable, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, ParentElement as _, - Render, RenderOnce, Role, StatefulInteractiveElement as _, StyleRefinement, Styled, - Subscription, Window, div, prelude::FluentBuilder as _, + Anchor, AnyElement, App, AppContext as _, Context, DismissEvent, ElementId, EventEmitter, + FocusHandle, Focusable, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, + ParentElement as _, Render, RenderOnce, Role, StatefulInteractiveElement as _, StyleRefinement, + Styled, Subscription, Window, div, prelude::FluentBuilder as _, }; use crate::{ - DeferredPopover, GlobalState, Popup, ResolvedPosition, Selectable, StyledExt as _, + DeferredPopover, GlobalState, Popup, ResolvedPosition, Selectable, actions::{Cancel, Confirm}, }; @@ -378,7 +378,7 @@ impl RenderOnce for Popover { #[cfg(test)] mod tests { use super::*; - use gpui::{AppContext as _, Context, Render, point, px}; + use gpui::{Context, Render, point, px}; use std::{cell::RefCell, rc::Rc}; /// Popover state lives in element state, which is collected as soon as it diff --git a/crates/base/src/popup.rs b/crates/base/src/popup.rs index b7fa42ada8..86faf3b412 100644 --- a/crates/base/src/popup.rs +++ b/crates/base/src/popup.rs @@ -6,7 +6,7 @@ use gpui::{ StyleRefinement, Styled, Window, canvas, deferred, div, point, px, }; -use crate::{Positioner, ResolvedPosition, StyledExt as _}; +use crate::{Positioner, ResolvedPosition}; /// Distance kept between a popup and the window edge. const WINDOW_MARGIN: Pixels = px(8.); diff --git a/crates/base/src/progress.rs b/crates/base/src/progress.rs index 1c6c0be995..4a418907f5 100644 --- a/crates/base/src/progress.rs +++ b/crates/base/src/progress.rs @@ -5,8 +5,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; - /// An unstyled linear progress root with controlled value accessibility. #[derive(IntoElement)] pub struct Progress { diff --git a/crates/base/src/radio.rs b/crates/base/src/radio.rs index 1940f655c0..905775da5c 100644 --- a/crates/base/src/radio.rs +++ b/crates/base/src/radio.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{StateStyle, TestSupportExt as _}; type ChangeHandler = Rc; diff --git a/crates/base/src/radio_group.rs b/crates/base/src/radio_group.rs index 7dffa03ab8..05ffa43164 100644 --- a/crates/base/src/radio_group.rs +++ b/crates/base/src/radio_group.rs @@ -5,8 +5,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; - /// An unstyled container for a set of radio elements. #[derive(IntoElement)] pub struct RadioGroup { diff --git a/crates/base/src/resizable/panel.rs b/crates/base/src/resizable/panel.rs index d4032077f7..323a534413 100644 --- a/crates/base/src/resizable/panel.rs +++ b/crates/base/src/resizable/panel.rs @@ -10,7 +10,7 @@ use gpui::{ prelude::FluentBuilder, }; -use crate::{AxisExt, ElementExt, StyledExt as _, h_flex, resizable::PANEL_MIN_SIZE, v_flex}; +use crate::{AxisExt, ElementExt, h_flex, resizable::PANEL_MIN_SIZE, v_flex}; use super::{ResizableState, ResizeHandleRenderer, resizable_panel, resize_handle}; diff --git a/crates/base/src/resizable/resize_handle.rs b/crates/base/src/resizable/resize_handle.rs index 23b2cfb788..f989d6a2a7 100644 --- a/crates/base/src/resizable/resize_handle.rs +++ b/crates/base/src/resizable/resize_handle.rs @@ -388,7 +388,7 @@ impl Element for ResizeHandle { window.on_mouse_event({ let state = state.clone(); let hitbox = hitbox.clone(); - move |ev: &MouseDownEvent, phase, window, _| { + move |_ev: &MouseDownEvent, phase, window, _| { if phase.bubble() && hitbox.is_hovered(window) && state.set(ResizeHandleState::Pressed) @@ -401,7 +401,7 @@ impl Element for ResizeHandle { window.on_mouse_event({ let state = state.clone(); let hitbox = hitbox.clone(); - move |ev: &MouseMoveEvent, phase, window, _| { + move |_ev: &MouseMoveEvent, phase, window, _| { if !phase.bubble() { return; } @@ -424,7 +424,7 @@ impl Element for ResizeHandle { window.on_mouse_event({ let state = state.clone(); let hitbox = hitbox.clone(); - move |ev: &MouseUpEvent, _, window, _| { + move |_ev: &MouseUpEvent, _, window, _| { if !state.get().is_active() { return; } diff --git a/crates/base/src/root.rs b/crates/base/src/root.rs index cf6e3ef14a..4bc3cedb6b 100644 --- a/crates/base/src/root.rs +++ b/crates/base/src/root.rs @@ -1,6 +1,6 @@ //! Window roots and presentation-layer plugins. +use crate::TextSelectionLayer; use crate::input::Copy; -use crate::{StyledExt, TextSelectionLayer}; use gpui::{ AnyElement, AnyView, App, AppContext, ClipboardItem, Context, Div, Entity, Global, InteractiveElement, IntoElement, KeyBinding, ParentElement, Render, Stateful, StyleRefinement, diff --git a/crates/base/src/scroll_bounce.rs b/crates/base/src/scroll_bounce.rs index 78ff285a05..2923bafef7 100644 --- a/crates/base/src/scroll_bounce.rs +++ b/crates/base/src/scroll_bounce.rs @@ -2,9 +2,9 @@ use crate::{OngoingScrollExt as _, ScrollbarHandle}; use gpui::{ - AnyElement, App, Bounds, ContentMask, DispatchPhase, Element, ElementId, GlobalElementId, - Hitbox, HitboxBehavior, InspectorElementId, IntoElement, LayoutId, OngoingScroll, Pixels, - ScrollDelta, ScrollWheelEvent, TouchPhase, Window, point, px, + AnyElement, App, AppContext as _, Bounds, ContentMask, DispatchPhase, Element, ElementId, + GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId, IntoElement, LayoutId, + OngoingScroll, Pixels, ScrollDelta, ScrollWheelEvent, TouchPhase, Window, point, px, }; #[cfg(not(target_family = "wasm"))] use std::time::Instant; @@ -247,7 +247,11 @@ impl Element for ScrollBounce { state.physics.offset() }; let hitbox = window.insert_hitbox(bounds, HitboxBehavior::Normal); - window.with_content_mask(Some(ContentMask { bounds }), |window| { + let mask = ContentMask { + bounds, + fade_out: Default::default(), + }; + window.with_content_mask(Some(mask), |window| { window.with_element_offset(point(px(0.), px(offset)), |window| { self.child.prepaint(window, cx); }); @@ -405,9 +409,11 @@ impl Element for ScrollBounce { } }); } - window.with_content_mask(Some(ContentMask { bounds }), |window| { - self.child.paint(window, cx) - }); + let mask = ContentMask { + bounds, + fade_out: Default::default(), + }; + window.with_content_mask(Some(mask), |window| self.child.paint(window, cx)); } } diff --git a/crates/base/src/scrollable_mask.rs b/crates/base/src/scrollable_mask.rs index 6b840328d3..904b133dbf 100644 --- a/crates/base/src/scrollable_mask.rs +++ b/crates/base/src/scrollable_mask.rs @@ -2,15 +2,15 @@ use std::cell::RefCell; use std::rc::Rc; use gpui::{ - App, Axis, BorderStyle, Bounds, ContentMask, Edges, Element, ElementId, GlobalElementId, - Hitbox, Hsla, InteractiveElement as _, IntoElement, IsZero as _, LayoutId, OngoingScroll, - PaintQuad, ParentElement as _, Point, Position, ScrollHandle, ScrollWheelEvent, + App, AppContext as _, Axis, BorderStyle, Bounds, ContentMask, Edges, Element, ElementId, + GlobalElementId, Hitbox, Hsla, InteractiveElement as _, IntoElement, IsZero as _, LayoutId, + OngoingScroll, ParentElement as _, Point, Position, ScrollHandle, ScrollWheelEvent, StatefulInteractiveElement as _, Style, StyleRefinement, Styled as _, Window, div, px, relative, }; use gpui::{Corners, Pixels}; -use crate::{AxisExt, OngoingScrollExt as _, ScrollbarHandle, StyledExt as _}; +use crate::{AxisExt, OngoingScrollExt as _, ScrollbarHandle}; /// Default element id for a mask: the call site, so two masks built in /// different places never share their per-gesture axis lock. @@ -197,16 +197,20 @@ impl Element for ScrollableMask { }) .unwrap_or_default(); - window.with_content_mask(Some(ContentMask { bounds }), |window| { + let mask = ContentMask { + bounds, + fade_out: Default::default(), + }; + window.with_content_mask(Some(mask), |window| { if let Some(color) = self.debug { - window.paint_quad(PaintQuad { - bounds, - border_widths: Edges::all(px(1.0)), - border_color: color.into(), - background: gpui::transparent_white().into(), - corner_radii: Corners::all(px(0.)), - border_style: BorderStyle::default(), - }); + window.paint_quad( + gpui::PaintQuad::new(bounds) + .border_widths(Edges::all(px(1.0))) + .border_color(color) + .background(gpui::transparent_white()) + .corner_radii(Corners::all(px(0.))) + .border_style(BorderStyle::default()), + ); } window.on_mouse_event({ diff --git a/crates/base/src/scrollbar.rs b/crates/base/src/scrollbar.rs index ebf029fe4d..45c7a0317b 100644 --- a/crates/base/src/scrollbar.rs +++ b/crates/base/src/scrollbar.rs @@ -8,11 +8,12 @@ use crate::{ theme::ActiveTheme as _, }; use gpui::{ - Anchor, App, Axis, Background, BorderStyle, Bounds, ColorExt as _, ContentMask, CursorStyle, - Edges, Element, ElementId, EntityId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, - InspectorElementId, IntoElement, IsZero, LayoutId, ListState, MouseDownEvent, MouseMoveEvent, - MouseUpEvent, PaintQuad, Pixels, Point, Position, ScrollHandle, ScrollWheelEvent, Size, Style, - UniformListScrollHandle, Window, fill, point, prelude::FluentBuilder, px, relative, size, + Anchor, App, AppContext as _, Axis, Background, BorderStyle, Bounds, ColorExt as _, + ContentMask, CursorStyle, Edges, Element, ElementId, EntityId, GlobalElementId, Hitbox, + HitboxBehavior, Hsla, InspectorElementId, IntoElement, IsZero, LayoutId, ListState, + MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Point, Position, ScrollHandle, + ScrollWheelEvent, Size, Style, UniformListScrollHandle, Window, point, prelude::FluentBuilder, + px, relative, size, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -1289,9 +1290,13 @@ impl Element for Scrollbar { cx: &mut App, ) -> Self::PrepaintState { let bounds = self.resolved_viewport_bounds(bounds); - let hitbox = window.with_content_mask(Some(ContentMask { bounds }), |window| { - window.insert_hitbox(bounds, HitboxBehavior::Normal) - }); + let hitbox = window.with_content_mask( + Some(ContentMask { + fade_out: Default::default(), + bounds, + }), + |window| window.insert_hitbox(bounds, HitboxBehavior::Normal), + ); let state = window .use_state(cx, |_, _| ScrollbarState::default()) @@ -1532,9 +1537,13 @@ impl Element for Scrollbar { ) }; - let bar_hitbox = window.with_content_mask(Some(ContentMask { bounds }), |window| { - window.insert_hitbox(bounds, gpui::HitboxBehavior::Normal) - }); + let bar_hitbox = window.with_content_mask( + Some(ContentMask { + fade_out: Default::default(), + bounds, + }), + |window| window.insert_hitbox(bounds, gpui::HitboxBehavior::Normal), + ); states.push(AxisPrepaintState { axis, @@ -1581,6 +1590,7 @@ impl Element for Scrollbar { window.with_content_mask( Some(ContentMask { + fade_out: Default::default(), bounds: hitbox_bounds, }), |window| { @@ -1609,33 +1619,37 @@ impl Element for Scrollbar { window.set_cursor_style(CursorStyle::default(), &state.bar_hitbox); window.paint_layer(hitbox_bounds, |cx| { - cx.paint_quad(fill(painted_bounds, painted_track_bg)); - - cx.paint_quad(PaintQuad { - bounds: painted_bounds, - corner_radii: (0.).into(), - background: gpui::transparent_black().into(), - border_widths: if is_vertical { - Edges { - top: px(0.), - right: px(0.), - bottom: px(0.), - left: px(0.), - } - } else { - Edges { - top: px(0.), - right: px(0.), - bottom: px(0.), - left: px(0.), - } - }, - border_color: painted_border.into(), - border_style: BorderStyle::default(), - }); + cx.paint_quad( + gpui::PaintQuad::new(painted_bounds).background(painted_track_bg), + ); + + cx.paint_quad( + gpui::PaintQuad::new(painted_bounds) + .corner_radii(0.) + .background(gpui::transparent_black()) + .border_widths(if is_vertical { + Edges { + top: px(0.), + right: px(0.), + bottom: px(0.), + left: px(0.), + } + } else { + Edges { + top: px(0.), + right: px(0.), + bottom: px(0.), + left: px(0.), + } + }) + .border_color(painted_border) + .border_style(BorderStyle::default()), + ); cx.paint_quad( - fill(painted_thumb_bounds, painted_thumb_bg).corner_radii(radius), + gpui::PaintQuad::new(painted_thumb_bounds) + .background(painted_thumb_bg) + .corner_radii(radius), ); }); diff --git a/crates/base/src/select.rs b/crates/base/src/select.rs index 71f9b88249..2fe7a93b0f 100644 --- a/crates/base/src/select.rs +++ b/crates/base/src/select.rs @@ -7,8 +7,8 @@ use gpui::{ prelude::FluentBuilder as _, }; +use crate::TestSupportExt as _; use crate::actions::{Cancel, Confirm, SelectDown, SelectUp}; -use crate::{StyledExt as _, TestSupportExt as _}; const CONTEXT: &str = "Select"; diff --git a/crates/base/src/selectable_text.rs b/crates/base/src/selectable_text.rs index f53b61166c..c3aa3561e3 100644 --- a/crates/base/src/selectable_text.rs +++ b/crates/base/src/selectable_text.rs @@ -2,8 +2,8 @@ use std::ops::Range; use gpui::{ App, BorderStyle, Bounds, Corners, Edges, Element, ElementId, GlobalElementId, Hitbox, - HitboxBehavior, Hsla, InspectorElementId, IntoElement, LayoutId, PaintQuad, Pixels, Point, - SharedString, StyledText, TextStyleRefinement, Window, transparent_black, + HitboxBehavior, Hsla, InspectorElementId, IntoElement, LayoutId, Pixels, Point, SharedString, + StyledText, TextStyleRefinement, Window, transparent_black, }; use crate::{TextSelection, TextSelectionHandle, TextSelectionRegistration, TextSelectionRun}; @@ -85,14 +85,14 @@ impl SelectableText { return; }; for bounds in selection_quad_bounds(start, end, layout.bounds(), layout.line_height()) { - window.paint_quad(PaintQuad { - bounds, - background: color.into(), - corner_radii: Corners::default(), - border_widths: Edges::default(), - border_color: transparent_black(), - border_style: BorderStyle::default(), - }); + window.paint_quad( + gpui::PaintQuad::new(bounds) + .background(color) + .corner_radii(Corners::default()) + .border_widths(Edges::default()) + .border_color(transparent_black()) + .border_style(BorderStyle::default()), + ); } } } @@ -173,6 +173,14 @@ impl Element for SelectableText { self.styled_text .request_layout(global_id, inspector_id, window, cx) }; + let layout_id = window.request_layout( + gpui::Style { + display: gpui::Display::Flex, + ..Default::default() + }, + [layout_id], + cx, + ); (layout_id, handle) } diff --git a/crates/base/src/sheet.rs b/crates/base/src/sheet.rs index f969647d93..9d2b992209 100644 --- a/crates/base/src/sheet.rs +++ b/crates/base/src/sheet.rs @@ -7,7 +7,7 @@ use gpui::{ point, prelude::FluentBuilder as _, px, }; -use crate::{FocusTrapElement as _, StyledExt as _, actions::Cancel}; +use crate::{FocusTrapElement as _, actions::Cancel}; const CONTEXT: &str = "Sheet"; diff --git a/crates/base/src/styled.rs b/crates/base/src/styled.rs index ecf3635baf..f683d333e4 100644 --- a/crates/base/src/styled.rs +++ b/crates/base/src/styled.rs @@ -1,6 +1,6 @@ use gpui::{ - App, BoxShadow, Corners, DefiniteLength, Div, Edges, FocusHandle, Hsla, Pixels, - Refineable as _, Role, StyleRefinement, Styled, Window, div, hsla, point, + App, BoxShadow, Corners, DefiniteLength, Div, Edges, FocusHandle, Hsla, Pixels, Role, Styled, + Window, div, hsla, point, }; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] @@ -76,11 +76,6 @@ macro_rules! font_weight { gpui_macros::derive_inspector_reflection )] pub trait StyledExt: Styled + Sized { - fn refine_style(mut self, style: &StyleRefinement) -> Self { - self.style().refine(style); - self - } - /// Lays children out in a row, centered on the cross axis. /// /// The centering is the desktop default for a row of controls — an icon diff --git a/crates/base/src/switch.rs b/crates/base/src/switch.rs index ff72fe2ff6..723cab6ded 100644 --- a/crates/base/src/switch.rs +++ b/crates/base/src/switch.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{StateStyle, TestSupportExt as _}; type ChangeHandler = Rc; diff --git a/crates/base/src/table.rs b/crates/base/src/table.rs index 105dade7c2..7f6884a175 100644 --- a/crates/base/src/table.rs +++ b/crates/base/src/table.rs @@ -5,8 +5,6 @@ use gpui::{ Window, div, prelude::FluentBuilder as _, }; -use crate::StyledExt as _; - macro_rules! table_part { ($name:ident, $role:expr, $docs:literal) => { #[doc = $docs] diff --git a/crates/base/src/tabs.rs b/crates/base/src/tabs.rs index 2cc196de57..c7efecafcc 100644 --- a/crates/base/src/tabs.rs +++ b/crates/base/src/tabs.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{StateStyle, TestSupportExt as _}; type ClickHandler = Rc; diff --git a/crates/base/src/test_text_system.rs b/crates/base/src/test_text_system.rs new file mode 100644 index 0000000000..e7d34a2a87 --- /dev/null +++ b/crates/base/src/test_text_system.rs @@ -0,0 +1,22 @@ +//! Real shaping for tests that exercise wrapping and multiline geometry. +use gpui::{PlatformTextSystem, TestAppContext}; +use std::{borrow::Cow, sync::Arc}; + +pub(crate) fn platform() -> Arc { + let system = Arc::new( + gpui_ce_parley::ParleyTextSystem::without_system_fonts() + .with_fallback_families(["JetBrains Mono"]), + ); + system + .add_fonts(vec![Cow::Borrowed(include_bytes!( + "../../story-web/fonts/JetBrainsMono-Regular.ttf" + ))]) + .unwrap(); + system +} + +pub(crate) fn install(cx: &mut TestAppContext) { + // GPUI's default test backend deliberately models only a single row. + // Replace the empty app before any entities or windows are created. + *cx = TestAppContext::build_with_text_system(cx.dispatcher.clone(), None, platform()); +} diff --git a/crates/base/src/text/format/html.rs b/crates/base/src/text/format/html.rs index 17f9ac4fd6..226a322c04 100644 --- a/crates/base/src/text/format/html.rs +++ b/crates/base/src/text/format/html.rs @@ -768,8 +768,8 @@ mod tests { #[test] fn test_value_to_length() { assert_eq!(super::value_to_length("100px"), Some(px(100.).into())); - assert_eq!(super::value_to_length("100%"), Some(relative(1.))); - assert_eq!(super::value_to_length("56%"), Some(relative(0.56))); + assert_eq!(super::value_to_length("100%"), Some(relative(1.).into())); + assert_eq!(super::value_to_length("56%"), Some(relative(0.56).into())); assert_eq!(super::value_to_length("240"), Some(px(240.).into())); } @@ -808,7 +808,7 @@ mod tests { children: vec![InlineNode::image(ImageNode { url: "https://example.com/image.png".to_string().into(), alt: Some("Example".to_string().into()), - width: Some(relative(0.8)), + width: Some(relative(0.8).into()), height: None, title: Some("Example Image".to_string().into()), ..Default::default() diff --git a/crates/base/src/text/inline.rs b/crates/base/src/text/inline.rs index 45cca816ba..a7cee49b77 100644 --- a/crates/base/src/text/inline.rs +++ b/crates/base/src/text/inline.rs @@ -9,11 +9,11 @@ use std::{ }; use gpui::{ - App, BorderStyle, Bounds, ClickEvent, ColorExt as _, CursorStyle, Edges, Element, ElementId, - GlobalElementId, Half, HighlightStyle, Hitbox, HitboxBehavior, Hsla, InspectorElementId, - IntoElement, LayoutId, MouseButton, MouseClickEvent, MouseDownEvent, MouseMoveEvent, - MouseUpEvent, Pixels, Point, SharedString, StyledText, TextAlign, TextLayout, TextRun, - TextStyle, Window, point, px, quad, size, + App, AppContext as _, BorderStyle, Bounds, ClickEvent, ColorExt as _, CursorStyle, Edges, + Element, ElementId, GlobalElementId, Half, HighlightStyle, Hitbox, HitboxBehavior, Hsla, + InspectorElementId, IntoElement, LayoutId, MouseButton, MouseClickEvent, MouseDownEvent, + MouseMoveEvent, MouseUpEvent, Pixels, Point, SharedString, StyledText, TextAlign, TextLayout, + TextRun, TextStyle, Window, point, px, size, }; use crate::{ @@ -425,37 +425,13 @@ impl Inline { return; }; let text_layout = self.styled_text.layout(); - let bounds = text_layout.bounds(); let line_height = text_layout.line_height(); - let glyphs = glyph_boxes( - text_layout, - window.text_style().text_align, - bounds.size.width, - ); - // The glyph drawing the text at the offset, or, for text with no - // glyph of its own such as a line break, the next glyph, or the last. - let offset = reveal.offset(); - let (row, left, right) = range_boxes(&glyphs, offset..offset + 1) - .first() - .copied() - .or_else(|| { - glyphs - .iter() - .find(|glyph| glyph.text.start >= offset) - .or(glyphs.last()) - .map(|glyph| (glyph.row, glyph.left, glyph.right)) - }) - .unwrap_or((0, Pixels::ZERO, Pixels::ZERO)); - let line = Bounds::from_corners( - point( - bounds.left() + left, - bounds.top() + line_height * row as f32, - ), - point( - bounds.left() + right.max(left + px(1.)), - bounds.top() + line_height * (row + 1) as f32, - ), - ); + // The backend already owns wrap, newline, and caret affinity geometry. + // Looking up one caret also avoids walking every cluster in a long paragraph. + let Some(position) = text_layout.position_for_index(reveal.offset()) else { + return; + }; + let line = Bounds::new(position, size(px(1.), line_height)); window.request_autoscroll(line); // A list scrolls the line to its edge, which layout may miss by a // fraction of a pixel. @@ -498,14 +474,14 @@ impl Inline { /// Paint selected bounds for debug. #[allow(unused)] fn paint_selected_bounds(&self, bounds: Bounds, window: &mut Window, cx: &mut App) { - window.paint_quad(gpui::PaintQuad { - bounds, - background: gpui::hsla(0.58, 0.85, 0.62, 0.01).into(), - corner_radii: Corners::default(), - border_color: gpui::transparent_black(), - border_style: BorderStyle::default(), - border_widths: gpui::Edges::all(px(0.)), - }); + window.paint_quad( + gpui::PaintQuad::new(bounds) + .background(gpui::hsla(0.58, 0.85, 0.62, 0.01)) + .corner_radii(Corners::default()) + .border_color(gpui::transparent_black()) + .border_style(BorderStyle::default()) + .border_widths(gpui::Edges::all(px(0.))), + ); } fn layout_selections( @@ -688,34 +664,26 @@ impl Inline { ) -> Vec> { let origin = text_layout.bounds().origin; let lines = text_layout.line_layouts(); - let row_count: usize = lines - .iter() - .map(|line| line.wrap_boundaries.len() + 1) - .sum(); + let row_count: usize = lines.iter().map(|line| line.line_count()).sum(); let mut line_bounds = Vec::with_capacity(row_count); let mut row_ix = 0; let mut y = origin.y; for line in &lines { - let layout = &line.unwrapped_layout; - let mut row_start = 0; - let row_ends = line - .wrap_boundaries - .iter() - .map(|boundary| layout.runs[boundary.run_ix].glyphs[boundary.glyph_ix].index) - .chain([line.len()]); - for row_end in row_ends { - let mut width = layout.x_for_index(row_end) - layout.x_for_index(row_start); + for visual_line in line.visual_lines() { + let mut width = visual_line.advance_width; row_ix += 1; if row_ix < row_count { width += line_height.half(); } - let bounds = Bounds::new(point(origin.x, y), size(width, line_height)) - .intersect(&mask_bounds); + let bounds = Bounds::new( + point(origin.x + visual_line.offset, y), + size(width, line_height), + ) + .intersect(&mask_bounds); if bounds.size.width > px(0.) && bounds.size.height > px(0.) { line_bounds.push(bounds); } y += line_height; - row_start = row_end; } } line_bounds @@ -766,55 +734,55 @@ impl Inline { let line_height = text_layout.line_height(); if start_position.y == end_position.y { - window.paint_quad(quad( - Bounds::from_corners( + window.paint_quad( + gpui::PaintQuad::new(Bounds::from_corners( start_position, point(end_position.x, end_position.y + line_height), - ), - px(0.), - color, - Edges::default(), - gpui::transparent_black(), - BorderStyle::default(), - )); + )) + .corner_radii(px(0.)) + .background(color) + .border_widths(Edges::default()) + .border_color(gpui::transparent_black()) + .border_style(BorderStyle::default()), + ); } else { - window.paint_quad(quad( - Bounds::from_corners( + window.paint_quad( + gpui::PaintQuad::new(Bounds::from_corners( start_position, point(bounds.right(), start_position.y + line_height), - ), - px(0.), - color, - Edges::default(), - gpui::transparent_black(), - BorderStyle::default(), - )); + )) + .corner_radii(px(0.)) + .background(color) + .border_widths(Edges::default()) + .border_color(gpui::transparent_black()) + .border_style(BorderStyle::default()), + ); if end_position.y > start_position.y + line_height { - window.paint_quad(quad( - Bounds::from_corners( + window.paint_quad( + gpui::PaintQuad::new(Bounds::from_corners( point(bounds.left(), start_position.y + line_height), point(bounds.right(), end_position.y), - ), - px(0.), - color, - Edges::default(), - gpui::transparent_black(), - BorderStyle::default(), - )); + )) + .corner_radii(px(0.)) + .background(color) + .border_widths(Edges::default()) + .border_color(gpui::transparent_black()) + .border_style(BorderStyle::default()), + ); } - window.paint_quad(quad( - Bounds::from_corners( + window.paint_quad( + gpui::PaintQuad::new(Bounds::from_corners( point(bounds.left(), end_position.y), point(end_position.x, end_position.y + line_height), - ), - px(0.), - color, - Edges::default(), - gpui::transparent_black(), - BorderStyle::default(), - )); + )) + .corner_radii(px(0.)) + .background(color) + .border_widths(Edges::default()) + .border_color(gpui::transparent_black()) + .border_style(BorderStyle::default()), + ); } } @@ -829,13 +797,13 @@ impl Inline { let line_height = text_layout.line_height(); for (range, color) in &self.range_backgrounds { for (row, left, right) in range_boxes(&glyphs, range.clone()) { - window.paint_quad(gpui::fill( - Bounds::from_corners( + window.paint_quad( + gpui::PaintQuad::new(Bounds::from_corners( point(origin.x + left, origin.y + line_height * row as f32), point(origin.x + right, origin.y + line_height * (row + 1) as f32), - ), - *color, - )); + )) + .background(*color), + ); } } } @@ -889,6 +857,17 @@ impl Element for Inline { self.styled_text .request_layout(global_element_id, inspector_id, window, cx); + // This renderer owns selection and range geometry. Keep StyledText out + // of the parent's automatic inline flow, which bypasses its TextLayout. + let layout_id = window.request_layout( + gpui::Style { + display: gpui::Display::Flex, + flex_direction: gpui::FlexDirection::Column, + ..Default::default() + }, + [layout_id], + cx, + ); (layout_id, ()) } @@ -1179,92 +1158,58 @@ struct GlyphBox { right: Pixels, } -/// The glyphs of `text_layout`, sorted by the text they draw, each placed -/// the way GPUI paints it: every row aligned in `align_width` by `align`, -/// and a glyph reaching to the next one on its row, or to the row's end. -/// -/// Glyphs are read in the order they paint, so right-to-left text, whose -/// glyphs paint in the reverse order of its text, is placed as it shows. +/// Backend cluster geometry in logical text order, including bidi placement. +/// GPUI 0.3 no longer exposes a source byte index on each painted glyph. fn glyph_boxes(text_layout: &TextLayout, align: TextAlign, align_width: Pixels) -> Vec { let mut boxes = Vec::new(); - let mut row = 0; - let mut line_start = 0; + let line_height = text_layout.line_height(); + let mut row_offset = 0; + let mut text_offset = 0; for line in text_layout.line_layouts() { - let layout = &line.unwrapped_layout; - let glyphs = layout - .runs - .iter() - .flat_map(|run| run.glyphs.iter()) - .collect::>(); - // Each row starts at a wrap boundary glyph, and ends where the next - // row starts, or at the end of the line. - let run_offsets = layout - .runs - .iter() - .scan(0, |offset, run| { - let start = *offset; - *offset += run.glyphs.len(); - Some(start) - }) - .collect::>(); - let row_starts = line - .wrap_boundaries - .iter() - .map(|boundary| run_offsets[boundary.run_ix] + boundary.glyph_ix) - .collect::>(); - let line_boxes = boxes.len(); - let mut from = 0; - for (row_in_line, to) in row_starts.iter().copied().chain([glyphs.len()]).enumerate() { - let start_x = if row_in_line == 0 { - Pixels::ZERO - } else { - glyphs[from].position.x - }; - let end_x = glyphs - .get(to) - .map_or(layout.width, |glyph| glyph.position.x); - let shift = aligned_row_left(align, align_width, end_x - start_x) - start_x; - for ix in from..to { - let glyph = glyphs[ix]; - let right = if ix + 1 < to { - glyphs[ix + 1].position.x - } else { - end_x - }; - boxes.push(GlyphBox { - text: line_start + glyph.index..line_start + glyph.index, - row: row + row_in_line, - left: shift + glyph.position.x, - right: shift + right, - }); + let mut index = 0; + while let Some(range) = + line.logical_cluster_after(gpui::CaretPosition::attached_to_next_cluster(index)) + { + if range.end <= index { + break; } - from = to; - } - - // A glyph draws its text up to where the next glyph's text starts. - let line_boxes = &mut boxes[line_boxes..]; - line_boxes.sort_by_key(|glyph| glyph.text.start); - let line_end = line_start + line.len(); - for ix in 0..line_boxes.len() { - let start = line_boxes[ix].text.start; - line_boxes[ix].text.end = line_boxes[ix + 1..] - .iter() - .map(|glyph| glyph.text.start) - .find(|next| *next > start) - .unwrap_or(line_end); + for bounds in line.selection_bounds(range.clone(), line_height) { + let row = (f32::from(bounds.origin.y) / f32::from(line_height)).round() as usize; + if let Some(visual_line) = line.visual_lines().get(row) { + let shift = aligned_row_left( + align, + align_width, + visual_line.advance_width, + visual_line.direction, + ) - visual_line.offset; + boxes.push(GlyphBox { + text: text_offset + range.start..text_offset + range.end, + row: row_offset + row, + left: shift + bounds.origin.x, + right: shift + bounds.right(), + }); + } + } + index = range.end; } - - row += line.wrap_boundaries.len() + 1; - line_start = line_end + 1; + row_offset += line.line_count(); + text_offset += line.len(); } boxes } -fn aligned_row_left(align: TextAlign, align_width: Pixels, width: Pixels) -> Pixels { +fn aligned_row_left( + align: TextAlign, + align_width: Pixels, + width: Pixels, + direction: gpui::ResolvedDirection, +) -> Pixels { match align { - TextAlign::Left => Pixels::ZERO, + TextAlign::Start if direction.is_rtl() => align_width - width, + TextAlign::Start | TextAlign::Left => Pixels::ZERO, + TextAlign::End if direction.is_rtl() => Pixels::ZERO, TextAlign::Center => (align_width - width) / 2., - TextAlign::Right => align_width - width, + TextAlign::End | TextAlign::Right => align_width - width, } } @@ -1542,11 +1487,8 @@ mod line_bounds_tests { #[cfg(test)] mod range_highlight_tests { + use super::test_draw::in_prepaint; use super::*; - use super::{ - test_draw::in_prepaint, - test_fonts::{BODY, WideMonoTextSystem}, - }; use gpui::{AvailableSpace, TestApp, size}; /// Lays `text` out at `wrap_width` and returns the highlight boxes of @@ -1558,11 +1500,11 @@ mod range_highlight_tests { align: TextAlign, range: Range, ) -> Vec<(Pixels, Pixels, usize)> { - let mut app = TestApp::with_text_system(Arc::new(WideMonoTextSystem)); + let mut app = TestApp::with_text_system(crate::test_text_system::platform()); in_prepaint(&mut app, move |window, cx| { let style = TextStyle { - font_family: BODY.into(), - font_size: px(16.).into(), + font_family: "JetBrains Mono".into(), + font_size: px(40. / 3.).into(), ..Default::default() }; let styled = StyledText::new(SharedString::from(text)).with_runs(text_runs( @@ -1572,13 +1514,21 @@ mod range_highlight_tests { )); let layout = styled.layout().clone(); let mut element = styled.into_any_element(); - element.layout_as_root( - size( - AvailableSpace::Definite(px(wrap_width)), - AvailableSpace::MinContent, - ), - window, - cx, + window.with_text_style( + Some(gpui::TextStyleRefinement { + text_align: Some(align), + ..Default::default() + }), + |window| { + element.layout_as_root( + size( + AvailableSpace::Definite(px(wrap_width)), + AvailableSpace::MinContent, + ), + window, + cx, + ); + }, ); let origin = point(px(7.), px(11.)); element.prepaint_at(origin, window, cx); @@ -1597,11 +1547,11 @@ mod range_highlight_tests { /// places at the end of the row before it, holds no row the walk tests. #[test] fn text_rows_extent_matches_the_character_walk() { - let mut app = TestApp::with_text_system(Arc::new(WideMonoTextSystem)); + let mut app = TestApp::with_text_system(crate::test_text_system::platform()); in_prepaint(&mut app, |window, cx| { let style = TextStyle { - font_family: BODY.into(), - font_size: px(16.).into(), + font_family: "JetBrains Mono".into(), + font_size: px(40. / 3.).into(), ..Default::default() }; let origin = point(px(7.), px(11.3)); @@ -1761,12 +1711,277 @@ pub(super) mod test_draw { #[cfg(test)] pub(super) mod test_fonts { + // Single-row interaction fixture adapted from GPUI CE 0.3 platform.rs (Apache-2.0). + use gpui::{ + CaretAffinity, CaretMovement, CaretPosition, PlatformTextLayout, Point, TextBoundary, + TextDirection, TextMovement, TextSelectionKind, VisualDirection, + }; + use std::ops::Range; + #[derive(Debug)] + /// A deterministic test layout with exactly one visual and hard line. + struct TestPlatformTextLayout { + /// Source text. + text: String, + /// Ordered (byte index, x position) caret stops. + stops: Vec<(usize, Pixels)>, + /// Size of the single visual line. + size: Size, + } + + impl TestPlatformTextLayout { + fn caret_stop(&self, byte_offset: usize) -> (usize, Pixels) { + let stop_index = self + .stops + .partition_point(|(index, _position)| *index <= byte_offset) + .saturating_sub(1); + + self.stops[stop_index] + } + } + + impl PlatformTextLayout for TestPlatformTextLayout { + fn len(&self) -> usize { + self.stops.last().map_or(0, |(index, _)| *index) + } + + fn line_count(&self) -> usize { + // This test layout deliberately reports its single visual line. + 1 + } + + fn size(&self) -> Size { + self.size + } + + fn byte_index_from_pixel_point( + &self, + pixel_point: Point, + line_height: Pixels, + ) -> Result { + let closest = self + .caret_from_pixel_point(pixel_point, line_height) + .unwrap_or_else(|caret| caret) + .index; + self.stops + .windows(2) + .find_map(|stops| { + let [(start_index, start_x), (_end_index, end_x)] = stops else { + return None; + }; + + (pixel_point.x >= *start_x && pixel_point.x < *end_x) + .then_some(Ok(*start_index)) + }) + .unwrap_or(Err(closest)) + } + + fn caret_from_pixel_point( + &self, + pixel_point: Point, + line_height: Pixels, + ) -> Result { + let index = self + .stops + .iter() + .min_by(|(_, left), (_, right)| { + (f32::from(*left) - f32::from(pixel_point.x)) + .abs() + .total_cmp(&(f32::from(*right) - f32::from(pixel_point.x)).abs()) + }) + .map_or(0, |(index, _)| *index); + let caret = self.normalized_caret(CaretPosition { + index, + affinity: CaretAffinity::Downstream, + }); + + if pixel_point.y >= Pixels::ZERO + && pixel_point.y < line_height + && pixel_point.x >= Pixels::ZERO + && pixel_point.x < self.size.width + { + Ok(caret) + } else { + Err(caret) + } + } + + fn caret_bounds( + &self, + caret: CaretPosition, + line_height: Pixels, + ) -> Option> { + let caret = self.normalized_caret(caret); + let (_index, position) = self.caret_stop(caret.index); + + Some(Bounds::new( + point(position, Pixels::ZERO), + size(Pixels::ZERO, line_height), + )) + } + + fn normalized_caret(&self, caret: CaretPosition) -> CaretPosition { + let (index, _position) = self.caret_stop(caret.index); + let affinity = if index == self.len() && index != 0 { + CaretAffinity::Upstream + } else { + caret.affinity + }; + + CaretPosition { index, affinity } + } + + fn adjacent_visual_caret( + &self, + caret: CaretPosition, + direction: VisualDirection, + ) -> Option { + let caret = self.normalized_caret(caret); + let position = self + .stops + .iter() + .position(|(index, _)| *index == caret.index)?; + let position = match direction { + VisualDirection::Left => position.checked_sub(1)?, + VisualDirection::Right => position.checked_add(1)?, + }; + + let index = self.stops.get(position)?.0; + Some(self.normalized_caret(CaretPosition { + index, + affinity: CaretAffinity::Downstream, + })) + } + + fn selection_bounds( + &self, + byte_range: Range, + line_height: Pixels, + ) -> Vec> { + if byte_range.is_empty() { + return Vec::new(); + } + + let (_start_index, start) = self.caret_stop(byte_range.start); + let (_end_index, end) = self.caret_stop(byte_range.end); + + // The platform contract returns one bound per visual line. Since this test + // layout has exactly one visual line, every non-empty selection has one bound. + vec![Bounds::from_corners( + point(start.min(end), Pixels::ZERO), + point(start.max(end), line_height), + )] + } + + fn logical_cluster_before(&self, caret: CaretPosition) -> Option> { + self.stops + .windows(2) + .rev() + .find(|stops| stops[1].0 <= caret.index) + .map(|stops| stops[0].0..stops[1].0) + } + + fn logical_cluster_after(&self, caret: CaretPosition) -> Option> { + self.stops + .windows(2) + .find(|stops| stops[0].0 >= caret.index) + .map(|stops| stops[0].0..stops[1].0) + } + + fn caret_movement( + &self, + caret: CaretPosition, + movement: TextMovement, + vertical_navigation_x: Option, + ) -> CaretMovement { + use TextBoundary::*; + use TextDirection::*; + + let index = match (movement.direction, movement.boundary) { + (Left, Cluster) => { + self.adjacent_visual_caret(caret, VisualDirection::Left) + .unwrap_or(caret) + .index + } + (Right, Cluster) => { + self.adjacent_visual_caret(caret, VisualDirection::Right) + .unwrap_or(caret) + .index + } + (Left, Word) => { + let prefix = &self.text[..caret.index.min(self.text.len())]; + let trimmed = prefix.trim_end_matches(char::is_whitespace); + trimmed.rfind(char::is_whitespace).map_or(0, |index| { + index + trimmed[index..].chars().next().unwrap().len_utf8() + }) + } + (Right, Word) => { + let start = caret.index.min(self.text.len()); + let suffix = &self.text[start..]; + let word_end = suffix.find(char::is_whitespace).unwrap_or(suffix.len()); + let rest = &suffix[word_end..]; + start + + word_end + + rest + .find(|character: char| !character.is_whitespace()) + .unwrap_or(rest.len()) + } + // This test layout has one visual and hard line. Without wrapping or + // additional hard lines, these movements resolve to the document endpoints. + (Up | Start, VisualLine) | (Start, HardLine | Document) => 0, + (Down | End, VisualLine) | (End, HardLine | Document) => self.len(), + _ => caret.index, + }; + + let vertical_navigation_x = + matches!(movement.direction, TextDirection::Up | TextDirection::Down).then(|| { + vertical_navigation_x.unwrap_or_else(|| { + self.caret_bounds(caret, self.size.height) + .map_or(Pixels::ZERO, |bounds| bounds.origin.x) + }) + }); + + CaretMovement { + result: self.normalized_caret(CaretPosition { + index, + affinity: CaretAffinity::Downstream, + }), + vertical_navigation_x, + } + } + + fn selection_from_pixel_point( + &self, + pixel_point: Point, + line_height: Pixels, + kind: TextSelectionKind, + ) -> Range { + if !matches!(kind, TextSelectionKind::Word) { + return 0..self.len(); + } + + let index = self + .caret_from_pixel_point(pixel_point, line_height) + .unwrap_or_else(|caret| caret) + .index + .min(self.text.len()); + let start = self.text[..index] + .rfind(char::is_whitespace) + .map_or(0, |offset| { + offset + self.text[offset..].chars().next().unwrap().len_utf8() + }); + let end = self.text[index..] + .find(char::is_whitespace) + .map_or(self.text.len(), |offset| index + offset); + start..end + } + } + use gpui::{ - Bounds, DevicePixels, Font, FontId, FontMetrics, FontRun, FontWeight, GlyphId, LineLayout, - Pixels, PlatformTextSystem, RenderGlyphParams, ShapedGlyph, ShapedRun, Size, - TextRenderingMode, point, px, size, + Bounds, Font, FontId, FontMetrics, FontWeight, GlyphId, LineLayout, Pixels, + PlatformTextSystem, RenderGlyphParams, ShapedGlyph, Size, TextRenderingMode, point, px, + size, }; - use std::{borrow::Cow, cell::RefCell}; + use std::borrow::Cow; pub(crate) const BODY: &str = "Body"; pub(crate) const MONO: &str = "Mono"; @@ -1856,51 +2071,44 @@ pub(super) mod test_fonts { Some(GlyphId(ch as u32)) } - fn glyph_raster_bounds( - &self, - _params: &RenderGlyphParams, - ) -> anyhow::Result> { - Ok(Bounds::default()) - } - fn rasterize_glyph( &self, - _params: &RenderGlyphParams, - raster_bounds: Bounds, - ) -> anyhow::Result<(Size, Vec)> { - Ok((raster_bounds.size, Vec::new())) + params: &RenderGlyphParams, + ) -> anyhow::Result { + gpui::TestTextSystem.rasterize_glyph(params) } - fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout { - thread_local! { - static SHAPED_LINE_RECORDER: RefCell>> = - const { RefCell::new(None) }; - } - SHAPED_LINE_RECORDER.with(|recorder| { - if let Some(lines) = recorder.borrow_mut().as_mut() { - lines.push(text.to_string()); - } - }); - + fn layout_text(&self, request: gpui::TextLayoutRequest<'_>) -> LineLayout { + let text = request.text; + let font_size = request.font_size; let mut position = px(0.); - let mut shaped_runs = Vec::new(); + let mut fragments = Vec::new(); + let mut stops = vec![(0, position)]; let mut run_start = 0; - for run in runs { + for (source_run, run) in request.runs.iter().enumerate() { let run_text = &text[run_start..run_start + run.len]; - let advance = font_size * (Self::advance_units(run.font_id) / UNITS_PER_EM); + let font_id = self.font_id(&run.font).unwrap(); + let advance = font_size * (Self::advance_units(font_id) / UNITS_PER_EM); + let start_x = position; let mut glyphs = Vec::new(); for (ix, ch) in run_text.char_indices() { glyphs.push(ShapedGlyph { id: GlyphId(ch as u32), position: point(position, px(0.)), - index: run_start + ix, is_emoji: false, }); position += advance; + stops.push((run_start + ix + ch.len_utf8(), position)); } - shaped_runs.push(ShapedRun { - font_id: run.font_id, - glyphs, + fragments.push(gpui::PaintFragment { + source_run, + font_id, + font_size, + glyphs: glyphs.into(), + x_range: start_x..position, + style: run.into(), + underline_offset: None, + strikethrough_offset: None, }); run_start += run.len; } @@ -1909,13 +2117,28 @@ pub(super) mod test_fonts { font_size, width: position, ascent: font_size * (metrics.ascent / UNITS_PER_EM), - // Native backends normalize the signed font metric for shaped lines. descent: font_size * (-metrics.descent / UNITS_PER_EM), - runs: shaped_runs, + visual_lines: [gpui::VisualLine { + text_range: 0..text.len(), + paint_fragment_range: 0..fragments.len(), + advance_width: position, + ..Default::default() + }] + .into(), + paint_fragments: fragments, len: text.len(), + platform_layout: std::sync::Arc::new(TestPlatformTextLayout { + text: text.to_string(), + stops, + size: size(position, font_size), + }), } } + fn layout_inline(&self, request: gpui::InlineLayoutRequest<'_>) -> gpui::InlineLayout { + gpui::TestTextSystem.layout_inline(request) + } + fn recommended_rendering_mode( &self, _font_id: FontId, @@ -1963,9 +2186,33 @@ mod tests { #[test] fn rows_align_the_way_gpui_paints_them() { let width = px(100.); - assert_eq!(aligned_row_left(TextAlign::Left, width, px(40.)), px(0.)); - assert_eq!(aligned_row_left(TextAlign::Center, width, px(40.)), px(30.)); - assert_eq!(aligned_row_left(TextAlign::Right, width, px(40.)), px(60.)); + assert_eq!( + aligned_row_left( + TextAlign::Left, + width, + px(40.), + gpui::ResolvedDirection::LeftToRight + ), + px(0.) + ); + assert_eq!( + aligned_row_left( + TextAlign::Center, + width, + px(40.), + gpui::ResolvedDirection::LeftToRight + ), + px(30.) + ); + assert_eq!( + aligned_row_left( + TextAlign::Right, + width, + px(40.), + gpui::ResolvedDirection::LeftToRight + ), + px(60.) + ); } fn glyph(text: Range, row: usize, left: f32, right: f32) -> GlyphBox { diff --git a/crates/base/src/text/inline_flow.rs b/crates/base/src/text/inline_flow.rs index 78a79dccf5..2e4b56e504 100644 --- a/crates/base/src/text/inline_flow.rs +++ b/crates/base/src/text/inline_flow.rs @@ -1,3 +1,5 @@ +use crate::text_compat::ShapedLineExt as _; +use crate::text_compat::{LineFragment as WrapLineFragment, LineWrapperExt as _}; use std::{ cell::RefCell, ops::Range, @@ -9,9 +11,9 @@ use unicode_segmentation::UnicodeSegmentation as _; use gpui::{ AbsoluteLength, AnyElement, App, AvailableSpace, Bounds, DefiniteLength, Element, ElementId, GlobalElementId, Hsla, ImageSource, InspectorElementId, InteractiveElement as _, IntoElement, - LayoutId, LineFragment as WrapLineFragment, ObjectFit, Pixels, Refineable as _, ShapedLine, - SharedString, Size, StatefulInteractiveElement as _, Styled, StyledImage as _, TextRun, - TextStyle, WhiteSpace, Window, img, point, prelude::FluentBuilder as _, px, relative, size, + LayoutId, ObjectFit, Pixels, Refineable as _, ShapedLine, SharedString, Size, + StatefulInteractiveElement as _, Styled, StyledImage as _, TextRun, TextStyle, WhiteSpace, + Window, img, point, prelude::FluentBuilder as _, px, relative, size, }; use crate::text::text_view::{LinkClickHandlerFn, handle_link_click}; @@ -677,7 +679,11 @@ impl Element for InlineFlow { let radius = crate::Theme::global(cx).tokens.radius.sm; for (element, background) in prepaint { if let Some((bounds, color)) = background { - window.paint_quad(gpui::fill(*bounds, *color).corner_radii(radius)); + window.paint_quad( + gpui::PaintQuad::new(*bounds) + .background(*color) + .corner_radii(radius), + ); } element.paint(window, cx); } @@ -1123,7 +1129,11 @@ fn code_background( .iter() .map(|run| { let font = window.text_system().resolve_font(&run.font); - window.text_system().cap_height(font, font_size) + window + .text_system() + .typographic_bounds(font, font_size, 'H') + .map(|bounds| bounds.size.height) + .unwrap_or_else(|_| window.text_system().ascent(font, font_size)) }) .fold(Pixels::ZERO, Pixels::max); let vertical_padding = font_size * 0.125 + shaped_line.descent / 2.; @@ -1268,7 +1278,7 @@ fn line_ranges( /// Where the first line of `fragments` (which start at byte `start`) wraps at /// `wrap_width`; `end` when it all fits. fn next_wrap( - wrapper: &mut gpui::LineWrapperHandle, + wrapper: &mut crate::text_compat::LineWrapper, fragments: &[WrapLineFragment], wrap_width: Pixels, start: usize, @@ -1467,7 +1477,6 @@ fn push_text_wrap_fragments<'a>( text, font_size * highlight.font_size_scale.unwrap_or(1.), &runs, - None, ) .width }; @@ -1602,7 +1611,7 @@ fn shape_line( runs: &[TextRun], window: &mut Window, ) -> ShapedLine { - window.text_system().shape_line(text, font_size, runs, None) + window.text_system().shape_line(text, font_size, runs) } /// The line height GPUI's text layout gives a plain line in `text_style`. diff --git a/crates/base/src/text/inline_object.rs b/crates/base/src/text/inline_object.rs index e1e1c92135..f9b1628d84 100644 --- a/crates/base/src/text/inline_object.rs +++ b/crates/base/src/text/inline_object.rs @@ -5,10 +5,10 @@ use std::{ }; use gpui::{ - AnyElement, App, AvailableSpace, Bounds, CursorStyle, Element, ElementId, GlobalElementId, - Hitbox, HitboxBehavior, InspectorElementId, IntoElement, LayoutId, MouseButton, MouseDownEvent, - ParentElement, Pixels, Refineable as _, Role, SharedString, Size, Styled, StyledText, - TextStyle, Window, div, px, size, + AnyElement, App, AppContext as _, AvailableSpace, Bounds, CursorStyle, Element, ElementId, + GlobalElementId, Hitbox, HitboxBehavior, InspectorElementId, IntoElement, LayoutId, + MouseButton, MouseDownEvent, ParentElement, Pixels, Refineable as _, Role, SharedString, Size, + Styled, StyledText, TextStyle, Window, div, px, size, }; use super::{ @@ -59,12 +59,10 @@ impl MeasuredInlineObject { ) -> Self { let font_size = style.font_size.to_pixels(window.rem_size()); let text: SharedString = text.replace(['\r', '\n'], " ").into(); - let line = window.text_system().shape_line( - text.clone(), - font_size, - &[style.to_run(text.len())], - None, - ); + let line = + window + .text_system() + .shape_line(text.clone(), font_size, &[style.to_run(text.len())]); let height = style .line_height_in_pixels(window.rem_size()) .max(line.ascent + line.descent); @@ -328,7 +326,7 @@ impl Element for InlineObject { } if selected { let color = view.as_ref().unwrap().read(cx).text_view_style.selection(); - window.paint_quad(gpui::fill(bounds, color)); + window.paint_quad(gpui::PaintQuad::new(bounds).background(color)); } if let Some(link) = self.link.clone() { window.set_cursor_style(CursorStyle::PointingHand, hitbox); diff --git a/crates/base/src/text/node.rs b/crates/base/src/text/node.rs index 7dd127aadb..338c1153e7 100644 --- a/crates/base/src/text/node.rs +++ b/crates/base/src/text/node.rs @@ -14,7 +14,7 @@ use gpui::{ use markdown::mdast; use crate::{ - StyledExt, h_flex, + h_flex, scrollable_mask::horizontal_scroll_area, text::{ CodeBlockActionsFn, CodeBlockHighlighterFn, LinkClickHandlerFn, MarkdownExtensions, @@ -2613,7 +2613,7 @@ fn measure_table_columns( let runs = text_runs(range.len(), &text_style, &highlights); line_w += window .text_system() - .layout_line(&line[range], font_size * scale, &runs, None) + .layout_line(&line[range], font_size * scale, &runs) .width; } w = w.max(f32::from(line_w)); diff --git a/crates/base/src/text/state.rs b/crates/base/src/text/state.rs index 66c5dd3246..43c3e20d5b 100644 --- a/crates/base/src/text/state.rs +++ b/crates/base/src/text/state.rs @@ -2728,11 +2728,14 @@ mod tests { container: Container, cx: &'a mut TestAppContext, ) -> (Entity, &'a mut VisualTestContext) { + crate::test_text_system::install(cx); cx.update(crate::init); let (root, cx) = cx.add_window_view(|_, cx| Root { state: cx.new(|cx| TextViewState::markdown(markdown, cx)), container, }); + // GPUI 0.3 lays the root out at the actual viewport size. + cx.simulate_resize(gpui::size(px(200.), px(100.))); cx.run_until_parked(); draw(cx); let state = root.read_with(cx, |root, _| root.state.clone()); diff --git a/crates/base/src/text/text_view.rs b/crates/base/src/text/text_view.rs index 1f6d248037..0dc1209434 100644 --- a/crates/base/src/text/text_view.rs +++ b/crates/base/src/text/text_view.rs @@ -8,7 +8,6 @@ use gpui::{ StyleRefinement, Styled, Window, div, point, px, }; -use crate::StyledExt; use crate::text::TextViewFormat; use crate::text::markdown_ext::{MarkdownExtensions, MarkdownNode, MarkdownPlugin}; use crate::text::node::{CodeBlock, TableData}; @@ -800,6 +799,7 @@ impl Element for TextView { // Snap the `max_lines` clip to the last whole line that fits, so a // line of glyphs is never cut in half. let mask = ContentMask { + fade_out: Default::default(), bounds: Bounds::from_corners(bounds.origin, point(bounds.right(), clip_bottom)), }; window.with_content_mask(Some(mask), |window| { @@ -1326,6 +1326,7 @@ mod tests { /// keeps describing it. #[gpui::test] fn replacing_a_document_with_an_equal_block_count_remeasures(cx: &mut TestAppContext) { + crate::test_text_system::install(cx); cx.update(crate::init); const BLOCKS: usize = 24; @@ -1336,6 +1337,7 @@ mod tests { text_view: cx.new(|cx| TextViewState::markdown(&short, cx)), }); let cx: &mut VisualTestContext = cx; + cx.simulate_resize(gpui::size(px(400.), px(200.))); // The list is populated and measured during layout, so every // assertion below has to follow a real frame. diff --git a/crates/base/src/text_compat.rs b/crates/base/src/text_compat.rs new file mode 100644 index 0000000000..15ca3ab10b --- /dev/null +++ b/crates/base/src/text_compat.rs @@ -0,0 +1,412 @@ +//! Compatibility for the component library's row-based editor model. +//! Wrapping algorithm adapted from GPUI CE `afc7a95c8971c3d829a2fe8a2646ed3c436ca2b4`, +//! `crates/gpui/src/text_system/line_wrapper.rs` (Apache-2.0). +//! Wrapping retains the pre-0.3 GPUI algorithm; shaping and hit testing use GPUI 0.3. +use gpui::{CaretPosition, Font, Pixels, ShapedLine, TextSystem, WindowTextSystem, point, px}; +use std::{collections::HashMap, iter, ops::Deref, sync::Arc}; + +pub struct LineWrapper { + text_system: WindowTextSystem, + font: Font, + font_size: Pixels, + letter_spacing: Option, + cached_ascii_char_widths: [Option; 128], + cached_other_char_widths: HashMap, +} +impl LineWrapper { + pub const MAX_INDENT: u32 = 256; + fn new(font: Font, font_size: Pixels, text_system: Arc) -> Self { + Self { + font, + text_system: WindowTextSystem::new(text_system), + font_size, + letter_spacing: None, + cached_ascii_char_widths: [None; 128], + cached_other_char_widths: HashMap::new(), + } + } + /// Wrap a line of text to the given width with this wrapper's font and font size. + pub fn wrap_line<'a>( + &'a mut self, + fragments: &'a [LineFragment], + wrap_width: Pixels, + ) -> impl Iterator + 'a { + let mut width = px(0.); + let mut first_non_whitespace_ix = None; + let mut indent = None; + let mut last_candidate_ix = 0; + let mut last_candidate_width = px(0.); + let mut last_wrap_ix = 0; + let mut prev_c = '\0'; + let mut index = 0; + let mut previous_text_character = false; + let mut candidates = fragments + .iter() + .flat_map(move |fragment| fragment.wrap_boundary_candidates()) + .peekable(); + iter::from_fn(move || { + for candidate in candidates.by_ref() { + let ix = index; + index += candidate.len_utf8(); + let mut new_prev_c = prev_c; + let mut item_had_spacing = false; + let item_width = match candidate { + WrapBoundaryCandidate::Char { character: c } => { + if c == '\n' { + previous_text_character = false; + continue; + } + + if Self::is_word_char(c) { + if prev_c == ' ' && c != ' ' && first_non_whitespace_ix.is_some() { + last_candidate_ix = ix; + last_candidate_width = width; + } + } else { + // CJK may not be space separated, e.g.: `Hello world你好世界` + if c != ' ' && first_non_whitespace_ix.is_some() { + last_candidate_ix = ix; + last_candidate_width = width; + } + } + + if c != ' ' && first_non_whitespace_ix.is_none() { + first_non_whitespace_ix = Some(ix); + } + + new_prev_c = c; + + let width = self.width_for_char(c); + let spacing = if previous_text_character { + self.letter_spacing.unwrap_or_default() + } else { + px(0.) + }; + item_had_spacing = previous_text_character; + previous_text_character = true; + width + spacing + } + WrapBoundaryCandidate::Element { + width: element_width, + .. + } => { + if prev_c == ' ' && first_non_whitespace_ix.is_some() { + last_candidate_ix = ix; + last_candidate_width = width; + } + + if first_non_whitespace_ix.is_none() { + first_non_whitespace_ix = Some(ix); + } + + element_width + } + }; + + width += item_width; + if width > wrap_width && ix > last_wrap_ix { + if let (None, Some(first_non_whitespace_ix)) = (indent, first_non_whitespace_ix) + { + indent = Some( + Self::MAX_INDENT.min((first_non_whitespace_ix - last_wrap_ix) as u32), + ); + } + + if last_candidate_ix > 0 { + last_wrap_ix = last_candidate_ix; + width -= last_candidate_width; + width -= self.letter_spacing.unwrap_or_default(); + last_candidate_ix = 0; + } else { + last_wrap_ix = ix; + width = if item_had_spacing { + item_width - self.letter_spacing.unwrap_or_default() + } else { + item_width + }; + } + + if let Some(indent) = indent { + width += self.width_for_char(' ') * indent as f32; + } + + return Some(Boundary::new(last_wrap_ix, indent.unwrap_or(0))); + } + + prev_c = new_prev_c; + } + + None + }) + } + + /// Any character in this list should be treated as a word character, + /// meaning it can be part of a word that should not be wrapped. + pub(crate) fn is_word_char(c: char) -> bool { + // ASCII alphanumeric characters, for English, numbers: `Hello123`, etc. + c.is_ascii_alphanumeric() || + // Latin script in Unicode for French, German, Spanish, etc. + // Latin-1 Supplement + // https://en.wikipedia.org/wiki/Latin-1_Supplement + matches!(c, '\u{00C0}'..='\u{00FF}') || + // Latin Extended-A + // https://en.wikipedia.org/wiki/Latin_Extended-A + matches!(c, '\u{0100}'..='\u{017F}') || + // Latin Extended-B + // https://en.wikipedia.org/wiki/Latin_Extended-B + matches!(c, '\u{0180}'..='\u{024F}') || + // Cyrillic for Russian, Ukrainian, etc. + // https://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode + matches!(c, '\u{0400}'..='\u{04FF}') || + + // Vietnamese (https://vietunicode.sourceforge.net/charset/) + matches!(c, '\u{1E00}'..='\u{1EFF}') || // Latin Extended Additional + matches!(c, '\u{0300}'..='\u{036F}') || // Combining Diacritical Marks + + // Bengali (https://en.wikipedia.org/wiki/Bengali_(Unicode_block)) + matches!(c, '\u{0980}'..='\u{09FF}') || + + // Some other known special characters that should be treated as word characters, + // e.g. `a-b`, `var_name`, `I'm`/`won’t`, '@mention`, `#hashtag`, `100%`, `3.1415`, + // `2^3`, `a~b`, `a=1`, `Self::new`, etc. Trailing punctuation like `,`, `.`, `:`, `;` + // is included so it stays attached to the preceding word when wrapping. + matches!(c, '-' | '_' | '.' | '\'' | '’' | '‘' | '$' | '%' | '@' | '#' | '^' | '~' | ',' | '=' | ':' | ';') || + // Closing punctuation never starts a line (UAX #14 LB13: no break + // before `!`, `)`, `]`, `}`, closing quotes or an ellipsis) — `plz!`, + // `see)`, `quoted”` wrap as one word instead of orphaning the mark on + // the next line. `/` and `?` stay break opportunities so long paths + // and URLs (`a/b`, `foo?b=2`) can wrap. + matches!(c, '!' | ')' | ']' | '}' | '"' | '”' | '»' | '…') || + // `⋯` character is special used in Zed, to keep this at the end of the line. + matches!(c, '⋯') || + + // Non-breaking glue characters + matches!(c, '\u{202F}' | '\u{00A0}' | '\u{2011}') + } + + #[inline(always)] + fn width_for_char(&mut self, c: char) -> Pixels { + if (c as u32) < 128 { + if let Some(cached_width) = self.cached_ascii_char_widths[c as usize] { + cached_width + } else { + let width = self.measure_char(c); + self.cached_ascii_char_widths[c as usize] = Some(width); + width + } + } else if let Some(cached_width) = self.cached_other_char_widths.get(&c) { + *cached_width + } else { + let width = self.measure_char(c); + self.cached_other_char_widths.insert(c, width); + width + } + } + + fn measure_char(&self, c: char) -> Pixels { + // Shape through the backend so fallback glyphs have their painted width, + // including characters absent from the requested font (emoji and CJK). + let text = c.to_string(); + self.text_system + .shape_line( + text.clone().into(), + self.font_size, + &[gpui::TextRun { + len: text.len(), + font: self.font.clone(), + ..Default::default() + }], + ) + .width + } +} +/// A fragment of a line that can be wrapped. +pub enum LineFragment<'a> { + /// A text fragment consisting of characters. + Text { + /// The text content of the fragment. + text: &'a str, + }, + /// A non-text element with a fixed width. + Element { + /// The width of the element in pixels. + width: Pixels, + /// The UTF-8 encoded length of the element. + len_utf8: usize, + }, +} + +impl<'a> LineFragment<'a> { + /// Creates a new text fragment from the given text. + pub fn text(text: &'a str) -> Self { + LineFragment::Text { text } + } + + /// Creates a new non-text element with the given width and UTF-8 encoded length. + pub fn element(width: Pixels, len_utf8: usize) -> Self { + LineFragment::Element { width, len_utf8 } + } + + fn wrap_boundary_candidates(&self) -> impl Iterator { + let text = match self { + LineFragment::Text { text } => text, + LineFragment::Element { .. } => "\0", + }; + text.chars().map(move |character| { + if let LineFragment::Element { width, len_utf8 } = self { + WrapBoundaryCandidate::Element { + width: *width, + len_utf8: *len_utf8, + } + } else { + WrapBoundaryCandidate::Char { character } + } + }) + } +} + +enum WrapBoundaryCandidate { + Char { character: char }, + Element { width: Pixels, len_utf8: usize }, +} + +impl WrapBoundaryCandidate { + pub fn len_utf8(&self) -> usize { + match self { + WrapBoundaryCandidate::Char { character } => character.len_utf8(), + WrapBoundaryCandidate::Element { len_utf8: len, .. } => *len, + } + } +} + +/// A boundary between two lines of text. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct Boundary { + /// The index of the last character in a line + pub ix: usize, + /// The indent of the next line. + pub next_indent: u32, +} + +impl Boundary { + fn new(ix: usize, next_indent: u32) -> Self { + Self { ix, next_indent } + } +} + +pub trait LineWrapperExt { + fn line_wrapper(&self, font: Font, size: Pixels) -> LineWrapper; +} +impl LineWrapperExt for Arc { + fn line_wrapper(&self, font: Font, size: Pixels) -> LineWrapper { + LineWrapper::new(font, size, self.clone()) + } +} +impl LineWrapperExt for WindowTextSystem { + fn line_wrapper(&self, font: Font, size: Pixels) -> LineWrapper { + LineWrapper::new(font, size, self.deref().clone()) + } +} + +pub trait ShapedLineExt { + fn x_for_index(&self, index: usize) -> Pixels; + fn closest_index_for_x(&self, x: Pixels) -> usize; + fn index_for_x(&self, x: Pixels) -> Option; +} +impl ShapedLineExt for ShapedLine { + fn x_for_index(&self, index: usize) -> Pixels { + self.platform_layout + .caret_bounds( + CaretPosition::attached_to_next_cluster(index.min(self.len())), + self.font_size, + ) + .map_or(self.width, |bounds| bounds.origin.x) + } + fn closest_index_for_x(&self, x: Pixels) -> usize { + if self.width == px(0.) { + return if x <= px(0.) { 0 } else { self.len() }; + } + let height = self.font_size.max(px(1.)); + self.platform_layout + .caret_from_pixel_point(point(x, height / 2.), height) + .unwrap_or_else(|caret| caret) + .index + } + fn index_for_x(&self, x: Pixels) -> Option { + let height = self.font_size.max(px(1.)); + self.platform_layout + .byte_index_from_pixel_point(point(x, height / 2.), height) + .ok() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use gpui::TextRun; + use std::borrow::Cow; + + fn text_system() -> Arc { + let system = Arc::new(TextSystem::new(Arc::new( + gpui_ce_parley::ParleyTextSystem::without_system_fonts(), + ))); + system + .add_fonts(vec![Cow::Borrowed(include_bytes!( + "../../story-web/fonts/IBMPlexSans-Regular.ttf" + ))]) + .unwrap(); + system + } + + #[test] + fn wrapping_preserves_unicode_and_atomic_elements() { + let system = text_system(); + let font = Font::default(); + let id = system.resolve_font(&font); + let cell = system.advance(id, px(16.), 'a').unwrap().width; + let mut wrapper = system.line_wrapper(font, px(16.)); + let fragments = [ + LineFragment::text("é "), + LineFragment::element(cell * 2., 4), + LineFragment::text("🙂 end"), + ]; + let boundaries = wrapper.wrap_line(&fragments, cell * 3.).collect::>(); + let source = "é @tag🙂 end"; + assert!(!boundaries.is_empty()); + assert!( + boundaries + .iter() + .all(|boundary| source.is_char_boundary(boundary.ix)) + ); + assert!(boundaries.windows(2).all(|pair| pair[0].ix < pair[1].ix)); + assert!( + boundaries + .iter() + .all(|boundary| !("é ".len() + 1.."é @tag".len()).contains(&boundary.ix)) + ); + assert!(boundaries.iter().any(|boundary| boundary.ix == "é ".len())); + } + + #[test] + fn shaped_line_carets_use_backend_utf8_indices() { + let system = WindowTextSystem::new(text_system()); + let text = "abé🙂 end"; + let line = system.shape_line( + text.into(), + px(16.), + &[TextRun { + len: text.len(), + ..Default::default() + }], + ); + for index in text + .char_indices() + .map(|(index, _)| index) + .chain([text.len()]) + { + assert_eq!(line.closest_index_for_x(line.x_for_index(index)), index); + } + assert_eq!(line.index_for_x(px(-10.)), None); + assert_eq!(line.closest_index_for_x(line.width + px(10.)), text.len()); + } +} diff --git a/crates/base/src/text_selection.rs b/crates/base/src/text_selection.rs index 061d22a8ee..ba4d3292eb 100644 --- a/crates/base/src/text_selection.rs +++ b/crates/base/src/text_selection.rs @@ -527,7 +527,7 @@ pub(crate) fn text_rows_extent(text_layout: &TextLayout, line_height: Pixels) -> last_line_top += line.size(layout_line_height).height; } let last_row_top = lines.last().map_or(top, |line| { - last_line_top + line.wrap_boundaries.len() as f32 * layout_line_height + last_line_top + line.line_count().saturating_sub(1) as f32 * layout_line_height }); (top, last_row_top + line_height) } @@ -2943,7 +2943,11 @@ mod tests { .map(|(index, text)| { let text = StyledText::new(text.clone()); self.layouts.push(text.layout().clone()); - div().absolute().top(px(index as f32 * 40.)).child(text) + div() + .flex() + .absolute() + .top(px(index as f32 * 40.)) + .child(text) }) .collect::>(); div().size_full().children(children) @@ -2969,9 +2973,14 @@ mod tests { self.selection.clone(), TextSelectionRegistration::new( Hitbox { + fragments: None, + tags: Vec::new(), id: HitboxId::placeholder(), bounds, - content_mask: ContentMask { bounds }, + content_mask: ContentMask { + fade_out: Default::default(), + bounds, + }, behavior: HitboxBehavior::Normal, }, bounds, @@ -3128,9 +3137,14 @@ mod tests { fn public_selection_data_uses_builders_and_readers(cx: &mut TestAppContext) { let bounds = Bounds::new(point(px(1.), px(2.)), size(px(30.), px(10.))); let hitbox = Hitbox { + fragments: None, + tags: Vec::new(), id: HitboxId::placeholder(), bounds, - content_mask: ContentMask { bounds }, + content_mask: ContentMask { + fade_out: Default::default(), + bounds, + }, behavior: HitboxBehavior::Normal, }; let scope = TextSelectionScopeId::from_raw(7); @@ -3939,9 +3953,14 @@ mod tests { participant.selection.clone(), TextSelectionRegistration::new( Hitbox { + fragments: None, + tags: Vec::new(), id: HitboxId::placeholder(), bounds: collapsed, - content_mask: ContentMask { bounds: collapsed }, + content_mask: ContentMask { + fade_out: Default::default(), + bounds: collapsed, + }, behavior: HitboxBehavior::Normal, }, collapsed, @@ -4101,9 +4120,14 @@ mod tests { selection.set_local_selection(true, cx); let bounds = Bounds::new(point(px(0.), px(0.)), size(px(100.), px(20.))); let hitbox = Hitbox { + fragments: None, + tags: Vec::new(), id: HitboxId::placeholder(), bounds, - content_mask: ContentMask { bounds }, + content_mask: ContentMask { + fade_out: Default::default(), + bounds, + }, behavior: HitboxBehavior::Normal, }; selection.register( diff --git a/crates/base/src/time_field.rs b/crates/base/src/time_field.rs index f4572d9640..3ad2b4fbac 100644 --- a/crates/base/src/time_field.rs +++ b/crates/base/src/time_field.rs @@ -10,7 +10,7 @@ use gpui::{ }; use crate::{ - Decrement, Increment, StyledExt as _, + Decrement, Increment, actions::{SelectLeft, SelectNextColumn, SelectPrevColumn, SelectRight}, input::Delete, }; diff --git a/crates/base/src/toast.rs b/crates/base/src/toast.rs index 371595beaf..5f10265cf2 100644 --- a/crates/base/src/toast.rs +++ b/crates/base/src/toast.rs @@ -12,10 +12,7 @@ use gpui::{ prelude::FluentBuilder as _, px, }; -use crate::{ - StyledExt as _, - motion::{Spring, spring}, -}; +use crate::motion::{Spring, spring}; /// Motion tokens used by an unstyled toast stack. #[derive(Clone, Copy, Debug)] diff --git a/crates/base/src/toggle.rs b/crates/base/src/toggle.rs index ade88c56de..f1610ff50b 100644 --- a/crates/base/src/toggle.rs +++ b/crates/base/src/toggle.rs @@ -8,7 +8,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{StateStyle, StyledExt as _, TestSupportExt as _}; +use crate::{StateStyle, TestSupportExt as _}; type ChangeHandler = Rc; diff --git a/crates/base/src/toggle_group.rs b/crates/base/src/toggle_group.rs index 3a6991f6c3..66d20bb6c8 100644 --- a/crates/base/src/toggle_group.rs +++ b/crates/base/src/toggle_group.rs @@ -5,8 +5,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; - /// An unstyled container for a set of toggle elements. #[derive(IntoElement)] pub struct ToggleGroup { diff --git a/crates/base/src/toolbar.rs b/crates/base/src/toolbar.rs index 0f3b90b63c..85bbb04c62 100644 --- a/crates/base/src/toolbar.rs +++ b/crates/base/src/toolbar.rs @@ -6,8 +6,6 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::StyledExt as _; - /// Upper bound on tab-stop hops when wrapping focus back into the toolbar, so /// a toolbar whose items all vanished from the tab order can never hang the /// key handler. Mirrors `Root`'s focus-trap loop bound. diff --git a/crates/base/src/touch_selection.rs b/crates/base/src/touch_selection.rs index 0f052d5b0b..eb042323ca 100644 --- a/crates/base/src/touch_selection.rs +++ b/crates/base/src/touch_selection.rs @@ -9,7 +9,7 @@ //! to draw them. The handles and the menu themselves are drawn by the styled //! layer, which also decides how large a handle's touch target is. -use gpui::{Bounds, Hsla, Pixels, Point, Window, fill, point, px, size}; +use gpui::{Bounds, Hsla, Pixels, Point, Window, point, px, size}; /// One end of a selection, as a touch handle grabs it. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -180,8 +180,12 @@ impl TouchHandle { point(caret.left() - Self::KNOB_SIZE / 2., knob_top), size(Self::KNOB_SIZE, Self::KNOB_SIZE), ); - window.paint_quad(fill(bar, color)); - window.paint_quad(fill(knob, color).corner_radii(Self::KNOB_SIZE / 2.)); + window.paint_quad(gpui::PaintQuad::new(bar).background(color)); + window.paint_quad( + gpui::PaintQuad::new(knob) + .background(color) + .corner_radii(Self::KNOB_SIZE / 2.), + ); } } diff --git a/crates/base/src/tree.rs b/crates/base/src/tree.rs index 8bc0371e1b..00a2542f2b 100644 --- a/crates/base/src/tree.rs +++ b/crates/base/src/tree.rs @@ -9,10 +9,7 @@ use gpui::{ uniform_list, }; -use crate::{ - actions::{Confirm, SelectDown, SelectLeft, SelectRight, SelectUp}, - styled::StyledExt as _, -}; +use crate::actions::{Confirm, SelectDown, SelectLeft, SelectRight, SelectUp}; const CONTEXT: &str = "Tree"; diff --git a/crates/base/src/virtual_list.rs b/crates/base/src/virtual_list.rs index 5184d18770..1c89add1d8 100644 --- a/crates/base/src/virtual_list.rs +++ b/crates/base/src/virtual_list.rs @@ -701,7 +701,10 @@ impl Element for VirtualList { let items = (self.render_items)(visible_range.clone(), window, cx); - let content_mask = ContentMask { bounds }; + let content_mask = ContentMask { + fade_out: Default::default(), + bounds, + }; window.with_content_mask(Some(content_mask), |window| { for (mut item, ix) in items.into_iter().zip(visible_range.clone()) { let item_origin = match self.axis { @@ -825,6 +828,8 @@ mod tests { assert!(initial_range.end < item_sizes.len()); scroll_handle.scroll_to_item(12, ScrollStrategy::Top); + // Mutating an external scroll handle requires its owner to invalidate the view. + cx.update(|window, _| window.refresh()); cx.update(|window, cx| window.draw(cx).clear(cx)); let scrolled_range = visible_ranges.borrow().last().cloned().unwrap(); assert!(scrolled_range.contains(&12)); diff --git a/crates/component/Cargo.toml b/crates/component/Cargo.toml index cc4c0601bf..dab290482b 100644 --- a/crates/component/Cargo.toml +++ b/crates/component/Cargo.toml @@ -129,10 +129,6 @@ num-traits = "0.2" # Markdown Parser markdown = { version = "1.0.0", features = ["serde"] } -# HTML Parser -html5ever = "0.27" -markup5ever_rcdom = "0.3.0" - # Calendar chrono = "0.4.38" @@ -218,6 +214,7 @@ windows = { workspace = true, features = [ ] } [dev-dependencies] +gpui_ce_parley = { version = "0.3.0", default-features = false } gpui = { workspace = true, features = ["test-support"] } indoc = "2" diff --git a/crates/component/src/attachment.rs b/crates/component/src/attachment.rs index 3bb73d4156..b5f3b6d5c8 100644 --- a/crates/component/src/attachment.rs +++ b/crates/component/src/attachment.rs @@ -1,12 +1,12 @@ use std::{rc::Rc, time::Duration}; use gpui::{ - AbsoluteLength, AnyElement, App, Axis, Bounds, ClickEvent, ColorExt as _, ElementId, Hsla, - ImageSource, InteractiveElement as _, IntoElement, MouseButton, ObjectFit, ParentElement, Path, - PathBuilder, Pixels, Refineable as _, RenderOnce, ScrollHandle, SharedString, - StatefulInteractiveElement as _, StyleRefinement, Styled, StyledImage as _, Window, black, - canvas, div, img, linear_color_stop, linear_gradient, point, prelude::FluentBuilder as _, px, - relative, rems, white, + AbsoluteLength, AnyElement, App, AppContext as _, Axis, Bounds, ClickEvent, ColorExt as _, + ElementId, Hsla, ImageSource, InteractiveElement as _, IntoElement, MouseButton, ObjectFit, + ParentElement, Path, PathBuilder, Pixels, Refineable as _, RenderOnce, ScrollHandle, + SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled, StyledImage as _, + Window, black, canvas, div, img, linear_color_stop, linear_gradient, point, + prelude::FluentBuilder as _, px, relative, rems, white, }; use gpui_base::{ is_mobile, diff --git a/crates/component/src/avatar/avatar.rs b/crates/component/src/avatar/avatar.rs index 06ad661476..3a9ee14359 100644 --- a/crates/component/src/avatar/avatar.rs +++ b/crates/component/src/avatar/avatar.rs @@ -5,7 +5,7 @@ use gpui::{ use gpui_base::{Avatar as BaseAvatar, AvatarFallback, AvatarImage}; use crate::{ - ActiveTheme, Icon, IconName, Sizable, Size, StyledExt, ThemeStyled as _, + ActiveTheme, Icon, IconName, Sizable, Size, ThemeStyled as _, avatar::{AvatarSized as _, avatar_size}, oklch, }; diff --git a/crates/component/src/badge.rs b/crates/component/src/badge.rs index bccdefec73..fbcc16d900 100644 --- a/crates/component/src/badge.rs +++ b/crates/component/src/badge.rs @@ -3,7 +3,7 @@ use gpui::{ div, prelude::FluentBuilder, px, relative, }; -use crate::{ActiveTheme, Icon, Sizable, Size, StyledExt, ThemeStyled as _, h_flex, white}; +use crate::{ActiveTheme, Icon, Sizable, Size, ThemeStyled as _, h_flex, white}; #[derive(Default, Clone)] enum BadgeVariant { diff --git a/crates/component/src/breadcrumb.rs b/crates/component/src/breadcrumb.rs index e831ce2f92..d50f43ac17 100644 --- a/crates/component/src/breadcrumb.rs +++ b/crates/component/src/breadcrumb.rs @@ -6,7 +6,7 @@ use gpui::{ prelude::FluentBuilder as _, }; -use crate::{ActiveTheme, Icon, IconName, StyledExt, h_flex}; +use crate::{ActiveTheme, Icon, IconName, h_flex}; /// A breadcrumb navigation element. #[derive(IntoElement)] diff --git a/crates/component/src/bubble.rs b/crates/component/src/bubble.rs index e0a9a2fa2d..92ec2090fe 100644 --- a/crates/component/src/bubble.rs +++ b/crates/component/src/bubble.rs @@ -3,10 +3,7 @@ use gpui::{ prelude::FluentBuilder as _, relative, rems, }; -use crate::{ - ActiveTheme as _, Colorize as _, StyledExt as _, button::Button, message::MessageAlignment, - v_flex, -}; +use crate::{ActiveTheme as _, Colorize as _, button::Button, message::MessageAlignment, v_flex}; /// Visual treatment for a chat bubble. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] diff --git a/crates/component/src/button/button.rs b/crates/component/src/button/button.rs index 04bbe5b23a..1eb8afa496 100644 --- a/crates/component/src/button/button.rs +++ b/crates/component/src/button/button.rs @@ -2,7 +2,7 @@ use std::rc::Rc; use crate::{ ActiveTheme, Colorize as _, Disableable, Icon, Placement, RoleOverride, Selectable, Sizable, - Size, StyleSized, StyledExt, + Size, StyleSized, button::ButtonIcon, h_flex, select::Caret, diff --git a/crates/component/src/button/button_group.rs b/crates/component/src/button/button_group.rs index 7075d1d05b..8c0fcb1287 100644 --- a/crates/component/src/button/button_group.rs +++ b/crates/component/src/button/button_group.rs @@ -9,7 +9,7 @@ use gpui::{ use std::{cell::Cell, rc::Rc}; use crate::{ - Disableable, Sizable, Size, StyledExt, + Disableable, Sizable, Size, button::{Button, ButtonVariant, ButtonVariants}, }; diff --git a/crates/component/src/button/toggle.rs b/crates/component/src/button/toggle.rs index c133c1a1de..5d28b5aeb0 100644 --- a/crates/component/src/button/toggle.rs +++ b/crates/component/src/button/toggle.rs @@ -8,7 +8,7 @@ use gpui::{ use gpui_base::{Toggle as BaseToggle, ToggleGroup as BaseToggleGroup}; use smallvec::{SmallVec, smallvec}; -use crate::{ActiveTheme, Disableable, Icon, Sizable, Size, StyledExt, tooltip::ComponentTooltip}; +use crate::{ActiveTheme, Disableable, Icon, Sizable, Size, tooltip::ComponentTooltip}; #[derive(Default, Copy, Debug, Clone, PartialEq, Eq, Hash)] pub enum ToggleVariant { diff --git a/crates/component/src/carousel/carousel.rs b/crates/component/src/carousel/carousel.rs index ea17a7584d..2dbd552bb6 100644 --- a/crates/component/src/carousel/carousel.rs +++ b/crates/component/src/carousel/carousel.rs @@ -13,7 +13,7 @@ use rust_i18n::t; use super::{CONTEXT, scroll_mask::CarouselScrollMask, state::CarouselState}; use crate::{ AxisExt as _, Disableable as _, ElementExt as _, Selectable as _, Sizable as _, Size, - StyledExt as _, ThemeStyled as _, + ThemeStyled as _, actions::{SelectDown, SelectFirst, SelectLast, SelectLeft, SelectRight, SelectUp}, button::Button, icon::IconName, diff --git a/crates/component/src/carousel/scroll_mask.rs b/crates/component/src/carousel/scroll_mask.rs index 8c3f2c4fde..f2f1d615c2 100644 --- a/crates/component/src/carousel/scroll_mask.rs +++ b/crates/component/src/carousel/scroll_mask.rs @@ -120,7 +120,11 @@ impl Element for CarouselScrollMask { }) .unwrap_or_default(); - window.with_content_mask(Some(ContentMask { bounds }), |window| { + let mask = ContentMask { + bounds, + fade_out: Default::default(), + }; + window.with_content_mask(Some(mask), |window| { let pointer_state = state.clone(); window.on_mouse_event(move |event: &MouseDownEvent, phase, window, cx| { if phase.capture() diff --git a/crates/component/src/chart/candlestick_chart.rs b/crates/component/src/chart/candlestick_chart.rs index 0b64671569..154737511c 100644 --- a/crates/component/src/chart/candlestick_chart.rs +++ b/crates/component/src/chart/candlestick_chart.rs @@ -2,7 +2,7 @@ use std::{hash::Hash, rc::Rc}; use gpui::{ AnyElement, App, Bounds, ElementId, Hsla, IntoElement, Pixels, Point, SharedString, Window, - fill, point, px, + point, px, }; use gpui_component_macros::IntoPlot; use rust_i18n::t; @@ -380,7 +380,7 @@ where origin_point(px(center_x - 0.5), px(wick_top), origin), origin_point(px(center_x + 0.5), px(wick_bottom), origin), ); - window.paint_quad(fill(wick_bounds, color)); + window.paint_quad(gpui::PaintQuad::new(wick_bounds).background(color)); // Draw body (open to close rectangle) // For bullish: top is close, bottom is open @@ -396,7 +396,7 @@ where origin_point(px(body_right), px(bottom), origin), ); - window.paint_quad(fill(body_bounds, color)); + window.paint_quad(gpui::PaintQuad::new(body_bounds).background(color)); } }); } diff --git a/crates/component/src/chart/mod.rs b/crates/component/src/chart/mod.rs index 97a81ac4c5..0cfed8908f 100644 --- a/crates/component/src/chart/mod.rs +++ b/crates/component/src/chart/mod.rs @@ -117,6 +117,7 @@ pub(crate) fn reveal_mask( let start = bounds.left() + px(left) - bleed; let end = start + (bounds.right() + bleed - start) * progress.max(0.); Some(ContentMask { + fade_out: Default::default(), bounds: Bounds::from_corners( gpui::point(bounds.left() - bleed, bounds.top() - bleed), gpui::point(end, bounds.bottom() + bleed), @@ -572,6 +573,7 @@ impl PointAxes { pub(crate) fn pinned_plot_mask(bounds: Bounds, height: f32) -> ContentMask { let bleed = HOVER_DOT_SIZE / 2.; ContentMask { + fade_out: Default::default(), bounds: Bounds::from_corners( bounds.origin - gpui::point(bleed, bleed), gpui::point(bounds.right() + bleed, bounds.top() + px(height) + bleed), diff --git a/crates/component/src/chart/sankey_chart.rs b/crates/component/src/chart/sankey_chart.rs index 29920d970f..46c7e3676c 100644 --- a/crates/component/src/chart/sankey_chart.rs +++ b/crates/component/src/chart/sankey_chart.rs @@ -6,7 +6,7 @@ use std::{ use gpui::ColorExt as _; use gpui::{ AnyElement, App, Bounds, Corners, ElementId, Hsla, IntoElement, Pixels, Point, SharedString, - TextAlign, Window, fill, linear_color_stop, linear_gradient, point, prelude::FluentBuilder, px, + TextAlign, Window, linear_color_stop, linear_gradient, point, prelude::FluentBuilder, px, }; use gpui_component_macros::IntoPlot; @@ -660,7 +660,11 @@ impl Plot for SankeyChart { // Keep tiny nodes visible with a minimum 1px height. origin_point(px(node.x1), px(node.y1.max(node.y0 + 1.)), bounds.origin), ); - window.paint_quad(fill(node_bounds, colors[node.index]).corner_radii(corner_radii)); + window.paint_quad( + gpui::PaintQuad::new(node_bounds) + .background(colors[node.index]) + .corner_radii(corner_radii), + ); } }); diff --git a/crates/component/src/color_picker.rs b/crates/component/src/color_picker.rs index 60a82827c8..d82b833767 100644 --- a/crates/component/src/color_picker.rs +++ b/crates/component/src/color_picker.rs @@ -10,8 +10,8 @@ use gpui_base::{ColorPicker as BaseColorPicker, ColorSwatch}; pub use gpui_base::{ColorPickerEvent, ColorPickerState}; use crate::{ - ActiveTheme as _, Colorize as _, Icon, Selectable, Sizable, Size, StyleSized, StyledExt as _, - ThemeStyled as _, h_flex, + ActiveTheme as _, Colorize as _, Icon, Selectable, Sizable, Size, StyleSized, ThemeStyled as _, + h_flex, input::{Input, input_style}, popover::Popover, select::Caret, diff --git a/crates/component/src/command/command.rs b/crates/component/src/command/command.rs index 1bf4222ceb..bde110b353 100644 --- a/crates/component/src/command/command.rs +++ b/crates/component/src/command/command.rs @@ -250,7 +250,7 @@ impl RenderOnce for Command { on_cancel: self.on_cancel, }; self.state.update(cx, |state, cx| { - state.set_options(options); + state.set_options(options, cx); state.install_model(model, cx); }); diff --git a/crates/component/src/command/state.rs b/crates/component/src/command/state.rs index 6366b04112..b7388ecf1e 100644 --- a/crates/component/src/command/state.rs +++ b/crates/component/src/command/state.rs @@ -171,11 +171,18 @@ impl CommandState { } /// Apply the presentation of the latest [`crate::command::Command`] render. - pub(crate) fn set_options(&mut self, options: CommandOptions) { + pub(crate) fn set_options(&mut self, options: CommandOptions, cx: &mut Context) { + let changed = self.options.style != options.style + || self.options.max_h != options.max_h + || self.options.bordered != options.bordered + || self.options.placeholder != options.placeholder; if self.options.style.text != options.style.text { self.needs_measure = true; } self.options = options; + if changed { + cx.notify(); + } } pub(crate) fn install_model(&mut self, model: CommandModel, cx: &mut Context) { @@ -797,7 +804,7 @@ impl CommandState { let action = item.action.as_ref()?; Kbd::binding_for_action_in(action.as_ref(), &self.focus_handle(cx), window) - .or_else(|| Kbd::binding_for_action(action.as_ref(), None, window)) + .or_else(|| Kbd::binding_for_action(action.as_ref(), Some(CONTEXT), window)) } fn render_item( @@ -1224,13 +1231,16 @@ mod tests { cx: &mut gpui::Context, ) -> impl IntoElement { let width = self.width.clone(); - let item = self.state.update(cx, |state, cx| { + let mut item = self.state.update(cx, |state, cx| { state.render_item(self.matched_ix, window, cx) }); - div() - .on_children_prepainted(move |bounds, _, _| width.set(Some(bounds[0].size.width))) - .child(item) + // Measure without installing temporary hitboxes over the real palette. + width.set(Some( + item.layout_as_root(AvailableSpace::min_size(), window, cx) + .width, + )); + gpui::Empty } } @@ -2334,6 +2344,7 @@ mod tests { #[gpui::test] fn wrapping_rows_remeasure_for_the_list_content_width(cx: &mut TestAppContext) { + crate::test_text_system::install(cx); cx.update(crate::init); let (harness, cx) = cx.add_window_view(|window, cx| WrappingHarness { @@ -2402,6 +2413,7 @@ mod tests { #[gpui::test] fn wrapping_rows_remeasure_when_inherited_typography_changes(cx: &mut TestAppContext) { + crate::test_text_system::install(cx); cx.update(crate::init); let (harness, cx) = cx.add_window_view(|window, cx| WrappingHarness { @@ -2590,6 +2602,8 @@ mod tests { move |_, _| settled_state.into_any_element(), ); let after_first_draw = renders.get(); + // Standalone draws do not process entity invalidations like Window::draw. + cx.update(|window, _| window.refresh()); cx.draw( gpui::point(px(0.), px(0.)), gpui::AvailableSpace::min_size(), diff --git a/crates/component/src/dialog/alert_dialog.rs b/crates/component/src/dialog/alert_dialog.rs index 54ea569334..02ce6eb82e 100644 --- a/crates/component/src/dialog/alert_dialog.rs +++ b/crates/component/src/dialog/alert_dialog.rs @@ -4,7 +4,7 @@ use gpui::{ }; use crate::{ - StyledExt as _, WindowExt as _, + WindowExt as _, button::ButtonVariant, dialog::{ Dialog, DialogButtonProps, DialogDescription, DialogFooter, DialogHeader, DialogTitle, diff --git a/crates/component/src/dialog/content.rs b/crates/component/src/dialog/content.rs index f96da0c3fc..0767aee19a 100644 --- a/crates/component/src/dialog/content.rs +++ b/crates/component/src/dialog/content.rs @@ -2,7 +2,7 @@ use gpui::{ AnyElement, App, IntoElement, ParentElement, RenderOnce, StyleRefinement, Styled, Window, }; -use crate::{ActiveTheme as _, StyledExt as _, v_flex}; +use crate::{ActiveTheme as _, v_flex}; /// Content container for a dialog. #[derive(IntoElement)] diff --git a/crates/component/src/dialog/description.rs b/crates/component/src/dialog/description.rs index 55edab761f..07dd68ee08 100644 --- a/crates/component/src/dialog/description.rs +++ b/crates/component/src/dialog/description.rs @@ -3,7 +3,7 @@ use gpui::{ }; use gpui_base::DialogDescription as BaseDialogDescription; -use crate::{ActiveTheme as _, StyledExt as _}; +use crate::ActiveTheme as _; /// Description element for a dialog header. /// diff --git a/crates/component/src/dialog/dialog.rs b/crates/component/src/dialog/dialog.rs index 839aca5f14..0a50c65892 100644 --- a/crates/component/src/dialog/dialog.rs +++ b/crates/component/src/dialog/dialog.rs @@ -12,7 +12,7 @@ use gpui_base::{ElementExt as _, TextSelectionScopeId}; use rust_i18n::t; use crate::{ - ActiveTheme as _, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT, WindowExt as _, + ActiveTheme as _, IconName, Sizable as _, TITLE_BAR_HEIGHT, WindowExt as _, animation::cubic_bezier, button::{Button, ButtonVariant, ButtonVariants as _}, dialog::{DialogContent, DialogDispatchAnchor, DialogTitle}, @@ -713,7 +713,7 @@ impl RenderOnce for Dialog { }) .when(!self.children.is_empty(), |this| { this.child( - div().flex_1().overflow_hidden().child( + v_flex().flex_1().overflow_hidden().child( // Body v_flex() .size_full() @@ -756,14 +756,14 @@ impl RenderOnce for Dialog { // This is equivalent to `shadow_xl` with an extra opacity. let shadow = vec![ BoxShadow { - color: hsla(0., 0., 0., 0.1 * delta), + color: hsla(0., 0., 0., 0.1 * delta).into(), offset: point(px(0.), px(20.)), blur_radius: px(25.), spread_radius: px(-5.), inset: false, }, BoxShadow { - color: hsla(0., 0., 0., 0.1 * delta), + color: hsla(0., 0., 0., 0.1 * delta).into(), offset: point(px(0.), px(8.)), blur_radius: px(10.), spread_radius: px(-6.), diff --git a/crates/component/src/dialog/footer.rs b/crates/component/src/dialog/footer.rs index bb686d5b66..478588dbd1 100644 --- a/crates/component/src/dialog/footer.rs +++ b/crates/component/src/dialog/footer.rs @@ -4,7 +4,7 @@ use gpui::{ }; use crate::{ - ActiveTheme as _, StyledExt as _, + ActiveTheme as _, button::Button, dialog::{Confirm, DialogDispatchAnchor}, h_flex, diff --git a/crates/component/src/dialog/header.rs b/crates/component/src/dialog/header.rs index 1167a7f1a0..ee706c5f16 100644 --- a/crates/component/src/dialog/header.rs +++ b/crates/component/src/dialog/header.rs @@ -2,7 +2,7 @@ use gpui::{ AnyElement, App, IntoElement, ParentElement, RenderOnce, StyleRefinement, Styled, Window, }; -use crate::{StyledExt as _, v_flex}; +use crate::v_flex; /// Header section of a dialog, typically contains DialogTitle and DialogDescription. /// diff --git a/crates/component/src/dock/panel.rs b/crates/component/src/dock/panel.rs index 3c0c7788ff..cbd262d118 100644 --- a/crates/component/src/dock/panel.rs +++ b/crates/component/src/dock/panel.rs @@ -475,7 +475,11 @@ mod tests { }); cx.run_until_parked(); recovered.borrow_mut().tab_names.clear(); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( recovered.borrow().tab_names, @@ -523,7 +527,11 @@ mod tests { cx.update(|window, cx| area.update(cx, |area, cx| area.load(state, window, cx).unwrap())); cx.run_until_parked(); recovered.borrow_mut().tab_names.clear(); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( recovered.borrow().tab_names, @@ -555,7 +563,11 @@ mod tests { }); cx.run_until_parked(); recovered.borrow_mut().tab_names.clear(); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( recovered.borrow().tab_names, diff --git a/crates/component/src/dock/tab_panel.rs b/crates/component/src/dock/tab_panel.rs index c97ba7cdd7..46fac34191 100644 --- a/crates/component/src/dock/tab_panel.rs +++ b/crates/component/src/dock/tab_panel.rs @@ -952,7 +952,11 @@ mod tests { }); cx.run_until_parked(); log.borrow_mut().draggable.clear(); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( log.borrow().draggable, @@ -980,7 +984,11 @@ mod tests { }); cx.run_until_parked(); log.borrow_mut().draggable.clear(); - cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.update(|window, cx| { + // This probe observes renderer calls, so request a fresh render. + window.refresh(); + window.draw(cx).clear(cx); + }); assert_eq!( log.borrow().draggable, diff --git a/crates/component/src/form/form.rs b/crates/component/src/form/form.rs index f217f8444e..f7696a247a 100644 --- a/crates/component/src/form/form.rs +++ b/crates/component/src/form/form.rs @@ -4,7 +4,7 @@ use gpui::{ }; use crate::{ - Sizable, Size, StyledExt, + Sizable, Size, form::{Field, FieldProps}, h_flex, v_flex, }; diff --git a/crates/component/src/group_box.rs b/crates/component/src/group_box.rs index 51140d83ac..54a867837b 100644 --- a/crates/component/src/group_box.rs +++ b/crates/component/src/group_box.rs @@ -4,7 +4,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{ActiveTheme, StyledExt as _, v_flex}; +use crate::{ActiveTheme, v_flex}; /// The variant of the GroupBox. #[derive(Debug, Clone, Default, Copy, PartialEq, Eq, Hash)] diff --git a/crates/component/src/hover_card.rs b/crates/component/src/hover_card.rs index 41c5f64b68..48c896f9b5 100644 --- a/crates/component/src/hover_card.rs +++ b/crates/component/src/hover_card.rs @@ -8,7 +8,7 @@ use gpui_base::HoverCard as BaseHoverCard; pub use gpui_base::HoverCardState; use web_time::Duration; -use crate::{StyledExt as _, popover::Popover}; +use crate::popover::Popover; /// A hover card element that displays content when hovering over a trigger element. /// diff --git a/crates/component/src/icon.rs b/crates/component/src/icon.rs index 61036537e6..517dbad2c0 100644 --- a/crates/component/src/icon.rs +++ b/crates/component/src/icon.rs @@ -193,10 +193,7 @@ impl Icon { }) .map(|this| match self.source { IconSource::Path(path) => this.path(path), - // GPUI CE's Svg renders only asset paths; a data icon keeps - // its bytes for builders and clones but paints nothing until - // GPUI CE grows an inline-data API. - IconSource::Data(_) => this, + IconSource::Data(data) => this.data(&data), }) .when_some(self.transformation, |this, transformation| { this.with_transformation(transformation) diff --git a/crates/component/src/input/content_type.rs b/crates/component/src/input/content_type.rs index 064cb04eb5..492a970760 100644 --- a/crates/component/src/input/content_type.rs +++ b/crates/component/src/input/content_type.rs @@ -98,7 +98,7 @@ pub enum InputContentType { } impl InputContentType { - #[cfg(target_os = "macos")] + #[cfg(all(target_os = "macos", any(not(feature = "test-support"), test)))] pub(crate) const fn ns_text_content_type(self) -> Option<&'static str> { match self { Self::Name => Some("name"), diff --git a/crates/component/src/input/editor.rs b/crates/component/src/input/editor.rs index 455c516bd6..3758c9538d 100644 --- a/crates/component/src/input/editor.rs +++ b/crates/component/src/input/editor.rs @@ -7,7 +7,7 @@ use gpui::{ use super::{EditorState, Input}; use crate::native_menu::NativeMenu; -use crate::{ActiveTheme as _, RoleOverride, StyledExt as _}; +use crate::{ActiveTheme as _, RoleOverride}; /// A code editor takes its rows from the font, so that a smaller or larger /// font keeps its leading in proportion. diff --git a/crates/component/src/input/input.rs b/crates/component/src/input/input.rs index ae7b9ccd83..9af0b43d1d 100644 --- a/crates/component/src/input/input.rs +++ b/crates/component/src/input/input.rs @@ -15,7 +15,7 @@ use crate::spinner::Spinner; use crate::touch_selection::{EditMenuItem, TouchSelectionOverlay}; use crate::{ActiveTheme, Colorize, v_flex}; use crate::{IconName, Size}; -use crate::{RoleOverride, Selectable, StyledExt, h_flex}; +use crate::{RoleOverride, Selectable, h_flex}; use crate::{Sizable, StyleSized}; use gpui_base::InputBase as BaseInput; use rust_i18n::t; @@ -1081,7 +1081,7 @@ mod tests { cx.update(|window, cx| { base.set_disabled(disabled, cx); base.set_readonly(!disabled, cx); - window.blur(); + window.blur(cx); Input::handle_accessibility_focus(&base, window, cx); assert_eq!( base.presentation(cx).focus_handle().is_focused(window), diff --git a/crates/component/src/input/number_input.rs b/crates/component/src/input/number_input.rs index d5ce0596b8..fa8c8a9713 100644 --- a/crates/component/src/input/number_input.rs +++ b/crates/component/src/input/number_input.rs @@ -9,7 +9,7 @@ use gpui::{ prelude::FluentBuilder as _, }; -use crate::{Disableable, Icon, IconName, Sizable, Size, StyleSized as _, StyledExt as _}; +use crate::{Disableable, Icon, IconName, Sizable, Size, StyleSized as _}; use super::{Input, InputState, input::input_style}; use crate::ThemeStyled as _; diff --git a/crates/component/src/input/popovers/hover_popover.rs b/crates/component/src/input/popovers/hover_popover.rs index 913081f03b..79ad1cbf36 100644 --- a/crates/component/src/input/popovers/hover_popover.rs +++ b/crates/component/src/input/popovers/hover_popover.rs @@ -8,7 +8,7 @@ use gpui::{ }; use crate::{ - StyledExt, ThemeStyled as _, + ThemeStyled as _, input::{EditorState, popovers::render_markdown}, }; diff --git a/crates/component/src/input/textarea.rs b/crates/component/src/input/textarea.rs index d7daaec728..f90808aa60 100644 --- a/crates/component/src/input/textarea.rs +++ b/crates/component/src/input/textarea.rs @@ -7,7 +7,7 @@ use gpui::{ use super::{Input, TextareaState}; use crate::native_menu::NativeMenu; -use crate::{RoleOverride, Sizable, Size, StyledExt as _}; +use crate::{RoleOverride, Sizable, Size}; /// A styled ordinary multi-line text field. #[derive(IntoElement)] diff --git a/crates/component/src/input/token.rs b/crates/component/src/input/token.rs index 43b253d305..ef14163d65 100644 --- a/crates/component/src/input/token.rs +++ b/crates/component/src/input/token.rs @@ -1,5 +1,5 @@ use super::InlineTokenContext; -use crate::{ActiveTheme as _, Icon, StyledExt as _}; +use crate::{ActiveTheme as _, Icon}; use gpui::{ App, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, StyleRefinement, Styled, Window, div, prelude::FluentBuilder as _, diff --git a/crates/component/src/inspector.rs b/crates/component/src/inspector.rs index ece250284c..cc7f5a0ae9 100644 --- a/crates/component/src/inspector.rs +++ b/crates/component/src/inspector.rs @@ -48,27 +48,14 @@ pub(crate) fn init(cx: &mut App) { }); }); - cx.register_inspector_element(|id, state: &DivInspectorState, window, cx| { - // The registry runs once, before any window exists to inspect; the - // view is built lazily on the first inspection instead. - #[derive(Default)] - struct DivInspectorGlobal { - view: Option>, + cx.register_inspector_element(|window, cx| { + let div_inspector = cx.new(|cx| DivInspector::new(window, cx)); + move |id, state: &DivInspectorState, window, cx| { + div_inspector.update(cx, |this, cx| { + this.update_inspected_element(id, state.clone(), window, cx); + this.render(window, cx).into_any_element() + }) } - impl gpui::Global for DivInspectorGlobal {} - if cx.try_global::().is_none() { - cx.set_global(DivInspectorGlobal::default()); - } - let existing = cx.global::().view.clone(); - let div_inspector = existing.unwrap_or_else(|| { - let view = cx.new(|cx| DivInspector::new(window, cx)); - cx.global_mut::().view = Some(view.clone()); - view - }); - div_inspector.update(cx, |this, cx| { - this.update_inspected_element(id, state.clone(), window, cx); - this.render(window, cx).into_any_element() - }) }); cx.set_inspector_renderer(Box::new(render_inspector)); diff --git a/crates/component/src/kbd.rs b/crates/component/src/kbd.rs index 98e3e1c09a..5dfdc728fd 100644 --- a/crates/component/src/kbd.rs +++ b/crates/component/src/kbd.rs @@ -4,7 +4,7 @@ use gpui::{ prelude::FluentBuilder as _, relative, }; -use crate::{ActiveTheme, StyledExt}; +use crate::ActiveTheme; /// A tag for displaying keyboard keybindings. #[derive(IntoElement, Clone, Debug)] diff --git a/crates/component/src/label.rs b/crates/component/src/label.rs index adbec05901..b7a04c0b2b 100644 --- a/crates/component/src/label.rs +++ b/crates/component/src/label.rs @@ -5,7 +5,7 @@ use gpui::{ Styled, StyledText, Window, div, prelude::FluentBuilder, rems, }; -use crate::{ActiveTheme, StyledExt}; +use crate::ActiveTheme; const MASKED: &'static str = "•"; diff --git a/crates/component/src/lib.rs b/crates/component/src/lib.rs index 3b2f2b2a69..086541da1d 100644 --- a/crates/component/src/lib.rs +++ b/crates/component/src/lib.rs @@ -165,3 +165,6 @@ pub(crate) fn measure_enable() -> bool { static MEASURE_ENABLED: LazyLock = LazyLock::new(gpui_base::measurement_enabled); *MEASURE_ENABLED } + +#[cfg(test)] +mod test_text_system; diff --git a/crates/component/src/link.rs b/crates/component/src/link.rs index 1950e5c802..6c70028ac9 100644 --- a/crates/component/src/link.rs +++ b/crates/component/src/link.rs @@ -4,7 +4,7 @@ use gpui::{ RenderOnce, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, div, }; -use crate::{ActiveTheme as _, StyledExt}; +use crate::ActiveTheme as _; /// A Link element like a `` tag in HTML. #[derive(IntoElement)] diff --git a/crates/component/src/list/list_item.rs b/crates/component/src/list/list_item.rs index e13ff676c9..2ef34b4823 100644 --- a/crates/component/src/list/list_item.rs +++ b/crates/component/src/list/list_item.rs @@ -1,4 +1,4 @@ -use crate::{ActiveTheme, Disableable, Icon, Selectable, Sizable as _, StyledExt, h_flex}; +use crate::{ActiveTheme, Disableable, Icon, Selectable, Sizable as _, h_flex}; use gpui::{ AnyElement, App, ClickEvent, Div, ElementId, InteractiveElement, Interactivity, IntoElement, MouseButton, MouseDownEvent, MouseMoveEvent, ParentElement, RenderOnce, SharedString, Stateful, diff --git a/crates/component/src/list/separator_item.rs b/crates/component/src/list/separator_item.rs index 85eb3a73d2..9620ab2ea3 100644 --- a/crates/component/src/list/separator_item.rs +++ b/crates/component/src/list/separator_item.rs @@ -1,7 +1,8 @@ +use gpui::Styled as _; use gpui::{AnyElement, ParentElement, RenderOnce, StyleRefinement}; use smallvec::SmallVec; -use crate::{Selectable, StyledExt, list::ListItem}; +use crate::{Selectable, list::ListItem}; pub struct ListSeparatorItem { style: StyleRefinement, diff --git a/crates/component/src/marker.rs b/crates/component/src/marker.rs index 46e3cc5b93..bd910dfdb5 100644 --- a/crates/component/src/marker.rs +++ b/crates/component/src/marker.rs @@ -1,5 +1,5 @@ use crate::{ - ActiveTheme as _, RoleOverride, Sizable as _, StyledExt as _, h_flex, + ActiveTheme as _, RoleOverride, Sizable as _, h_flex, shimmer::{ShimmerStyle, ShimmerText}, spinner::Spinner, }; diff --git a/crates/component/src/menu/context_menu.rs b/crates/component/src/menu/context_menu.rs index a60435395f..0d0b18aaf8 100644 --- a/crates/component/src/menu/context_menu.rs +++ b/crates/component/src/menu/context_menu.rs @@ -197,7 +197,7 @@ impl DeferredMenu { ), ), ) - .with_priority(gpui_base::POPUP_PRIORITY) + .priority(gpui_base::POPUP_PRIORITY) .into_any() } } diff --git a/crates/component/src/menu/menu_item.rs b/crates/component/src/menu/menu_item.rs index bea28d9814..da1644a93c 100644 --- a/crates/component/src/menu/menu_item.rs +++ b/crates/component/src/menu/menu_item.rs @@ -1,4 +1,4 @@ -use crate::{ActiveTheme, Disableable, StyledExt, h_flex}; +use crate::{ActiveTheme, Disableable, h_flex}; use gpui::{ AnyElement, App, ClickEvent, ElementId, InteractiveElement, IntoElement, MouseButton, ParentElement, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, diff --git a/crates/component/src/message_scroller.rs b/crates/component/src/message_scroller.rs index 4f98759267..72ae14626d 100644 --- a/crates/component/src/message_scroller.rs +++ b/crates/component/src/message_scroller.rs @@ -8,7 +8,7 @@ use gpui::{ }; use gpui_base::motion::{Transition, transition}; -use crate::{ActiveTheme as _, Disableable as _, IconName, StyledExt as _, button::Button}; +use crate::{ActiveTheme as _, Disableable as _, IconName, button::Button}; use crate::{ button::ButtonVariants as _, scroll::{ScrollableElement as _, ScrollableMask}, diff --git a/crates/component/src/native_menu/macos.rs b/crates/component/src/native_menu/macos.rs index 4a857ee2be..2a85e309a1 100644 --- a/crates/component/src/native_menu/macos.rs +++ b/crates/component/src/native_menu/macos.rs @@ -2,7 +2,7 @@ use std::{cell::Cell, sync::Arc}; -use gpui::{Action, App, AssetSource, Pixels, Point, Window}; +use gpui::{Action, App, AssetRegistry, Pixels, Point, Window}; use objc2::rc::Retained; use objc2::runtime::{AnyObject, NSObject}; use objc2::{AnyThread, DefinedClass, MainThreadMarker, define_class, msg_send, sel}; @@ -52,7 +52,7 @@ impl MenuTarget { /// borrowed while the menu is open. pub(super) fn show( items: Vec, - asset_source: Arc, + assets: Arc, position: Point, window: &mut Window, cx: &mut App, @@ -65,7 +65,7 @@ pub(super) fn show( let handle = Window::window_handle(window); cx.spawn(async move |cx| { - let action = run_menu(view_ptr, &items, asset_source.as_ref(), position); + let action = run_menu(view_ptr, &items, assets.as_ref(), position); let _ = cx.update(move |app| { let _ = handle.update(app, move |_, window, app| { if let Some(action) = action { @@ -88,7 +88,7 @@ pub(super) fn show( fn run_menu( view_ptr: usize, items: &[NativeMenuItem], - asset_source: &dyn AssetSource, + assets: &AssetRegistry, position: Point, ) -> Option> { let mtm = MainThreadMarker::new()?; @@ -98,7 +98,7 @@ fn run_menu( let target = MenuTarget::new(); let mut actions: Vec<&Box> = Vec::new(); - let ns_menu = build_menu(items, asset_source, &target, mtm, &mut actions); + let ns_menu = build_menu(items, assets, &target, mtm, &mut actions); // `position` is window-relative, logical pixels, origin top-left (GPUI). // AppKit view coordinates have their origin at the bottom-left, so flip y. @@ -121,7 +121,7 @@ fn run_menu( /// to its index in `actions`, so the selected tag maps back to its action. fn build_menu<'a>( items: &'a [NativeMenuItem], - asset_source: &dyn AssetSource, + assets: &AssetRegistry, target: &MenuTarget, mtm: MainThreadMarker, actions: &mut Vec<&'a Box>, @@ -145,7 +145,7 @@ fn build_menu<'a>( ns_item.setTitle(&NSString::from_str(label)); ns_item.setEnabled(!*disabled); if let Some(icon) = icon { - if let Some(ns_image) = ns_image_for_icon(icon, asset_source) { + if let Some(ns_image) = ns_image_for_icon(icon, assets) { ns_image.setSize(NSSize::new(MENU_IMAGE_SIZE, MENU_IMAGE_SIZE)); ns_image.setTemplate(true); ns_item.setImage(Some(&ns_image)); @@ -173,7 +173,7 @@ fn build_menu<'a>( items, } => { let ns_item = NSMenuItem::new(mtm); - let submenu = build_menu(items, asset_source, target, mtm, actions); + let submenu = build_menu(items, assets, target, mtm, actions); ns_item.setTitle(&NSString::from_str(label)); ns_item.setEnabled(!*disabled); ns_item.setSubmenu(Some(&submenu)); @@ -185,11 +185,8 @@ fn build_menu<'a>( menu } -fn ns_image_for_icon( - icon: &crate::Icon, - asset_source: &dyn AssetSource, -) -> Option> { - let image = resolve_icon_image(icon, asset_source)?; +fn ns_image_for_icon(icon: &crate::Icon, assets: &AssetRegistry) -> Option> { + let image = resolve_icon_image(icon, assets)?; if image.bytes.is_empty() { return None; } diff --git a/crates/component/src/native_menu/mod.rs b/crates/component/src/native_menu/mod.rs index 80049cbece..1f6b6c6e3e 100644 --- a/crates/component/src/native_menu/mod.rs +++ b/crates/component/src/native_menu/mod.rs @@ -28,12 +28,12 @@ use crate::Icon; #[cfg(any(target_os = "macos", target_os = "windows", test))] use crate::icon::IconSource; -#[cfg(any(target_os = "macos", target_os = "windows"))] -use gpui::AssetSource; +#[cfg(any(target_os = "macos", target_os = "windows", test))] +use gpui::AssetRegistry; use gpui::{Action, App, Pixels, Point, SharedString, Window}; -#[cfg(any(target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "macos", target_os = "windows", test))] use gpui::{Image, ImageFormat}; -#[cfg(any(target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "macos", target_os = "windows", test))] use std::{path::Path, sync::Arc}; #[cfg(target_os = "macos")] @@ -107,7 +107,7 @@ impl NativeMenu { /// Append an item showing `icon` next to its label. /// /// Native platform menus load absolute paths ([`Path::is_absolute`]) from the filesystem, - /// and every other path through the application [`gpui::AssetSource`]. + /// and every other path through the application [`gpui::AssetRegistry`]. /// Icons created with [`Icon::data`] use their SVG bytes directly, without an asset lookup. /// [`crate::IconName`] resolves as an asset and works across all backends. /// - **macOS**: loaded into an `NSImage` as a template image, so it tints with the item @@ -205,13 +205,13 @@ impl NativeMenu { #[cfg(target_os = "macos")] { - macos::show(self.items, cx.asset_source().clone(), position, window, cx); + macos::show(self.items, cx.assets().clone(), position, window, cx); } #[cfg(target_os = "windows")] { windows::show( self.items, - cx.asset_source().clone(), + cx.assets().clone(), position, cx.theme().is_dark(), window, @@ -223,11 +223,8 @@ impl NativeMenu { } } -#[cfg(any(target_os = "macos", target_os = "windows"))] -pub(super) fn resolve_icon_image( - icon: &Icon, - asset_source: &dyn AssetSource, -) -> Option> { +#[cfg(any(target_os = "macos", target_os = "windows", test))] +pub(super) fn resolve_icon_image(icon: &Icon, assets: &AssetRegistry) -> Option> { let path = match icon.source_ref() { IconSource::Path(path) => path, IconSource::Data(bytes) => { @@ -246,17 +243,13 @@ pub(super) fn resolve_icon_image( let bytes = if icon_path.is_absolute() { std::fs::read(icon_path).ok()? } else { - asset_source - .load(path.as_ref()) - .ok() - .flatten()? - .into_owned() + assets.load(path.as_ref())?.into_owned() }; let format = image_format(path.as_ref(), &bytes)?; Some(Arc::new(Image::from_bytes(format, bytes))) } -#[cfg(any(target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "macos", target_os = "windows", test))] fn image_format(path: &str, bytes: &[u8]) -> Option { if let Some(extension) = Path::new(path) .extension() @@ -280,7 +273,7 @@ fn image_format(path: &str, bytes: &[u8]) -> Option { image_format_from_bytes(bytes) } -#[cfg(any(target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "macos", target_os = "windows", test))] fn image_format_from_bytes(bytes: &[u8]) -> Option { let bytes = bytes.strip_prefix(b"\xef\xbb\xbf").unwrap_or(bytes); if bytes.starts_with(b"\x89PNG\r\n\x1a\n") { @@ -309,7 +302,7 @@ fn image_format_from_bytes(bytes: &[u8]) -> Option { } } -#[cfg(any(target_os = "macos", target_os = "windows"))] +#[cfg(any(target_os = "macos", target_os = "windows", test))] fn is_svg_bytes(bytes: &[u8]) -> bool { let text = match std::str::from_utf8(&bytes[..bytes.len().min(256)]) { Ok(text) => text.trim_start(), @@ -414,8 +407,7 @@ mod tests { assert!(matches!(icon.source_ref(), IconSource::Path(path) if path.ends_with("inbox.svg"))); } - /// Icon resolution is only compiled for the platforms with an OS-native menu. - #[cfg(any(target_os = "macos", target_os = "windows"))] + // Exercise native icon lookup on every test host, including Linux. mod icon_resolution { use super::*; use std::{borrow::Cow, fs, path::PathBuf}; @@ -423,16 +415,10 @@ mod tests { const ASSET_SVG: &[u8] = br#""#; const FILE_SVG: &[u8] = br#""#; - struct TestAssetSource(Option<&'static [u8]>); - - impl AssetSource for TestAssetSource { - fn load(&self, _path: &str) -> gpui::Result>> { - Ok(self.0.map(Cow::Borrowed)) - } - - fn list(&self, _path: &str) -> gpui::Result> { - Ok(Vec::new()) - } + fn assets(path: impl Into, bytes: &'static [u8]) -> AssetRegistry { + let mut assets = AssetRegistry::default(); + assets.insert(path, Cow::Borrowed(bytes)).unwrap(); + assets } /// A file written into the current directory for the duration of one test. @@ -464,7 +450,7 @@ mod tests { #[test] fn test_native_menu_icon_asset_resolves_to_bytes() { let icon = Icon::new(IconName::Github); - let image = resolve_icon_image(&icon, &gpui_kit_assets::Assets) + let image = resolve_icon_image(&icon, &AssetRegistry::from(gpui_kit_assets::Assets)) .expect("icon asset should resolve"); assert_eq!(image.format, ImageFormat::Svg); @@ -472,16 +458,27 @@ mod tests { } #[test] - fn test_relative_icon_path_only_uses_asset_source() { + fn test_relative_icon_path_only_uses_assets() { let path: SharedString = "native-menu-relative-shadow-test.svg".into(); let _file = TestIconFile::create(path.as_ref(), FILE_SVG); - let icon = Icon::default().path(path); - let image = resolve_icon_image(&icon, &TestAssetSource(Some(ASSET_SVG))) + let icon = Icon::default().path(path.clone()); + let image = resolve_icon_image(&icon, &assets(path, ASSET_SVG)) .expect("relative icon should resolve from the asset source"); assert_eq!(image.bytes, ASSET_SVG); - assert!(resolve_icon_image(&icon, &TestAssetSource(None)).is_none()); + assert!(resolve_icon_image(&icon, &AssetRegistry::default()).is_none()); + } + + #[test] + fn test_on_demand_icon_uses_the_registry_loader() { + let mut assets = AssetRegistry::default(); + assets + .insert("icons/on-demand.svg", || Some(Cow::Borrowed(ASSET_SVG))) + .unwrap(); + let image = resolve_icon_image(&Icon::default().path("icons/on-demand.svg"), &assets) + .expect("on-demand registry entries should resolve"); + assert_eq!(image.bytes, ASSET_SVG); } #[test] @@ -493,8 +490,8 @@ mod tests { let path: SharedString = path.to_string_lossy().into_owned().into(); let image = resolve_icon_image( - &Icon::default().path(path), - &TestAssetSource(Some(ASSET_SVG)), + &Icon::default().path(path.clone()), + &assets(path, ASSET_SVG), ) .expect("absolute icon should resolve from the filesystem"); assert_eq!(image.bytes, FILE_SVG); @@ -503,13 +500,13 @@ mod tests { #[test] fn test_native_menu_icon_data_replaces_path_and_survives_clone() { let icon = Icon::default().path("icons/previous.png").data(FILE_SVG); - let image = resolve_icon_image(&icon.clone(), &TestAssetSource(None)) + let image = resolve_icon_image(&icon.clone(), &AssetRegistry::default()) .expect("SVG data should resolve without an asset source"); assert_eq!(image.format, ImageFormat::Svg); assert_eq!(image.bytes, FILE_SVG); let icon = icon.path("icons/replacement.svg"); - let image = resolve_icon_image(&icon, &TestAssetSource(Some(ASSET_SVG))) + let image = resolve_icon_image(&icon, &assets("icons/replacement.svg", ASSET_SVG)) .expect("a later path should replace the data source"); assert_eq!(image.bytes, ASSET_SVG); } diff --git a/crates/component/src/native_menu/windows.rs b/crates/component/src/native_menu/windows.rs index 1ba91b5928..2a74c7ad9d 100644 --- a/crates/component/src/native_menu/windows.rs +++ b/crates/component/src/native_menu/windows.rs @@ -5,7 +5,7 @@ use std::{ sync::{Arc, OnceLock}, }; -use gpui::{Action, App, AssetSource, ImageFormat, Pixels, Point, Window}; +use gpui::{Action, App, AssetRegistry, ImageFormat, Pixels, Point, Window}; use raw_window_handle::{HasWindowHandle, RawWindowHandle}; use windows::Win32::Foundation::{BOOL, GlobalFree, HANDLE, HWND, POINT}; use windows::Win32::Graphics::Gdi::{ @@ -41,7 +41,7 @@ const MENU_IMAGE_SIZE: u32 = 16; /// run from a foreground task to avoid re-entering GPUI while it is borrowed. pub(super) fn show( items: Vec, - asset_source: Arc, + assets: Arc, position: Point, dark_mode: bool, window: &mut Window, @@ -65,7 +65,7 @@ pub(super) fn show( let Some(action) = run_menu( hwnd, &items, - asset_source.as_ref(), + assets.as_ref(), client_x, client_y, image_px, @@ -87,7 +87,7 @@ pub(super) fn show( fn run_menu( hwnd: isize, items: &[NativeMenuItem], - asset_source: &dyn AssetSource, + assets: &AssetRegistry, client_x: i32, client_y: i32, image_px: u32, @@ -105,7 +105,7 @@ fn run_menu( // Bitmaps attached to menu items must outlive the menu; freed below. let mut bitmaps: Vec = Vec::new(); - let menu = build_menu(items, asset_source, &mut actions, &mut bitmaps, image_px)?; + let menu = build_menu(items, assets, &mut actions, &mut bitmaps, image_px)?; let mut point = POINT { x: client_x, @@ -196,7 +196,7 @@ unsafe fn apply_menu_theme(hwnd: HWND, dark_mode: bool) { /// Win32 menu creation; the returned `HMENU` must be destroyed by the caller. unsafe fn build_menu<'a>( items: &'a [NativeMenuItem], - asset_source: &dyn AssetSource, + assets: &AssetRegistry, actions: &mut Vec<&'a Box>, bitmaps: &mut Vec, image_px: u32, @@ -237,7 +237,7 @@ unsafe fn build_menu<'a>( }; let _ = unsafe { AppendMenuW(menu, flags, id, PCWSTR(wide.as_ptr())) }; if let Some(icon) = icon { - if let Some(bitmap) = unsafe { load_hbitmap(icon, asset_source, image_px) } { + if let Some(bitmap) = unsafe { load_hbitmap(icon, assets, image_px) } { let info = MENUITEMINFOW { cbSize: std::mem::size_of::() as u32, fMask: MIIM_BITMAP, @@ -256,7 +256,7 @@ unsafe fn build_menu<'a>( items, } => { let Some(submenu) = - (unsafe { build_menu(items, asset_source, actions, bitmaps, image_px) }) + (unsafe { build_menu(items, assets, actions, bitmaps, image_px) }) else { continue; }; @@ -324,10 +324,10 @@ impl Drop for GdiplusSession { /// Calls GDI+ /GDI flat APIs; the returned handle is owned by the caller. unsafe fn load_hbitmap( icon: &crate::Icon, - asset_source: &dyn AssetSource, + assets: &AssetRegistry, image_px: u32, ) -> Option { - let image = resolve_icon_image(icon, asset_source)?; + let image = resolve_icon_image(icon, assets)?; if image.bytes.is_empty() { return None; } diff --git a/crates/component/src/notification.rs b/crates/component/src/notification.rs index 7eb5764ebe..e692c080fc 100644 --- a/crates/component/src/notification.rs +++ b/crates/component/src/notification.rs @@ -677,7 +677,7 @@ impl SystemNotificationRegistry { // Errs when the window is already closed: the entry is removed and the // application is still brought to the foreground. let _ = entry.window.update(cx, |_, window, cx| { - window.activate_window(); + window.activate(); if let Some(list) = entry.list.upgrade() { // No-op when the toast already closed or was never created // (system-only delivery). @@ -1177,7 +1177,7 @@ mod tests { list: cx.new(|cx| NotificationList::new(window, cx)), other_focus: cx.focus_handle(), }); - cx.update(|window, _| window.activate_window()); + cx.update(|window, _| window.activate()); let list = root.read_with(cx, |root, _| root.list.clone()); // The left stack is pushed first, so it owns the lower group index. @@ -1223,7 +1223,7 @@ mod tests { list: cx.new(|cx| NotificationList::new(window, cx)), other_focus: cx.focus_handle(), }); - cx.update(|window, _| window.activate_window()); + cx.update(|window, _| window.activate()); let list = root.read_with(cx, |root, _| root.list.clone()); list.update_in(cx, |list, window, cx| { @@ -1271,7 +1271,7 @@ mod tests { list: cx.new(|cx| NotificationList::new(window, cx)), other_focus: cx.focus_handle(), }); - cx.update(|window, _| window.activate_window()); + cx.update(|window, _| window.activate()); let list = root.read_with(cx, |root, _| root.list.clone()); list.update_in(cx, |list, window, cx| { @@ -1303,7 +1303,7 @@ mod tests { list: cx.new(|cx| NotificationList::new(window, cx)), other_focus: cx.focus_handle(), }); - cx.update(|window, _| window.activate_window()); + cx.update(|window, _| window.activate()); let list = root.read_with(cx, |root, _| root.list.clone()); // A list that has never shown anything arms no timer. @@ -1346,7 +1346,7 @@ mod tests { list: cx.new(|cx| NotificationList::new(window, cx)), other_focus: cx.focus_handle(), }); - cx.update(|window, _| window.activate_window()); + cx.update(|window, _| window.activate()); let list = root.read_with(cx, |root, _| root.list.clone()); list.update_in(cx, |list, window, cx| { @@ -1756,7 +1756,7 @@ mod tests { list: cx.new(|cx| NotificationList::new(window, cx)), other_focus: cx.focus_handle(), }); - cx.update(|window, _| window.activate_window()); + cx.update(|window, _| window.activate()); let list = root.read_with(cx, |r, _| r.list.clone()); // Autohide expiry leaves the system notification in the center. diff --git a/crates/component/src/popover.rs b/crates/component/src/popover.rs index f36b3056f0..509da6637c 100644 --- a/crates/component/src/popover.rs +++ b/crates/component/src/popover.rs @@ -8,7 +8,7 @@ use std::{cell::Cell, rc::Rc, time::Duration}; use crate::{ActiveTheme as _, ThemeStyled as _}; use crate::{ - Selectable, StyledExt as _, + Selectable, animation::ease_out_cubic, styled::{popover_ring, popover_shadow}, v_flex, @@ -381,10 +381,14 @@ impl RenderOnce for Popover { // The triangle ends exactly at the surface edge. // Cover the ring and the antialiased base on both // sides of that edge before drawing its two slopes. - window.paint_quad(gpui::fill( - arrow_join_bounds(points, side, px(1.)), - background, - )); + window.paint_quad( + gpui::PaintQuad::new(arrow_join_bounds( + points, + side, + px(1.), + )) + .background(background), + ); if appearance { let mut outline = PathBuilder::stroke(px(1.)); outline.move_to(points[0]); @@ -967,15 +971,14 @@ mod tests { #[gpui::test] fn the_enter_motion_starts_over_every_time_the_dropdown_opens(cx: &mut gpui::TestAppContext) { cx.update(crate::init); + let executor = cx.executor(); let (view, window) = cx.add_window_view(|_, _| Harness { open: true }); window.update(|window, cx| window.draw(cx).clear(cx)); let opening = window.debug_bounds("surface").unwrap().origin; - // The animation runs off the wall clock, so settling is waited out - // rather than stepped. Several times the duration leaves room for a - // loaded machine. - std::thread::sleep(DROPDOWN_ENTER_DURATION * 4); + // GPUI 0.3 animations use the scheduler clock, which tests control. + executor.advance_clock(DROPDOWN_ENTER_DURATION * 4); window.update(|window, cx| window.draw(cx).clear(cx)); let settled = window.debug_bounds("surface").unwrap().origin; diff --git a/crates/component/src/progress/progress.rs b/crates/component/src/progress/progress.rs index 165b70dfab..610634b49a 100644 --- a/crates/component/src/progress/progress.rs +++ b/crates/component/src/progress/progress.rs @@ -1,4 +1,4 @@ -use crate::{ActiveTheme, Sizable, Size, StyledExt}; +use crate::{ActiveTheme, Sizable, Size}; use gpui::{ Animation, AnimationExt as _, App, Background, ElementId, Hsla, IntoElement, IsZero as _, ParentElement, RenderOnce, SharedString, StyleRefinement, Styled, Window, ease_in_out, diff --git a/crates/component/src/progress/progress_circle.rs b/crates/component/src/progress/progress_circle.rs index 0f0f1ea91b..bac5eab65b 100644 --- a/crates/component/src/progress/progress_circle.rs +++ b/crates/component/src/progress/progress_circle.rs @@ -1,4 +1,4 @@ -use crate::{ActiveTheme, Sizable, Size, StyledExt}; +use crate::{ActiveTheme, Sizable, Size}; use gpui::Bounds; use gpui::ColorExt as _; use gpui::prelude::FluentBuilder as _; diff --git a/crates/component/src/questionnaire/components.rs b/crates/component/src/questionnaire/components.rs index d1223ec99b..4799e36d7f 100644 --- a/crates/component/src/questionnaire/components.rs +++ b/crates/component/src/questionnaire/components.rs @@ -9,7 +9,7 @@ use gpui_base::RadioGroup; use rust_i18n::t; use crate::{ - ActiveTheme as _, IconName, Sizable, Size, StyledExt as _, ThemeStyled as _, + ActiveTheme as _, IconName, Sizable, Size, ThemeStyled as _, button::{Button, ButtonVariants as _}, icon::IconNamed as _, input::Input, diff --git a/crates/component/src/rating.rs b/crates/component/src/rating.rs index e770f1421f..ab566ea26d 100644 --- a/crates/component/src/rating.rs +++ b/crates/component/src/rating.rs @@ -1,5 +1,5 @@ use crate::theme::ActiveTheme; -use crate::{Disableable, Icon, IconName, Sizable, Size, StyledExt, h_flex}; +use crate::{Disableable, Icon, IconName, Sizable, Size, h_flex}; use std::rc::Rc; use gpui::{ diff --git a/crates/component/src/scroll/scrollable.rs b/crates/component/src/scroll/scrollable.rs index 1e960bd82c..d90cf79da8 100644 --- a/crates/component/src/scroll/scrollable.rs +++ b/crates/component/src/scroll/scrollable.rs @@ -1,6 +1,6 @@ use std::{panic::Location, rc::Rc}; -use crate::{InteractiveElementExt as _, StyledExt}; +use crate::InteractiveElementExt as _; use super::{Scrollbar, ScrollbarAxis, ScrollbarHandle}; use gpui::{ @@ -376,7 +376,7 @@ mod tests { .w(px(200.)) .child( crate::v_flex().flex_1().overflow_hidden().child( - div().flex_1().overflow_hidden().child( + crate::v_flex().flex_1().overflow_hidden().child( crate::v_flex() .size_full() .overflow_y_scrollbar() @@ -396,22 +396,24 @@ mod tests { fn render(&mut self, _: &mut Window, _: &mut Context) -> impl IntoElement { // Mimics a Dialog with `max_h`: the panel grows with content up // to the max height, then the body starts scrolling. - crate::v_flex() - .w(px(200.)) - .max_h(px(100.)) - .child( - crate::v_flex().flex_1().overflow_hidden().child( - div().flex_1().overflow_hidden().child( - crate::v_flex() - .size_full() - .overflow_y_scrollbar() - .child(plain_row(50.)) - .child(plain_row(50.)) - .child(row("max-height-last-row", 50.)), + div().size_full().child( + crate::v_flex() + .w(px(200.)) + .max_h(px(100.)) + .child( + crate::v_flex().flex_1().overflow_hidden().child( + crate::v_flex().flex_1().overflow_hidden().child( + crate::v_flex() + .size_full() + .overflow_y_scrollbar() + .child(plain_row(50.)) + .child(plain_row(50.)) + .child(row("max-height-last-row", 50.)), + ), ), - ), - ) - .child(row("max-height-footer", 10.)) + ) + .child(row("max-height-footer", 10.)), + ) } } @@ -431,6 +433,7 @@ mod tests { fn max_height_parent_clamps_and_scrolls(cx: &mut TestAppContext) { cx.update(crate::init); let (_, cx) = cx.add_window_view(|_, _| MaxHeightParentTest); + cx.simulate_resize(gpui::size(px(200.), px(100.))); let cx: &mut VisualTestContext = cx; draw(cx); diff --git a/crates/component/src/searchable_list/item.rs b/crates/component/src/searchable_list/item.rs index 15e5a4d4ab..afa0551aba 100644 --- a/crates/component/src/searchable_list/item.rs +++ b/crates/component/src/searchable_list/item.rs @@ -5,8 +5,7 @@ use gpui::{ }; use crate::{ - ActiveTheme, Disableable, Icon, IconName, Selectable, Sizable, Size, StyleSized, StyledExt, - h_flex, + ActiveTheme, Disableable, Icon, IconName, Selectable, Sizable, Size, StyleSized, h_flex, }; /// A single row element used inside searchable-list dropdowns (Select, ComboBox, MultiComboBox). diff --git a/crates/component/src/separator.rs b/crates/component/src/separator.rs index 357ec1d526..e421eb3967 100644 --- a/crates/component/src/separator.rs +++ b/crates/component/src/separator.rs @@ -1,4 +1,4 @@ -use crate::{ActiveTheme, StyledExt}; +use crate::ActiveTheme; use gpui::{ App, Axis, Div, Hsla, IntoElement, ParentElement, PathBuilder, RenderOnce, SharedString, StyleRefinement, Styled, Window, canvas, div, point, prelude::FluentBuilder as _, px, diff --git a/crates/component/src/setting/fields/bool.rs b/crates/component/src/setting/fields/bool.rs index 77f68ec11b..9e480f0be0 100644 --- a/crates/component/src/setting/fields/bool.rs +++ b/crates/component/src/setting/fields/bool.rs @@ -1,7 +1,8 @@ +use gpui::Styled as _; use std::rc::Rc; use crate::{ - Disableable, Sizable, StyledExt, + Disableable, Sizable, checkbox::Checkbox, setting::{ AnySettingField, RenderOptions, diff --git a/crates/component/src/setting/fields/dropdown.rs b/crates/component/src/setting/fields/dropdown.rs index 7a69fbcdbe..6515b1174a 100644 --- a/crates/component/src/setting/fields/dropdown.rs +++ b/crates/component/src/setting/fields/dropdown.rs @@ -6,7 +6,7 @@ use gpui::{ }; use crate::{ - AxisExt, Disableable, Sizable, StyledExt, + AxisExt, Disableable, Sizable, button::Button, menu::{DropdownMenu, PopupMenuItem}, setting::{ diff --git a/crates/component/src/setting/fields/number.rs b/crates/component/src/setting/fields/number.rs index 19b114cb17..02bd3fb4c4 100644 --- a/crates/component/src/setting/fields/number.rs +++ b/crates/component/src/setting/fields/number.rs @@ -6,7 +6,7 @@ use gpui::{ }; use crate::{ - AxisExt, Disableable, Sizable, StyledExt, + AxisExt, Disableable, Sizable, input::{InputEvent, InputState, NumberInput}, setting::{ AnySettingField, RenderOptions, diff --git a/crates/component/src/setting/fields/string.rs b/crates/component/src/setting/fields/string.rs index e0acfd3cae..b4421f4fa3 100644 --- a/crates/component/src/setting/fields/string.rs +++ b/crates/component/src/setting/fields/string.rs @@ -6,7 +6,7 @@ use gpui::{ }; use crate::{ - AxisExt as _, Sizable, StyledExt, + AxisExt as _, Sizable, input::{Input, InputEvent, InputState}, setting::{ AnySettingField, RenderOptions, diff --git a/crates/component/src/setting/group.rs b/crates/component/src/setting/group.rs index c94664f290..0ccb4e4ff5 100644 --- a/crates/component/src/setting/group.rs +++ b/crates/component/src/setting/group.rs @@ -6,7 +6,7 @@ use gpui::{ }; use crate::{ - ActiveTheme, StyledExt, + ActiveTheme, group_box::{GroupBox, GroupBoxVariant, GroupBoxVariants}, label::Label, setting::{RenderOptions, SettingItem}, diff --git a/crates/component/src/setting/page.rs b/crates/component/src/setting/page.rs index 842c8ed3a7..9553f23f2d 100644 --- a/crates/component/src/setting/page.rs +++ b/crates/component/src/setting/page.rs @@ -8,7 +8,7 @@ use gpui::{ use rust_i18n::t; use crate::{ - ActiveTheme, Icon, IconName, Sizable, StyledExt, + ActiveTheme, Icon, IconName, Sizable, button::{Button, ButtonVariants}, h_flex, label::Label, diff --git a/crates/component/src/setting/settings.rs b/crates/component/src/setting/settings.rs index 4422d5f2e0..1afcc0c9a8 100644 --- a/crates/component/src/setting/settings.rs +++ b/crates/component/src/setting/settings.rs @@ -1,7 +1,7 @@ use std::ops::Range; use crate::{ - IconName, Sizable, Size, StyledExt, + IconName, Sizable, Size, group_box::GroupBoxVariant, h_resizable, input::{Input, InputState}, diff --git a/crates/component/src/shimmer.rs b/crates/component/src/shimmer.rs index 69ce8aba99..a1fdebc408 100644 --- a/crates/component/src/shimmer.rs +++ b/crates/component/src/shimmer.rs @@ -1,12 +1,11 @@ use gpui::{ Animation, AnimationExt as _, App, Bounds, ContentMask, Element, ElementId, GlobalElementId, - Hsla, InspectorElementId, IntoElement, LayoutId, LineLayout, ParentElement as _, Pixels, Point, - RenderOnce, SharedString, StyleRefinement, Styled, StyledText, TextAlign, Window, WrapBoundary, - div, point, px, size, + Hsla, InspectorElementId, IntoElement, LayoutId, ParentElement as _, Pixels, RenderOnce, + SharedString, StyleRefinement, Styled, StyledText, Window, div, point, px, size, }; use web_time::Duration; -use crate::{ActiveTheme as _, Colorize as _, StyledExt as _}; +use crate::{ActiveTheme as _, Colorize as _}; const SHIMMER_LAYER_COUNT: usize = 12; const DEFAULT_SHIMMER_SPREAD: f32 = 0.3; @@ -256,8 +255,10 @@ struct ShimmerGlyphs { impl ShimmerGlyphs { fn paint_highlight(&self, bounds: Bounds, window: &mut Window, cx: &mut App) { let masks = std::array::from_fn::<_, SHIMMER_LAYER_COUNT, _>(|layer| { - shimmer_band_bounds(bounds, self.phase, self.spread, layer) - .map(|bounds| ContentMask { bounds }) + shimmer_band_bounds(bounds, self.phase, self.spread, layer).map(|bounds| ContentMask { + fade_out: Default::default(), + bounds, + }) }); if masks.iter().all(Option::is_none) { @@ -273,78 +274,41 @@ impl ShimmerGlyphs { ); let layout = self.text.layout(); let line_height = layout.line_height(); - let text_align = window.text_style().text_align; let mut line_origin = bounds.origin; window.paint_layer(bounds, |window| { for wrapped_line in layout.line_layouts() { - let line = &wrapped_line.unwrapped_layout; - let baseline_offset = point( - px(0.), - (line_height - line.ascent - line.descent) / 2. + line.ascent, - ); - let mut wraps = wrapped_line.wrap_boundaries.iter().peekable(); - let mut glyph_origin = point( - shimmer_aligned_origin_x( - line_origin, - bounds.size.width, - px(0.), - text_align, - line, - wraps.peek().copied(), - ), - line_origin.y, - ); - let mut previous_glyph_position = Point::default(); - - for (run_index, run) in line.runs.iter().enumerate() { - let glyph_size = cx - .text_system() - .bounding_box(run.font_id, line.font_size) - .size; - - for (glyph_index, glyph) in run.glyphs.iter().enumerate() { - glyph_origin.x += glyph.position.x - previous_glyph_position.x; - - if wraps.peek().is_some_and(|wrap| { - wrap.run_ix == run_index && wrap.glyph_ix == glyph_index - }) { - wraps.next(); - glyph_origin.x = shimmer_aligned_origin_x( - line_origin, - bounds.size.width, - glyph.position.x, - text_align, - line, - wraps.peek().copied(), - ); - glyph_origin.y += line_height; - } - - previous_glyph_position = glyph.position; - - if glyph.is_emoji { - continue; - } - - let glyph_bounds = Bounds::new(glyph_origin, glyph_size); - let paint_origin = - glyph_origin + baseline_offset + point(px(0.), glyph.position.y); - - for mask in masks.iter().flatten() { - if !glyph_bounds.intersects(&mask.bounds) { - continue; + for (row, visual_line) in wrapped_line.visual_lines().iter().enumerate() { + let baseline = (line_height - wrapped_line.ascent() - wrapped_line.descent()) + / 2. + + wrapped_line.ascent(); + let origin = point( + line_origin.x + visual_line.offset, + line_origin.y + line_height * row as f32, + ); + for fragment in wrapped_line.fragments_for_line(visual_line) { + let glyph_size = cx + .text_system() + .bounding_box(fragment.font_id, fragment.font_size) + .size; + for glyph in fragment.glyphs.iter().filter(|glyph| !glyph.is_emoji) { + let glyph_origin = origin + point(glyph.position.x, px(0.)); + let glyph_bounds = Bounds::new(glyph_origin, glyph_size); + let paint_origin = origin + glyph.position + point(px(0.), baseline); + for mask in masks.iter().flatten() { + if !glyph_bounds.intersects(&mask.bounds) { + continue; + } + window.with_content_mask(Some(*mask), |window| { + let _ = window.paint_glyph( + paint_origin, + fragment.font_id, + glyph.id, + fragment.font_size, + color, + ); + }); } - - window.with_content_mask(Some(*mask), |window| { - let _ = window.paint_glyph( - paint_origin, - run.font_id, - glyph.id, - line.font_size, - color, - ); - }); } } } @@ -382,8 +346,18 @@ impl Element for ShimmerGlyphs { window: &mut Window, cx: &mut App, ) -> (LayoutId, Self::RequestLayoutState) { - self.text - .request_layout(global_id, inspector_id, window, cx) + let (layout_id, ()) = self + .text + .request_layout(global_id, inspector_id, window, cx); + let layout_id = window.request_layout( + gpui::Style { + display: gpui::Display::Flex, + ..Default::default() + }, + [layout_id], + cx, + ); + (layout_id, ()) } fn prepaint( @@ -480,26 +454,6 @@ fn shimmer_band_bounds( }) } -fn shimmer_aligned_origin_x( - origin: Point, - align_width: Pixels, - previous_glyph_x: Pixels, - align: TextAlign, - layout: &LineLayout, - next_wrap: Option<&WrapBoundary>, -) -> Pixels { - let line_end = next_wrap - .map(|wrap| layout.runs[wrap.run_ix].glyphs[wrap.glyph_ix].position.x) - .unwrap_or(layout.width); - let line_width = line_end - previous_glyph_x; - - match align { - TextAlign::Left => origin.x, - TextAlign::Center => (origin.x * 2. + align_width - line_width) / 2., - TextAlign::Right => origin.x + align_width - line_width, - } -} - #[cfg(test)] mod tests { use super::*; @@ -627,11 +581,23 @@ mod tests { assert_eq!(custom.color.lightness, muted.color.lightness); let animation = loading_animation(Duration::from_secs(3), false); - assert_eq!(animation.duration, Duration::from_secs(3)); - assert!(!animation.oneshot); + assert_eq!( + animation.motion.forward_pass().duration(), + Duration::from_secs(3) + ); + assert_eq!( + animation.motion.playback().iterations(), + gpui::Iterations::Forever + ); let animation = loading_animation(Duration::from_secs(3), true); - assert_eq!(animation.duration, Duration::from_secs(3)); - assert!(animation.oneshot); + assert_eq!( + animation.motion.forward_pass().duration(), + Duration::from_secs(3) + ); + assert_eq!( + animation.motion.playback().iterations(), + gpui::Iterations::default() + ); } } diff --git a/crates/component/src/sidebar/mod.rs b/crates/component/src/sidebar/mod.rs index c9ac4722be..dc691dee94 100644 --- a/crates/component/src/sidebar/mod.rs +++ b/crates/component/src/sidebar/mod.rs @@ -1,5 +1,5 @@ use crate::{ - ActiveTheme, Collapsible, Icon, IconName, Side, Sizable, StyledExt, + ActiveTheme, Collapsible, Icon, IconName, Side, Sizable, button::{Button, ButtonVariants}, h_flex, scroll::ScrollableElement, diff --git a/crates/component/src/skeleton.rs b/crates/component/src/skeleton.rs index 4166fd405b..782e3f0f08 100644 --- a/crates/component/src/skeleton.rs +++ b/crates/component/src/skeleton.rs @@ -1,4 +1,4 @@ -use crate::{ActiveTheme, StyledExt}; +use crate::ActiveTheme; use gpui::ColorExt as _; use gpui::{ Animation, AnimationExt, IntoElement, RenderOnce, StyleRefinement, Styled, bounce, div, diff --git a/crates/component/src/status_bar.rs b/crates/component/src/status_bar.rs index eca4c20b09..f93c73bb61 100644 --- a/crates/component/src/status_bar.rs +++ b/crates/component/src/status_bar.rs @@ -4,7 +4,7 @@ use gpui::{ }; use smallvec::SmallVec; -use crate::{ActiveTheme, StyledExt, h_flex}; +use crate::{ActiveTheme, h_flex}; /// A horizontal status bar, usually placed at the bottom of a window or pane. /// diff --git a/crates/component/src/switch.rs b/crates/component/src/switch.rs index 7ba9b4d9bd..0b3a3cded3 100644 --- a/crates/component/src/switch.rs +++ b/crates/component/src/switch.rs @@ -508,6 +508,7 @@ mod tests { #[gpui::test] fn long_labels_preserve_track_size_in_narrow_containers(cx: &mut TestAppContext) { + crate::test_text_system::install(cx); struct NarrowSwitch { size: Size, checked: bool, diff --git a/crates/component/src/tab/tab_bar.rs b/crates/component/src/tab/tab_bar.rs index 9db5debd11..998fd3a0b4 100644 --- a/crates/component/src/tab/tab_bar.rs +++ b/crates/component/src/tab/tab_bar.rs @@ -528,7 +528,7 @@ impl RenderOnce for TabBar { // `on_prepaint` adds a canvas child. Keep that helper on // the non-scrolling wrapper so it cannot shift tab indices. .when_some(bounds_rc.clone(), |this, rc| { - this.on_prepaint(move |bounds, _, _| { + gpui_base::ElementExt::on_prepaint(this, move |bounds, _, _| { rc.borrow_mut().container = bounds; }) }) diff --git a/crates/component/src/table/table.rs b/crates/component/src/table/table.rs index c78a4363b7..cc7279316c 100644 --- a/crates/component/src/table/table.rs +++ b/crates/component/src/table/table.rs @@ -9,7 +9,7 @@ use gpui_base::{ TableRow as BaseTableRow, }; -use crate::{ActiveTheme as _, AnyChildElement, ChildElement, Sizable, Size, StyledExt as _}; +use crate::{ActiveTheme as _, AnyChildElement, ChildElement, Sizable, Size}; const MIN_CELL_WIDTH: Pixels = px(100.); diff --git a/crates/component/src/tag.rs b/crates/component/src/tag.rs index 8de90e9c0f..368b6eef0c 100644 --- a/crates/component/src/tag.rs +++ b/crates/component/src/tag.rs @@ -1,4 +1,4 @@ -use crate::{ColorName, Sizable, Size, StyledExt, theme::ActiveTheme as _}; +use crate::{ColorName, Sizable, Size, theme::ActiveTheme as _}; use gpui::ColorExt as _; use gpui::{ AbsoluteLength, AnyElement, App, Hsla, InteractiveElement as _, IntoElement, ParentElement, diff --git a/crates/component/src/test_text_system.rs b/crates/component/src/test_text_system.rs new file mode 100644 index 0000000000..e7d34a2a87 --- /dev/null +++ b/crates/component/src/test_text_system.rs @@ -0,0 +1,22 @@ +//! Real shaping for tests that exercise wrapping and multiline geometry. +use gpui::{PlatformTextSystem, TestAppContext}; +use std::{borrow::Cow, sync::Arc}; + +pub(crate) fn platform() -> Arc { + let system = Arc::new( + gpui_ce_parley::ParleyTextSystem::without_system_fonts() + .with_fallback_families(["JetBrains Mono"]), + ); + system + .add_fonts(vec![Cow::Borrowed(include_bytes!( + "../../story-web/fonts/JetBrainsMono-Regular.ttf" + ))]) + .unwrap(); + system +} + +pub(crate) fn install(cx: &mut TestAppContext) { + // GPUI's default test backend deliberately models only a single row. + // Replace the empty app before any entities or windows are created. + *cx = TestAppContext::build_with_text_system(cx.dispatcher.clone(), None, platform()); +} diff --git a/crates/component/src/text/window_selection.rs b/crates/component/src/text/window_selection.rs index cf1583cf91..88b78714ad 100644 --- a/crates/component/src/text/window_selection.rs +++ b/crates/component/src/text/window_selection.rs @@ -70,8 +70,20 @@ mod tests { window: &mut Window, cx: &mut App, ) -> (LayoutId, Self::RequestLayoutState) { - self.styled_text - .request_layout(id, inspector_id, window, cx) + let (layout_id, ()) = self + .styled_text + .request_layout(id, inspector_id, window, cx); + ( + window.request_layout( + gpui::Style { + display: gpui::Display::Flex, + ..Default::default() + }, + [layout_id], + cx, + ), + (), + ) } fn prepaint( diff --git a/crates/component/src/theme/mod.rs b/crates/component/src/theme/mod.rs index 9fcf7f360f..e77383bf14 100644 --- a/crates/component/src/theme/mod.rs +++ b/crates/component/src/theme/mod.rs @@ -24,7 +24,6 @@ mod mono_font; mod motion; mod registry; mod schema; -mod system_font; mod theme_color; pub use color::*; @@ -328,7 +327,7 @@ impl Theme { let fonts_changed = (&theme.font_family, &theme.mono_font_family) != (&fonts_before.0, &fonts_before.1); if mode_changed || reload_mode || fonts_changed { - system_font::resolve_default_font(cx); + // GPUI 0.3 caches virtual system-font resolution in TextSystem. mono_font::resolve_default_mono_font(cx); } Self::sync_base(cx); diff --git a/crates/component/src/theme/system_font.rs b/crates/component/src/theme/system_font.rs deleted file mode 100644 index 672d85427d..0000000000 --- a/crates/component/src/theme/system_font.rs +++ /dev/null @@ -1,100 +0,0 @@ -//! Keeps the theme's UI family on the font GPUI actually draws it with. -//! -//! The default UI family is the virtual `.SystemUIFont`, which GPUI maps to a -//! platform name and, when that name is not installed, resolves through its -//! own fallback stack. The fallback works, but it is paid for on every text -//! run of every frame: the failed lookup is cached as an error that is -//! formatted and allocated again each time it is hit, once per entry of the -//! stack that is missing too. On Linux the mapped name is one most desktops -//! do not ship, so this is the common case there. -//! -//! This probe asks GPUI once which family `.SystemUIFont` lands on and, when -//! that is an installed family rather than the system font itself, names it -//! on the theme directly, so every later lookup hits the cache and the text -//! is drawn exactly as before. A family the application or a theme file -//! chose explicitly is used as-is. -//! -//! GPUI panics when neither `.SystemUIFont` nor any family of its fallback -//! stack is installed. On the web the text system starts with no fonts at -//! all and only sees the ones the application adds, usually after `init`, so -//! the probe does nothing while no font is installed: there would be nothing -//! to name anyway. - -use gpui::{App, SharedString, font}; - -use super::mono_font::installed_font_names; - -/// The virtual family GPUI resolves on every platform. -const SYSTEM_UI_FONT: &str = ".SystemUIFont"; - -/// Replaces `.SystemUIFont` on the global theme with the installed family GPUI -/// resolves it to, when that differs. Any other family is left alone. -pub(super) fn resolve_default_font(cx: &mut App) { - if cx.global::().font_family != SYSTEM_UI_FONT { - return; - } - let installed = installed_font_names(cx); - if installed.is_empty() { - return; - } - let text_system = cx.text_system(); - let resolved = text_system - .get_font_for_id(text_system.resolve_font(&font(SYSTEM_UI_FONT))) - .map(|font| font.family); - let Some(family) = substitute(SYSTEM_UI_FONT, resolved.as_deref(), installed) else { - return; - }; - tracing::info!("UI font {SYSTEM_UI_FONT:?} resolves to {family:?}, naming it on the theme."); - cx.global_mut::().font_family = family; -} - -/// The family to name instead of `requested`: the one GPUI resolved it to, -/// when that is a different, installed family. -fn substitute( - requested: &str, - resolved: Option<&str>, - installed: &[String], -) -> Option { - let resolved = resolved.filter(|resolved| *resolved != requested)?; - installed - .iter() - .any(|name| name == resolved) - .then(|| resolved.to_string().into()) -} - -#[cfg(test)] -mod tests { - use super::*; - - fn names(names: &[&str]) -> Vec { - names.iter().map(|name| name.to_string()).collect() - } - - #[test] - fn keeps_the_system_font_when_it_resolves_to_itself() { - let installed = names(&["Noto Sans", ".SystemUIFont"]); - assert_eq!( - substitute(".SystemUIFont", Some(".SystemUIFont"), &installed), - None - ); - } - - #[test] - fn names_the_installed_family_the_system_font_fell_back_to() { - let installed = names(&["Noto Sans", "DejaVu Sans"]); - assert_eq!( - substitute(".SystemUIFont", Some("Noto Sans"), &installed), - Some(SharedString::from("Noto Sans")) - ); - } - - #[test] - fn keeps_the_system_font_when_the_resolved_family_is_not_installed() { - let installed = Vec::new(); - assert_eq!( - substitute(".SystemUIFont", Some("Noto Sans"), &installed), - None - ); - assert_eq!(substitute(".SystemUIFont", None, &installed), None); - } -} diff --git a/crates/component/src/time/date_picker.rs b/crates/component/src/time/date_picker.rs index d7d1e5e094..541ec7cc5c 100644 --- a/crates/component/src/time/date_picker.rs +++ b/crates/component/src/time/date_picker.rs @@ -11,7 +11,7 @@ use rust_i18n::t; use crate::ThemeStyled as _; use crate::{ - ActiveTheme, Disableable, Icon, IconName, Sizable, Size, StyleSized as _, StyledExt as _, + ActiveTheme, Disableable, Icon, IconName, Sizable, Size, StyleSized as _, actions::{Cancel, Confirm}, button::{Button, ButtonVariants as _}, h_flex, @@ -23,7 +23,7 @@ use super::calendar::{Calendar, CalendarEvent, CalendarState, Date, Matcher}; use super::time_field::{ HourCycle, TimeField, TimeFieldEvent, TimeFieldState, TimePrecision, tabular_figures, }; -use gpui_base::{DatePicker as BaseDatePicker, ElementExt as _}; +use gpui_base::DatePicker as BaseDatePicker; const CONTEXT: &'static str = "DatePicker"; pub(crate) fn init(cx: &mut App) { @@ -708,9 +708,11 @@ impl RenderOnce for DatePicker { .flex_none() .w_full() .relative() - .on_prepaint({ - let state = self.state.clone(); - move |bounds, _, cx| state.update(cx, |state, _| state.bounds = bounds) + .map(|this| { + gpui_base::ElementExt::on_prepaint(this, { + let state = self.state.clone(); + move |bounds, _, cx| state.update(cx, |state, _| state.bounds = bounds) + }) }) .input_text_size(self.size) .refine_style(&self.style) diff --git a/crates/component/src/time/time_field.rs b/crates/component/src/time/time_field.rs index 06ea4a2998..c88ac91f16 100644 --- a/crates/component/src/time/time_field.rs +++ b/crates/component/src/time/time_field.rs @@ -6,8 +6,8 @@ use gpui::{ }; use crate::{ - ActiveTheme as _, Disableable, Sizable, Size, StyleSized as _, StyledExt as _, - ThemeStyled as _, input::input_style, + ActiveTheme as _, Disableable, Sizable, Size, StyleSized as _, ThemeStyled as _, + input::input_style, }; use gpui_base::TimeField as BaseTimeField; diff --git a/crates/component/src/title_bar.rs b/crates/component/src/title_bar.rs index d254964602..09982211d5 100644 --- a/crates/component/src/title_bar.rs +++ b/crates/component/src/title_bar.rs @@ -1,8 +1,6 @@ use std::rc::Rc; -use crate::{ - ActiveTheme, Icon, IconName, InteractiveElementExt as _, Sizable as _, StyledExt, h_flex, -}; +use crate::{ActiveTheme, Icon, IconName, InteractiveElementExt as _, Sizable as _, h_flex}; use gpui::{ AnyElement, App, Background, ClickEvent, Context, Decorations, Hsla, InteractiveElement, IntoElement, MouseButton, ParentElement, Pixels, Render, RenderOnce, Rgba, diff --git a/crates/component/src/toolbar.rs b/crates/component/src/toolbar.rs index 6a4fa321b7..088eef90ba 100644 --- a/crates/component/src/toolbar.rs +++ b/crates/component/src/toolbar.rs @@ -6,7 +6,7 @@ use smallvec::SmallVec; use gpui_base::{Toolbar as BaseToolbar, ToolbarGroup as BaseToolbarGroup}; -use crate::{Sizable, Size, StyleSized as _, StyledExt as _}; +use crate::{Sizable, Size, StyleSized as _}; enum ToolbarItem { Sized(Box AnyElement>), diff --git a/crates/component/src/touch_selection/edit_menu.rs b/crates/component/src/touch_selection/edit_menu.rs index 29ee692313..01f37c230e 100644 --- a/crates/component/src/touch_selection/edit_menu.rs +++ b/crates/component/src/touch_selection/edit_menu.rs @@ -151,6 +151,6 @@ impl RenderOnce for EditMenu { }), ), ) - .with_priority(gpui_base::POPUP_PRIORITY) + .priority(gpui_base::POPUP_PRIORITY) } } diff --git a/crates/component/src/touch_selection/handle.rs b/crates/component/src/touch_selection/handle.rs index 59f22eab98..c97a4fb8d7 100644 --- a/crates/component/src/touch_selection/handle.rs +++ b/crates/component/src/touch_selection/handle.rs @@ -184,6 +184,6 @@ impl RenderOnce for SelectionHandles { .absolute() .size_0(), ) - .with_priority(gpui_base::POPUP_PRIORITY) + .priority(gpui_base::POPUP_PRIORITY) } } diff --git a/crates/component/src/tree.rs b/crates/component/src/tree.rs index 3c70632b37..f81da82630 100644 --- a/crates/component/src/tree.rs +++ b/crates/component/src/tree.rs @@ -6,7 +6,7 @@ use gpui::{ }; use crate::{ - Selectable as _, StyledExt, + Selectable as _, list::ListItem, menu::{ContextMenuExt as _, PopupMenu}, scroll::ScrollableElement, diff --git a/crates/component/src/window_border.rs b/crates/component/src/window_border.rs index e926484e82..57f5615318 100644 --- a/crates/component/src/window_border.rs +++ b/crates/component/src/window_border.rs @@ -219,7 +219,7 @@ impl RenderOnce for WindowBorder { // does not grow the paint bounds for blur, so a larger blur // or offset would be visibly cut off by the window surface. gpui::BoxShadow { - color: hsla(0., 0., 0., 0.18 * opacity), + color: hsla(0., 0., 0., 0.18 * opacity).into(), // GNOME-style ambient shadow: horizontally centered // with only a slight downward bias. blur_radius: px(10.), @@ -230,7 +230,7 @@ impl RenderOnce for WindowBorder { // The contact layer adds definition without increasing the // space between the content and the outer window bounds. gpui::BoxShadow { - color: hsla(0., 0., 0., 0.18 * opacity), + color: hsla(0., 0., 0., 0.18 * opacity).into(), blur_radius: px(3.), spread_radius: px(0.), offset: point(px(0.0), px(1.0)), diff --git a/crates/component/tests/controlled_change_callbacks.rs b/crates/component/tests/controlled_change_callbacks.rs index 2ab9239bac..7c597f4330 100644 --- a/crates/component/tests/controlled_change_callbacks.rs +++ b/crates/component/tests/controlled_change_callbacks.rs @@ -127,7 +127,7 @@ fn controlled_change_callbacks_preserve_activation_and_replace_aliases(cx: &mut Modifiers::default(), ); visual.update(|window, cx| { - window.blur(); + window.blur(cx); window.focus_next(cx); }); for key in ["enter", "space"] { diff --git a/crates/fps/src/sampler.rs b/crates/fps/src/sampler.rs index 21ca7d0d63..56f7136d22 100644 --- a/crates/fps/src/sampler.rs +++ b/crates/fps/src/sampler.rs @@ -2,7 +2,7 @@ use std::{collections::VecDeque, time::Duration}; use gpui::{ WindowId, - profiler::{FrameTiming, FrameTimingCollector}, + profiler::{FrameEvent, FrameTiming, FrameTimingCollector}, }; use web_time::Instant; @@ -103,20 +103,25 @@ impl FrameSampler { /// Drains the frames drawn since the previous call. Call once per rendered /// frame. pub(crate) fn tick(&mut self) { - // GPUI-CE's profiler reports draw timings only; there are no present - // events to source, so the present pipeline stays empty on this frame. - let draws = self - .collector - .collect_unseen() - .into_iter() - .filter(|timing| timing.window_id == self.window_id) - .collect::>(); + let mut draws = Vec::new(); + let mut presents = Vec::new(); + for event in self.collector.collect_unseen() { + match event { + FrameEvent::Draw(timing) if timing.window_id == self.window_id => { + draws.push(timing) + } + FrameEvent::Present(timing) if timing.window_id == self.window_id => { + presents.push(timing.present_end) + } + _ => {} + } + } if !self.drained_backlog { self.drained_backlog = true; self.warmup = self.warmup.saturating_add(draws.len() as u32); } self.ingest_draws(draws); - self.ingest_presents([], Instant::now()); + self.ingest_presents(presents, Instant::now()); } /// Starts over, as for a HUD shown again after a spell hidden: a new @@ -519,6 +524,9 @@ mod tests { invalidations, draw_start: start, draw_end: start + draw, + refresh_interval: None, + signal_at: None, + phases: Default::default(), } } @@ -545,6 +553,9 @@ mod tests { invalidations, draw_start: start, draw_end: start + draw, + refresh_interval: None, + signal_at: None, + phases: Default::default(), } } diff --git a/crates/kit/tests/components.rs b/crates/kit/tests/components.rs index 610e500016..1ca26927d0 100644 --- a/crates/kit/tests/components.rs +++ b/crates/kit/tests/components.rs @@ -134,7 +134,7 @@ fn scrollable_elements_forward_observed_focus_binding(cx: &mut TestAppContext) { window.within("scroll").find(content.clone()).focused(), Some(true) ); - window.blur(); + window.blur(cx); window.render_frame(cx); assert_eq!(window.within("scroll").find(content).focused(), Some(false)); }) diff --git a/crates/kit/tests/controls.rs b/crates/kit/tests/controls.rs index 684f98055b..b44b8dedbc 100644 --- a/crates/kit/tests/controls.rs +++ b/crates/kit/tests/controls.rs @@ -183,7 +183,7 @@ fn select_emits_one_dismiss_event_for_each_open_to_closed_transition(cx: &mut Te form.language.clone() }) .unwrap(); - cx.update_window(handle.into(), |_, window, _| window.activate_window()) + cx.update_window(handle.into(), |_, window, _| window.activate()) .unwrap(); cx.run_until_parked(); let events = Rc::new(RefCell::new(Vec::new())); @@ -218,7 +218,7 @@ fn select_emits_one_dismiss_event_for_each_open_to_closed_transition(cx: &mut Te match close { "escape" => window.press("escape", cx), "outside" => window.click("agree", cx), - "blur" => window.blur(), + "blur" => window.blur(cx), "confirm" => window.press("enter", cx), _ => unreachable!(), } @@ -236,7 +236,7 @@ fn select_emits_one_dismiss_event_for_each_open_to_closed_transition(cx: &mut Te // Follow-up Escape and blur notifications must not dismiss twice. language.update(cx, |language, cx| language.focus(window, cx)); window.press("escape", cx); - window.blur(); + window.blur(cx); window.render_frame(cx); }) .unwrap(); diff --git a/crates/kit/tests/input/completions.rs b/crates/kit/tests/input/completions.rs index 69feeb5c5d..2b0f020d42 100644 --- a/crates/kit/tests/input/completions.rs +++ b/crates/kit/tests/input/completions.rs @@ -220,7 +220,7 @@ impl Fixture { }) }); if activate { - cx.update_window(handle.into(), |_, window, _| window.activate_window()) + cx.update_window(handle.into(), |_, window, _| window.activate()) .unwrap(); cx.run_until_parked(); } diff --git a/crates/kit/tests/input/constraints.rs b/crates/kit/tests/input/constraints.rs index d47fd5aa8d..81f6b011d2 100644 --- a/crates/kit/tests/input/constraints.rs +++ b/crates/kit/tests/input/constraints.rs @@ -519,7 +519,7 @@ fn disabled_single_and_double_click_do_not_focus_the_editor(cx: &mut TestAppCont if preserve_focus { previous_focus.focus(window, cx); } else { - window.blur(); + window.blur(cx); } window.render_frame(cx); let before = window.focused(cx); @@ -561,7 +561,7 @@ fn enabling_a_disabled_input_allows_mouse_focus_and_replacement(cx: &mut TestApp }) .unwrap(); // Render the disabled state before enabling the same retained input. - ui(handle, cx, |window, _cx| window.blur()); + ui(handle, cx, |window, _cx| window.blur(_cx)); common::update_content(handle, &view, cx, |view, _, cx| { view.disabled = false; cx.notify(); diff --git a/crates/kit/tests/input/history.rs b/crates/kit/tests/input/history.rs index 24216f6f5b..24f5f84392 100644 --- a/crates/kit/tests/input/history.rs +++ b/crates/kit/tests/input/history.rs @@ -159,7 +159,7 @@ fn blur_splits_typing_without_moving_the_caret(cx: &mut TestAppContext) { }) }); // GPUI only delivers focus/blur callbacks for an active platform window. - cx.update_window(handle.into(), |_, window, _| window.activate_window()) + cx.update_window(handle.into(), |_, window, _| window.activate()) .unwrap(); cx.run_until_parked(); cx.update_window(handle.into(), |_, window, cx| { diff --git a/crates/kit/tests/input/lifecycle.rs b/crates/kit/tests/input/lifecycle.rs index 82d803948a..e5dfa7ec16 100644 --- a/crates/kit/tests/input/lifecycle.rs +++ b/crates/kit/tests/input/lifecycle.rs @@ -232,7 +232,7 @@ fn readonly_transition_keeps_selection_copyable_and_reenable_restores_editing( fn focus_and_blur_events_fire_once_per_transition_across_all_controls(cx: &mut TestAppContext) { let (handle, fields, ids) = mount(cx); // GPUI delivers focus/blur subscriptions only for an active platform window. - cx.update_window(handle.into(), |_, window, _| window.activate_window()) + cx.update_window(handle.into(), |_, window, _| window.activate()) .unwrap(); cx.run_until_parked(); let mut expected = [[0; 2]; 3]; @@ -264,7 +264,7 @@ fn focus_and_blur_events_fire_once_per_transition_across_all_controls(cx: &mut T expected ); - cx.update_window(handle.into(), |_, window, _cx| window.blur()) + cx.update_window(handle.into(), |_, window, _cx| window.blur(_cx)) .unwrap(); cx.run_until_parked(); expected[ix][1] += 1; @@ -313,7 +313,7 @@ fn disabling_focused_controls_blocks_edits_and_click_focus_until_reenabled( ); assert_eq!(window.find(id.clone()).value(), Some("saved🦀")); - window.blur(); + window.blur(cx); }) .unwrap(); cx.run_until_parked(); diff --git a/crates/kit/tests/lifecycle.rs b/crates/kit/tests/lifecycle.rs index bd7368ddcc..6d5f54f8a8 100644 --- a/crates/kit/tests/lifecycle.rs +++ b/crates/kit/tests/lifecycle.rs @@ -28,7 +28,11 @@ impl Render for Host { .size_full() .when(self.hidden, |this| this.invisible()) .when(self.mounted, |this| { - this.child(self.child.clone().cached(Default::default())) + this.child( + self.child + .clone() + .cached(gpui::StyleRefinement::default().size(px(40.))), + ) }) } } diff --git a/crates/kit/tests/overlays.rs b/crates/kit/tests/overlays.rs index 09f5e10ee0..ac93d48a53 100644 --- a/crates/kit/tests/overlays.rs +++ b/crates/kit/tests/overlays.rs @@ -84,7 +84,10 @@ impl Render for Workspace { #[gpui_kit::test] async fn dialog_validates_scoped_input_saves_and_dismisses_notification(cx: &mut TestAppContext) { - cx.update(gpui_kit::init); + cx.update(|cx| { + gpui_kit::init(cx); + cx.set_reduce_motion(true); + }); let (handle, _) = common::open_window(cx, Some(size(px(800.), px(700.))), |window, cx| { let view = cx.new(|cx| Workspace { saved: cx.new(|cx| InputState::new(window, cx)), @@ -130,8 +133,6 @@ async fn dialog_validates_scoped_input_saves_and_dismisses_notification(cx: &mut window.try_find("dialog").is_none() && window.try_find("notification").is_some() }) .await; - // Toast entrance also uses GPUI's wall-clock Animation (400 ms). - std::thread::sleep(Duration::from_millis(410)); cx.update_window(handle.into(), |_, window, cx| { assert_eq!(window.find("name").value(), Some("Ada 中文")); assert!(window.find("notification").visible()); @@ -182,9 +183,8 @@ async fn escape_dismisses_dialog_and_sheet_and_restores_focus(cx: &mut TestAppCo window.try_find("sheet-content").is_some() }) .await; - // GPUI's non-synced Animation uses std::time::Instant, not the test clock. - // Finish the actual 150 ms entrance before asserting its final geometry. - std::thread::sleep(Duration::from_millis(160)); + // Finish the scheduler-driven entrance before asserting final geometry. + cx.executor().advance_clock(Duration::from_millis(160)); cx.update_window(handle.into(), |_, window, cx| { window.render_frame(cx); let sheet = window.find("sheet-content").bounds(); diff --git a/crates/kit/tests/rendering.rs b/crates/kit/tests/rendering.rs index b6c9008e0f..26ad4806b4 100644 --- a/crates/kit/tests/rendering.rs +++ b/crates/kit/tests/rendering.rs @@ -156,7 +156,7 @@ mod macos { cx.update_window(handle, |_, window, cx| { window.click("name", cx); window.input("Ada", cx); - window.blur(); + window.blur(cx); window.render_frame(cx); assert_eq!(window.find("name").value(), Some("Ada")); }) diff --git a/crates/kit/tests/root.rs b/crates/kit/tests/root.rs index 98f02c8580..ab248a5557 100644 --- a/crates/kit/tests/root.rs +++ b/crates/kit/tests/root.rs @@ -25,7 +25,10 @@ fn open_and_notify(window: &mut Window, cx: &mut App) { #[gpui_kit::test] fn a_root_renders_the_layers_a_plain_view_leaves_out(cx: &mut TestAppContext) { - cx.update(gpui_kit::init); + cx.update(|cx| { + gpui_kit::init(cx); + cx.set_reduce_motion(true); + }); let (handle, _) = common::open_window(cx, Some(size(px(800.), px(600.))), |_window, cx| { let view = cx.new(|_| PlainView); view @@ -49,7 +52,10 @@ fn a_root_renders_the_layers_a_plain_view_leaves_out(cx: &mut TestAppContext) { #[gpui_kit::test] fn open_window_wraps_the_view_in_a_root_and_returns_the_view(cx: &mut TestAppContext) { - cx.update(gpui_kit::init); + cx.update(|cx| { + gpui_kit::init(cx); + cx.set_reduce_motion(true); + }); let (handle, view) = cx .update(|cx| { gpui_kit::open_window(WindowOptions::default(), cx, |_, cx| cx.new(|_| PlainView)) diff --git a/crates/kit/tests/window.rs b/crates/kit/tests/window.rs index 8599cd4b6a..230c46be89 100644 --- a/crates/kit/tests/window.rs +++ b/crates/kit/tests/window.rs @@ -670,7 +670,7 @@ fn renaming_observed_elements_preserves_focus_binding(cx: &mut TestAppContext) { assert_eq!(window.find("final").focused(), Some(true)); assert!(window.try_find("original").is_none()); assert!(window.try_find("renamed").is_none()); - window.blur(); + window.blur(cx); window.render_frame(cx); assert_eq!(window.find("final").focused(), Some(false)); }) diff --git a/crates/story/src/lib.rs b/crates/story/src/lib.rs index e6c825d2b1..a0ceb69c5c 100644 --- a/crates/story/src/lib.rs +++ b/crates/story/src/lib.rs @@ -146,7 +146,7 @@ pub fn create_new_window_with_size( }), kind: WindowKind::Normal, #[cfg(target_os = "linux")] - window_background: story_window_background(), + linux_window_background: story_window_background(), #[cfg(target_os = "linux")] window_decorations: Some(gpui_kit::WindowDecorations::Client), ..TitleBar::window_options() @@ -172,7 +172,7 @@ pub fn create_new_window_with_size( .expect("failed to open window"); window.update(cx, |_, window, _| { - window.activate_window(); + window.activate(); window.set_window_title(&title); })?; @@ -182,11 +182,11 @@ pub fn create_new_window_with_size( } #[cfg(target_os = "linux")] -fn story_window_background() -> gpui_kit::WindowBackgroundAppearance { +fn story_window_background() -> gpui_kit::LinuxWindowBackground { // The component gallery is a normal application window. Advertising an // alpha surface lets compositors show the desktop through light themes, // even though every story is designed against an opaque canvas. - gpui_kit::WindowBackgroundAppearance::Opaque + gpui_kit::LinuxWindowBackground::Opaque } impl Global for AppState {} @@ -1230,7 +1230,7 @@ mod tests { fn component_story_window_is_opaque() { assert_eq!( super::story_window_background(), - gpui_kit::WindowBackgroundAppearance::Opaque + gpui_kit::LinuxWindowBackground::Opaque ); } diff --git a/crates/story/src/stories/theme_story/checkerboard.rs b/crates/story/src/stories/theme_story/checkerboard.rs index 2f179e5fa3..01c5f92120 100644 --- a/crates/story/src/stories/theme_story/checkerboard.rs +++ b/crates/story/src/stories/theme_story/checkerboard.rs @@ -53,17 +53,17 @@ impl RenderOnce for Checkerboard { let origin = bounds.origin + gpui_kit::point(size * (col as f32), size * (row as f32)); - window.paint_quad(gpui_kit::PaintQuad { - bounds: gpui_kit::Bounds { + window.paint_quad( + gpui_kit::gpui::PaintQuad::new(gpui_kit::Bounds { origin, size: gpui_kit::size(size, size), - }, - corner_radii: gpui_kit::Corners::default(), - background: c2.into(), - border_widths: gpui_kit::Edges::default(), - border_color: gpui_kit::transparent_black(), - border_style: gpui_kit::BorderStyle::default(), - }); + }) + .corner_radii(gpui_kit::Corners::default()) + .background(c2) + .border_widths(gpui_kit::Edges::default()) + .border_color(gpui_kit::transparent_black()) + .border_style(gpui_kit::BorderStyle::default()), + ); } } } diff --git a/crates/webview/src/lib.rs b/crates/webview/src/lib.rs index 453d472992..790f03022d 100644 --- a/crates/webview/src/lib.rs +++ b/crates/webview/src/lib.rs @@ -234,14 +234,20 @@ impl Element for WebViewElement { _: &mut App, ) { let bounds = hitbox.clone().map(|h| h.bounds).unwrap_or(bounds); - window.with_content_mask(Some(ContentMask { bounds }), |window| { - let webview = self.view.clone(); - window.on_mouse_event(move |event: &MouseDownEvent, _, _, _| { - if !bounds.contains(&event.position) { - // Click white space to blur the input focus - let _ = webview.focus_parent(); - } - }); - }); + window.with_content_mask( + Some(ContentMask { + fade_out: Default::default(), + bounds, + }), + |window| { + let webview = self.view.clone(); + window.on_mouse_event(move |event: &MouseDownEvent, _, _, _| { + if !bounds.contains(&event.position) { + // Click white space to blur the input focus + let _ = webview.focus_parent(); + } + }); + }, + ); } } diff --git a/docs/GPUI-CE-0.3.md b/docs/GPUI-CE-0.3.md new file mode 100644 index 0000000000..88fda5c02e --- /dev/null +++ b/docs/GPUI-CE-0.3.md @@ -0,0 +1,64 @@ +# GPUI CE 0.3 compatibility + +The workspace uses the stable `gpui-ce`, `gpui_ce_platform`, `gpui_ce_macros`, +and `gpui_ce_web` 0.3 releases together, pinned exactly to `=0.3.0`. Consumers +must use the same GPUI version as the component crates to avoid incompatible element and context types. + +GPUI now provides `Styled::refine_style`. Import `gpui::Styled` for that method; +the duplicate `gpui_base::StyledExt` method has been removed. Other `StyledExt` +helpers retain their existing paths. + +The editor retains its row model, UTF-8 offsets, atomic inline elements, and +continuation indentation. The internal `text_compat` module owns the previous +GPUI wrapping algorithm, adapted to shape character widths through the 0.3 +backend. This preserves fallback-font measurements. Single-line caret geometry +and hit testing also use the backend rather than inspecting glyph runs. + +Rich text selection, range highlights, row extents, and shimmer painting use +GPUI's visual lines, paint fragments, and backend cluster geometry. StyledText +layouts already include alignment, so these consumers do not align them again. +The old system-font reverse-lookup optimization has been removed: GPUI 0.3 +caches font resolution and no longer exposes the resolved font descriptor. + +The port also adapts content masks, paint builders, shadow backgrounds, +activation, inspector registration, and the deterministic text test fixtures. +The component widget and theme APIs otherwise remain unchanged. + +Inline SVG bytes now use GPUI's `Svg::data` API. Native menus resolve assets +through `AssetRegistry`. Command presentation changes invalidate the retained +view, and first-frame keybinding lookup uses an explicit context. Dialog bodies +use a flex column so a capped panel gives its scroll viewport the remaining +height. Selectable text uses a column wrapper so the shaper receives the available +width; reveal requests query the target caret rather than walking every cluster. + +CI targets the CE package names and validates the shared stable release pin. +The removed JavaScript Shell packages are no longer scheduled. Website version +resolution accepts CE manifests while retaining the legacy variable name for +historical documentation builds. + +## Validation + +Run `cargo fmt --all --check`, then the Base and Component library tests: + +```sh +cargo test -p gpui_ce_components_base -p gpui_ce_components --lib +``` + +The `text_compat` tests shape through Parley with the repository's bundled IBM +Plex font. They cover Unicode byte boundaries, atomic elements, and caret round +trips without depending on installed system fonts. + +Wrapping, highlight, and reveal tests use a bundled JetBrains Mono font through +Parley. Renderer probes request fresh renders when testing callbacks; geometry +fixtures set their actual viewport size, and animation tests advance the scheduler +clock instead of sleeping on wall time. + +Kit integration fixtures give cached views an explicit root size. Functional +overlay checks disable motion, while animation geometry checks advance the +scheduler clock. The non-WebView workspace passes 2,245 tests and doctests with +three existing ignores. The no-default-features checks and workspace Clippy +also pass on Linux. + +A full workspace check also needs the platform development dependencies for +Story and WebView. Native Story, accessibility, macOS, and Windows checks remain +part of platform validation; a headless library test is not a substitute for them. diff --git a/examples/dock/src/main.rs b/examples/dock/src/main.rs index e847f5bbfd..97f54fea45 100644 --- a/examples/dock/src/main.rs +++ b/examples/dock/src/main.rs @@ -431,7 +431,7 @@ impl StoryWorkspace { height: px(480.), }), #[cfg(target_os = "linux")] - window_background: gpui_kit::WindowBackgroundAppearance::Transparent, + linux_window_background: gpui_kit::LinuxWindowBackground::Transparent, #[cfg(target_os = "linux")] window_decorations: Some(gpui_kit::WindowDecorations::Client), kind: WindowKind::Normal, @@ -447,7 +447,7 @@ impl StoryWorkspace { window .update(cx, |_, window, cx| { - window.activate_window(); + window.activate(); window.set_window_title("GPUI App"); cx.on_release(|_, cx| { // exit app diff --git a/examples/fps_monitor/src/main.rs b/examples/fps_monitor/src/main.rs index e577a952f0..2f63fafd1c 100644 --- a/examples/fps_monitor/src/main.rs +++ b/examples/fps_monitor/src/main.rs @@ -416,7 +416,7 @@ fn main() { cx.activate(true); gpui_kit::open_window(WindowOptions::default(), cx, |window, cx| { - window.activate_window(); + window.activate(); window.set_window_title("FPS Monitor"); cx.new(|cx| Example::new(window, cx)) }) diff --git a/examples/system_monitor/src/main.rs b/examples/system_monitor/src/main.rs index 2c7f5f9f25..b8d1c1ddb3 100644 --- a/examples/system_monitor/src/main.rs +++ b/examples/system_monitor/src/main.rs @@ -568,7 +568,7 @@ fn main() { }; gpui_kit::open_window(window_options, cx, |window, cx| { - window.activate_window(); + window.activate(); window.set_window_title("System Monitor"); Theme::change(ThemeMode::Dark, Some(window), cx); diff --git a/script/build-website-versions b/script/build-website-versions index 96c0be514d..7cc8ace050 100755 --- a/script/build-website-versions +++ b/script/build-website-versions @@ -67,7 +67,7 @@ git -C "$repo_root" worktree add --detach "$work_dir/main" origin/main >/dev/nul # the temporary website copies have no workspace manifest next to them. gpui_pre_version() { git -C "$repo_root" show "$1:Cargo.toml" 2>/dev/null \ - | sed -nE 's/^gpui[[:space:]]*=.*package[[:space:]]*=[[:space:]]*"gpui-pre".*version[[:space:]]*=[[:space:]]*"=?([^"]+)".*/\1/p' \ + | sed -nE 's/^gpui[[:space:]]*=.*package[[:space:]]*=[[:space:]]*"(gpui-ce|gpui-pre)".*version[[:space:]]*=[[:space:]]*"=?([^"]+)".*/\2/p' \ | head -n 1 } @@ -75,8 +75,15 @@ gpui_kit_version() { if [[ "$1" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then printf '%s\n' "${1#v}" else - git -C "$repo_root" show "$1:crates/kit/Cargo.toml" \ - | sed -nE 's/^version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' | head -n 1 + local kit_manifest_version + kit_manifest_version=$(git -C "$repo_root" show "$1:crates/kit/Cargo.toml" \ + | sed -nE 's/^version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' | head -n 1) + if [ -n "$kit_manifest_version" ]; then + printf '%s\n' "$kit_manifest_version" + else + git -C "$repo_root" show "$1:Cargo.toml" \ + | python3 -c 'import sys, tomllib; print(tomllib.load(sys.stdin.buffer)["workspace"]["package"]["version"])' + fi fi } diff --git a/script/check-ai b/script/check-ai index 213517ead0..d4fd32ec00 100755 --- a/script/check-ai +++ b/script/check-ai @@ -13,18 +13,11 @@ PROFILES = { [sys.executable, "-m", "unittest", "discover", "-s", "script/tests"], ], "rust": [ - ["cargo", "test", "--locked", "-p", "gpui-component", "--no-default-features", + ["cargo", "test", "--locked", "-p", "gpui_ce_components", "--no-default-features", "--test", "controlled_change_callbacks", "--test", "legacy_controls_compat"], - ["cargo", "test", "--locked", "-p", "gpui-component", "--no-default-features", + ["cargo", "test", "--locked", "-p", "gpui_ce_components", "--no-default-features", "--lib", "form::form::tests"], ], - "shell": [ - ["cargo", "test", "--locked", "-p", "gpui-shell", "--lib", "typings"], - ["cargo", "test", "--locked", "-p", "gpui-shell", "--lib", "tests::render"], - ["cargo", "test", "--locked", "-p", "gpui-component-shell", "--all-targets"], - ["npm", "--prefix", "crates/component-shell/tests/types", "ci"], - ["npm", "--prefix", "crates/component-shell/tests/types", "test"], - ], } diff --git a/script/check-gpui-pin.test.ts b/script/check-gpui-pin.test.ts new file mode 100644 index 0000000000..6a4c6cc212 --- /dev/null +++ b/script/check-gpui-pin.test.ts @@ -0,0 +1,35 @@ +import { expect, test } from "bun:test"; +import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +const packages = ["gpui-ce", "gpui_ce_platform", "gpui_ce_macros", "gpui_ce_web"]; + +function check(versions: (string | undefined)[]) { + const directory = mkdtempSync(join(tmpdir(), "gpui-ce-pin-")); + try { + const manifest = join(directory, "Cargo.toml"); + writeFileSync(manifest, "[workspace.dependencies]\n" + versions.flatMap((version, index) => + version === undefined ? [] : [`dep${index} = { package = "${packages[index]}", version = "${version}" }`] + ).join("\n")); + return Bun.spawnSync([process.execPath, join(import.meta.dir, "check-gpui-pin.ts"), manifest]); + } finally { + rmSync(directory, { recursive: true }); + } +} + +test("accepts one exact CE release", () => { + expect(check(packages.map(() => "=0.3.0")).exitCode).toBe(0); +}); + +test("rejects mismatched CE releases", () => { + expect(check(["=0.3.0", "=0.3.1", "=0.3.0", "=0.3.0"]).exitCode).toBe(1); +}); + +test("rejects a floating CE requirement", () => { + expect(check(["0.3.0", "=0.3.0", "=0.3.0", "=0.3.0"]).exitCode).toBe(1); +}); + +test("rejects a missing CE crate", () => { + expect(check(["=0.3.0", undefined, "=0.3.0", "=0.3.0"]).exitCode).toBe(1); +}); diff --git a/script/check-gpui-pin.ts b/script/check-gpui-pin.ts index add9e62cc2..86ac6aa524 100644 --- a/script/check-gpui-pin.ts +++ b/script/check-gpui-pin.ts @@ -1,26 +1,13 @@ #!/usr/bin/env bun -/** - * Verify that the workspace pins every `gpui-pre-*` crate to an exact version. - * - * The published gpui-kit crates carry the workspace's requirements to - * crates.io. A caret requirement lets the weekly gpui-pre release move an - * application onto a snapshot that gpui-component was never built against, - * which is how gpui-kit 0.6.4 stopped compiling the day gpui-pre 0.3.6 came - * out (#3156). Every snapshot crate has to stay on one `=x.y.z` requirement, - * and all of them on the same version, so a release resolves exactly the - * snapshot it was tested with. The hand-published `gpui-pre-reqwest` fork - * (see `DEPENDENCY_OVERRIDES` in bump-gpui.ts) has its own version line and - * only needs to be exact. - * - * bun script/check-gpui-pin.ts [path/to/Cargo.toml] +/** Verify that the GPUI CE release crates stay on one exact version. + * Usage: bun script/check-gpui-pin.ts [path/to/Cargo.toml] */ import { readFileSync } from "node:fs"; import { join, resolve } from "node:path"; const REPO_ROOT = resolve(import.meta.dir, ".."); const MANIFEST = "Cargo.toml"; -const SNAPSHOT_PREFIX = "gpui-pre"; -const OWN_VERSION_LINE = new Set(["gpui-pre-reqwest"]); +const RELEASE_PACKAGES = new Set(["gpui-ce", "gpui_ce_platform", "gpui_ce_macros", "gpui_ce_web"]); const EXACT_VERSION = /^=(\d+\.\d+\.\d+)$/; interface Dependency { @@ -29,7 +16,7 @@ interface Dependency { version: string | undefined; } -function snapshotDependencies(manifestPath: string): Dependency[] { +function releaseDependencies(manifestPath: string): Dependency[] { const manifest = Bun.TOML.parse(readFileSync(manifestPath, "utf8")) as { workspace?: { dependencies?: Record }; }; @@ -37,7 +24,7 @@ function snapshotDependencies(manifestPath: string): Dependency[] { for (const [alias, spec] of Object.entries(manifest.workspace?.dependencies ?? {})) { if (typeof spec !== "object" || spec === null) continue; const { package: pkg, version } = spec as { package?: unknown; version?: unknown }; - if (typeof pkg !== "string" || !pkg.startsWith(SNAPSHOT_PREFIX)) continue; + if (typeof pkg !== "string" || !RELEASE_PACKAGES.has(pkg)) continue; dependencies.push({ alias, package: pkg, version: typeof version === "string" ? version : undefined }); } return dependencies; @@ -49,31 +36,34 @@ function describe(dependency: Dependency): string { function problems(dependencies: Dependency[]): string[] { const found: string[] = []; - if (dependencies.length === 0) found.push(`no \`${SNAPSHOT_PREFIX}-*\` dependency in [workspace.dependencies]`); - const snapshotVersions = new Map(); + for (const pkg of RELEASE_PACKAGES) { + if (!dependencies.some(dependency => dependency.package === pkg)) { + found.push(`missing ${pkg} in [workspace.dependencies]`); + } + } + const releaseVersions = new Map(); for (const dependency of dependencies) { const exact = dependency.version === undefined ? null : EXACT_VERSION.exec(dependency.version); if (exact === null) { found.push(`${describe(dependency)} is not an exact \`=x.y.z\` requirement`); continue; } - if (OWN_VERSION_LINE.has(dependency.package)) continue; - const aliases = snapshotVersions.get(exact[1]) ?? []; + const aliases = releaseVersions.get(exact[1]) ?? []; aliases.push(dependency.package); - snapshotVersions.set(exact[1], aliases); + releaseVersions.set(exact[1], aliases); } - if (snapshotVersions.size > 1) { - const detail = [...snapshotVersions].map(([version, names]) => `${version} (${names.join(", ")})`).join(", "); - found.push(`the snapshot crates are pinned to more than one version: ${detail}`); + if (releaseVersions.size > 1) { + const detail = [...releaseVersions].map(([version, names]) => `${version} (${names.join(", ")})`).join(", "); + found.push(`the GPUI CE crates are pinned to more than one version: ${detail}`); } return found; } const manifestPath = process.argv[2] ?? join(REPO_ROOT, MANIFEST); -const found = problems(snapshotDependencies(manifestPath)); +const found = problems(releaseDependencies(manifestPath)); if (found.length > 0) { for (const problem of found) console.error(`::error file=${MANIFEST}::${problem}`); - console.error(`\n${MANIFEST} must pin every ${SNAPSHOT_PREFIX}-* crate to the exact snapshot gpui-kit was built against.`); + console.error(`\n${MANIFEST} must pin every GPUI CE crate to the exact release gpui-kit was built against.`); process.exit(1); } -console.log(`${MANIFEST} pins the ${SNAPSHOT_PREFIX}-* crates exactly`); +console.log(`${MANIFEST} pins the GPUI CE crates exactly`); diff --git a/website/src/lib/doc-variables.js b/website/src/lib/doc-variables.js index 2e1bc6682d..f01392da0e 100644 --- a/website/src/lib/doc-variables.js +++ b/website/src/lib/doc-variables.js @@ -21,15 +21,24 @@ function readGpuiKitVersion() { if (tag) return tag[1]; const manifest = resolve(process.cwd(), '..', 'crates', 'kit', 'Cargo.toml'); if (!existsSync(manifest)) return undefined; - return readFileSync(manifest, 'utf8').match(/^version\s*=\s*"([^"]+)"/m)?.[1]; + const kitManifest = readFileSync(manifest, 'utf8'); + const version = kitManifest.match(/^version\s*=\s*"([^"]+)"/m)?.[1]; + if (version) return version; + if (!/^version\.workspace\s*=\s*true/m.test(kitManifest)) return undefined; + const workspaceManifest = resolve(process.cwd(), '..', 'Cargo.toml'); + if (!existsSync(workspaceManifest)) return undefined; + const workspacePackage = readFileSync(workspaceManifest, 'utf8') + .split('[workspace.package]')[1]?.split(/^\[/m)[0]; + return workspacePackage?.match(/^version\s*=\s*"([^"]+)"/m)?.[1]; } +// Keep the legacy variable name for existing and versioned Markdown pages. function readGpuiPreVersion() { if (process.env.GPUI_PRE_VERSION) return process.env.GPUI_PRE_VERSION; const manifest = resolve(process.cwd(), '..', 'Cargo.toml'); if (!existsSync(manifest)) return undefined; const pin = readFileSync(manifest, 'utf8') - .match(/^gpui\s*=\s*\{[^}\n]*package\s*=\s*"gpui-pre"[^}\n]*version\s*=\s*"=?([^"]+)"/m); + .match(/^gpui\s*=\s*\{[^}\n]*package\s*=\s*"(?:gpui-ce|gpui-pre)"[^}\n]*version\s*=\s*"=?([^"]+)"/m); return pin?.[1]; } diff --git a/website/tests/release-version.test.ts b/website/tests/release-version.test.ts index ed0aed7ffc..cdb4e3b47a 100644 --- a/website/tests/release-version.test.ts +++ b/website/tests/release-version.test.ts @@ -1,5 +1,8 @@ import { expect, test } from 'bun:test'; import { join } from 'node:path'; +import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { pathToFileURL } from 'node:url'; for (const [label, variables, expected] of [ ['release tag', { PUBLIC_SITE_VERSION: 'v0.8.1', GPUI_KIT_VERSION: '' }, '0.8.1'], @@ -15,3 +18,30 @@ for (const [label, variables, expected] of [ expect(result.stdout.toString().trim()).toBe(`gpui-kit = "${expected}"`); }); } + +for (const [label, manifest, expected] of [ + ['explicit package version', '[package]\nversion = "1.2.3"', '1.2.3'], + ['inherited workspace version', '[package]\nversion.workspace = true', '4.5.6'], +] as const) { + test(`local documentation resolves an ${label}`, () => { + const directory = mkdtempSync(join(tmpdir(), 'gpui-doc-version-')); + try { + mkdirSync(join(directory, 'crates', 'kit'), { recursive: true }); + mkdirSync(join(directory, 'website')); + writeFileSync(join(directory, 'crates', 'kit', 'Cargo.toml'), manifest); + writeFileSync(join(directory, 'Cargo.toml'), '[workspace.package]\nversion = "4.5.6"\n[workspace.dependencies]\n'); + const source = pathToFileURL(join(import.meta.dir, '../src/lib/doc-variables.js')).href; + const result = Bun.spawnSync([process.execPath, '--eval', ` + const { docVariable } = await import(${JSON.stringify(source)}); + console.log(docVariable('gpui_kit_version')); + `], { + cwd: join(directory, 'website'), + env: { ...process.env, PUBLIC_SITE_VERSION: '', GPUI_KIT_VERSION: '' }, + }); + expect(result.exitCode).toBe(0); + expect(result.stdout.toString().trim()).toBe(expected); + } finally { + rmSync(directory, { recursive: true }); + } + }); +}