diff --git a/.github/DISCUSSION_TEMPLATE/1-q-a.yml b/.github/DISCUSSION_TEMPLATE/1-q-a.yml index ab64c16e..394e0cf6 100644 --- a/.github/DISCUSSION_TEMPLATE/1-q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/1-q-a.yml @@ -22,10 +22,10 @@ body: validations: required: true - type: textarea - id: debug + id: env attributes: - label: "`yazi --debug` output" - description: Please run `yazi --debug` and paste the debug information here. + label: "`ya env` output" + description: Run `ya env` and paste the environment information here. render: Shell validations: required: true diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 8c33c266..157822ba 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -26,10 +26,10 @@ body: validations: required: true - type: textarea - id: debug + id: env attributes: - label: "`yazi --debug` output" - description: Please run `yazi --debug` and paste the debug information here. + label: "`ya env` output" + description: Run `ya env` and paste the environment information here. render: Shell validations: required: true @@ -65,6 +65,6 @@ body: options: - label: I tried the [latest nightly build](https://yazi-rs.github.io/docs/installation#binaries), and the issue is still reproducible required: true - - label: I updated the debug information (`yazi --debug`) input box to the nightly that I tried + - label: I updated the environment information (`ya env`) field to the nightly that I tried required: true - label: I can reproduce it after disabling all custom configs/plugins (`mv ~/.config/yazi ~/.config/yazi-backup`) diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 26ab7706..647f0534 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -4,10 +4,10 @@ labels: [feature] assignees: [] body: - type: textarea - id: debug + id: env attributes: - label: "`yazi --debug` output" - description: Please run `yazi --debug` and paste the debug information here. + label: "`ya env` output" + description: Run `ya env` and paste the environment information here. render: Shell validations: required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6ad65887..8c7716aa 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,3 +15,7 @@ A clear and concise description of the rationale of the changes, to help our rev If it has already been detailed in the associated issue, please skip this section. --> + +## Checklist + +- [ ] I have read [CONTRIBUTING.md](https://github.com/sxyazi/yazi/blob/main/CONTRIBUTING.md) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccb14fab..0240dec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,14 +14,33 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): ### Added +- Drag and drop ([#4005]) - Bulk create ([#3793]) +- Dynamic keymap Lua API ([#4031]) +- New `ui.Input` element ([#4040]) - Image preview with Überzug++ on Niri ([#3990]) +- New gait for input `backward` and `forward` actions ([#4012]) ### Changed - Rename `` to `` ([#3989]) - Remove Legacy Console Mode on Windows ([#3989]) +### Deprecated + +- Deprecate `backward --far` and `forward --far` in favor of `backward wide` and `forward wide`, respectively ([#4012]) + +### Fixed + +- Normalize `\\?\`-prefixed Verbatim paths when creating relative symlinks on Windows ([#4067]) +- Keep package hashes indifferent to line endings when `ya pkg` pulls packages ([#4064]) +- Use WebP as `magick` preset preloader cache format to keep image transparency ([#4065]) +- Use cleaned and normalized `$PWD` as startup CWD to avoid MSYS2/git-bash path quirks ([#4068]) + +### Improved + +- Eliminate hacks in image and UI conflict resolution ([#4022]) + ## [v26.5.6] ### Added @@ -1729,3 +1748,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3943]: https://github.com/sxyazi/yazi/pull/3943 [#3989]: https://github.com/sxyazi/yazi/pull/3989 [#3990]: https://github.com/sxyazi/yazi/pull/3990 +[#4005]: https://github.com/sxyazi/yazi/pull/4005 +[#4012]: https://github.com/sxyazi/yazi/pull/4012 +[#4022]: https://github.com/sxyazi/yazi/pull/4022 +[#4031]: https://github.com/sxyazi/yazi/pull/4031 +[#4040]: https://github.com/sxyazi/yazi/pull/4040 +[#4064]: https://github.com/sxyazi/yazi/pull/4064 +[#4065]: https://github.com/sxyazi/yazi/pull/4065 +[#4067]: https://github.com/sxyazi/yazi/pull/4067 +[#4068]: https://github.com/sxyazi/yazi/pull/4068 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c74755d8..ce91de1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,6 +11,7 @@ This guide will help you understand how to contribute to the project. 3. [Development Setup](#development-setup) 4. [How to Contribute](#how-to-contribute) 5. [Pull Requests](#pull-requests) +6. [AI Policy](#ai-policy) ## Getting Started @@ -164,3 +165,10 @@ We want you to succeed, and it can be discouraging to find that a lot of re-work - Your code passes all tests and lints. - Your pull request description clearly explains the changes and why they are needed. 4. Address any review comments. Make sure to push updates to the same branch on your fork. + +## AI Policy + +1. All issue, PR, and discussion descriptions must be written by humans, not AI. +2. Any use of AI must be disclosed. You must declare which model you used and the extent of AI assistance. +3. Any AI-generated code must be reviewed, tested, and simplified by a human before publishing. This requires you to fully understand how it interacts with the greater system without AI assistance. +4. Any AI tools used must explicitly state they do not assert copyright over the work. diff --git a/Cargo.lock b/Cargo.lock index 363c3c2b..b0376978 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,31 +19,31 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aead" -version = "0.6.0-rc.10" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b657e772794c6b04730ea897b66a058ccd866c16d1967da05eeeecec39043fe" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" dependencies = [ - "crypto-common 0.2.2", - "inout 0.2.2", + "crypto-common", + "inout", ] [[package]] name = "aes" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8" +checksum = "f1fc76eaeac4c9164506c466d4ffdd8ec9d0c5bf57ee97177c4d8eceb3a0e138" dependencies = [ "cipher", "cpubits", - "cpufeatures 0.3.0", + "cpufeatures", "zeroize", ] [[package]] name = "aes-gcm" -version = "0.11.0-rc.3" +version = "0.11.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22c0c90bbe8d4f77c3ca9ddabe41a1f8382d6fc1f7cea89459d0f320371f972" +checksum = "da8c919c118108f144adecad74b425b804ad075580d605d9b33c2d6d1c62a2f8" dependencies = [ "aead", "aes", @@ -102,7 +102,7 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42366bb9d958f042bf58f0a85e1b2d091997c1257ca49bddd7e4827aadc65fd" dependencies = [ - "nom 8.0.0", + "nom", "ratatui-core", "simdutf8", "smallvec", @@ -165,6 +165,15 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + [[package]] name = "arbitrary" version = "1.4.2" @@ -189,7 +198,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -200,7 +209,7 @@ checksum = "7af50940b73bf4e16c15c448a2b121c63f2d68e3e54b6a8731673cb4aa0cdff5" dependencies = [ "base64ct", "blake2", - "cpufeatures 0.3.0", + "cpufeatures", "password-hash", ] @@ -228,20 +237,11 @@ dependencies = [ "event-listener", ] -[[package]] -name = "atomic" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89cbf775b137e9b968e67227ef7f775587cde3fd31b0d8599dbd0f598a48340" -dependencies = [ - "bytemuck", -] - [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "av-scenechange" @@ -272,7 +272,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom 8.0.0", + "nom", "num-rational", "v_frame", ] @@ -327,7 +327,7 @@ checksum = "144e573728da132683b9488acd528274c790e07fc06ff81ee29f9d8f8b1041e0" dependencies = [ "blowfish", "pbkdf2", - "sha2 0.11.0", + "sha2", ] [[package]] @@ -349,21 +349,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bit-set" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - [[package]] name = "bit_field" version = "0.10.3" @@ -372,15 +357,9 @@ checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" dependencies = [ "serde_core", ] @@ -396,9 +375,9 @@ dependencies = [ [[package]] name = "bitvec" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837" dependencies = [ "funty", "radium", @@ -412,37 +391,19 @@ version = "0.11.0-rc.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "061f1a09225e328e1ffbb378d2d49923c0ca5fee19fb5ac1cc9c1e9d52b93690" dependencies = [ - "digest 0.11.3", + "digest", ] [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array 0.14.9", -] - -[[package]] -name = "block-buffer" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" dependencies = [ "hybrid-array", "zeroize", ] -[[package]] -name = "block-padding" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" -dependencies = [ - "generic-array 0.14.9", -] - [[package]] name = "block-padding" version = "0.4.2" @@ -462,6 +423,31 @@ dependencies = [ "cipher", ] +[[package]] +name = "bon" +version = "3.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a602c73c7b0148ec6d12af6fd5cc7a46e2eacc8878271a999abac56eed12f561" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dee98b0db6a962de883bf5d20362dee4d7ca0d12fe39a7c6c73c844e1cd7c1f" +dependencies = [ + "darling", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + [[package]] name = "bs58" version = "0.5.1" @@ -489,9 +475,9 @@ checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" [[package]] name = "bumpalo" -version = "3.20.2" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "by_address" @@ -516,7 +502,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -533,9 +519,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "castaway" @@ -557,9 +543,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.62" +version = "1.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" dependencies = [ "find-msvc-tools", "jobserver", @@ -587,16 +573,16 @@ checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" dependencies = [ "cfg-if", "cipher", - "cpufeatures 0.3.0", + "cpufeatures", "rand_core 0.10.1", "zeroize", ] [[package]] name = "chrono" -version = "0.4.44" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", "js-sys", @@ -612,9 +598,9 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ - "block-buffer 0.12.0", - "crypto-common 0.2.2", - "inout 0.2.2", + "block-buffer", + "crypto-common", + "inout", "zeroize", ] @@ -678,7 +664,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -698,9 +684,9 @@ dependencies = [ [[package]] name = "cmov" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f88a43d011fc4a6876cb7344703e297c71dda42494fee094d5f7c76bf13f746" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" [[package]] name = "color_quant" @@ -716,9 +702,9 @@ checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "compact_str" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" +checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" dependencies = [ "castaway", "cfg-if", @@ -756,15 +742,6 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" -[[package]] -name = "convert_case" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -777,15 +754,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - [[package]] name = "cpufeatures" version = "0.3.0" @@ -804,6 +772,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -838,51 +812,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "crossterm" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" -dependencies = [ - "bitflags 2.11.1", - "crossterm_winapi", - "mio", - "parking_lot", - "rustix 0.38.44", - "serde", - "signal-hook 0.3.18", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" -dependencies = [ - "bitflags 2.11.1", - "crossterm_winapi", - "derive_more", - "document-features", - "mio", - "parking_lot", - "rustix 1.1.4", - "serde", - "signal-hook 0.3.18", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm_winapi" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" -dependencies = [ - "winapi", -] - [[package]] name = "crunchy" version = "0.2.4" @@ -891,13 +820,13 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] name = "crypto-bigint" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a0d26b245348befa0c121944541476763dcc46ede886c88f9d12e1697d27c3" +checksum = "97bb4a855e3b10f84c4e7e895a7de01db7f9a7b7eb7f73ed9773fd52ac686451" dependencies = [ "cpubits", "ctutils", - "getrandom 0.4.2", + "getrandom 0.4.3", "hybrid-array", "num-traits", "rand_core 0.10.1", @@ -906,48 +835,27 @@ dependencies = [ "zeroize", ] -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array 0.14.9", - "typenum", -] - [[package]] name = "crypto-common" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ - "getrandom 0.4.2", + "getrandom 0.4.3", "hybrid-array", "rand_core 0.10.1", ] [[package]] name = "crypto-primes" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21f41f23de7d24cdbda7f0c4d9c0351f99a4ceb258ef30e5c1927af8987ffe5a" +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" dependencies = [ "crypto-bigint", - "libm", "rand_core 0.10.1", ] -[[package]] -name = "csscolorparser" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2a7d3066da2de787b7f032c736763eb7ae5d355f81a68bab2675a96008b0bf" -dependencies = [ - "lab", - "phf", -] - [[package]] name = "ctr" version = "0.10.1" @@ -969,14 +877,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "5.0.0-pre.6" +version = "5.0.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335f1947f241137a14106b6f5acc5918a5ede29c9d71d3f2cb1678d5075d9fc3" +checksum = "4f359e08ca85e7bd759e1fd933ff2bccd81864c60a8fba0e259c7f822b0924bf" dependencies = [ "cfg-if", - "cpufeatures 0.2.17", + "cpufeatures", "curve25519-dalek-derive", - "digest 0.11.3", + "digest", "fiat-crypto", "rustc_version", "subtle", @@ -991,17 +899,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", -] - -[[package]] -name = "darling" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" -dependencies = [ - "darling_core 0.20.11", - "darling_macro 0.20.11", + "syn", ] [[package]] @@ -1010,22 +908,8 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ - "darling_core 0.23.0", - "darling_macro 0.23.0", -] - -[[package]] -name = "darling_core" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.117", + "darling_core", + "darling_macro", ] [[package]] @@ -1038,18 +922,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.117", -] - -[[package]] -name = "darling_macro" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" -dependencies = [ - "darling_core 0.20.11", - "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -1058,9 +931,9 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ - "darling_core 0.23.0", + "darling_core", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -1097,15 +970,9 @@ checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] -[[package]] -name = "deltae" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" - [[package]] name = "der" version = "0.8.0" @@ -1123,63 +990,9 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ - "powerfmt", "serde_core", ] -[[package]] -name = "derive_builder" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" -dependencies = [ - "darling 0.20.11", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "derive_builder_macro" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" -dependencies = [ - "derive_builder_core", - "syn 2.0.117", -] - -[[package]] -name = "derive_more" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.117", -] - [[package]] name = "des" version = "0.9.0" @@ -1189,25 +1002,15 @@ dependencies = [ "cipher", ] -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common 0.1.6", -] - [[package]] name = "digest" version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.0", + "block-buffer", "const-oid", - "crypto-common 0.2.2", + "crypto-common", "ctutils", ] @@ -1232,15 +1035,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "document-features" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" -dependencies = [ - "litrs", -] - [[package]] name = "dyn-clone" version = "1.0.20" @@ -1254,7 +1048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54fb064faabbee66e1fc8e5c5a9458d4269dc2d8b638fe86a425adb2510d1a96" dependencies = [ "der", - "digest 0.11.3", + "digest", "elliptic-curve", "rfc6979", "signature", @@ -1274,15 +1068,15 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "3.0.0-pre.7" +version = "3.0.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20449acd54b660981ae5caa2bcb56d1fe7f25f2e37a38ec507400fab034d4bb6" +checksum = "b011170fe4f04665565b4110afef66774fe9ffff278f3eb5b81cc73d26e27d60" dependencies = [ "curve25519-dalek", "ed25519", "rand_core 0.10.1", "serde", - "sha2 0.11.0", + "sha2", "signature", "subtle", "zeroize", @@ -1296,22 +1090,22 @@ checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "elliptic-curve" -version = "0.14.0-rc.32" +version = "0.14.0-rc.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda94f31325c4275e9706adecbb6f0650dee2f904c915a98e3d81adaaaa757aa" +checksum = "102d3643d30dd8b559613c5cced68317199597fffb278cdc88daa2ef7fafc935" dependencies = [ "base16ct", "crypto-bigint", - "crypto-common 0.2.2", - "digest 0.11.3", + "crypto-common", + "digest", + "ff", + "group", "hkdf", "hybrid-array", "once_cell", "pem-rfc7468", "pkcs8", "rand_core 0.10.1", - "rustcrypto-ff", - "rustcrypto-group", "sec1", "subtle", "zeroize", @@ -1332,7 +1126,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -1352,7 +1146,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -1388,15 +1182,6 @@ version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" -[[package]] -name = "euclid" -version = "0.22.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" -dependencies = [ - "num-traits", -] - [[package]] name = "event-listener" version = "4.0.3" @@ -1422,22 +1207,18 @@ dependencies = [ "zune-inflate", ] -[[package]] -name = "fancy-regex" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" -dependencies = [ - "bit-set", - "regex", -] - [[package]] name = "fast-srgb8" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1" +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + [[package]] name = "fax" version = "0.2.7" @@ -1463,41 +1244,28 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "ff" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f" +dependencies = [ + "rand_core 0.10.1", + "subtle", +] + [[package]] name = "fiat-crypto" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" -[[package]] -name = "filedescriptor" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e40758ed24c9b2eeb76c35fb0aebc66c626084edd827e07e1552279814c6682d" -dependencies = [ - "libc", - "thiserror 1.0.69", - "winapi", -] - [[package]] name = "find-msvc-tools" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" -[[package]] -name = "finl_unicode" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9844ddc3a6e533d62bba727eb6c28b5d360921d5175e9ff0f1e621a5c590a4d5" - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - [[package]] name = "flate2" version = "1.1.9" @@ -1514,12 +1282,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -1597,7 +1359,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -1641,9 +1403,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "1.4.1" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dab9e9188e97a93276e1fe7b56401b851e2b45a46d045ca658100c1303ada649" +checksum = "c2e55f16dcf0e9c00efbe2e655ffe45fc98e7066b52bc92f8a79e64060a79351" dependencies = [ "generic-array 0.14.9", "rustversion", @@ -1657,10 +1419,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1677,16 +1437,16 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi 6.0.0", "rand_core 0.10.1", - "wasip2", - "wasip3", + "wasm-bindgen", ] [[package]] @@ -1727,6 +1487,17 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "group" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4" +dependencies = [ + "ff", + "rand_core 0.10.1", + "subtle", +] + [[package]] name = "half" version = "2.7.1" @@ -1744,15 +1515,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" @@ -1761,7 +1523,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -1772,7 +1534,7 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", + "foldhash", "serde", "serde_core", ] @@ -1816,7 +1578,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" dependencies = [ - "digest 0.11.3", + "digest", ] [[package]] @@ -1855,12 +1617,6 @@ dependencies = [ "cc", ] -[[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - [[package]] name = "ident_case" version = "1.0.1" @@ -1902,9 +1658,9 @@ dependencies = [ [[package]] name = "imgref" -version = "1.12.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40fac9d56ed6437b198fddba683305e8e2d651aa42647f00f5ae542e7f5c94a2" +checksum = "89194689a993ab15268672e99e7b0e19da2da3268ac682e8f02d29d4d1434cd7" [[package]] name = "indexmap" @@ -1940,11 +1696,11 @@ dependencies = [ [[package]] name = "inotify" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5b3eaf1a28b758ac0faa5a4254e8ab2705605496f1b1f3fbbc3988ad73d199" +checksum = "533e68a5842e734946fe159fb03fc9bbbb254f590dd0d8ad321ae5ff7beca2c1" dependencies = [ - "bitflags 2.11.1", + "bitflags", "inotify-sys", "libc", ] @@ -1958,23 +1714,13 @@ dependencies = [ "libc", ] -[[package]] -name = "inout" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" -dependencies = [ - "block-padding 0.3.3", - "generic-array 0.14.9", -] - [[package]] name = "inout" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" dependencies = [ - "block-padding 0.4.2", + "block-padding", "hybrid-array", ] @@ -1984,11 +1730,11 @@ version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eb2d60ef19920a3a9193c3e371f726ec1dafc045dac788d0fb3704272458971" dependencies = [ - "darling 0.23.0", + "darling", "indoc", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2011,7 +1757,16 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", +] + +[[package]] +name = "inventory" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b" +dependencies = [ + "rustversion", ] [[package]] @@ -2047,13 +1802,12 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.98" +version = "0.3.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67df7112613f8bfd9150013a0314e196f4800d3201ae742489d999db2f979f08" +checksum = "03d04c30968dffe80775bd4d7fb676131cd04a1fb46d2686dbffbaec2d9dfd31" dependencies = [ "cfg-if", "futures-util", - "once_cell", "wasm-bindgen", ] @@ -2075,7 +1829,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e24a010dd405bd7ed803e5253182815b41bf2e6a80cc3bfc066658e03a198aa" dependencies = [ "cfg-if", - "cpufeatures 0.3.0", + "cpufeatures", ] [[package]] @@ -2084,15 +1838,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd" dependencies = [ - "crypto-common 0.2.2", + "crypto-common", "rand_core 0.10.1", ] [[package]] name = "kqueue" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a" +checksum = "273c0752728918e0ac4976f2b275b6fefb9ecd400585dec929419f3844cd87b5" dependencies = [ "kqueue-sys", "libc", @@ -2104,28 +1858,16 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" dependencies = [ - "bitflags 2.11.1", + "bitflags", "libc", ] -[[package]] -name = "lab" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f" - [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "lebe" version = "0.5.3" @@ -2140,9 +1882,9 @@ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] name = "libfuzzer-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12a681b7dd8ce12bff52488013ba614b869148d54dd79836ab85aafdd53f08d" +checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2" dependencies = [ "arbitrary", "cc", @@ -2156,9 +1898,9 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" dependencies = [ "libc", ] @@ -2169,27 +1911,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f50e8f47623268b5407192d26876c4d7f89d686ca130fdc53bced4814cd29f8" dependencies = [ - "bitflags 2.11.1", + "bitflags", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - [[package]] name = "linux-raw-sys" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" -[[package]] -name = "litrs" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" - [[package]] name = "lock_api" version = "0.4.14" @@ -2201,9 +1931,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.29" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" [[package]] name = "loop9" @@ -2214,15 +1944,6 @@ dependencies = [ "imgref", ] -[[package]] -name = "lru" -version = "0.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" -dependencies = [ - "hashbrown 0.16.1", -] - [[package]] name = "lru" version = "0.18.0" @@ -2251,16 +1972,6 @@ dependencies = [ "which", ] -[[package]] -name = "mac_address" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" -dependencies = [ - "nix 0.29.0", - "winapi", -] - [[package]] name = "matchers" version = "0.2.0" @@ -2281,21 +1992,15 @@ dependencies = [ [[package]] name = "md5" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" +checksum = "ae960838283323069879657ca3de837e9f7bbb4c7bf6ea7f1b290d5e9476d2e0" [[package]] name = "memchr" -version = "2.8.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" - -[[package]] -name = "memmem" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" [[package]] name = "memoffset" @@ -2306,12 +2011,6 @@ dependencies = [ "autocfg", ] -[[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" @@ -2324,9 +2023,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" dependencies = [ "libc", "log", @@ -2396,7 +2095,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.117", + "syn", ] [[package]] @@ -2426,26 +2125,13 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[package]] -name = "nix" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" -dependencies = [ - "bitflags 2.11.1", - "cfg-if", - "cfg_aliases", - "libc", - "memoffset", -] - [[package]] name = "nix" version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d" dependencies = [ - "bitflags 2.11.1", + "bitflags", "cfg-if", "cfg_aliases", "libc", @@ -2460,16 +2146,6 @@ dependencies = [ "memchr", ] -[[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" @@ -2491,7 +2167,7 @@ version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3" dependencies = [ - "bitflags 2.11.1", + "bitflags", "fsevent-sys", "inotify", "kqueue", @@ -2509,7 +2185,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a" dependencies = [ - "bitflags 2.11.1", + "bitflags", ] [[package]] @@ -2545,7 +2221,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2597,12 +2273,6 @@ dependencies = [ "libc", ] -[[package]] -name = "numtoa" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f" - [[package]] name = "objc2" version = "0.6.4" @@ -2624,7 +2294,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ - "bitflags 2.11.1", + "bitflags", "objc2", ] @@ -2655,7 +2325,7 @@ version = "6.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cc3cbf698f9438986c11a880c90a6d04b9de27575afd28bbf45b154b6c709e2" dependencies = [ - "bitflags 2.11.1", + "bitflags", "libc", "once_cell", "onig_sys", @@ -2686,15 +2356,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "ordered-float" -version = "4.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" -dependencies = [ - "num-traits", -] - [[package]] name = "ordered-float" version = "5.3.0" @@ -2708,43 +2369,43 @@ dependencies = [ [[package]] name = "p256" -version = "0.14.0-rc.9" +version = "0.14.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b97e3bf0465157ae90975ff52dbeb1362ba618924878c9f74c25baa27a65f9a" +checksum = "41adc63effe99d48837a8cc0e6d7a77e32ae6a07f6000df466178dbc2193093e" dependencies = [ "ecdsa", "elliptic-curve", "primefield", "primeorder", - "sha2 0.11.0", + "sha2", ] [[package]] name = "p384" -version = "0.14.0-rc.9" +version = "0.14.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "437f30ebcb1e16ff48acead5f08bd69fbcdbc82421687bb48af5c315a0bfab03" +checksum = "9bd5333afa5ae0347f39e6a0f2c9c155da431583fd71fe5555bd0521b4ccaf02" dependencies = [ "ecdsa", "elliptic-curve", "fiat-crypto", "primefield", "primeorder", - "sha2 0.11.0", + "sha2", ] [[package]] name = "p521" -version = "0.14.0-rc.9" +version = "0.14.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9fd792bab86ecf6249561752fb5a413511f999887107dd054bbda5143743d7" +checksum = "a3a5297f53dc16d35909060ba3032cff7867e8809f01e273ff325579d5f0ceae" dependencies = [ "base16ct", "ecdsa", "elliptic-curve", "primefield", "primeorder", - "sha2 0.11.0", + "sha2", ] [[package]] @@ -2760,7 +2421,7 @@ dependencies = [ "futures", "log", "rand 0.10.1", - "sha2 0.11.0", + "sha2", "thiserror 2.0.18", "tokio", "windows 0.62.2", @@ -2773,6 +2434,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6" dependencies = [ + "approx", "bytemuck", "fast-srgb8", "libm", @@ -2788,7 +2450,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2847,7 +2509,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629" dependencies = [ - "digest 0.11.3", + "digest", "hmac", ] @@ -2866,49 +2528,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "pest" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" -dependencies = [ - "memchr", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "pest_meta" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" -dependencies = [ - "pest", - "sha2 0.10.9", -] - [[package]] name = "phc" version = "0.6.1" @@ -2919,58 +2538,6 @@ dependencies = [ "ctutils", ] -[[package]] -name = "phf" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" -dependencies = [ - "phf_macros", - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" -dependencies = [ - "phf_shared", - "rand 0.8.6", -] - -[[package]] -name = "phf_macros" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "phf_shared" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" -dependencies = [ - "siphasher", -] - [[package]] name = "pin-project-lite" version = "0.2.17" @@ -2999,7 +2566,7 @@ dependencies = [ "pbkdf2", "rand_core 0.10.1", "scrypt", - "sha2 0.11.0", + "sha2", "spki", ] @@ -3040,7 +2607,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags 2.11.1", + "bitflags", "crc32fast", "fdeflate", "flate2", @@ -3053,7 +2620,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00baa632505d05512f48a963e16051c54fda9a95cc9acea1a4e3c90991c4a2e" dependencies = [ - "cpufeatures 0.3.0", + "cpufeatures", "universal-hash", "zeroize", ] @@ -3065,7 +2632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dfc63250416fea14f5749b90725916a6c903f599d51cb635aa7a52bfd03eede" dependencies = [ "cpubits", - "cpufeatures 0.3.0", + "cpufeatures", "universal-hash", ] @@ -3097,28 +2664,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.117", + "syn", ] [[package]] name = "primefield" -version = "0.14.0-rc.9" +version = "0.14.0-rc.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b52e6ee42db392378a95622b463c9740631171d1efce43fa445a569c1600cb6" +checksum = "8675564771a62f69a0af716b03e89b917b963c7b173b5855575e84fd4f605ca0" dependencies = [ "crypto-bigint", - "crypto-common 0.2.2", + "crypto-common", + "ff", "rand_core 0.10.1", - "rustcrypto-ff", "subtle", "zeroize", ] [[package]] name = "primeorder" -version = "0.14.0-rc.9" +version = "0.14.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0556580e42c19833f5d232aca11a7687a503ee41f937b54f5ae1d50fc2a6a36a" +checksum = "7d2793f22b9b6fd11ef3ac1d59bf003c2573593e4968702341605c2748fd90bf" dependencies = [ "elliptic-curve", ] @@ -3142,7 +2709,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3170,7 +2737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4488a4a36b9a4ba6b9334a32a39971f77c1436ec82c38707bce707699cc3bbcb" dependencies = [ "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3273,7 +2840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" dependencies = [ "chacha20", - "getrandom 0.4.2", + "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -3311,91 +2878,43 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" -[[package]] -name = "ratatui" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1ce67fb8ba4446454d1c8dbaeda0557ff5e94d39d5e5ed7f10a65eb4c8266bc" -dependencies = [ - "instability", - "ratatui-core", - "ratatui-crossterm", - "ratatui-termion", - "ratatui-termwiz", - "ratatui-widgets", - "serde", -] - [[package]] name = "ratatui-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef8dea09a92caaf73bff7adb70b76162e5937524058a7e5bff37869cbbec293" +checksum = "cbb175c433c8e28a809d1f5773a2ae96e68c0ce40db865cbab1020bf33ae479c" dependencies = [ - "bitflags 2.11.1", + "bitflags", "compact_str", - "hashbrown 0.16.1", - "indoc", + "critical-section", + "hashbrown 0.17.1", "itertools", "kasuari", - "lru 0.16.4", + "lru", + "palette", "serde", - "strum 0.27.2", + "strum", "thiserror 2.0.18", "unicode-segmentation", "unicode-truncate", "unicode-width", ] -[[package]] -name = "ratatui-crossterm" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "577c9b9f652b4c121fb25c6a391dd06406d3b092ba68827e6d2f09550edc54b3" -dependencies = [ - "cfg-if", - "crossterm 0.28.1", - "crossterm 0.29.0", - "instability", - "ratatui-core", -] - -[[package]] -name = "ratatui-termion" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cade85a8591fbc911e147951422f0d6fd40f4948b271b6216c7dc01838996f8" -dependencies = [ - "instability", - "ratatui-core", - "termion", -] - -[[package]] -name = "ratatui-termwiz" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f76fe0bd0ed4295f0321b1676732e2454024c15a35d01904ddb315afd3d545c" -dependencies = [ - "ratatui-core", - "termwiz", -] - [[package]] name = "ratatui-widgets" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7dbfa023cd4e604c2553483820c5fe8aa9d71a42eea5aa77c6e7f35756612db" +checksum = "66e3d19bcc9130ca376277d93b60767ff121ace3be06f5f95f81dd68956407d1" dependencies = [ - "bitflags 2.11.1", - "hashbrown 0.16.1", + "bitflags", + "hashbrown 0.17.1", "indoc", "instability", "itertools", "line-clipping", "ratatui-core", "serde", - "strum 0.27.2", + "strum", "time", "unicode-segmentation", "unicode-width", @@ -3476,7 +2995,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.11.1", + "bitflags", ] [[package]] @@ -3507,14 +3026,14 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] name = "regex" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" dependencies = [ "aho-corasick", "memchr", @@ -3535,9 +3054,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "rfc6979" @@ -3578,11 +3097,11 @@ dependencies = [ "const-oid", "crypto-bigint", "crypto-primes", - "digest 0.11.3", + "digest", "pkcs1", "pkcs8", "rand_core 0.10.1", - "sha2 0.11.0", + "sha2", "signature", "spki", "zeroize", @@ -3590,13 +3109,13 @@ dependencies = [ [[package]] name = "russh" -version = "0.61.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba341d1fce5e094392f088499c5808d2a60d3a658f58fe480c26ac77b1c7dd3" +checksum = "bbf893f64684e58da8a68d56a5e84d1cf0440226274c515770fe267707a7d0b0" dependencies = [ "aes", - "bitflags 2.11.1", - "block-padding 0.4.2", + "bitflags", + "block-padding", "byteorder", "bytes", "cbc", @@ -3607,19 +3126,18 @@ dependencies = [ "data-encoding", "delegate", "der", - "digest 0.11.3", + "digest", "ecdsa", "ed25519-dalek", "elliptic-curve", "enum_dispatch", "futures", - "generic-array 1.4.1", - "getrandom 0.2.17", + "generic-array 1.4.3", + "getrandom 0.4.3", "ghash", "hex-literal", - "hkdf", "hmac", - "inout 0.1.4", + "inout", "internal-russh-num-bigint", "keccak", "log", @@ -3646,7 +3164,7 @@ dependencies = [ "scrypt", "sec1", "sha1", - "sha2 0.11.0", + "sha2", "sha3", "signature", "spki", @@ -3667,7 +3185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443f6bbcfacb34a1aab2b12b99bf08e0c63abdc5a0db261901365df9d57fff51" dependencies = [ "log", - "nix 0.31.3", + "nix", "ssh-encoding", "windows-sys 0.61.2", ] @@ -3705,50 +3223,16 @@ dependencies = [ "semver", ] -[[package]] -name = "rustcrypto-ff" -version = "0.14.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2a8adb347447693cd2ba0d218c4b66c62da9b0a5672b17b981e4291ec65ff6" -dependencies = [ - "rand_core 0.10.1", - "subtle", -] - -[[package]] -name = "rustcrypto-group" -version = "0.14.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "369f9b61aa45933c062c9f6b5c3c50ab710687eca83dd3802653b140b43f85ed" -dependencies = [ - "rand_core 0.10.1", - "rustcrypto-ff", - "subtle", -] - -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.11.1", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - [[package]] name = "rustix" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.11.1", + "bitflags", "errno", "libc", - "linux-raw-sys 0.12.1", + "linux-raw-sys", "windows-sys 0.61.2", ] @@ -3831,7 +3315,7 @@ dependencies = [ "cfg-if", "pbkdf2", "salsa20", - "sha2 0.11.0", + "sha2", ] [[package]] @@ -3891,7 +3375,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3918,9 +3402,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.20.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72c1c2cb7b223fafb600a619537a871c2818583d619401b785e7c0b746ccde2" +checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c" dependencies = [ "base64", "bs58", @@ -3938,14 +3422,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.20.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b90c488738ecb4fb0262f41f43bc40efc5868d9fb744319ddf5f5317f417bfac" +checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660" dependencies = [ - "darling 0.23.0", + "darling", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3965,19 +3449,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" dependencies = [ "cfg-if", - "cpufeatures 0.3.0", - "digest 0.11.3", -] - -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures 0.2.17", - "digest 0.10.7", + "cpufeatures", + "digest", ] [[package]] @@ -3987,8 +3460,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" dependencies = [ "cfg-if", - "cpufeatures 0.3.0", - "digest 0.11.3", + "cpufeatures", + "digest", ] [[package]] @@ -3997,7 +3470,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be176f1a57ce4e3d31c1a166222d9768de5954f811601fb7ca06fc8203905ce1" dependencies = [ - "digest 0.11.3", + "digest", "keccak", ] @@ -4012,19 +3485,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "signal-hook" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" -dependencies = [ - "libc", - "signal-hook-registry", -] +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "signal-hook" @@ -4036,17 +3499,6 @@ dependencies = [ "signal-hook-registry", ] -[[package]] -name = "signal-hook-mio" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" -dependencies = [ - "libc", - "mio", - "signal-hook 0.3.18", -] - [[package]] name = "signal-hook-registry" version = "1.4.8" @@ -4065,7 +3517,7 @@ checksum = "e513e435a8898a0002270f29d0a708b7879708fb5c4d00e46983ca2d2d378cf0" dependencies = [ "futures-core", "libc", - "signal-hook 0.4.4", + "signal-hook", "tokio", ] @@ -4075,7 +3527,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" dependencies = [ - "digest 0.11.3", + "digest", "rand_core 0.10.1", ] @@ -4100,12 +3552,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" -[[package]] -name = "siphasher" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" - [[package]] name = "slab" version = "0.4.12" @@ -4114,15 +3560,15 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "socket2" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" dependencies = [ "libc", "windows-sys 0.61.2", @@ -4168,7 +3614,7 @@ dependencies = [ "bytes", "crypto-bigint", "ctutils", - "digest 0.11.3", + "digest", "pem-rfc7468", "zeroize", ] @@ -4192,7 +3638,7 @@ dependencies = [ "rsa", "sec1", "sha1", - "sha2 0.11.0", + "sha2", "signature", "ssh-cipher", "ssh-encoding", @@ -4217,34 +3663,13 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "strum" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" -dependencies = [ - "strum_macros 0.27.2", -] - [[package]] name = "strum" 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.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.117", + "strum_macros", ] [[package]] @@ -4256,7 +3681,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -4273,20 +3698,9 @@ checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -4320,78 +3734,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] -name = "terminfo" -version = "0.9.0" +name = "tempfile" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ - "fnv", - "nom 7.1.3", - "phf", - "phf_codegen", -] - -[[package]] -name = "termion" -version = "4.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f44138a9ae08f0f502f24104d82517ef4da7330c35acd638f1f29d3cd5475ecb" -dependencies = [ - "libc", - "numtoa", - "serde", -] - -[[package]] -name = "termios" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" -dependencies = [ - "libc", -] - -[[package]] -name = "termwiz" -version = "0.23.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4676b37242ccbd1aabf56edb093a4827dc49086c0ffd764a5705899e0f35f8f7" -dependencies = [ - "anyhow", - "base64", - "bitflags 2.11.1", - "fancy-regex", - "filedescriptor", - "finl_unicode", - "fixedbitset", - "hex", - "lazy_static", - "libc", - "log", - "memmem", - "nix 0.29.0", - "num-derive", - "num-traits", - "ordered-float 4.6.0", - "pest", - "pest_derive", - "phf", - "serde", - "sha2 0.10.9", - "signal-hook 0.3.18", - "siphasher", - "terminfo", - "termios", - "thiserror 1.0.69", - "ucd-trie", - "unicode-segmentation", - "vtparse", - "wezterm-bidi", - "wezterm-blob-leases", - "wezterm-color-types", - "wezterm-dynamic", - "wezterm-input-types", - "winapi", + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", ] [[package]] @@ -4420,7 +3772,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -4431,7 +3783,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -4479,12 +3831,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.47" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +checksum = "711a53c2d47bbd818258c498c8dbfe186a2526c631495cfe7e078567f86b8469" dependencies = [ "deranged", - "itoa", "libc", "num-conv", "num_threads", @@ -4496,15 +3847,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +checksum = "71c652a3727a9cbb9a02f707f530b618ce00d0ccd762009c8c23bd191df3c17d" dependencies = [ "num-conv", "time-core", @@ -4550,7 +3901,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -4648,7 +3999,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -4731,15 +4082,20 @@ checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" [[package]] name = "typenum" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] -name = "ucd-trie" -version = "0.1.7" +name = "uds_windows" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] [[package]] name = "unicode-ident" @@ -4749,9 +4105,9 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-truncate" @@ -4770,19 +4126,13 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "universal-hash" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" dependencies = [ - "crypto-common 0.2.2", + "crypto-common", "ctutils", ] @@ -4804,19 +4154,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" -dependencies = [ - "atomic", - "getrandom 0.4.2", - "js-sys", - "serde_core", - "wasm-bindgen", -] - [[package]] name = "uzers" version = "0.12.2" @@ -4846,12 +4183,12 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "vergen" -version = "9.1.0" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b849a1f6d8639e8de261e81ee0fc881e3e3620db1af9f2e0da015d4382ceaf75" +checksum = "7bdf18a54cf91b4d98a8e8b67f6321606539fbcdcac02536286ad1de37b53fd2" dependencies = [ "anyhow", - "derive_builder", + "bon", "rustc_version", "rustversion", "time", @@ -4860,12 +4197,12 @@ dependencies = [ [[package]] name = "vergen-gitcl" -version = "9.1.0" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ff3b5300a085d6bcd8fc96a507f706a28ae3814693236c9b409db71a1d15b9" +checksum = "4961429ed12888cb3c6dd20f7dc9508c821091a3ba5fec0156ed5a654c1c4572" dependencies = [ "anyhow", - "derive_builder", + "bon", "rustversion", "time", "vergen", @@ -4874,12 +4211,12 @@ dependencies = [ [[package]] name = "vergen-lib" -version = "9.1.0" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34a29ba7e9c59e62f229ae1932fb1b8fb8a6fdcc99215a641913f5f5a59a569" +checksum = "910e8471e27130bbc019e9bfa6bda16dfc4c6dd7c5d0793da70a9256caeae984" dependencies = [ "anyhow", - "derive_builder", + "bon", "rustversion", ] @@ -4889,15 +4226,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "vtparse" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9b2acfb050df409c972a37d3b8e08cdea3bddb0c09db9d53137e504cfabed0" -dependencies = [ - "utf8parse", -] - [[package]] name = "walkdir" version = "2.5.0" @@ -4916,27 +4244,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.3+wasi-0.2.9" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "wit-bindgen 0.57.1", -] - -[[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen 0.51.0", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.121" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49ace1d07c165b0864824eee619580c4689389afa9dc9ed3a4c75040d82e6790" +checksum = "8ddb3f79143bced6de84270411622a2699cee572fc0875aeaf1e7867cf9fca1a" dependencies = [ "cfg-if", "once_cell", @@ -4947,9 +4266,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.71" +version = "0.4.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96492d0d3ffba25305a7dc88720d250b1401d7edca02cc3bcd50633b424673b8" +checksum = "503b14d284f2c8dac03b819967e155ea753f573586193b2b2c95990cb5d69280" dependencies = [ "js-sys", "wasm-bindgen", @@ -4957,9 +4276,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.121" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e68e6f4afd367a562002c05637acb8578ff2dea1943df76afb9e83d177c8578" +checksum = "4e21a184b13fb19e157296e2c46056aec9092264fab83e4ba59e68c61b323c3d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4967,175 +4286,51 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.121" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a9ec35c64b2a7cb35d3fead40c4238d0940c86d107136999567a4703259f2" +checksum = "fecefd9c35bd935a20fc3fc344b5f29138961e4f47fb03297d88f2587afb5ebd" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.117", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.121" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e0100b01e9f0d03189a92b96772a1fb998639d981193d7dbab487302513441" +checksum = "23939e44bb9a5d7576fa2b563dc2e136628f1224e88a8deed09e04858b77871f" dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap 2.14.0", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags 2.11.1", - "hashbrown 0.15.5", - "indexmap 2.14.0", - "semver", -] - [[package]] name = "weezl" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" -[[package]] -name = "wezterm-bidi" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0a6e355560527dd2d1cf7890652f4f09bb3433b6aadade4c9b5ed76de5f3ec" -dependencies = [ - "log", - "wezterm-dynamic", -] - -[[package]] -name = "wezterm-blob-leases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692daff6d93d94e29e4114544ef6d5c942a7ed998b37abdc19b17136ea428eb7" -dependencies = [ - "getrandom 0.3.4", - "mac_address", - "serde", - "sha2 0.10.9", - "thiserror 1.0.69", - "uuid", -] - -[[package]] -name = "wezterm-color-types" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de81ef35c9010270d63772bebef2f2d6d1f2d20a983d27505ac850b8c4b4296" -dependencies = [ - "csscolorparser", - "deltae", - "lazy_static", - "serde", - "wezterm-dynamic", -] - -[[package]] -name = "wezterm-dynamic" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f2ab60e120fd6eaa68d9567f3226e876684639d22a4219b313ff69ec0ccd5ac" -dependencies = [ - "log", - "ordered-float 4.6.0", - "strsim", - "thiserror 1.0.69", - "wezterm-dynamic-derive", -] - -[[package]] -name = "wezterm-dynamic-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c0cf2d539c645b448eaffec9ec494b8b19bd5077d9e58cb1ae7efece8d575b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wezterm-input-types" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7012add459f951456ec9d6c7e6fc340b1ce15d6fc9629f8c42853412c029e57e" -dependencies = [ - "bitflags 1.3.2", - "euclid", - "lazy_static", - "serde", - "wezterm-dynamic", -] - [[package]] name = "which" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81995fafaaaf6ae47a7d0cc83c67caf92aeb7e5331650ae6ff856f7c0c60c459" +checksum = "48d7cd18d4acb58fb3cdfe9ea54e6cd96a4e7d4cc45c56338b236e82dad47248" dependencies = [ "libc", ] [[package]] name = "wide" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7714cd0430a663154667c74da5d09325c2387695bee18b3f7f72825aa3693a" +checksum = "dfdfe6a32973f2d1b268b8895845a8a96cac2f0191e72c27cc929036060dbf89" dependencies = [ "bytemuck", "safe_arch", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.11" @@ -5145,12 +4340,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows" version = "0.56.0" @@ -5226,7 +4415,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -5237,7 +4426,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -5248,7 +4437,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -5259,7 +4448,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -5485,100 +4674,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - [[package]] name = "wit-bindgen" version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap 2.14.0", - "prettyplease", - "syn 2.0.117", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn 2.0.117", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags 2.11.1", - "indexmap 2.14.0", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap 2.14.0", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - [[package]] name = "wyz" version = "0.5.1" @@ -5606,7 +4707,7 @@ dependencies = [ "libc", "mlua", "paste", - "ratatui", + "ratatui-core", "scopeguard", "tokio", "tokio-stream", @@ -5642,11 +4743,12 @@ dependencies = [ "anyhow", "base64", "image", + "inventory", "moxcms", "palette", "quantette", - "ratatui", - "strum 0.28.0", + "ratatui-core", + "strum", "tokio", "tracing", "yazi-config", @@ -5655,8 +4757,8 @@ dependencies = [ "yazi-macro", "yazi-shared", "yazi-shim", - "yazi-term", "yazi-tty", + "yazi-widgets", ] [[package]] @@ -5667,26 +4769,20 @@ dependencies = [ "anyhow", "futures", "hashbrown 0.17.1", + "image", "libc", "mlua", - "paste", - "ratatui", + "ratatui-core", + "ratatui-widgets", + "serde", "serde_json", + "strum", "tokio", - "tokio-stream", - "tracing", "unicode-width", "windows-sys 0.61.2", - "yazi-adapter", "yazi-codegen", - "yazi-config", - "yazi-fs", "yazi-macro", - "yazi-shared", "yazi-shim", - "yazi-term", - "yazi-vfs", - "yazi-widgets", ] [[package]] @@ -5699,16 +4795,11 @@ dependencies = [ "clap_complete_nushell", "futures", "hashbrown 0.17.1", - "regex", - "vergen-gitcl", - "yazi-adapter", - "yazi-config", - "yazi-emulator", "yazi-fs", "yazi-macro", "yazi-shared", "yazi-shim", - "yazi-term", + "yazi-version", "yazi-vfs", ] @@ -5730,18 +4821,23 @@ dependencies = [ "clap_complete_fig", "clap_complete_nushell", "hashbrown 0.17.1", + "regex", "serde", "serde_json", "tokio", "toml", "twox-hash", - "vergen-gitcl", + "yazi-adapter", "yazi-boot", + "yazi-config", "yazi-dds", + "yazi-emulator", "yazi-fs", "yazi-macro", "yazi-shared", "yazi-term", + "yazi-tty", + "yazi-version", ] [[package]] @@ -5750,7 +4846,7 @@ version = "26.5.6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -5759,18 +4855,20 @@ version = "26.5.6" dependencies = [ "anyhow", "arc-swap", - "bitflags 2.11.1", + "bitflags", "globset", "hashbrown 0.17.1", "indexmap 2.14.0", - "ratatui", + "inventory", + "mlua", + "ratatui-core", + "ratatui-widgets", "regex", "serde", "serde_with", - "strum 0.28.0", - "tokio", "toml", "tracing", + "yazi-binding", "yazi-codegen", "yazi-fs", "yazi-macro", @@ -5778,6 +4876,7 @@ dependencies = [ "yazi-shim", "yazi-term", "yazi-tty", + "yazi-widgets", ] [[package]] @@ -5790,10 +4889,11 @@ dependencies = [ "indexmap 2.14.0", "mlua", "parking_lot", - "ratatui", + "ratatui-core", + "ratatui-widgets", "serde", "serde_with", - "strum 0.28.0", + "strum", "syntect", "tokio", "tokio-stream", @@ -5812,6 +4912,7 @@ dependencies = [ "yazi-shared", "yazi-shim", "yazi-term", + "yazi-tty", "yazi-vfs", "yazi-watcher", "yazi-widgets", @@ -5824,8 +4925,8 @@ dependencies = [ "anyhow", "hashbrown 0.17.1", "indexmap 2.14.0", + "inventory", "mlua", - "ordered-float 5.3.0", "parking_lot", "paste", "serde", @@ -5833,13 +4934,14 @@ dependencies = [ "tokio", "tokio-stream", "tracing", - "vergen-gitcl", + "uds_windows", "yazi-binding", "yazi-boot", "yazi-fs", "yazi-macro", "yazi-shared", "yazi-shim", + "yazi-version", ] [[package]] @@ -5848,7 +4950,7 @@ version = "26.5.6" dependencies = [ "anyhow", "either", - "ratatui", + "ratatui-core", "scopeguard", "tokio", "tracing", @@ -5880,8 +4982,8 @@ dependencies = [ "libc", "mlua", "paste", - "ratatui", - "scopeguard", + "ratatui-core", + "ratatui-widgets", "signal-hook-tokio", "tikv-jemallocator", "tokio", @@ -5919,13 +5021,15 @@ version = "26.5.6" dependencies = [ "anyhow", "arc-swap", - "bitflags 2.11.1", + "bitflags", "core-foundation-sys", "dirs", "either", - "foldhash 0.2.0", + "foldhash", "hashbrown 0.17.1", + "inventory", "libc", + "mlua", "objc2", "parking_lot", "percent-encoding", @@ -5933,13 +5037,14 @@ dependencies = [ "regex", "scopeguard", "serde", - "strum 0.28.0", + "strum", "tokio", "tracing", "trash", "typed-path", "uzers", "windows-sys 0.61.2", + "yazi-binding", "yazi-ffi", "yazi-macro", "yazi-shared", @@ -5959,16 +5064,15 @@ name = "yazi-parser" version = "26.5.6" dependencies = [ "anyhow", - "bitflags 2.11.1", + "bitflags", "hashbrown 0.17.1", "mlua", "paste", - "ratatui", + "ratatui-core", "serde", "serde_with", - "strum 0.28.0", + "strum", "tokio", - "yazi-binding", "yazi-boot", "yazi-config", "yazi-core", @@ -5977,6 +5081,7 @@ dependencies = [ "yazi-macro", "yazi-scheduler", "yazi-shared", + "yazi-shim", "yazi-term", "yazi-vfs", "yazi-widgets", @@ -5989,10 +5094,12 @@ dependencies = [ "ansi-to-tui", "anyhow", "futures", + "inventory", "libc", "mlua", - "paste", - "ratatui", + "percent-encoding", + "ratatui-core", + "ratatui-widgets", "serde_json", "tokio", "tokio-stream", @@ -6003,6 +5110,7 @@ dependencies = [ "yazi-adapter", "yazi-binding", "yazi-boot", + "yazi-codegen", "yazi-config", "yazi-core", "yazi-dds", @@ -6015,6 +5123,7 @@ dependencies = [ "yazi-shared", "yazi-shim", "yazi-term", + "yazi-tty", "yazi-vfs", "yazi-widgets", ] @@ -6031,8 +5140,10 @@ version = "26.5.6" dependencies = [ "anyhow", "tokio", + "tracing", "yazi-config", "yazi-core", + "yazi-dds", "yazi-macro", "yazi-scheduler", "yazi-shared", @@ -6053,13 +5164,12 @@ dependencies = [ "tokio-util", "tracing", "yazi-binding", - "yazi-boot", "yazi-config", - "yazi-dds", "yazi-fs", "yazi-macro", "yazi-shared", "yazi-shim", + "yazi-version", ] [[package]] @@ -6068,15 +5178,15 @@ version = "26.5.6" dependencies = [ "anyhow", "async-priority-channel", - "foldhash 0.2.0", + "foldhash", "hashbrown 0.17.1", "libc", - "lru 0.18.0", + "lru", "mlua", "ordered-float 5.3.0", "parking_lot", "serde", - "strum 0.28.0", + "strum", "tokio", "tracing", "yazi-binding", @@ -6086,6 +5196,7 @@ dependencies = [ "yazi-macro", "yazi-runner", "yazi-shared", + "yazi-shim", "yazi-term", "yazi-vfs", ] @@ -6094,7 +5205,7 @@ dependencies = [ name = "yazi-sftp" version = "26.5.6" dependencies = [ - "bitflags 2.11.1", + "bitflags", "parking_lot", "russh", "serde", @@ -6108,23 +5219,26 @@ version = "26.5.6" dependencies = [ "anyhow", "dyn-clone", - "foldhash 0.2.0", + "foldhash", "futures", "hashbrown 0.17.1", + "inventory", "libc", "memchr", + "mlua", "ordered-float 5.3.0", "parking_lot", "paste", "percent-encoding", "serde", "serde_with", - "strum 0.28.0", + "strum", "thiserror 2.0.18", "tokio", "typed-path", "uzers", "windows-sys 0.61.2", + "yazi-codegen", "yazi-macro", "yazi-shim", "yazi-term", @@ -6134,10 +5248,14 @@ dependencies = [ name = "yazi-shim" version = "26.5.6" dependencies = [ + "anyhow", "arc-swap", + "base64", "hashbrown 0.17.1", "mlua", - "ratatui", + "percent-encoding", + "ratatui-core", + "ratatui-widgets", "serde", "thiserror 2.0.18", "toml", @@ -6153,12 +5271,14 @@ version = "26.5.6" dependencies = [ "anyhow", "base64", - "bitflags 2.11.1", + "bitflags", "futures", + "mlua", "parking_lot", - "ratatui", - "rustix 1.1.4", - "signal-hook 0.4.4", + "rustix", + "serde", + "signal-hook", + "strum", "thiserror 2.0.18", "tokio", "windows-sys 0.61.2", @@ -6171,10 +5291,15 @@ dependencies = [ name = "yazi-tty" version = "26.5.9" dependencies = [ + "base64", + "bitflags", "libc", + "mlua", "parking_lot", + "ratatui-core", "tracing", "windows-sys 0.61.2", + "yazi-binding", "yazi-macro", "yazi-shim", ] @@ -6184,17 +5309,25 @@ name = "yazi-tui" version = "26.5.9" dependencies = [ "anyhow", - "ratatui", + "ratatui-core", "tokio", "yazi-config", "yazi-emulator", "yazi-macro", + "yazi-proxy", "yazi-shared", "yazi-shim", "yazi-term", "yazi-tty", ] +[[package]] +name = "yazi-version" +version = "26.5.6" +dependencies = [ + "vergen-gitcl", +] + [[package]] name = "yazi-vfs" version = "26.5.6" @@ -6205,12 +5338,16 @@ dependencies = [ "either", "futures", "hashbrown 0.17.1", + "mlua", "parking_lot", "russh", + "serde", "tokio", + "toml", "tracing", "typed-path", - "yazi-config", + "yazi-binding", + "yazi-codegen", "yazi-fs", "yazi-macro", "yazi-sftp", @@ -6245,15 +5382,21 @@ version = "26.5.6" dependencies = [ "anyhow", "clipboard-win", + "dyn-clone", "futures", + "inventory", "mlua", "parking_lot", - "ratatui", + "ratatui-core", + "ratatui-widgets", "serde", + "strum", "tokio", + "tokio-stream", + "tracing", "unicode-width", - "yazi-adapter", - "yazi-config", + "yazi-binding", + "yazi-dds", "yazi-macro", "yazi-shared", "yazi-shim", @@ -6263,29 +5406,29 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" [[package]] name = "zmij" diff --git a/Cargo.toml b/Cargo.toml index d7ff624f..6985c10a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,8 +39,8 @@ ansi-to-tui = "8.0.1" anyhow = "1.0.102" arc-swap = { version = "1.9.1", features = [ "serde" ] } base64 = "0.22.1" -bitflags = { version = "2.11.1", features = [ "serde" ] } -chrono = "0.4.44" +bitflags = { version = "2.13.0", features = [ "serde" ] } +chrono = "0.4.45" clap = { version = "4.6.1", features = [ "derive" ] } core-foundation-sys = "0.8.7" dirs = "6.0.0" @@ -50,7 +50,9 @@ foldhash = "0.2.0" futures = "0.3.32" globset = "0.4.18" hashbrown = { version = "0.17.1", features = [ "serde" ] } +image = { version = "0.25.10", default-features = false, features = [ "avif", "bmp", "dds", "exr", "ff", "gif", "hdr", "ico", "jpeg", "png", "pnm", "qoi", "tga", "tiff", "webp" ] } indexmap = { version = "2.14.0", features = [ "serde" ] } +inventory = "0.3.24" libc = "0.2.186" lru = "0.18.0" mlua = { version = "0.11.6", features = [ "anyhow", "async", "error-send", "lua55", "macros", "serde" ] } @@ -60,13 +62,14 @@ parking_lot = "0.12.5" paste = "1.0.15" percent-encoding = "2.3.2" rand = { version = "0.10.1", default-features = false, features = [ "std", "sys_rng" ] } -ratatui = { version = "0.30.0", default-features = false, features = [ "layout-cache", "serde", "underline-color", "unstable-rendered-line-info", "unstable-widget-ref" ] } -regex = "1.12.3" -russh = { version = "0.61.0", default-features = false, features = [ "ring", "rsa" ] } +ratatui-core = { version = "0.1.2", default-features = false, features = [ "std", "layout-cache", "serde", "underline-color" ] } +ratatui-widgets = { version = "0.3.2", default-features = false, features = [ "std", "unstable-rendered-line-info" ] } +regex = "1.12.4" +russh = { version = "0.61.2", default-features = false, features = [ "ring", "rsa" ] } scopeguard = "1.2.0" serde = { version = "1.0.228", features = [ "derive" ] } serde_json = "1.0.150" -serde_with = "3.20.0" +serde_with = "3.21.0" strum = { version = "0.28.0", features = [ "derive" ] } syntect = { version = "5.3.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] } thiserror = "2.0.18" diff --git a/README.md b/README.md index 1cd2e097..831a8ae7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo - 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths - 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, code, directories, etc.) - 🔄 Bulk Rename/Create, Archive Extraction, Visual Mode, File Chooser, [Git Integration](https://github.com/yazi-rs/plugins/tree/main/git.yazi), [Mount Manager](https://github.com/yazi-rs/plugins/tree/main/mount.yazi) -- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u, OSC 52 +- 🎨 Theme System, Mouse Support, Drag and Drop, Trash Bin, Custom Layouts, CSI u, OSC 52 - ... and more! https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265cc7 diff --git a/cspell.json b/cspell.json index 289f3fd0..0685a4f8 100644 --- a/cspell.json +++ b/cspell.json @@ -1 +1 @@ -{"language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg","foldhash","tilded","futs","chdir","hashbrown","JEMALLOC","RUSTFLAGS","RDONLY","GETPATH","fcntl","casefold","inodes","Splatable","casefied","thiserror","memchr","memmem","russh","deadpool","keepalive","nodelay","publickey","deadpool","initing","treelize","TOCTOU","fellback","watchee","Textlike","sstr","pointee","writef","wakeup","nonblocking","sigwinch","timespec","termios","tcgetattr","tcsetattr","tcgetwinsize","rustix","codepoint","codepoints","Raterm"],"version":"0.2","flagWords":[]} \ No newline at end of file +{"flagWords":[],"version":"0.2","language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg","foldhash","tilded","futs","chdir","hashbrown","JEMALLOC","RUSTFLAGS","RDONLY","GETPATH","fcntl","casefold","inodes","Splatable","casefied","thiserror","memchr","memmem","russh","deadpool","keepalive","nodelay","publickey","deadpool","initing","treelize","TOCTOU","fellback","watchee","Textlike","sstr","pointee","writef","wakeup","nonblocking","sigwinch","timespec","termios","tcgetattr","tcsetattr","tcgetwinsize","rustix","codepoint","codepoints","Raterm","mimetypes","Mimelist","renderables","redrawer","Padable"]} \ No newline at end of file diff --git a/flake.lock b/flake.lock index d485f39e..052f6d36 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1776329215, - "narHash": "sha256-a8BYi3mzoJ/AcJP8UldOx8emoPRLeWqALZWu4ZvjPXw=", + "lastModified": 1779877693, + "narHash": "sha256-NOF9NAREhxr50bbBfVcVOq+ArCMSoe8dP79Pk2uyARk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b86751bc4085f48661017fa226dee99fab6c651b", + "rev": "4100e830e085863741bc69b156ec4ccd53ab5be0", "type": "github" }, "original": { @@ -48,11 +48,11 @@ ] }, "locked": { - "lastModified": 1776741231, - "narHash": "sha256-k9G98qzn+7npROUaks8VqCFm7cFtEG8ulQLBBo5lItg=", + "lastModified": 1779851998, + "narHash": "sha256-UkkMh3bX9QW4Luqkm98nUaOqKWrU6i65mUnph3WeSSw=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "02061303f7c4c964f7b4584dabd9e985b4cd442b", + "rev": "6cddd512fa2bf7231f098d3a2f92f6e4cff71e0a", "type": "github" }, "original": { diff --git a/nix/yazi-unwrapped.nix b/nix/yazi-unwrapped.nix index 3601b485..2cae987c 100644 --- a/nix/yazi-unwrapped.nix +++ b/nix/yazi-unwrapped.nix @@ -28,9 +28,6 @@ rustPlatform.buildRustPackage (finalAttrs: { cargoLock = { lockFile = "${src}/Cargo.lock"; - #outputHashes = { - # "mlua-0.10.0" = "sha256-Xg6/jc+UP8tbJJ6x1sbAgt8ZHt051xEBBcjmikQqYlw="; - #}; }; env = { @@ -54,6 +51,11 @@ rustPlatform.buildRustPackage (finalAttrs: { --fish ./yazi-boot/completions/yazi.fish \ --zsh ./yazi-boot/completions/_yazi + installShellCompletion --cmd ya \ + --bash ./yazi-cli/completions/ya.bash \ + --fish ./yazi-cli/completions/ya.fish \ + --zsh ./yazi-cli/completions/_ya + # Resize logo for RES in 16 24 32 48 64 128 256; do mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps @@ -75,7 +77,7 @@ rustPlatform.buildRustPackage (finalAttrs: { hash = "sha256-kEVXejDg4ChFoMNBvKlwdFEyUuTcY2VuK9j0PdafKus="; }; }; - + meta = { description = "Blazing fast terminal file manager written in Rust, based on async I/O"; diff --git a/scripts/validate-form/main.js b/scripts/validate-form/main.js index 925b4e16..bd3fddb8 100644 --- a/scripts/validate-form/main.js +++ b/scripts/validate-form/main.js @@ -13,7 +13,7 @@ function bugReportBody(creator, content, hash) { I noticed that you did not correctly follow the issue template. Please ensure that: - The bug can still be reproduced on the [newest nightly build](https://yazi-rs.github.io/docs/installation/#binaries). -- The debug information (\`yazi --debug\`) is updated for the newest nightly. +- The environment info (\`ya env\`) is updated for the newest nightly. - The non-optional items in the checklist are checked. Issues with \`${LABEL_NAME}\` will be marked ready once edited with the proper content, or closed after 2 days of inactivity. @@ -32,7 +32,7 @@ function featureRequestBody(creator, content) { I noticed that you did not correctly follow the issue template. Please ensure that: - The requested feature does not exist in the [newest nightly build](https://yazi-rs.github.io/docs/installation/#binaries). -- The debug information (\`yazi --debug\`) is updated for the newest nightly. +- The environment info (\`ya env\`) is updated for the newest nightly. - The non-optional items in the checklist are checked. Issues with \`${LABEL_NAME}\` will be marked ready once edited with the proper content, or closed after 2 days of inactivity. diff --git a/scripts/validate-form/package-lock.json b/scripts/validate-form/package-lock.json index 6e873bca..87395153 100644 --- a/scripts/validate-form/package-lock.json +++ b/scripts/validate-form/package-lock.json @@ -238,9 +238,9 @@ } }, "node_modules/undici": { - "version": "6.25.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.25.0.tgz", - "integrity": "sha512-ZgpWDC5gmNiuY9CnLVXEH8rl50xhRCuLNA97fAUnKi8RRuV4E6KG31pDTsLVUKnohJE0I3XDrTeEydAXRw47xg==", + "version": "6.27.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.27.0.tgz", + "integrity": "sha512-YmfV3YnEDzXRC5lZ2jWtWWHKGUm1zIt8AhesR1tens+HTNv+YZlN/dp6G727LOvMJ8xjP9Be7Y2Sdr96LDm+pg==", "license": "MIT", "engines": { "node": ">=18.17" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 78abbfe2..91e5949f 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -133,9 +133,16 @@ parts: - --prefix=/usr build-attributes: - enable-patchelf + organize: + # `libgomp1` installs libgomp into the multiarch directory, but the + # `magick` binary's RPATH only searches `$ORIGIN/../lib` (i.e. usr/lib). + # Move it alongside the Magick libraries so the bundled binary can load + # it at runtime; otherwise magick fails with: + # "libgomp.so.1: cannot open shared object file: No such file or directory" + usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libgomp.so*: usr/lib/ prime: - usr/bin/magick - - usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libgomp.so.1 + - usr/lib/libgomp.so* - usr/lib/libMagickCore-7.Q16HDRI.so* - usr/lib/libMagickWand-7.Q16HDRI.so* diff --git a/yazi-actor/Cargo.toml b/yazi-actor/Cargo.toml index c9b748d5..1015e74a 100644 --- a/yazi-actor/Cargo.toml +++ b/yazi-actor/Cargo.toml @@ -40,18 +40,18 @@ yazi-watcher = { path = "../yazi-watcher", version = "26.5.6" } yazi-widgets = { path = "../yazi-widgets", version = "26.5.6" } # External dependencies -anyhow = { workspace = true } -either = { workspace = true } -futures = { workspace = true } -hashbrown = { workspace = true } -indexmap = { workspace = true } -mlua = { workspace = true } -paste = { workspace = true } -ratatui = { workspace = true } -scopeguard = { workspace = true } -tokio = { workspace = true } -tokio-stream = { workspace = true } -tracing = { workspace = true } +anyhow = { workspace = true } +either = { workspace = true } +futures = { workspace = true } +hashbrown = { workspace = true } +indexmap = { workspace = true } +mlua = { workspace = true } +paste = { workspace = true } +ratatui-core = { workspace = true } +scopeguard = { workspace = true } +tokio = { workspace = true } +tokio-stream = { workspace = true } +tracing = { workspace = true } [target."cfg(unix)".dependencies] libc = { workspace = true } diff --git a/yazi-actor/src/app/accept_payload.rs b/yazi-actor/src/app/accept_payload.rs index e9de9bed..151e83b6 100644 --- a/yazi-actor/src/app/accept_payload.rs +++ b/yazi-actor/src/app/accept_payload.rs @@ -29,7 +29,7 @@ impl Actor for AcceptPayload { drop(lock); let kind = kind.to_owned(); - succ!(Lives::scope(cx.core, || { + succ!(Lives::scope(cx.core, |_| { let body = payload.body.into_lua(&LUA)?; for (id, cb) in handlers { if let Err(e) = runtime_scope!(LUA, &id, cb.call::<()>(body.clone())) { diff --git a/yazi-actor/src/app/dnd.rs b/yazi-actor/src/app/dnd.rs new file mode 100644 index 00000000..576418d8 --- /dev/null +++ b/yazi-actor/src/app/dnd.rs @@ -0,0 +1,43 @@ +use anyhow::Result; +use mlua::{ObjectLike, Table}; +use tracing::error; +use yazi_actor::lives::Lives; +use yazi_binding::runtime_scope; +use yazi_macro::succ; +use yazi_parser::app::DndForm; +use yazi_plugin::LUA; +use yazi_shared::data::Data; + +use crate::{Actor, Ctx}; + +pub struct Dnd; + +impl Actor for Dnd { + type Form = DndForm; + + const NAME: &str = "dnd"; + + fn act(cx: &mut Ctx, form: Self::Form) -> Result { + let Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() }; + let area = yazi_binding::elements::Rect::from(size); + + let result = Lives::scope(cx.core, move |_| { + runtime_scope!(LUA, "root", { + let root = LUA.globals().raw_get::("Root")?.call_method::
("new", area)?; + + if form.event.is_drag() { + root.call_method::<()>("drag", form.event)?; + } else { + root.call_method::<()>("drop", form.event)?; + } + + Ok(()) + }) + }); + + if let Err(ref e) = result { + error!("{e}"); + } + succ!(result?); + } +} diff --git a/yazi-actor/src/app/lua.rs b/yazi-actor/src/app/lua.rs index 65a50abf..fedf031e 100644 --- a/yazi-actor/src/app/lua.rs +++ b/yazi-actor/src/app/lua.rs @@ -1,10 +1,9 @@ use anyhow::Result; use yazi_binding::runtime_scope; -use yazi_dds::Sendable; use yazi_macro::succ; use yazi_parser::app::LuaForm; use yazi_plugin::LUA; -use yazi_shared::data::Data; +use yazi_shared::data::{Data, Sendable}; use crate::{Actor, Ctx, lives::Lives}; @@ -17,7 +16,7 @@ impl Actor for Lua { fn act(cx: &mut Ctx, form: Self::Form) -> Result { let chunk = LUA.load(&*form.code).set_name("anonymous"); - let result = Lives::scope(cx.core, || { + let result = Lives::scope(cx.core, |_| { runtime_scope!(LUA, "inline", Sendable::value_to_data(&LUA, chunk.eval()?)) }); succ!(result?); diff --git a/yazi-actor/src/app/mod.rs b/yazi-actor/src/app/mod.rs index 0b0a6086..b6c0bd1a 100644 --- a/yazi-actor/src/app/mod.rs +++ b/yazi-actor/src/app/mod.rs @@ -2,6 +2,7 @@ yazi_macro::mod_flat!( accept_payload bootstrap deprecate + dnd focus lua mouse diff --git a/yazi-actor/src/app/mouse.rs b/yazi-actor/src/app/mouse.rs index 7e121168..7eaecb61 100644 --- a/yazi-actor/src/app/mouse.rs +++ b/yazi-actor/src/app/mouse.rs @@ -19,31 +19,29 @@ impl Actor for Mouse { const NAME: &str = "mouse"; fn act(cx: &mut Ctx, form: Self::Form) -> Result { - let event = yazi_binding::MouseEvent::from(form.event); - let Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() }; let area = yazi_binding::elements::Rect::from(size); - let result = Lives::scope(cx.core, move || { - let root = runtime_scope!(LUA, "root", { - LUA.globals().raw_get::
("Root")?.call_method::
("new", area) - })?; + let result = Lives::scope(cx.core, move |_| { + runtime_scope!(LUA, "root", { + let root = LUA.globals().raw_get::
("Root")?.call_method::
("new", area)?; - match event.kind { - MouseEventKind::Down(_) => root.call_method("click", (event, false))?, - MouseEventKind::Up(_) => root.call_method("click", (event, true))?, + match form.event.kind { + MouseEventKind::Down(_) => root.call_method("click", (form.event, false))?, + MouseEventKind::Up(_) => root.call_method("click", (form.event, true))?, - MouseEventKind::ScrollDown => root.call_method("scroll", (event, 1))?, - MouseEventKind::ScrollUp => root.call_method("scroll", (event, -1))?, + MouseEventKind::ScrollDown => root.call_method("scroll", (form.event, 1))?, + MouseEventKind::ScrollUp => root.call_method("scroll", (form.event, -1))?, - MouseEventKind::ScrollRight => root.call_method("touch", (event, 1))?, - MouseEventKind::ScrollLeft => root.call_method("touch", (event, -1))?, + MouseEventKind::ScrollRight => root.call_method("touch", (form.event, 1))?, + MouseEventKind::ScrollLeft => root.call_method("touch", (form.event, -1))?, - MouseEventKind::Moved => root.call_method("move", event)?, - MouseEventKind::Drag(_) => root.call_method("drag", event)?, - } + MouseEventKind::Moved => root.call_method("move", form.event)?, + MouseEventKind::Drag(_) => root.call_method("drag", form.event)?, + } - Ok(()) + Ok(()) + }) }); if let Err(ref e) = result { diff --git a/yazi-actor/src/app/plugin_do.rs b/yazi-actor/src/app/plugin_do.rs index c62a390a..dc647bab 100644 --- a/yazi-actor/src/app/plugin_do.rs +++ b/yazi-actor/src/app/plugin_do.rs @@ -43,7 +43,7 @@ impl Actor for PluginDo { }; drop(loader); - let result = Lives::scope(cx.core, || { + let result = Lives::scope(cx.core, |_| { if let Some(cb) = opt.callback { cb(&LUA, plugin) } else { diff --git a/yazi-actor/src/app/reflow.rs b/yazi-actor/src/app/reflow.rs index cd4390a1..cfb55e3b 100644 --- a/yazi-actor/src/app/reflow.rs +++ b/yazi-actor/src/app/reflow.rs @@ -1,6 +1,6 @@ use anyhow::Result; use mlua::Value; -use ratatui::layout::Position; +use ratatui_core::layout::Position; use tracing::error; use yazi_actor::lives::Lives; use yazi_config::LAYOUT; @@ -21,7 +21,7 @@ impl Actor for Reflow { let Some(size) = cx.term.as_ref().and_then(|t| t.size().ok()) else { succ!() }; let mut layout = LAYOUT.get(); - let result = Lives::scope(cx.core, || { + let result = Lives::scope(cx.core, |_| { let comps = (form.reflow)((Position::ORIGIN, size).into())?; for v in comps.sequence_values::() { diff --git a/yazi-actor/src/app/title.rs b/yazi-actor/src/app/title.rs index e6011789..7b19d9e2 100644 --- a/yazi-actor/src/app/title.rs +++ b/yazi-actor/src/app/title.rs @@ -3,8 +3,7 @@ use yazi_actor::Ctx; use yazi_macro::{succ, writef}; use yazi_parser::{app::TitleForm, spark::SparkKind}; use yazi_shared::{Source, data::Data}; -use yazi_term::sequence::SetTitle; -use yazi_tty::TTY; +use yazi_tty::{TTY, sequence::SetTitle}; use yazi_tui::RatermState; use crate::Actor; diff --git a/yazi-actor/src/cmp/trigger.rs b/yazi-actor/src/cmp/trigger.rs index ce9a3468..964d715e 100644 --- a/yazi-actor/src/cmp/trigger.rs +++ b/yazi-actor/src/cmp/trigger.rs @@ -22,7 +22,7 @@ impl Actor for Trigger { if form.ticket.is_some_and(|t| t != cx.cmp.ticket) { succ!(); } else if form.ticket.is_none() { - cx.cmp.ticket = cx.input.ticket.current(); + cx.cmp.ticket = cx.input.lock().map(|g| g.ticket.current()).unwrap_or_default(); } cx.cmp.handle.take().map(|h| h.abort()); @@ -53,7 +53,7 @@ impl Actor for Trigger { if !cache.is_empty() { cache - .sort_unstable_by(|a, b| natsort(a.name.encoded_bytes(), b.name.encoded_bytes(), false)); + .sort_unstable_by(|a, b| natsort(a.name.encoded_bytes(), b.name.encoded_bytes(), true)); CmpProxy::show(CmpOpt { cache, cache_name: parent, word, ticket }); } diff --git a/yazi-actor/src/context.rs b/yazi-actor/src/context.rs index 1ad02d79..fbdc2863 100644 --- a/yazi-actor/src/context.rs +++ b/yazi-actor/src/context.rs @@ -2,8 +2,8 @@ use std::ops::{Deref, DerefMut}; use anyhow::{Result, anyhow}; use yazi_core::{Core, mgr::Tabs, tab::{Folder, Tab}}; -use yazi_fs::File; -use yazi_shared::{Id, Source, event::Action, url::UrlBuf}; +use yazi_fs::file::File; +use yazi_shared::{Source, event::Action, id::Id, url::UrlBuf}; use yazi_tui::Raterm; pub struct Ctx<'a> { diff --git a/yazi-actor/src/core/preflight.rs b/yazi-actor/src/core/preflight.rs index 56f6e4d0..92e8d0c9 100644 --- a/yazi-actor/src/core/preflight.rs +++ b/yazi-actor/src/core/preflight.rs @@ -16,7 +16,7 @@ impl Preflight { return Ok(opt.1); }; - Ok(Lives::scope(cx.core, || { + Ok(Lives::scope(cx.core, |_| { let mut body = opt.1.into_lua(&LUA)?; for (id, cb) in handlers { match runtime_scope!(LUA, &id, cb.call::(&body)) { diff --git a/yazi-actor/src/input/close.rs b/yazi-actor/src/input/close.rs index 0c0a8eb5..19ae12e7 100644 --- a/yazi-actor/src/input/close.rs +++ b/yazi-actor/src/input/close.rs @@ -1,7 +1,7 @@ use anyhow::Result; use yazi_macro::{act, render, succ}; -use yazi_parser::input::CloseForm; -use yazi_shared::data::Data; +use yazi_parser::{input::CloseForm, spark::SparkKind}; +use yazi_shared::{Source, data::Data}; use yazi_widgets::input::InputEvent; use crate::{Actor, Ctx}; @@ -14,16 +14,28 @@ impl Actor for Close { const NAME: &str = "close"; fn act(cx: &mut Ctx, form: Self::Form) -> Result { - let input = &mut cx.input; - input.visible = false; - input.ticket.next(); + let Some(mut guard) = cx.input.lock_mut() else { + succ!(); + }; - if let Some(tx) = input.tx.take() { - let value = input.snap().value.clone(); - _ = tx.send(if form.submit { InputEvent::Submit(value) } else { InputEvent::Cancel(value) }); + guard.ticket.next(); + if let Some(cb) = guard.cb.take() { + let value = guard.snap().value.clone(); + cb(if form.submit { InputEvent::Submit(value) } else { InputEvent::Cancel(value) }); } + drop(guard); + cx.input.main.visible = false; + act!(cmp:close, cx)?; succ!(render!()); } + + fn hook(cx: &Ctx, _form: &Self::Form) -> Option { + match cx.source() { + Source::Key => Some(SparkKind::KeyInputClose), + Source::Ind => Some(SparkKind::IndInputClose), + _ => None, + } + } } diff --git a/yazi-actor/src/input/complete.rs b/yazi-actor/src/input/complete.rs index 5380618d..394c92c8 100644 --- a/yazi-actor/src/input/complete.rs +++ b/yazi-actor/src/input/complete.rs @@ -13,11 +13,14 @@ impl Actor for Complete { const NAME: &str = "complete"; fn act(cx: &mut Ctx, form: Self::Form) -> Result { - let input = &mut cx.input; - if !input.visible || input.ticket.current() != form.ticket { + let Some(mut guard) = cx.input.lock_mut() else { + succ!(); + }; + + if guard.ticket.current() != form.ticket { succ!(); } - act!(complete, input, form) + act!(complete, guard, form) } } diff --git a/yazi-actor/src/input/escape.rs b/yazi-actor/src/input/escape.rs index 495e0528..6977792c 100644 --- a/yazi-actor/src/input/escape.rs +++ b/yazi-actor/src/input/escape.rs @@ -15,16 +15,20 @@ impl Actor for Escape { fn act(cx: &mut Ctx, _: Self::Form) -> Result { use yazi_widgets::input::InputMode as M; - let input = &mut cx.input; + let Some(mut guard) = cx.input.lock_mut() else { + succ!(); + }; - let mode = input.snap().mode; + let (mode, op) = (guard.snap().mode, guard.snap().op); + act!(escape, guard)?; + + drop(guard); match mode { - M::Normal if input.snap_mut().op == InputOp::None => act!(input:close, cx), + M::Normal if op == InputOp::None => act!(input:close, cx), M::Insert => act!(cmp:close, cx), M::Normal | M::Replace => Ok(().into()), }?; - act!(escape, cx.input)?; succ!(render!()); } } diff --git a/yazi-actor/src/input/show.rs b/yazi-actor/src/input/show.rs index 9b3ee137..3c3272c3 100644 --- a/yazi-actor/src/input/show.rs +++ b/yazi-actor/src/input/show.rs @@ -1,27 +1,34 @@ use std::ops::DerefMut; use anyhow::Result; +use yazi_config::{THEME, YAZI}; use yazi_macro::{act, render, succ}; +use yazi_parser::input::ShowForm; use yazi_shared::data::Data; -use yazi_widgets::input::InputOpt; +use yazi_shim::ratatui::Padable; use crate::{Actor, Ctx}; pub struct Show; impl Actor for Show { - type Form = InputOpt; + type Form = ShowForm; const NAME: &str = "show"; - fn act(cx: &mut Ctx, form: Self::Form) -> Result { + fn act(cx: &mut Ctx, Self::Form { mut opt }: Self::Form) -> Result { act!(input:close, cx)?; + let area = cx.mgr.area(opt.position).padding(cx.input.padding()); let input = &mut cx.input; - input.visible = true; - input.title = form.cfg.title.clone(); - input.position = form.cfg.position; - *input.deref_mut() = yazi_widgets::input::Input::new(form)?; + input.main.visible = true; + input.main.title = opt.title.clone(); + input.main.position = opt.position; + + opt.styles = (&THEME.input).into(); + opt.blinking = YAZI.input.cursor_blink; + *input.main.deref_mut() = yazi_widgets::input::Input::new(opt)?; + input.main.repos(area); succ!(render!()); } diff --git a/yazi-actor/src/lib.rs b/yazi-actor/src/lib.rs index 6706a76c..15eb9f27 100644 --- a/yazi-actor/src/lib.rs +++ b/yazi-actor/src/lib.rs @@ -3,3 +3,5 @@ extern crate self as yazi_actor; yazi_macro::mod_pub!(app cmp confirm core help input lives mgr notify pick spot tasks which); yazi_macro::mod_flat!(actor context); + +pub fn init() { lives::init(); } diff --git a/yazi-actor/src/lives/behavior.rs b/yazi-actor/src/lives/behavior.rs new file mode 100644 index 00000000..c97f3c1e --- /dev/null +++ b/yazi-actor/src/lives/behavior.rs @@ -0,0 +1,29 @@ +use std::ops::Deref; + +use mlua::{AnyUserData, UserData, UserDataMethods}; + +use super::{Lives, PtrCell}; + +pub(super) struct Behavior { + inner: PtrCell, +} + +impl Deref for Behavior { + type Target = yazi_scheduler::Behavior; + + fn deref(&self) -> &Self::Target { &self.inner } +} + +impl Behavior { + pub(super) fn make(inner: &yazi_scheduler::Behavior) -> mlua::Result { + let inner = PtrCell::from(inner); + + Lives::scoped_userdata(Self { inner }) + } +} + +impl UserData for Behavior { + fn add_methods>(methods: &mut M) { + methods.add_method("reset", |_, me, ()| Ok(me.reset())); + } +} diff --git a/yazi-actor/src/lives/core.rs b/yazi-actor/src/lives/core.rs index a32022c9..666a219b 100644 --- a/yazi-actor/src/lives/core.rs +++ b/yazi-actor/src/lives/core.rs @@ -1,10 +1,12 @@ use std::ops::Deref; -use mlua::{AnyUserData, IntoLua, MetaMethod, UserData, UserDataMethods, Value}; +use mlua::{AnyUserData, IntoLua, MetaMethod, UserData, UserDataMethods, UserDataRef, Value}; use paste::paste; use super::{Lives, PtrCell}; +pub(super) type CoreRef = UserDataRef; + pub(super) struct Core { inner: PtrCell, @@ -12,8 +14,9 @@ pub(super) struct Core { c_tabs: Option, c_tasks: Option, c_yanked: Option, - c_layer: Option, + c_input: Option, c_which: Option, + c_layer: Option, } impl Deref for Core { @@ -31,8 +34,9 @@ impl Core { c_tabs: None, c_tasks: None, c_yanked: None, - c_layer: None, + c_input: None, c_which: None, + c_layer: None, }) } } @@ -57,10 +61,9 @@ impl UserData for Core { b"tabs" => reuse!(tabs, super::Tabs::make(&me.mgr.tabs)), b"tasks" => reuse!(tasks, super::Tasks::make(&me.tasks)), b"yanked" => reuse!(yanked, super::Yanked::make(&me.mgr.yanked)), - b"layer" => { - reuse!(layer, Ok::<_, mlua::Error>(yazi_binding::Layer::from(me.layer()))) - } + b"input" => reuse!(input, super::Input::make(&me.input)), b"which" => reuse!(which, super::Which::make(&me.which)), + b"layer" => reuse!(layer, Ok::<_, mlua::Error>(me.layer())), _ => Value::Nil, }) }); diff --git a/yazi-actor/src/lives/file.rs b/yazi-actor/src/lives/file.rs index 3f259675..adca9c5f 100644 --- a/yazi-actor/src/lives/file.rs +++ b/yazi-actor/src/lives/file.rs @@ -1,37 +1,27 @@ use std::{ops::Deref, ptr}; -use mlua::{AnyUserData, IntoLua, UserData, UserDataFields, UserDataMethods, Value}; -use yazi_binding::{Range, Style, cached_field}; +use mlua::{AnyUserData, IntoLua, UserData, UserDataFields, UserDataMethods}; +use yazi_binding::{Range, style::Style}; use yazi_config::THEME; use yazi_shared::{path::AsPath, url::UrlLike}; -use super::Lives; -use crate::lives::PtrCell; +use super::{FILE_CACHE, Lives}; +use crate::lives::{CoreRef, PtrCell}; pub(super) struct File { idx: usize, folder: PtrCell, tab: PtrCell, - - v_cha: Option, - v_url: Option, - v_link_to: Option, - - v_name: Option, - v_path: Option, - v_cache: Option, - - v_bare: Option, } impl Deref for File { - type Target = yazi_fs::File; + type Target = yazi_fs::file::File; fn deref(&self) -> &Self::Target { &self.folder.files[self.idx] } } -impl AsRef for File { - fn as_ref(&self) -> &yazi_fs::File { self } +impl AsRef for File { + fn as_ref(&self) -> &yazi_fs::file::File { self } } impl File { @@ -42,24 +32,10 @@ impl File { ) -> mlua::Result { use hashbrown::hash_map::Entry; - Ok(match super::FILE_CACHE.borrow_mut().entry(PtrCell(&folder.files[idx])) { + Ok(match unsafe { (*FILE_CACHE.get()).assume_init_mut() }.entry(PtrCell(&folder.files[idx])) { Entry::Occupied(oe) => oe.into_mut().clone(), Entry::Vacant(ve) => { - let ud = Lives::scoped_userdata(Self { - idx, - folder: folder.into(), - tab: tab.into(), - - v_cha: None, - v_url: None, - v_link_to: None, - - v_name: None, - v_path: None, - v_cache: None, - - v_bare: None, - })?; + let ud = Lives::scoped_userdata(Self { idx, folder: folder.into(), tab: tab.into() })?; ve.insert(ud.clone()); ud } @@ -73,7 +49,7 @@ impl File { impl UserData for File { fn add_fields>(fields: &mut F) { yazi_binding::impl_file_fields!(fields); - cached_field!(fields, bare, |_, me| Ok(yazi_binding::File::new(&**me))); + fields.add_cached_field("bare", |_, me| Ok(yazi_fs::file::File::from(&**me))); fields.add_field_method_get("idx", |_, me| Ok(me.idx + 1)); fields.add_field_method_get("is_hovered", |_, me| Ok(me.is_hovered())); @@ -87,17 +63,15 @@ impl UserData for File { yazi_binding::impl_file_methods!(methods); methods.add_method("icon", |_, me, ()| { - use yazi_binding::Icon; // TODO: use a cache - Ok(yazi_config::THEME.icon.matches(me, me.is_hovered()).map(Icon::from)) + Ok(yazi_config::THEME.icon.matches(me, me.is_hovered())) }); methods.add_method("size", |_, me, ()| { Ok(if me.is_dir() { me.folder.files.sizes.get(&me.urn()).copied() } else { Some(me.len) }) }); methods.add_method("mime", |lua, me, ()| { - lua.named_registry_value::("cx")?.borrow_scoped(|core: &yazi_core::Core| { - core.mgr.mimetype.get(&me.url).map(|s| lua.create_string(s)).transpose() - })? + let core: CoreRef = lua.named_registry_value("cx")?; + core.mgr.mimetype.get(&me.url).map(|s| lua.create_string(s)).transpose() }); methods.add_method("prefix", |lua, me, ()| { if !me.url.has_trail() { @@ -109,20 +83,18 @@ impl UserData for File { Some(lua.create_string(comp.as_path().encoded_bytes())).transpose() }); methods.add_method("style", |lua, me, ()| { - lua.named_registry_value::("cx")?.borrow_scoped(|core: &yazi_core::Core| { - let mime = core.mgr.mimetype.get(&me.url).unwrap_or_default(); - THEME.filetype.match_style(me, mime).map(Style::from) - }) + let core: CoreRef = lua.named_registry_value("cx")?; + let mime = core.mgr.mimetype.get(&me.url).unwrap_or_default(); + Ok(THEME.filetype.match_style(me, mime).map(Style::from)) }); methods.add_method("is_yanked", |lua, me, ()| { - lua.named_registry_value::("cx")?.borrow_scoped(|core: &yazi_core::Core| { - if !core.mgr.yanked.contains(&me.url) { - 0u8 - } else if core.mgr.yanked.cut { - 2u8 - } else { - 1u8 - } + let core: CoreRef = lua.named_registry_value("cx")?; + Ok(if !core.mgr.yanked.contains(&me.url) { + 0u8 + } else if core.mgr.yanked.cut { + 2u8 + } else { + 1u8 }) }); methods.add_method("is_marked", |_, me, ()| { @@ -139,31 +111,30 @@ impl UserData for File { }); methods.add_method("is_selected", |_, me, ()| Ok(me.tab.selected.contains(&me.url))); methods.add_method("found", |lua, me, ()| { - lua.named_registry_value::("cx")?.borrow_scoped(|core: &yazi_core::Core| { - let Some(finder) = &core.active().finder else { - return Ok(None); - }; + let core: CoreRef = lua.named_registry_value("cx")?; + let Some(finder) = &core.active().finder else { + return Ok(None); + }; - let Some(idx) = finder.matched_idx(&me.folder, me.urn()) else { - return Ok(None); - }; + let Some(idx) = finder.matched_idx(&me.folder, me.urn()) else { + return Ok(None); + }; - Some(lua.create_sequence_from([idx.into_lua(lua)?, finder.matched.len().into_lua(lua)?])) - .transpose() - }) + lua.create_sequence_from([idx.into_lua(lua)?, finder.matched.len().into_lua(lua)?]).map(Some) }); methods.add_method("highlights", |lua, me, ()| { - lua.named_registry_value::("cx")?.borrow_scoped(|core: &yazi_core::Core| { - let Some(finder) = &core.active().finder else { - return None; - }; - if me.folder.url != me.tab.current.url { - return None; - } + let core: CoreRef = lua.named_registry_value("cx")?; + let Some(finder) = &core.active().finder else { + return Ok(None); + }; + if me.folder.url != me.tab.current.url { + return Ok(None); + } + let Some(Some(h)) = me.url.name().map(|s| finder.filter.highlighted(s)) else { + return Ok(None); + }; - let h = finder.filter.highlighted(me.url.name()?)?; - Some(h.into_iter().map(Range::from).collect::>()) - }) + lua.create_sequence_from(h.into_iter().map(Range::from)).map(Some) }); } } diff --git a/yazi-actor/src/lives/files.rs b/yazi-actor/src/lives/files.rs index 884f03dc..e67998ae 100644 --- a/yazi-actor/src/lives/files.rs +++ b/yazi-actor/src/lives/files.rs @@ -1,7 +1,7 @@ use std::ops::{Deref, Range}; -use mlua::{AnyUserData, MetaMethod, UserData, UserDataFields, UserDataMethods, Value}; -use yazi_binding::cached_field; +use mlua::{AnyUserData, MetaMethod, UserData, UserDataFields, UserDataMethods}; +use yazi_shim::mlua::UserDataFieldsExt; use super::{File, Filter, Lives, PtrCell}; @@ -9,8 +9,6 @@ pub(super) struct Files { window: Range, folder: PtrCell, tab: PtrCell, - - v_filter: Option, } impl Deref for Files { @@ -25,13 +23,13 @@ impl Files { folder: &yazi_core::tab::Folder, tab: &yazi_core::tab::Tab, ) -> mlua::Result { - Lives::scoped_userdata(Self { window, folder: folder.into(), tab: tab.into(), v_filter: None }) + Lives::scoped_userdata(Self { window, folder: folder.into(), tab: tab.into() }) } } impl UserData for Files { fn add_fields>(fields: &mut F) { - cached_field!(fields, filter, |_, me| me.filter().map(Filter::make).transpose()); + fields.add_static_field("filter", |_, me| me.filter().map(Filter::make).transpose()); } fn add_methods>(methods: &mut M) { diff --git a/yazi-actor/src/lives/folder.rs b/yazi-actor/src/lives/folder.rs index ab4ed872..e7fa3e38 100644 --- a/yazi-actor/src/lives/folder.rs +++ b/yazi-actor/src/lives/folder.rs @@ -1,8 +1,8 @@ use std::ops::{Deref, Range}; -use mlua::{AnyUserData, UserData, UserDataFields, Value}; -use yazi_binding::{FolderStage, Url, cached_field}; +use mlua::{AnyUserData, UserData, UserDataFields}; use yazi_config::LAYOUT; +use yazi_shim::mlua::UserDataFieldsExt; use super::{File, Files, Lives, PtrCell}; @@ -10,12 +10,6 @@ pub(super) struct Folder { window: Range, inner: PtrCell, tab: PtrCell, - - v_cwd: Option, - v_files: Option, - v_stage: Option, - v_window: Option, - v_hovered: Option, } impl Deref for Folder { @@ -38,30 +32,20 @@ impl Folder { } }; - Lives::scoped_userdata(Self { - window, - inner: inner.into(), - tab: tab.into(), - - v_cwd: None, - v_files: None, - v_stage: None, - v_window: None, - v_hovered: None, - }) + Lives::scoped_userdata(Self { window, inner: inner.into(), tab: tab.into() }) } } impl UserData for Folder { fn add_fields>(fields: &mut F) { - cached_field!(fields, cwd, |_, me| Ok(Url::new(&me.url))); - cached_field!(fields, files, |_, me| Files::make(0..me.files.len(), me, &me.tab)); - cached_field!(fields, stage, |_, me| Ok(FolderStage::new(me.stage.clone()))); - cached_field!(fields, window, |_, me| Files::make(me.window.clone(), me, &me.tab)); + fields.add_cached_field("cwd", |_, me| Ok(me.url.clone())); + fields.add_static_field("files", |_, me| Files::make(0..me.files.len(), me, &me.tab)); + fields.add_cached_field("stage", |_, me| Ok(me.stage.clone())); + fields.add_static_field("window", |_, me| Files::make(me.window.clone(), me, &me.tab)); fields.add_field_method_get("offset", |_, me| Ok(me.offset)); fields.add_field_method_get("cursor", |_, me| Ok(me.cursor)); - cached_field!(fields, hovered, |_, me| { + fields.add_static_field("hovered", |_, me| { me.hovered().map(|_| File::make(me.cursor, me, &me.tab)).transpose() }); } diff --git a/yazi-actor/src/lives/input.rs b/yazi-actor/src/lives/input.rs new file mode 100644 index 00000000..6bb6f555 --- /dev/null +++ b/yazi-actor/src/lives/input.rs @@ -0,0 +1,29 @@ +use std::ops::Deref; + +use mlua::{AnyUserData, UserData, UserDataFields}; +use yazi_shim::mlua::UserDataFieldsExt; + +use super::{Lives, PtrCell}; +use crate::lives::InputAlt; + +pub(super) struct Input { + inner: PtrCell, +} + +impl Deref for Input { + type Target = yazi_core::input::Input; + + fn deref(&self) -> &Self::Target { &self.inner } +} + +impl Input { + pub(super) fn make(inner: &yazi_core::input::Input) -> mlua::Result { + Lives::scoped_userdata(Self { inner: inner.into() }) + } +} + +impl UserData for Input { + fn add_fields>(fields: &mut F) { + fields.add_cached_field("alt", |_, me| me.alt.as_ref().map(InputAlt::make).transpose()); + } +} diff --git a/yazi-actor/src/lives/input_alt.rs b/yazi-actor/src/lives/input_alt.rs new file mode 100644 index 00000000..92c24208 --- /dev/null +++ b/yazi-actor/src/lives/input_alt.rs @@ -0,0 +1,26 @@ +use std::ops::Deref; + +use mlua::{AnyUserData, UserData, UserDataFields}; +use yazi_shim::mlua::UserDataFieldsExt; + +use super::{Lives, PtrCell}; + +pub(super) struct InputAlt(PtrCell); + +impl Deref for InputAlt { + type Target = yazi_core::input::InputAlt; + + fn deref(&self) -> &Self::Target { &self.0 } +} + +impl InputAlt { + pub(super) fn make(inner: &yazi_core::input::InputAlt) -> mlua::Result { + Lives::scoped_userdata(Self(inner.into())) + } +} + +impl UserData for InputAlt { + fn add_fields>(fields: &mut F) { + fields.add_cached_field("value", |lua, me| lua.create_string(me.lock().value())); + } +} diff --git a/yazi-actor/src/lives/lives.rs b/yazi-actor/src/lives/lives.rs index 1b969cd4..64b8046f 100644 --- a/yazi-actor/src/lives/lives.rs +++ b/yazi-actor/src/lives/lives.rs @@ -1,39 +1,38 @@ -use std::cell::RefCell; +use std::mem::MaybeUninit; use hashbrown::HashMap; use mlua::{AnyUserData, UserData}; use scopeguard::defer; use tracing::error; use yazi_plugin::LUA; -use yazi_shim::cell::RoCell; use super::{Core, PtrCell}; +use crate::lives::MutCell; -static TO_DESTROY: RoCell>> = RoCell::new_const(RefCell::new(Vec::new())); -pub(super) static FILE_CACHE: RoCell, AnyUserData>>> = - RoCell::new(); +pub(super) static TO_DESTROY: MutCell> = MutCell::new(Vec::new()); +pub(super) static FILE_CACHE: MutCell< + MaybeUninit, AnyUserData>>, +> = MutCell::new(MaybeUninit::uninit()); pub struct Lives; impl Lives { - pub fn scope(core: &yazi_core::Core, f: F) -> mlua::Result + pub fn scope(core: &mut yazi_core::Core, f: F) -> mlua::Result where - F: FnOnce() -> mlua::Result, + F: FnOnce(&mut yazi_core::Core) -> mlua::Result, { - FILE_CACHE.init(Default::default()); - defer! { FILE_CACHE.drop(); } - - let result = LUA.scope(|scope| { - scope.add_destructor(|| { - for ud in TO_DESTROY.borrow_mut().drain(..) { + defer! { + unsafe { + (*FILE_CACHE.get()).assume_init_mut().clear(); + for ud in (*TO_DESTROY.get()).drain(..) { ud.destroy().expect("failed to destruct scoped userdata"); } - }); + } + } - LUA.set_named_registry_value("cx", scope.create_any_userdata_ref(core)?)?; - LUA.globals().raw_set("cx", Core::make(core)?)?; - f() - }); + LUA.set_named_registry_value("cx", Core::make(core)?)?; + LUA.globals().raw_set("cx", Core::make(core)?)?; + let result = f(core); if let Err(ref e) = result { error!("{e}"); @@ -46,7 +45,7 @@ impl Lives { T: UserData + 'static, { let ud = LUA.create_userdata(data)?; - TO_DESTROY.borrow_mut().push(ud.clone()); + unsafe { &mut *TO_DESTROY.get() }.push(ud.clone()); Ok(ud) } } diff --git a/yazi-actor/src/lives/mod.rs b/yazi-actor/src/lives/mod.rs index d6c82311..ea093ddb 100644 --- a/yazi-actor/src/lives/mod.rs +++ b/yazi-actor/src/lives/mod.rs @@ -1 +1,5 @@ -yazi_macro::mod_flat!(core file files filter finder folder lives mode preference preview ptr selected tab tabs task tasks which yanked); +yazi_macro::mod_flat!(behavior core file files filter finder folder input input_alt lives mode mut_cell preference preview ptr selected tab tabs task tasks which yanked); + +pub(super) fn init() { + unsafe { FILE_CACHE.get().write(std::mem::MaybeUninit::new(<_>::default())) }; +} diff --git a/yazi-actor/src/lives/mut_cell.rs b/yazi-actor/src/lives/mut_cell.rs new file mode 100644 index 00000000..25b27c8d --- /dev/null +++ b/yazi-actor/src/lives/mut_cell.rs @@ -0,0 +1,11 @@ +use std::cell::UnsafeCell; + +pub(super) struct MutCell(UnsafeCell); + +unsafe impl Sync for MutCell {} + +impl MutCell { + pub(super) const fn new(value: T) -> Self { Self(UnsafeCell::new(value)) } + + pub(super) fn get(&self) -> *mut T { self.0.get() } +} diff --git a/yazi-actor/src/lives/preference.rs b/yazi-actor/src/lives/preference.rs index 011a8c64..db772993 100644 --- a/yazi-actor/src/lives/preference.rs +++ b/yazi-actor/src/lives/preference.rs @@ -1,18 +1,12 @@ use std::ops::Deref; -use mlua::{AnyUserData, UserData, UserDataFields, Value}; -use yazi_binding::cached_field; -use yazi_shim::strum::IntoStr; +use mlua::{AnyUserData, UserData, UserDataFields}; +use yazi_shim::{mlua::UserDataFieldsExt, strum::IntoStr}; use super::{Lives, PtrCell}; pub(super) struct Preference { inner: PtrCell, - - v_name: Option, - v_linemode: Option, - - v_sort_by: Option, } impl Deref for Preference { @@ -23,26 +17,19 @@ impl Deref for Preference { impl Preference { pub(super) fn make(inner: &yazi_core::tab::Preference) -> mlua::Result { - Lives::scoped_userdata(Self { - inner: inner.into(), - - v_name: None, - v_linemode: None, - - v_sort_by: None, - }) + Lives::scoped_userdata(Self { inner: inner.into() }) } } impl UserData for Preference { fn add_fields>(fields: &mut F) { // Display - cached_field!(fields, name, |lua, me| lua.create_string(&me.name)); - cached_field!(fields, linemode, |lua, me| lua.create_string(&*me.linemode)); + fields.add_cached_field("name", |lua, me| lua.create_string(&me.name)); + fields.add_cached_field("linemode", |lua, me| lua.create_string(&*me.linemode)); fields.add_field_method_get("show_hidden", |_, me| Ok(me.show_hidden)); // Sorting - cached_field!(fields, sort_by, |_, me| Ok(me.sort_by.into_str())); + fields.add_cached_field("sort_by", |_, me| Ok(me.sort_by.into_str())); fields.add_field_method_get("sort_sensitive", |_, me| Ok(me.sort_sensitive)); fields.add_field_method_get("sort_reverse", |_, me| Ok(me.sort_reverse)); fields.add_field_method_get("sort_dir_first", |_, me| Ok(me.sort_dir_first)); diff --git a/yazi-actor/src/lives/preview.rs b/yazi-actor/src/lives/preview.rs index 5390f48d..3cb58345 100644 --- a/yazi-actor/src/lives/preview.rs +++ b/yazi-actor/src/lives/preview.rs @@ -1,15 +1,13 @@ use std::ops::Deref; -use mlua::{AnyUserData, UserData, UserDataFields, Value}; -use yazi_binding::cached_field; +use mlua::{AnyUserData, UserData, UserDataFields}; use yazi_config::LAYOUT; +use yazi_shim::mlua::UserDataFieldsExt; use super::{Folder, Lives, PtrCell}; pub(super) struct Preview { tab: PtrCell, - - v_folder: Option, } impl Deref for Preview { @@ -22,17 +20,16 @@ impl Deref for Preview { impl Preview { pub(super) fn make(tab: &yazi_core::tab::Tab) -> mlua::Result { - Lives::scoped_userdata(Self { tab: tab.into(), v_folder: None }) + Lives::scoped_userdata(Self { tab: tab.into() }) } } impl UserData for Preview { fn add_fields>(fields: &mut F) { fields.add_field_method_get("skip", |_, me| Ok(me.skip)); - // TODO: Make sure we need this ? fields.add_field_method_get("search_idx", |_, me| Ok(me.search_idx)); - cached_field!(fields, folder, |_, me| { + fields.add_static_field("folder", |_, me| { me.tab .hovered_folder() .map(|f| { diff --git a/yazi-actor/src/lives/selected.rs b/yazi-actor/src/lives/selected.rs index 2956dd37..68694257 100644 --- a/yazi-actor/src/lives/selected.rs +++ b/yazi-actor/src/lives/selected.rs @@ -1,4 +1,5 @@ use mlua::AnyUserData; +use yazi_shared::url::UrlBuf; use super::Lives; use crate::lives::PtrCell; @@ -11,7 +12,7 @@ impl Selected { let inner = PtrCell::from(inner); Lives::scoped_userdata(yazi_binding::Iter::new( - inner.as_static().values().map(yazi_binding::Url::new), + inner.as_static().values().map(UrlBuf::from), Some(inner.len()), )) } diff --git a/yazi-actor/src/lives/tab.rs b/yazi-actor/src/lives/tab.rs index 69d5abb0..af7e8ba8 100644 --- a/yazi-actor/src/lives/tab.rs +++ b/yazi-actor/src/lives/tab.rs @@ -1,21 +1,13 @@ use std::{borrow::Cow, ops::Deref}; -use mlua::{AnyUserData, UserData, UserDataFields, UserDataMethods, Value}; -use yazi_binding::{Id, UrlRef, cached_field}; +use mlua::{AnyUserData, UserData, UserDataFields, UserDataMethods}; +use yazi_shared::url::UrlRef; +use yazi_shim::mlua::UserDataFieldsExt; use super::{Finder, Folder, Lives, Mode, Preference, Preview, PtrCell, Selected}; pub(super) struct Tab { inner: PtrCell, - - v_name: Option, - v_mode: Option, - v_pref: Option, - v_current: Option, - v_parent: Option, - v_selected: Option, - v_preview: Option, - v_finder: Option, } impl Deref for Tab { @@ -26,42 +18,29 @@ impl Deref for Tab { impl Tab { pub(super) fn make(inner: &yazi_core::tab::Tab) -> mlua::Result { - Lives::scoped_userdata(Self { - inner: inner.into(), - - v_name: None, - v_mode: None, - v_pref: None, - v_current: None, - v_parent: None, - v_selected: None, - v_preview: None, - v_finder: None, - }) + Lives::scoped_userdata(Self { inner: inner.into() }) } } impl UserData for Tab { fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - cached_field!(fields, name, |lua, me| { - match me.name() { - Cow::Borrowed(s) => lua.create_string(s), - Cow::Owned(s) => lua.create_external_string(s), - } + fields.add_field_method_get("id", |_, me| Ok(me.id)); + fields.add_cached_field("name", |lua, me| match me.name() { + Cow::Borrowed(s) => lua.create_string(s), + Cow::Owned(s) => lua.create_external_string(s), }); - cached_field!(fields, mode, |_, me| Mode::make(&me.mode)); - cached_field!(fields, pref, |_, me| Preference::make(&me.pref)); - cached_field!(fields, current, |_, me| Folder::make(None, &me.current, me)); - cached_field!(fields, parent, |_, me| { + fields.add_static_field("mode", |_, me| Mode::make(&me.mode)); + fields.add_static_field("pref", |_, me| Preference::make(&me.pref)); + fields.add_static_field("current", |_, me| Folder::make(None, &me.current, me)); + fields.add_static_field("parent", |_, me| { me.parent.as_ref().map(|f| Folder::make(None, f, me)).transpose() }); - cached_field!(fields, selected, |_, me| Selected::make(&me.selected)); + fields.add_static_field("selected", |_, me| Selected::make(&me.selected)); - cached_field!(fields, preview, |_, me| Preview::make(me)); - cached_field!(fields, finder, |_, me| me.finder.as_ref().map(Finder::make).transpose()); + fields.add_static_field("preview", |_, me| Preview::make(me)); + fields.add_static_field("finder", |_, me| me.finder.as_ref().map(Finder::make).transpose()); } fn add_methods>(methods: &mut M) { diff --git a/yazi-actor/src/lives/task.rs b/yazi-actor/src/lives/task.rs index 7deaae8e..964a2f63 100644 --- a/yazi-actor/src/lives/task.rs +++ b/yazi-actor/src/lives/task.rs @@ -1,16 +1,13 @@ use std::ops::Deref; -use mlua::{AnyUserData, LuaSerdeExt, UserData, UserDataFields, Value}; -use yazi_binding::{SER_OPT, cached_field}; +use mlua::{AnyUserData, LuaSerdeExt, UserData, UserDataFields}; use yazi_scheduler::Progress; +use yazi_shim::mlua::{SER_OPT, UserDataFieldsExt}; use super::{Lives, PtrCell}; pub(super) struct TaskSnap { inner: PtrCell, - - v_title: Option, - v_prog: Option, } impl Deref for TaskSnap { @@ -21,14 +18,14 @@ impl Deref for TaskSnap { impl TaskSnap { pub(super) fn make(inner: &yazi_scheduler::TaskSnap) -> mlua::Result { - Lives::scoped_userdata(Self { inner: inner.into(), v_title: None, v_prog: None }) + Lives::scoped_userdata(Self { inner: inner.into() }) } } impl UserData for TaskSnap { fn add_fields>(fields: &mut F) { - cached_field!(fields, title, |lua, me| lua.create_string(&me.title)); - cached_field!(fields, prog, |lua, me| lua.to_value_with(&me.prog, SER_OPT)); + fields.add_cached_field("title", |lua, me| lua.create_string(&me.title)); + fields.add_cached_field("prog", |lua, me| lua.to_value_with(&me.prog, SER_OPT)); fields.add_field_method_get("running", |_, me| Ok(me.prog.running())); fields.add_field_method_get("cooked", |_, me| Ok(me.prog.cooked())); diff --git a/yazi-actor/src/lives/tasks.rs b/yazi-actor/src/lives/tasks.rs index e547c138..b00cf715 100644 --- a/yazi-actor/src/lives/tasks.rs +++ b/yazi-actor/src/lives/tasks.rs @@ -1,16 +1,13 @@ use std::ops::Deref; -use mlua::{AnyUserData, LuaSerdeExt, UserData, UserDataFields, Value}; -use yazi_binding::{SER_OPT, cached_field}; +use mlua::{AnyUserData, LuaSerdeExt, UserData, UserDataFields}; +use yazi_shim::mlua::{SER_OPT, UserDataFieldsExt}; use super::{Lives, PtrCell}; -use crate::lives::TaskSnap; +use crate::lives::{Behavior, TaskSnap}; pub(super) struct Tasks { inner: PtrCell, - - v_snaps: Option, - v_summary: Option, } impl Deref for Tasks { @@ -21,12 +18,7 @@ impl Deref for Tasks { impl Tasks { pub(super) fn make(inner: &yazi_core::tasks::Tasks) -> mlua::Result { - Lives::scoped_userdata(Self { - inner: inner.into(), - - v_snaps: None, - v_summary: None, - }) + Lives::scoped_userdata(Self { inner: inner.into() }) } } @@ -34,7 +26,9 @@ impl UserData for Tasks { fn add_fields>(fields: &mut F) { fields.add_field_method_get("cursor", |_, me| Ok(me.cursor)); - cached_field!(fields, snaps, |lua, me| { + fields.add_static_field("behavior", |_, me| Behavior::make(&me.scheduler.behavior)); + + fields.add_static_field("snaps", |lua, me| { let tbl = lua.create_table_with_capacity(me.snaps.len(), 0)?; for snap in &me.snaps { tbl.raw_push(TaskSnap::make(snap)?)?; @@ -42,6 +36,6 @@ impl UserData for Tasks { Ok(tbl) }); - cached_field!(fields, summary, |lua, me| lua.to_value_with(&me.summary, SER_OPT)); + fields.add_cached_field("summary", |lua, me| lua.to_value_with(&me.summary, SER_OPT)); } } diff --git a/yazi-actor/src/lives/which.rs b/yazi-actor/src/lives/which.rs index 66016cfd..3e80cb7f 100644 --- a/yazi-actor/src/lives/which.rs +++ b/yazi-actor/src/lives/which.rs @@ -1,15 +1,12 @@ use std::ops::Deref; -use mlua::{AnyUserData, UserData, UserDataFields, Value}; -use yazi_binding::cached_field; +use mlua::{AnyUserData, UserData, UserDataFields}; +use yazi_shim::mlua::UserDataFieldsExt; use super::{Lives, PtrCell}; pub(super) struct Which { inner: PtrCell, - - v_tx: Option, - v_cands: Option, } impl Deref for Which { @@ -20,16 +17,16 @@ impl Deref for Which { impl Which { pub(super) fn make(inner: &yazi_core::which::Which) -> mlua::Result { - Lives::scoped_userdata(Self { inner: inner.into(), v_tx: None, v_cands: None }) + Lives::scoped_userdata(Self { inner: inner.into() }) } } impl UserData for Which { fn add_fields>(fields: &mut F) { - cached_field!(fields, tx, |_, me| Ok(me.tx.clone().map(yazi_binding::MpscUnboundedTx))); + fields.add_cached_field("tx", |_, me| Ok(me.tx.clone().map(yazi_binding::MpscUnboundedTx))); fields.add_field_method_get("times", |_, me| Ok(me.inner.times)); - cached_field!(fields, cands, |lua, me| { - lua.create_sequence_from(me.inner.cands.iter().cloned().map(yazi_binding::ChordCow)) + fields.add_cached_field("cands", |lua, me| { + lua.create_sequence_from(me.inner.cands.iter().cloned()) }); fields.add_field_method_get("active", |_, me| Ok(me.inner.active)); diff --git a/yazi-actor/src/lives/yanked.rs b/yazi-actor/src/lives/yanked.rs index d5b9ee92..1f30826c 100644 --- a/yazi-actor/src/lives/yanked.rs +++ b/yazi-actor/src/lives/yanked.rs @@ -1,7 +1,9 @@ use std::ops::Deref; use mlua::{AnyUserData, MetaMethod, MultiValue, ObjectLike, UserData, UserDataFields, UserDataMethods}; -use yazi_binding::{Iter, get_metatable}; +use yazi_binding::Iter; +use yazi_shared::url::UrlBuf; +use yazi_shim::mlua::get_metatable; use super::{Lives, PtrCell}; @@ -23,7 +25,7 @@ impl Yanked { Lives::scoped_userdata(Self { inner, iter: Lives::scoped_userdata(Iter::new( - inner.as_static().iter().map(yazi_binding::Url::new), + inner.as_static().iter().map(UrlBuf::from), Some(inner.len()), ))?, }) diff --git a/yazi-actor/src/mgr/bulk_create.rs b/yazi-actor/src/mgr/bulk_create.rs index 1b6defa0..e96f59c3 100644 --- a/yazi-actor/src/mgr/bulk_create.rs +++ b/yazi-actor/src/mgr/bulk_create.rs @@ -1,18 +1,18 @@ -use std::{fmt::{self, Display}, io::{self, Read, Write}, path::{MAIN_SEPARATOR, Path}, sync::Arc}; +use std::{fmt::{self, Display}, io::{self, Read, Write}, path::{MAIN_SEPARATOR, Path}}; use anyhow::{Result, anyhow}; use scopeguard::defer; use yazi_binding::Permit; -use yazi_config::{YAZI, opener::OpenerRule}; -use yazi_fs::{File, FilesOp, Splatter, provider::{Provider, local::Local}}; +use yazi_config::{YAZI, opener::OpenerRuleArc}; +use yazi_fs::{FilesOp, Splatter, file::File, provider::{Provider, local::Local}}; use yazi_macro::{succ, writef}; use yazi_parser::VoidForm; use yazi_proxy::TasksProxy; use yazi_scheduler::{AppProxy, NotifyProxy}; use yazi_shared::{data::Data, strand::Strand, url::{AsUrl, UrlBuf, UrlCow, UrlLike}}; use yazi_shim::path::CROSS_SEPARATOR; -use yazi_term::{YIELD_TO_SUBPROCESS, sequence::EraseScreen}; -use yazi_tty::TTY; +use yazi_term::YIELD_TO_SUBPROCESS; +use yazi_tty::{TTY, sequence::EraseScreen}; use yazi_vfs::{VfsFile, provider}; use yazi_watcher::WATCHER; @@ -106,7 +106,7 @@ impl BulkCreate { Ok(()) } - fn opener() -> Option> { + fn opener() -> Option { YAZI .open .match_dummy(Path::new("bulk-create.txt"), "text/plain") diff --git a/yazi-actor/src/mgr/bulk_rename.rs b/yazi-actor/src/mgr/bulk_rename.rs index b472aa44..0bd71e9b 100644 --- a/yazi-actor/src/mgr/bulk_rename.rs +++ b/yazi-actor/src/mgr/bulk_rename.rs @@ -1,20 +1,20 @@ -use std::{hash::Hash, io::{Read, Write}, ops::Deref, path::Path, sync::Arc}; +use std::{hash::Hash, io::{Read, Write}, ops::Deref, path::Path}; use anyhow::{Result, anyhow}; use hashbrown::HashMap; use scopeguard::defer; use tokio::io::AsyncWriteExt; use yazi_binding::Permit; -use yazi_config::{YAZI, opener::OpenerRule}; +use yazi_config::{YAZI, opener::OpenerRuleArc}; use yazi_dds::Pubsub; -use yazi_fs::{File, FilesOp, Splatter, max_common_root, path::skip_url, provider::{FileBuilder, Provider, local::{Gate, Local}}}; +use yazi_fs::{FilesOp, Splatter, file::File, max_common_root, path::skip_url, provider::{FileBuilder, Provider, local::{Gate, Local}}}; use yazi_macro::{err, succ, writef}; use yazi_parser::VoidForm; use yazi_proxy::TasksProxy; use yazi_scheduler::{AppProxy, NotifyProxy}; use yazi_shared::{data::Data, path::PathDyn, strand::{AsStrand, AsStrandJoin, Strand, StrandBuf, StrandLike}, url::{AsUrl, UrlBuf, UrlCow, UrlLike}}; -use yazi_term::{YIELD_TO_SUBPROCESS, sequence::EraseScreen}; -use yazi_tty::TTY; +use yazi_term::YIELD_TO_SUBPROCESS; +use yazi_tty::{TTY, sequence::EraseScreen}; use yazi_vfs::{VfsFile, maybe_exists, provider}; use yazi_watcher::WATCHER; @@ -152,7 +152,7 @@ impl BulkRename { Ok(()) } - fn opener() -> Option> { + fn opener() -> Option { YAZI .open .match_dummy(Path::new("bulk-rename.txt"), "text/plain") diff --git a/yazi-actor/src/mgr/cd.rs b/yazi-actor/src/mgr/cd.rs index 7192af9b..11da268d 100644 --- a/yazi-actor/src/mgr/cd.rs +++ b/yazi-actor/src/mgr/cd.rs @@ -3,10 +3,10 @@ use std::{mem, time::Duration}; use anyhow::Result; use tokio::pin; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; -use yazi_config::popup::InputCfg; +use yazi_config::YAZI; use yazi_core::mgr::CdSource; use yazi_dds::Pubsub; -use yazi_fs::{File, FilesOp, path::{clean_url, expand_url}}; +use yazi_fs::{FilesOp, file::File, path::{clean_url, expand_url}}; use yazi_macro::{act, err, input, render, succ}; use yazi_parser::mgr::CdForm; use yazi_proxy::{CmpProxy, MgrProxy}; @@ -63,7 +63,7 @@ impl Actor for Cd { impl Cd { fn cd_interactive(cx: &mut Ctx) -> Result { - let input = input!(cx, InputCfg::cd(cx.cwd().as_url()))?; + let input = input!(cx, YAZI.input.cd(cx.cwd().as_url()))?; tokio::spawn(async move { let rx = Debounce::new(UnboundedReceiverStream::new(input), Duration::from_millis(50)); diff --git a/yazi-actor/src/mgr/create.rs b/yazi-actor/src/mgr/create.rs index f1c7d2f1..08c6b027 100644 --- a/yazi-actor/src/mgr/create.rs +++ b/yazi-actor/src/mgr/create.rs @@ -1,6 +1,6 @@ use anyhow::{Result, bail}; -use yazi_config::popup::{ConfirmCfg, InputCfg}; -use yazi_fs::{File, FilesOp}; +use yazi_config::{YAZI, popup::ConfirmCfg}; +use yazi_fs::{FilesOp, file::File}; use yazi_macro::{input, ok_or_not_found, succ}; use yazi_parser::mgr::CreateForm; use yazi_proxy::{ConfirmProxy, MgrProxy}; @@ -20,7 +20,7 @@ impl Actor for Create { fn act(cx: &mut Ctx, form: Self::Form) -> Result { let cwd = cx.cwd().to_owned(); - let mut input = input!(cx, InputCfg::create(form.dir))?; + let mut input = input!(cx, YAZI.input.create(form.dir))?; tokio::spawn(async move { let Some(InputEvent::Submit(name)) = input.recv().await else { return }; diff --git a/yazi-actor/src/mgr/download.rs b/yazi-actor/src/mgr/download.rs index 8e9c174e..61b02d8a 100644 --- a/yazi-actor/src/mgr/download.rs +++ b/yazi-actor/src/mgr/download.rs @@ -4,7 +4,7 @@ use anyhow::Result; use futures::{StreamExt, stream::FuturesUnordered}; use hashbrown::HashSet; use yazi_core::mgr::OpenOpt; -use yazi_fs::{File, FsScheme, provider::{Provider, local::Local}}; +use yazi_fs::{FsScheme, file::File, provider::{Provider, local::Local}}; use yazi_macro::succ; use yazi_parser::mgr::DownloadForm; use yazi_proxy::MgrProxy; diff --git a/yazi-actor/src/mgr/filter.rs b/yazi-actor/src/mgr/filter.rs index dd070369..ade4752f 100644 --- a/yazi-actor/src/mgr/filter.rs +++ b/yazi-actor/src/mgr/filter.rs @@ -3,7 +3,7 @@ use std::time::Duration; use anyhow::Result; use tokio::pin; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; -use yazi_config::popup::InputCfg; +use yazi_config::YAZI; use yazi_core::mgr::FilterOpt; use yazi_macro::{input, succ}; use yazi_parser::mgr::FilterForm; @@ -21,7 +21,7 @@ impl Actor for Filter { const NAME: &str = "filter"; fn act(cx: &mut Ctx, Self::Form { opt }: Self::Form) -> Result { - let input = input!(cx, InputCfg::filter())?; + let input = input!(cx, YAZI.input.filter())?; tokio::spawn(async move { let rx = Debounce::new(UnboundedReceiverStream::new(input), Duration::from_millis(50)); diff --git a/yazi-actor/src/mgr/find.rs b/yazi-actor/src/mgr/find.rs index 8d1bcaf9..262df048 100644 --- a/yazi-actor/src/mgr/find.rs +++ b/yazi-actor/src/mgr/find.rs @@ -3,7 +3,7 @@ use std::time::Duration; use anyhow::Result; use tokio::pin; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; -use yazi_config::popup::InputCfg; +use yazi_config::YAZI; use yazi_core::mgr::FindDoOpt; use yazi_macro::{input, succ}; use yazi_parser::mgr::FindForm; @@ -21,7 +21,7 @@ impl Actor for Find { const NAME: &str = "find"; fn act(cx: &mut Ctx, form: Self::Form) -> Result { - let input = input!(cx, InputCfg::find(form.prev))?; + let input = input!(cx, YAZI.input.find(form.prev))?; tokio::spawn(async move { let rx = Debounce::new(UnboundedReceiverStream::new(input), Duration::from_millis(50)); diff --git a/yazi-actor/src/mgr/open.rs b/yazi-actor/src/mgr/open.rs index 4a39468c..2d789ed0 100644 --- a/yazi-actor/src/mgr/open.rs +++ b/yazi-actor/src/mgr/open.rs @@ -3,7 +3,7 @@ use futures::StreamExt; use hashbrown::HashSet; use yazi_boot::ARGS; use yazi_core::mgr::OpenDoOpt; -use yazi_fs::File; +use yazi_fs::file::File; use yazi_macro::{act, succ}; use yazi_parser::mgr::OpenForm; use yazi_proxy::MgrProxy; diff --git a/yazi-actor/src/mgr/open_do.rs b/yazi-actor/src/mgr/open_do.rs index defae85b..253151fb 100644 --- a/yazi-actor/src/mgr/open_do.rs +++ b/yazi-actor/src/mgr/open_do.rs @@ -1,7 +1,8 @@ use anyhow::Result; use hashbrown::HashMap; use indexmap::IndexSet; -use yazi_config::{YAZI, popup::PickCfg}; +use yazi_config::YAZI; +use yazi_fs::file::File; use yazi_macro::succ; use yazi_parser::mgr::OpenDoForm; use yazi_proxy::{PickProxy, TasksProxy}; @@ -40,7 +41,7 @@ impl Actor for OpenDo { succ!(); } - let pick = PickProxy::show(PickCfg::open(openers.iter().map(|o| o.desc()).collect())); + let pick = PickProxy::show(YAZI.pick.open(openers.iter().map(|o| o.desc()).collect())); let urls: Vec<_> = [UrlCow::default()] .into_iter() .chain(targets.into_iter().map(|(file, _)| file.url.into())) @@ -63,7 +64,7 @@ impl Actor for OpenDo { impl OpenDo { // TODO: remove - fn match_and_open(cx: &Ctx, cwd: UrlBuf, targets: Vec<(yazi_fs::File, &str)>) { + fn match_and_open(cx: &Ctx, cwd: UrlBuf, targets: Vec<(File, &str)>) { let mut openers = HashMap::new(); for (file, mime) in targets { if let Some(open) = YAZI.open.matches(&file, mime) diff --git a/yazi-actor/src/mgr/rename.rs b/yazi-actor/src/mgr/rename.rs index 1d956406..22d54467 100644 --- a/yazi-actor/src/mgr/rename.rs +++ b/yazi-actor/src/mgr/rename.rs @@ -1,11 +1,11 @@ use anyhow::Result; -use yazi_config::popup::{ConfirmCfg, InputCfg}; +use yazi_config::{YAZI, popup::ConfirmCfg}; use yazi_dds::Pubsub; -use yazi_fs::{File, FilesOp}; +use yazi_fs::{FilesOp, file::File}; use yazi_macro::{act, err, input, ok_or_not_found, succ}; use yazi_parser::mgr::RenameForm; use yazi_proxy::{ConfirmProxy, MgrProxy}; -use yazi_shared::{Id, data::Data, url::{UrlBuf, UrlLike}}; +use yazi_shared::{data::Data, id::Id, url::{UrlBuf, UrlLike}}; use yazi_vfs::{VfsFile, maybe_exists, provider}; use yazi_watcher::WATCHER; use yazi_widgets::input::InputEvent; @@ -42,7 +42,7 @@ impl Actor for Rename { }; let (tab, old) = (cx.tab().id, hovered.url_owned()); - let mut input = input!(cx, InputCfg::rename().with_value(name).with_cursor(cursor))?; + let mut input = input!(cx, YAZI.input.rename().with_value(name).with_cursor(cursor))?; tokio::spawn(async move { let Some(InputEvent::Submit(name)) = input.recv().await else { return }; diff --git a/yazi-actor/src/mgr/reveal.rs b/yazi-actor/src/mgr/reveal.rs index bc83fdfd..e7133d06 100644 --- a/yazi-actor/src/mgr/reveal.rs +++ b/yazi-actor/src/mgr/reveal.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use yazi_fs::{File, FilesOp}; +use yazi_fs::{FilesOp, file::File}; use yazi_macro::{act, render, succ}; use yazi_parser::mgr::RevealForm; use yazi_shared::{data::Data, url::UrlLike}; diff --git a/yazi-actor/src/mgr/search.rs b/yazi-actor/src/mgr/search.rs index 9602490b..70b380a8 100644 --- a/yazi-actor/src/mgr/search.rs +++ b/yazi-actor/src/mgr/search.rs @@ -3,7 +3,7 @@ use std::{borrow::Cow, time::Duration}; use anyhow::Result; use tokio::pin; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; -use yazi_config::popup::InputCfg; +use yazi_config::YAZI; use yazi_core::mgr::{CdSource, SearchVia}; use yazi_fs::{FilesOp, cha::Cha}; use yazi_macro::{act, input, succ}; @@ -28,7 +28,7 @@ impl Actor for Search { handle.abort(); } - let mut input = input!(cx, InputCfg::search(opt.via.into()).with_value(&*opt.subject))?; + let mut input = input!(cx, YAZI.input.search(opt.via.into()).with_value(&*opt.subject))?; tokio::spawn(async move { if let Some(InputEvent::Submit(subject)) = input.recv().await { diff --git a/yazi-actor/src/mgr/shell.rs b/yazi-actor/src/mgr/shell.rs index f935b359..33fb79c3 100644 --- a/yazi-actor/src/mgr/shell.rs +++ b/yazi-actor/src/mgr/shell.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use anyhow::Result; -use yazi_config::popup::InputCfg; +use yazi_config::YAZI; use yazi_macro::{act, input, succ}; use yazi_parser::mgr::ShellForm; use yazi_proxy::TasksProxy; @@ -25,7 +25,10 @@ impl Actor for Shell { let selected: Vec<_> = cx.tab().hovered_and_selected().cloned().map(Into::into).collect(); let input = if form.interactive { - Some(input!(cx, InputCfg::shell(form.block).with_value(&*form.run).with_cursor(form.cursor))?) + Some(input!( + cx, + YAZI.input.shell(form.block).with_value(&*form.run).with_cursor(form.cursor) + )?) } else { None }; diff --git a/yazi-actor/src/mgr/tab_rename.rs b/yazi-actor/src/mgr/tab_rename.rs index 238c5067..7a037129 100644 --- a/yazi-actor/src/mgr/tab_rename.rs +++ b/yazi-actor/src/mgr/tab_rename.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use anyhow::Result; -use yazi_config::popup::InputCfg; +use yazi_config::YAZI; use yazi_macro::{act, input, render, succ}; use yazi_parser::mgr::TabRenameForm; use yazi_proxy::MgrProxy; @@ -29,7 +29,7 @@ impl Actor for TabRename { let mut input = input!( cx, - InputCfg::tab_rename().with_value(form.name.unwrap_or(Cow::Borrowed(&pref.name))) + YAZI.input.tab_rename().with_value(form.name.unwrap_or(Cow::Borrowed(&pref.name))) )?; tokio::spawn(async move { diff --git a/yazi-actor/src/notify/tick.rs b/yazi-actor/src/notify/tick.rs index 1ee7b610..6cb9b256 100644 --- a/yazi-actor/src/notify/tick.rs +++ b/yazi-actor/src/notify/tick.rs @@ -1,7 +1,7 @@ use std::time::Duration; use anyhow::Result; -use ratatui::layout::Rect; +use ratatui_core::layout::Rect; use yazi_core::notify::Notify; use yazi_macro::{render, render_partial, succ}; use yazi_parser::notify::TickForm; diff --git a/yazi-actor/src/tasks/inspect.rs b/yazi-actor/src/tasks/inspect.rs index 22150212..e3606cd0 100644 --- a/yazi-actor/src/tasks/inspect.rs +++ b/yazi-actor/src/tasks/inspect.rs @@ -4,13 +4,12 @@ use anyhow::Result; use scopeguard::defer; use tokio::{io::{AsyncReadExt, stdin}, select, sync::mpsc, time}; use yazi_binding::Permit; -use yazi_term::TERM; use yazi_macro::{succ, writef}; use yazi_parser::VoidForm; use yazi_scheduler::AppProxy; use yazi_shared::data::Data; -use yazi_term::{YIELD_TO_SUBPROCESS, sequence::EraseScreen}; -use yazi_tty::TTY; +use yazi_term::{TERM, YIELD_TO_SUBPROCESS}; +use yazi_tty::{TTY, sequence::EraseScreen}; use crate::{Actor, Ctx}; diff --git a/yazi-actor/src/tasks/spawn.rs b/yazi-actor/src/tasks/spawn.rs index 0928fe3c..efa4b535 100644 --- a/yazi-actor/src/tasks/spawn.rs +++ b/yazi-actor/src/tasks/spawn.rs @@ -15,6 +15,8 @@ impl Actor for Spawn { fn act(cx: &mut Ctx, form: Self::Form) -> Result { succ!(match form.opt { + TaskOpt::Cut(r#in) => cx.tasks.scheduler.file_cut(r#in), + TaskOpt::Plugin(r#in) => cx.tasks.scheduler.plugin_entry(r#in), }) } diff --git a/yazi-adapter/Cargo.toml b/yazi-adapter/Cargo.toml index f3acea37..886c0128 100644 --- a/yazi-adapter/Cargo.toml +++ b/yazi-adapter/Cargo.toml @@ -19,18 +19,19 @@ yazi-fs = { path = "../yazi-fs", version = "26.5.6" } yazi-macro = { path = "../yazi-macro", version = "26.5.6" } yazi-shared = { path = "../yazi-shared", version = "26.5.6" } yazi-shim = { path = "../yazi-shim", version = "26.5.6" } -yazi-term = { path = "../yazi-term", version = "26.5.6" } yazi-tty = { path = "../yazi-tty", version = "26.5.9" } +yazi-widgets = { path = "../yazi-widgets", version = "26.5.6" } # External dependencies -ansi-to-tui = { workspace = true } -anyhow = { workspace = true } -base64 = { workspace = true } -image = { version = "0.25.10", default-features = false, features = [ "avif", "bmp", "dds", "exr", "ff", "gif", "hdr", "ico", "jpeg", "png", "pnm", "qoi", "tga", "tiff", "webp" ] } -moxcms = "0.8.1" -palette = { version = "0.7.6", default-features = false } -quantette = { version = "0.6.0", default-features = false } -ratatui = { workspace = true } -strum = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } +ansi-to-tui = { workspace = true } +anyhow = { workspace = true } +base64 = { workspace = true } +image = { workspace = true } +inventory = { workspace = true } +moxcms = "0.8.1" +palette = { version = "0.7.6", default-features = false } +quantette = { version = "0.6.0", default-features = false } +ratatui-core = { workspace = true } +strum = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } diff --git a/yazi-adapter/src/adapter.rs b/yazi-adapter/src/adapter.rs index f3fc75b2..b44a6e9a 100644 --- a/yazi-adapter/src/adapter.rs +++ b/yazi-adapter/src/adapter.rs @@ -1,105 +1,56 @@ -use std::{env, path::PathBuf}; +use std::{fmt::{self, Debug}, ops::Deref}; use anyhow::Result; -use ratatui::layout::Rect; -use strum::{Display, IntoStaticStr}; -use tracing::warn; -use yazi_emulator::{Emulator, TMUX}; -use yazi_shared::env_exists; +use ratatui_core::layout::Rect; +use yazi_emulator::EMULATOR; +use yazi_shim::cell::SyncCell; +use yazi_widgets::clear::ClearInventory; -use crate::{Adapters, SHOWN, drivers}; +use crate::{ADAPTOR, drivers::{Driver, Drivers}}; -#[derive(Clone, Copy, Debug, Display, Eq, IntoStaticStr, PartialEq)] -#[strum(serialize_all = "kebab-case")] -pub enum Adapter { - Kgp, - KgpOld, - Iip, - Sixel, +pub struct Adapter { + driver: Driver, + shown: SyncCell>, + pub collision: SyncCell, +} - // Supported by Überzug++ - X11, - Wayland, - Chafa, +impl Deref for Adapter { + type Target = Driver; + + fn deref(&self) -> &Self::Target { &self.driver } +} + +impl Debug for Adapter { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.driver.fmt(f) } } impl Adapter { - pub async fn image_show

(self, path: P, max: Rect) -> Result - where - P: Into, - { - if max.is_empty() { - return Ok(Rect::default()); - } - - let path = path.into(); - match self { - Self::Kgp => drivers::Kgp::image_show(path, max).await, - Self::KgpOld => drivers::KgpOld::image_show(path, max).await, - Self::Iip => drivers::Iip::image_show(path, max).await, - Self::Sixel => drivers::Sixel::image_show(path, max).await, - Self::X11 | Self::Wayland => drivers::Ueberzug::image_show(path, max).await, - Self::Chafa => drivers::Chafa::image_show(path, max).await, + pub(super) fn new() -> Self { + Self { + driver: Drivers::matches(&EMULATOR), + shown: SyncCell::new(None), + collision: SyncCell::new(false), } } - pub fn image_hide(self) -> Result<()> { - if let Some(area) = SHOWN.replace(None) { self.image_erase(area) } else { Ok(()) } + pub fn image_hide(&self) -> Result<()> { + if let Some(area) = self.shown.replace(None) { self.driver.image_erase(area) } else { Ok(()) } } - pub fn image_erase(self, area: Rect) -> Result<()> { - match self { - Self::Kgp => drivers::Kgp::image_erase(area), - Self::KgpOld => drivers::KgpOld::image_erase(area), - Self::Iip => drivers::Iip::image_erase(area), - Self::Sixel => drivers::Sixel::image_erase(area), - Self::X11 | Self::Wayland => drivers::Ueberzug::image_erase(area), - Self::Chafa => drivers::Chafa::image_erase(area), - } - } - - #[inline] - pub fn shown_load(self) -> Option { SHOWN.get() } - - #[inline] - pub(super) fn shown_store(area: Rect) { SHOWN.set(Some(area)); } - - pub(super) fn start(self) { drivers::Ueberzug::start(self); } - - #[inline] - pub(super) fn needs_ueberzug(self) -> bool { - !matches!(self, Self::Kgp | Self::KgpOld | Self::Iip | Self::Sixel) - } + pub(super) fn shown_store(&self, area: Rect) { self.shown.set(Some(area)); } } -impl Adapter { - pub fn matches(emulator: &Emulator) -> Self { - let mut adapters: Adapters = emulator.into(); - if env_exists("ZELLIJ_SESSION_NAME") { - adapters.retain(|p| *p == Self::Sixel); - } else if TMUX.get() { - adapters.retain(|p| *p != Self::KgpOld); - } - if let Some(p) = adapters.first() { - return *p; - } +inventory::submit! { + ClearInventory { + clear: |area| { + let overlap = area.intersection(ADAPTOR.shown.get()?); + if overlap.area() == 0 { + return None; + } - let supported_compositor = drivers::Ueberzug::supported_compositor(); - match env::var("XDG_SESSION_TYPE").unwrap_or_default().as_str() { - "x11" => return Self::X11, - "wayland" if supported_compositor => return Self::Wayland, - "wayland" if !supported_compositor => return Self::Chafa, - _ => warn!("[Adapter] Could not identify XDG_SESSION_TYPE"), - } - if env_exists("WAYLAND_DISPLAY") { - return if supported_compositor { Self::Wayland } else { Self::Chafa }; - } - match env::var("DISPLAY").unwrap_or_default().as_str() { - s if !s.is_empty() && !s.contains("/org.xquartz") => return Self::X11, - _ => {} - } - - warn!("[Adapter] Falling back to chafa"); - Self::Chafa + ADAPTOR.driver.image_erase(overlap).ok(); + ADAPTOR.collision.set(true); + Some(overlap) + }, } } diff --git a/yazi-adapter/src/adapters.rs b/yazi-adapter/src/adapters.rs deleted file mode 100644 index 77912c41..00000000 --- a/yazi-adapter/src/adapters.rs +++ /dev/null @@ -1,62 +0,0 @@ -use std::ops::{Deref, DerefMut}; - -use crate::Adapter; - -pub(super) struct Adapters(Vec); - -impl Deref for Adapters { - type Target = Vec; - - fn deref(&self) -> &Self::Target { &self.0 } -} - -impl DerefMut for Adapters { - fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } -} - -impl From<&yazi_emulator::Emulator> for Adapters { - fn from(value: &yazi_emulator::Emulator) -> Self { value.kind.either_into() } -} - -impl From for Adapters { - fn from(value: yazi_emulator::Brand) -> Self { - use yazi_emulator::Brand as B; - - use crate::Adapter as A; - - Self(match value { - B::Kitty => vec![A::Kgp], - B::Konsole => vec![A::KgpOld], - B::Iterm2 => vec![A::Iip, A::Sixel], - B::WezTerm => vec![A::Iip, A::Sixel], - B::Foot => vec![A::Sixel], - B::Ghostty => vec![A::Kgp], - B::Microsoft => vec![A::Sixel], - B::Warp => vec![A::Iip, A::KgpOld], - B::Rio => vec![A::Kgp], - B::BlackBox => vec![A::Sixel], - B::VSCode => vec![A::Iip, A::Sixel], - B::Tabby => vec![A::Iip, A::Sixel], - B::Hyper => vec![A::Iip, A::Sixel], - B::Mintty => vec![A::Iip], - B::Tmux => vec![], - B::VTerm => vec![], - B::Apple => vec![], - B::Urxvt => vec![], - B::Bobcat => vec![A::Iip, A::Sixel], - }) - } -} - -impl From for Adapters { - fn from(value: yazi_emulator::Unknown) -> Self { - use Adapter as A; - - Self(match (value.kgp, value.sixel) { - (true, true) => vec![A::Sixel, A::KgpOld], - (true, false) => vec![A::KgpOld], - (false, true) => vec![A::Sixel], - (false, false) => vec![], - }) - } -} diff --git a/yazi-adapter/src/drivers/chafa.rs b/yazi-adapter/src/drivers/chafa.rs index 651eafc5..c326595a 100644 --- a/yazi-adapter/src/drivers/chafa.rs +++ b/yazi-adapter/src/drivers/chafa.rs @@ -2,17 +2,18 @@ use std::{io::Write, path::PathBuf, process::Stdio}; use ansi_to_tui::IntoText; use anyhow::{Result, anyhow, bail}; -use ratatui::layout::Rect; +use ratatui_core::layout::Rect; use tokio::process::Command; +use yazi_config::THEME; use yazi_emulator::Emulator; -use yazi_term::sequence::MoveTo; +use yazi_tty::sequence::{MoveTo, ResetAttrs, SetBg}; -use crate::Adapter; +use crate::ADAPTOR; -pub(crate) struct Chafa; +pub(super) struct Chafa; impl Chafa { - pub(crate) async fn image_show(path: PathBuf, max: Rect) -> Result { + pub(super) async fn image_show(path: PathBuf, max: Rect) -> Result { let child = Command::new("chafa") .args([ "-f", @@ -57,8 +58,8 @@ impl Chafa { height: lines.len() as u16, }; - Adapter::Chafa.image_hide()?; - Adapter::shown_store(area); + ADAPTOR.image_hide()?; + ADAPTOR.shown_store(area); Emulator::move_lock((max.x, max.y), |w| { for (i, line) in lines.into_iter().enumerate() { w.write_all(line)?; @@ -68,14 +69,17 @@ impl Chafa { }) } - pub(crate) fn image_erase(area: Rect) -> Result<()> { + pub(super) fn image_erase(area: Rect) -> Result<()> { let s = " ".repeat(area.width as usize); Emulator::move_lock((0, 0), |w| { + if let Some(c) = THEME.app.overall.get().bg { + write!(w, "{}", SetBg(c))?; + } for y in area.top()..area.bottom() { write!(w, "{}", MoveTo(area.x, y))?; write!(w, "{s}")?; } - Ok(()) + Ok(write!(w, "{ResetAttrs}")?) }) } } diff --git a/yazi-adapter/src/drivers/driver.rs b/yazi-adapter/src/drivers/driver.rs new file mode 100644 index 00000000..e8660919 --- /dev/null +++ b/yazi-adapter/src/drivers/driver.rs @@ -0,0 +1,59 @@ +use std::path::PathBuf; + +use anyhow::Result; +use ratatui_core::layout::Rect; +use strum::{Display, IntoStaticStr}; + +use crate::drivers::{Chafa, Iip, Kgp, KgpOld, Sixel, Ueberzug}; + +#[derive(Clone, Copy, Debug, Display, Eq, IntoStaticStr, PartialEq)] +#[strum(serialize_all = "kebab-case")] +pub enum Driver { + Kgp, + KgpOld, + Iip, + Sixel, + + // Supported by Überzug++ + X11, + Wayland, + Chafa, +} + +impl Driver { + pub async fn image_show

(self, path: P, max: Rect) -> Result + where + P: Into, + { + if max.is_empty() { + return Ok(Rect::default()); + } + + let path = path.into(); + match self { + Self::Kgp => Kgp::image_show(path, max).await, + Self::KgpOld => KgpOld::image_show(path, max).await, + Self::Iip => Iip::image_show(path, max).await, + Self::Sixel => Sixel::image_show(path, max).await, + Self::X11 | Self::Wayland => Ueberzug::image_show(path, max).await, + Self::Chafa => Chafa::image_show(path, max).await, + } + } + + pub fn image_erase(self, area: Rect) -> Result<()> { + match self { + Self::Kgp => Kgp::image_erase(area), + Self::KgpOld => KgpOld::image_erase(area), + Self::Iip => Iip::image_erase(area), + Self::Sixel => Sixel::image_erase(area), + Self::X11 | Self::Wayland => Ueberzug::image_erase(area), + Self::Chafa => Chafa::image_erase(area), + } + } + + pub(crate) fn start(self) { Ueberzug::start(self); } + + pub(crate) fn needs_ueberzug(self) -> bool { + !matches!(self, Self::Kgp | Self::KgpOld | Self::Iip | Self::Sixel) + } +} diff --git a/yazi-adapter/src/drivers/drivers.rs b/yazi-adapter/src/drivers/drivers.rs new file mode 100644 index 00000000..ed442005 --- /dev/null +++ b/yazi-adapter/src/drivers/drivers.rs @@ -0,0 +1,94 @@ +use std::{env, ops::{Deref, DerefMut}}; + +use tracing::warn; +use yazi_emulator::{Emulator, TMUX}; +use yazi_shared::env_exists; + +use crate::drivers::{Driver as D, Ueberzug}; + +pub(crate) struct Drivers(Vec); + +impl Deref for Drivers { + type Target = Vec; + + fn deref(&self) -> &Self::Target { &self.0 } +} + +impl DerefMut for Drivers { + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } +} + +impl From<&yazi_emulator::Emulator> for Drivers { + fn from(value: &yazi_emulator::Emulator) -> Self { value.kind.either_into() } +} + +impl From for Drivers { + fn from(value: yazi_emulator::Brand) -> Self { + use yazi_emulator::Brand as B; + + Self(match value { + B::Kitty => vec![D::Kgp], + B::Konsole => vec![D::KgpOld], + B::Iterm2 => vec![D::Iip, D::Sixel], + B::WezTerm => vec![D::Iip, D::Sixel], + B::Foot => vec![D::Sixel], + B::Ghostty => vec![D::Kgp], + B::Microsoft => vec![D::Sixel], + B::Warp => vec![D::Iip, D::KgpOld], + B::Rio => vec![D::Kgp], + B::BlackBox => vec![D::Sixel], + B::VSCode => vec![D::Iip, D::Sixel], + B::Tabby => vec![D::Iip, D::Sixel], + B::Hyper => vec![D::Iip, D::Sixel], + B::Mintty => vec![D::Iip], + B::Tmux => vec![], + B::VTerm => vec![], + B::Apple => vec![], + B::Urxvt => vec![], + B::Bobcat => vec![D::Iip, D::Sixel], + }) + } +} + +impl From for Drivers { + fn from(value: yazi_emulator::Unknown) -> Self { + Self(match (value.kgp, value.sixel) { + (true, true) => vec![D::Sixel, D::KgpOld], + (true, false) => vec![D::KgpOld], + (false, true) => vec![D::Sixel], + (false, false) => vec![], + }) + } +} + +impl Drivers { + pub fn matches(emulator: &Emulator) -> D { + let mut adapters: Self = emulator.into(); + if env_exists("ZELLIJ_SESSION_NAME") { + adapters.retain(|p| *p == D::Sixel); + } else if TMUX.get() { + adapters.retain(|p| *p != D::KgpOld); + } + if let Some(p) = adapters.first() { + return *p; + } + + let supported_compositor = Ueberzug::supported_compositor(); + match env::var("XDG_SESSION_TYPE").unwrap_or_default().as_str() { + "x11" => return D::X11, + "wayland" if supported_compositor => return D::Wayland, + "wayland" if !supported_compositor => return D::Chafa, + _ => warn!("[Adapter] Could not identify XDG_SESSION_TYPE"), + } + if env_exists("WAYLAND_DISPLAY") { + return if supported_compositor { D::Wayland } else { D::Chafa }; + } + match env::var("DISPLAY").unwrap_or_default().as_str() { + s if !s.is_empty() && !s.contains("/org.xquartz") => return D::X11, + _ => {} + } + + warn!("[Adapter] Falling back to chafa"); + D::Chafa + } +} diff --git a/yazi-adapter/src/drivers/iip.rs b/yazi-adapter/src/drivers/iip.rs index 8859626b..8e03b5fa 100644 --- a/yazi-adapter/src/drivers/iip.rs +++ b/yazi-adapter/src/drivers/iip.rs @@ -1,39 +1,42 @@ -use std::{fmt::Write, io::Write as ioWrite, path::PathBuf}; +use std::{fmt::Write as _, io::Write as _, path::PathBuf}; use anyhow::Result; use base64::{Engine, engine::{Config, general_purpose::STANDARD}}; use image::{DynamicImage, ExtendedColorType, ImageEncoder, codecs::{jpeg::JpegEncoder, png::PngEncoder}}; -use ratatui::layout::Rect; -use yazi_config::YAZI; +use ratatui_core::layout::Rect; +use yazi_config::{THEME, YAZI}; use yazi_emulator::{CLOSE, Emulator, START}; -use yazi_term::sequence::MoveTo; +use yazi_tty::sequence::{MoveTo, ResetAttrs, SetBg}; -use crate::{Image, adapter::Adapter}; +use crate::{ADAPTOR, Image}; -pub(crate) struct Iip; +pub(super) struct Iip; impl Iip { - pub(crate) async fn image_show(path: PathBuf, max: Rect) -> Result { + pub(super) async fn image_show(path: PathBuf, max: Rect) -> Result { let img = Image::downscale(path, max).await?; let area = Image::pixel_area((img.width(), img.height()), max); let b = Self::encode(img).await?; - Adapter::Iip.image_hide()?; - Adapter::shown_store(area); + ADAPTOR.image_hide()?; + ADAPTOR.shown_store(area); Emulator::move_lock((max.x, max.y), |w| { w.write_all(&b)?; Ok(area) }) } - pub(crate) fn image_erase(area: Rect) -> Result<()> { + pub(super) fn image_erase(area: Rect) -> Result<()> { let s = " ".repeat(area.width as usize); Emulator::move_lock((0, 0), |w| { + if let Some(c) = THEME.app.overall.get().bg { + write!(w, "{}", SetBg(c))?; + } for y in area.top()..area.bottom() { write!(w, "{}", MoveTo(area.x, y))?; write!(w, "{s}")?; } - Ok(()) + Ok(write!(w, "{ResetAttrs}")?) }) } diff --git a/yazi-adapter/src/drivers/kgp.rs b/yazi-adapter/src/drivers/kgp.rs index 9cb533f7..dfeedbc8 100644 --- a/yazi-adapter/src/drivers/kgp.rs +++ b/yazi-adapter/src/drivers/kgp.rs @@ -4,12 +4,13 @@ use std::{io::Write, path::PathBuf}; use anyhow::Result; use base64::{Engine, engine::general_purpose}; use image::DynamicImage; -use ratatui::{layout::Rect, style::Color}; +use ratatui_core::{layout::Rect, style::Color}; +use yazi_config::THEME; use yazi_emulator::{CLOSE, ESCAPE, Emulator, START}; use yazi_shim::cell::SyncCell; -use yazi_term::sequence::{MoveTo, SetFg}; +use yazi_tty::sequence::{MoveTo, ResetAttrs, SetBg, SetFg}; -use crate::{adapter::Adapter, image::Image}; +use crate::{ADAPTOR, image::Image}; static DIACRITICS: [char; 297] = [ '\u{0305}', @@ -311,18 +312,18 @@ static DIACRITICS: [char; 297] = [ '\u{1D244}', ]; -pub(crate) struct Kgp; +pub(super) struct Kgp; impl Kgp { - pub(crate) async fn image_show(path: PathBuf, max: Rect) -> Result { + pub(super) async fn image_show(path: PathBuf, max: Rect) -> Result { let img = Image::downscale(path, max).await?; let area = Image::pixel_area((img.width(), img.height()), max); let b1 = Self::encode(img).await?; let b2 = Self::place(&area)?; - Adapter::Kgp.image_hide()?; - Adapter::shown_store(area); + ADAPTOR.image_hide()?; + ADAPTOR.shown_store(area); Emulator::move_lock((area.x, area.y), |w| { w.write_all(&b1)?; w.write_all(&b2)?; @@ -330,15 +331,19 @@ impl Kgp { }) } - pub(crate) fn image_erase(area: Rect) -> Result<()> { + pub(super) fn image_erase(area: Rect) -> Result<()> { let s = " ".repeat(area.width as usize); Emulator::move_lock((0, 0), |w| { + if let Some(c) = THEME.app.overall.get().bg { + write!(w, "{}", SetBg(c))?; + } + for y in area.top()..area.bottom() { write!(w, "{}", MoveTo(area.x, y))?; write!(w, "{s}")?; } - write!(w, "{START}_Gq=2,a=d,d=A{ESCAPE}\\{CLOSE}")?; + write!(w, "{ResetAttrs}{START}_Gq=2,a=d,d=A{ESCAPE}\\{CLOSE}")?; Ok(()) }) } @@ -381,12 +386,16 @@ impl Kgp { } fn place(area: &Rect) -> Result> { - let mut buf = Vec::with_capacity(area.width as usize * area.height as usize * 3 + 50); + let mut buf = Vec::with_capacity(area.width as usize * area.height as usize * 3 + 500); let id = Self::image_id(); let (r, g, b) = ((id >> 16) & 0xff, (id >> 8) & 0xff, id & 0xff); write!(buf, "{}", SetFg(Color::Rgb(r as u8, g as u8, b as u8)))?; + if let Some(c) = THEME.app.overall.get().bg { + write!(buf, "{}", SetBg(c))?; + } + for y in 0..area.height { write!(buf, "{}", MoveTo(area.x, area.y + y))?; for x in 0..area.width { @@ -395,6 +404,8 @@ impl Kgp { write!(buf, "{}", *DIACRITICS.get(x as usize).unwrap_or(&DIACRITICS[0]))?; } } + + write!(buf, "{ResetAttrs}")?; Ok(buf) } diff --git a/yazi-adapter/src/drivers/kgp_old.rs b/yazi-adapter/src/drivers/kgp_old.rs index bb78103b..1910703b 100644 --- a/yazi-adapter/src/drivers/kgp_old.rs +++ b/yazi-adapter/src/drivers/kgp_old.rs @@ -4,29 +4,29 @@ use std::{io::Write, path::PathBuf}; use anyhow::Result; use base64::{Engine, engine::general_purpose}; use image::DynamicImage; -use ratatui::layout::Rect; +use ratatui_core::layout::Rect; use yazi_emulator::{CLOSE, ESCAPE, Emulator, START}; use yazi_tty::TTY; -use crate::{Image, adapter::Adapter}; +use crate::{ADAPTOR, Image}; -pub(crate) struct KgpOld; +pub(super) struct KgpOld; impl KgpOld { - pub(crate) async fn image_show(path: PathBuf, max: Rect) -> Result { + pub(super) async fn image_show(path: PathBuf, max: Rect) -> Result { let img = Image::downscale(path, max).await?; let area = Image::pixel_area((img.width(), img.height()), max); let b = Self::encode(img).await?; - Adapter::KgpOld.image_hide()?; - Adapter::shown_store(area); + ADAPTOR.image_hide()?; + ADAPTOR.shown_store(area); Emulator::move_lock((area.x, area.y), |w| { w.write_all(&b)?; Ok(area) }) } - pub(crate) fn image_erase(_: Rect) -> Result<()> { + pub(super) fn image_erase(_: Rect) -> Result<()> { let mut w = TTY.lockout(); write!(w, "{START}_Gq=2,a=d,d=A{ESCAPE}\\{CLOSE}")?; w.flush()?; diff --git a/yazi-adapter/src/drivers/mod.rs b/yazi-adapter/src/drivers/mod.rs index 57eeaf4f..20e82086 100644 --- a/yazi-adapter/src/drivers/mod.rs +++ b/yazi-adapter/src/drivers/mod.rs @@ -1 +1 @@ -yazi_macro::mod_flat!(chafa iip kgp kgp_old sixel ueberzug); +yazi_macro::mod_flat!(chafa driver drivers iip kgp kgp_old sixel ueberzug); diff --git a/yazi-adapter/src/drivers/sixel.rs b/yazi-adapter/src/drivers/sixel.rs index 1a39661e..e019bf36 100644 --- a/yazi-adapter/src/drivers/sixel.rs +++ b/yazi-adapter/src/drivers/sixel.rs @@ -4,13 +4,14 @@ use anyhow::{Result, bail}; use image::{DynamicImage, GenericImageView, RgbImage}; use palette::{Srgb, cast::ComponentsAs}; use quantette::{PaletteSize, color_map::IndexedColorMap, wu::{BinnerU8x3, WuU8x3}}; -use ratatui::layout::Rect; +use ratatui_core::layout::Rect; +use yazi_config::THEME; use yazi_emulator::{CLOSE, ESCAPE, Emulator, START}; -use yazi_term::sequence::MoveTo; +use yazi_tty::sequence::{MoveTo, ResetAttrs, SetBg}; -use crate::{Image, adapter::Adapter}; +use crate::{ADAPTOR, Image}; -pub(crate) struct Sixel; +pub(super) struct Sixel; struct QuantizeOutput { indices: Vec, @@ -18,27 +19,30 @@ struct QuantizeOutput { } impl Sixel { - pub(crate) async fn image_show(path: PathBuf, max: Rect) -> Result { + pub(super) async fn image_show(path: PathBuf, max: Rect) -> Result { let img = Image::downscale(path, max).await?; let area = Image::pixel_area((img.width(), img.height()), max); let b = Self::encode(img).await?; - Adapter::Sixel.image_hide()?; - Adapter::shown_store(area); + ADAPTOR.image_hide()?; + ADAPTOR.shown_store(area); Emulator::move_lock((area.x, area.y), |w| { w.write_all(&b)?; Ok(area) }) } - pub(crate) fn image_erase(area: Rect) -> Result<()> { + pub(super) fn image_erase(area: Rect) -> Result<()> { let s = " ".repeat(area.width as usize); Emulator::move_lock((0, 0), |w| { + if let Some(c) = THEME.app.overall.get().bg { + write!(w, "{}", SetBg(c))?; + } for y in area.top()..area.bottom() { write!(w, "{}", MoveTo(area.x, y))?; write!(w, "{s}")?; } - Ok(()) + Ok(write!(w, "{ResetAttrs}")?) }) } diff --git a/yazi-adapter/src/drivers/ueberzug.rs b/yazi-adapter/src/drivers/ueberzug.rs index 6ab4aabd..ba6f5009 100644 --- a/yazi-adapter/src/drivers/ueberzug.rs +++ b/yazi-adapter/src/drivers/ueberzug.rs @@ -2,7 +2,7 @@ use std::{path::PathBuf, process::Stdio}; use anyhow::{Result, bail}; use image::ImageReader; -use ratatui::layout::Rect; +use ratatui_core::layout::Rect; use tokio::{io::AsyncWriteExt, process::{Child, Command}, sync::mpsc::{self, UnboundedSender}}; use tracing::{debug, warn}; use yazi_config::YAZI; @@ -10,21 +10,21 @@ use yazi_emulator::Dimension; use yazi_shared::{LOG_LEVEL, env_exists}; use yazi_shim::{cell::RoCell, strum::IntoStr}; -use crate::Adapter; +use crate::{ADAPTOR, drivers::Driver}; type Cmd = Option<(PathBuf, Rect)>; static DEMON: RoCell>> = RoCell::new(); -pub(crate) struct Ueberzug; +pub(super) struct Ueberzug; impl Ueberzug { - pub(crate) fn start(adapter: Adapter) { - if !adapter.needs_ueberzug() { + pub(super) fn start(driver: Driver) { + if !driver.needs_ueberzug() { return DEMON.init(None); } - let mut child = Self::create_demon(adapter).ok(); + let mut child = Self::create_demon(driver).ok(); let (tx, mut rx) = mpsc::unbounded_channel(); tokio::spawn(async move { @@ -34,17 +34,17 @@ impl Ueberzug { child = None; } if child.is_none() { - child = Self::create_demon(adapter).ok(); + child = Self::create_demon(driver).ok(); } if let Some(c) = &mut child { - Self::send_command(adapter, c, cmd).await.ok(); + Self::send_command(driver, c, cmd).await.ok(); } } }); DEMON.init(Some(tx)) } - pub(crate) async fn image_show(path: PathBuf, max: Rect) -> Result { + pub(super) async fn image_show(path: PathBuf, max: Rect) -> Result { let Some(tx) = &*DEMON else { bail!("uninitialized ueberzugpp"); }; @@ -64,11 +64,11 @@ impl Ueberzug { .unwrap_or(max); tx.send(Some((path, area)))?; - Adapter::shown_store(area); + ADAPTOR.shown_store(area); Ok(area) } - pub(crate) fn image_erase(_: Rect) -> Result<()> { + pub(super) fn image_erase(_: Rect) -> Result<()> { if let Some(tx) = &*DEMON { Ok(tx.send(None)?) } else { @@ -79,16 +79,16 @@ impl Ueberzug { // Currently Überzug++'s Wayland output only supports Niri, Sway, Hyprland and // Wayfire as it requires information from specific compositor socket directly. // These environment variables are from ueberzugpp src/canvas/wayland/config.cpp - pub(crate) fn supported_compositor() -> bool { + pub(super) fn supported_compositor() -> bool { env_exists("NIRI_SOCKET") || env_exists("SWAYSOCK") || env_exists("HYPRLAND_INSTANCE_SIGNATURE") || env_exists("WAYFIRE_SOCKET") } - fn create_demon(adapter: Adapter) -> Result { + fn create_demon(driver: Driver) -> Result { let result = Command::new("ueberzugpp") - .args(["layer", "-so", adapter.into_str()]) + .args(["layer", "-so", driver.into_str()]) .env("SPDLOG_LEVEL", if LOG_LEVEL.get().is_none() { "" } else { "debug" }) .kill_on_drop(true) .stdin(Stdio::piped()) @@ -113,7 +113,7 @@ impl Ueberzug { rect } - async fn send_command(adapter: Adapter, child: &mut Child, cmd: Cmd) -> Result<()> { + async fn send_command(driver: Driver, child: &mut Child, cmd: Cmd) -> Result<()> { let s = if let Some((path, rect)) = cmd { debug!("ueberzugpp rect before adjustment: {:?}", rect); let rect = Self::adjust_rect(rect); @@ -132,7 +132,7 @@ impl Ueberzug { format!(r#"{{"action":"remove","identifier":"yazi"}}{}"#, '\n') }; - debug!("`ueberzugpp layer -so {adapter}` command: {s}"); + debug!("`ueberzugpp layer -so {driver}` command: {s}"); child.stdin.as_mut().unwrap().write_all(s.as_bytes()).await?; Ok(()) diff --git a/yazi-adapter/src/icc.rs b/yazi-adapter/src/icc.rs index 6b3f0541..cf97bdb8 100644 --- a/yazi-adapter/src/icc.rs +++ b/yazi-adapter/src/icc.rs @@ -3,6 +3,7 @@ use image::{ColorType, DynamicImage, GrayAlphaImage, GrayImage, ImageDecoder, Rg use moxcms::{CicpColorPrimaries, ColorProfile, DataColorSpace, Layout, TransferCharacteristics, TransformOptions}; pub(super) struct Icc; + impl Icc { pub(super) fn transform(mut decoder: impl ImageDecoder) -> anyhow::Result { if let Some(layout) = Self::color_type_to_layout(decoder.color_type()) diff --git a/yazi-adapter/src/image.rs b/yazi-adapter/src/image.rs index 84355b19..5afeff56 100644 --- a/yazi-adapter/src/image.rs +++ b/yazi-adapter/src/image.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use anyhow::Result; use image::{DynamicImage, ImageDecoder, ImageError, ImageReader, Limits, codecs::{jpeg::JpegEncoder, png::PngEncoder}, imageops::FilterType, metadata::Orientation}; -use ratatui::layout::Rect; +use ratatui_core::layout::Rect; use yazi_config::YAZI; use yazi_emulator::Dimension; use yazi_fs::provider::{Provider, local::Local}; diff --git a/yazi-adapter/src/info.rs b/yazi-adapter/src/info.rs deleted file mode 100644 index 86d4052e..00000000 --- a/yazi-adapter/src/info.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::path::PathBuf; - -use image::{ImageDecoder, ImageError}; - -pub type ImageFormat = image::ImageFormat; -pub type ImageColor = image::ColorType; -pub type ImageOrientation = image::metadata::Orientation; - -#[derive(Clone, Copy)] -pub struct ImageInfo { - pub format: ImageFormat, - pub width: u32, - pub height: u32, - pub color: ImageColor, - pub orientation: Option, -} - -impl ImageInfo { - pub async fn new(path: PathBuf) -> image::ImageResult { - tokio::task::spawn_blocking(move || { - let reader = image::ImageReader::open(path)?.with_guessed_format()?; - - let Some(format) = reader.format() else { - return Err(ImageError::IoError(std::io::Error::new( - std::io::ErrorKind::InvalidData, - "unknown image format", - ))); - }; - - let mut decoder = reader.into_decoder()?; - let (width, height) = decoder.dimensions(); - Ok(Self { - format, - width, - height, - color: decoder.color_type(), - orientation: decoder.orientation().ok(), - }) - }) - .await - .map_err(|e| ImageError::IoError(e.into()))? - } -} diff --git a/yazi-adapter/src/lib.rs b/yazi-adapter/src/lib.rs index 01080816..347bd4e0 100644 --- a/yazi-adapter/src/lib.rs +++ b/yazi-adapter/src/lib.rs @@ -1,15 +1,12 @@ yazi_macro::mod_pub!(drivers); -yazi_macro::mod_flat!(adapter adapters icc image info); +yazi_macro::mod_flat!(adapter icc image); use yazi_emulator::{Brand, CLOSE, EMULATOR, ESCAPE, Emulator, Mux, START, TMUX}; use yazi_shared::in_wsl; -use yazi_shim::cell::SyncCell; +use yazi_shim::cell::{RoCell, SyncCell}; -pub static ADAPTOR: SyncCell = SyncCell::new(Adapter::Chafa); - -// Image state -static SHOWN: SyncCell> = SyncCell::new(None); +pub static ADAPTOR: RoCell = RoCell::new(); // WSL support pub static WSL: SyncCell = SyncCell::new(false); @@ -34,7 +31,7 @@ pub fn init() -> anyhow::Result<()> { EMULATOR.init(emulator); yazi_config::init_flavor(EMULATOR.light)?; - ADAPTOR.set(Adapter::matches(&EMULATOR)); - ADAPTOR.get().start(); + ADAPTOR.init(Adapter::new()); + ADAPTOR.start(); Ok(()) } diff --git a/yazi-binding/Cargo.toml b/yazi-binding/Cargo.toml index 1eb4fcc1..77cdc3c5 100644 --- a/yazi-binding/Cargo.toml +++ b/yazi-binding/Cargo.toml @@ -17,30 +17,24 @@ default = [ "vendored-lua" ] vendored-lua = [ "mlua/vendored" ] [dependencies] -yazi-adapter = { path = "../yazi-adapter", version = "26.5.6" } yazi-codegen = { path = "../yazi-codegen", version = "26.5.6" } -yazi-config = { path = "../yazi-config", version = "26.5.6" } -yazi-fs = { path = "../yazi-fs", version = "26.5.6" } yazi-macro = { path = "../yazi-macro", version = "26.5.6" } -yazi-shared = { path = "../yazi-shared", version = "26.5.6" } yazi-shim = { path = "../yazi-shim", version = "26.5.6" } -yazi-term = { path = "../yazi-term", version = "26.5.6" } -yazi-vfs = { path = "../yazi-vfs", version = "26.5.6" } -yazi-widgets = { path = "../yazi-widgets", version = "26.5.6" } # External dependencies -ansi-to-tui = { workspace = true } -anyhow = { workspace = true } -futures = { workspace = true } -hashbrown = { workspace = true } -mlua = { workspace = true } -paste = { workspace = true } -ratatui = { workspace = true } -serde_json = { workspace = true } -tokio = { workspace = true } -tokio-stream = { workspace = true } -tracing = { workspace = true } -unicode-width = { workspace = true } +ansi-to-tui = { workspace = true } +anyhow = { workspace = true } +futures = { workspace = true } +hashbrown = { workspace = true } +image = { workspace = true } +mlua = { workspace = true } +ratatui-core = { workspace = true } +ratatui-widgets = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +strum = { workspace = true } +tokio = { workspace = true } +unicode-width = { workspace = true } [target.'cfg(unix)'.dependencies] libc = { workspace = true } diff --git a/yazi-binding/src/access.rs b/yazi-binding/src/access.rs deleted file mode 100644 index 1134d982..00000000 --- a/yazi-binding/src/access.rs +++ /dev/null @@ -1,42 +0,0 @@ -use mlua::{AnyUserData, IntoLuaMulti, UserData, UserDataMethods, Value}; -use yazi_fs::provider::FileBuilder; - -use crate::{Error, Fd, UrlRef}; - -#[derive(Default)] -pub struct Access(yazi_vfs::provider::Gate); - -impl UserData for Access { - fn add_methods>(methods: &mut M) { - methods.add_function("append", |_, (ud, append): (AnyUserData, bool)| { - ud.borrow_mut::()?.0.append(append); - Ok(ud) - }); - methods.add_function("create", |_, (ud, create): (AnyUserData, bool)| { - ud.borrow_mut::()?.0.create(create); - Ok(ud) - }); - methods.add_function("create_new", |_, (ud, create_new): (AnyUserData, bool)| { - ud.borrow_mut::()?.0.create_new(create_new); - Ok(ud) - }); - methods.add_async_method("open", |lua, me, url: UrlRef| async move { - match me.0.open(&*url).await { - Ok(fd) => Fd(fd).into_lua_multi(&lua), - Err(e) => (Value::Nil, Error::Io(e)).into_lua_multi(&lua), - } - }); - methods.add_function("read", |_, (ud, read): (AnyUserData, bool)| { - ud.borrow_mut::()?.0.read(read); - Ok(ud) - }); - methods.add_function("truncate", |_, (ud, truncate): (AnyUserData, bool)| { - ud.borrow_mut::()?.0.truncate(truncate); - Ok(ud) - }); - methods.add_function("write", |_, (ud, write): (AnyUserData, bool)| { - ud.borrow_mut::()?.0.write(write); - Ok(ud) - }); - } -} diff --git a/yazi-binding/src/chord_cow.rs b/yazi-binding/src/chord_cow.rs deleted file mode 100644 index dc5821db..00000000 --- a/yazi-binding/src/chord_cow.rs +++ /dev/null @@ -1,15 +0,0 @@ -use mlua::UserData; -use yazi_codegen::FromLuaOwned; - -#[derive(Clone, FromLuaOwned)] -pub struct ChordCow(pub yazi_config::keymap::ChordCow); - -impl From for ChordCow { - fn from(value: yazi_config::keymap::ChordCow) -> Self { Self(value) } -} - -impl From for yazi_config::keymap::ChordCow { - fn from(value: ChordCow) -> Self { value.0 } -} - -impl UserData for ChordCow {} diff --git a/yazi-binding/src/composer.rs b/yazi-binding/src/composer.rs index ebfc5bd2..e12d237f 100644 --- a/yazi-binding/src/composer.rs +++ b/yazi-binding/src/composer.rs @@ -5,10 +5,9 @@ pub type ComposerGet = fn(&Lua, &[u8]) -> mlua::Result; pub type ComposerSet = fn(&Lua, &[u8], Value) -> mlua::Result; pub struct Composer { - get: G, - set: S, - parent: Option<(G, S)>, - cache: HashMap, Value>, + get: G, + set: S, + cache: HashMap, Value>, } impl Composer @@ -16,13 +15,7 @@ where G: Fn(&Lua, &[u8]) -> mlua::Result + 'static, S: Fn(&Lua, &[u8], Value) -> mlua::Result + 'static, { - #[inline] - pub fn new(get: G, set: S) -> Self { Self { get, set, parent: None, cache: Default::default() } } - - #[inline] - pub fn with_parent(get: G, set: S, p_get: G, p_set: S) -> Self { - Self { get, set, parent: Some((p_get, p_set)), cache: Default::default() } - } + pub fn new(get: G, set: S) -> Self { Self { get, set, cache: Default::default() } } } impl UserData for Composer @@ -37,14 +30,9 @@ where return Ok(v.clone()); } - let mut value = (me.get)(lua, &key)?; - if value.is_nil() - && let Some((p_get, _)) = &me.parent - { - value = p_get(lua, &key)?; - } - + let value = (me.get)(lua, &key)?; me.cache.insert(key.to_owned(), value.clone()); + Ok(value) }); @@ -56,11 +44,6 @@ where if value.is_nil() { me.cache.remove(key.as_ref()); - } else if let Some((_, p_set)) = &me.parent { - match p_set(lua, key.as_ref(), value)? { - Value::Nil => me.cache.remove(key.as_ref()), - v => me.cache.insert(key.to_owned(), v), - }; } else { me.cache.insert(key.to_owned(), value); } diff --git a/yazi-binding/src/config/fetcher.rs b/yazi-binding/src/config/fetcher.rs deleted file mode 100644 index 00ab805e..00000000 --- a/yazi-binding/src/config/fetcher.rs +++ /dev/null @@ -1,75 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, Value}; -use yazi_config::YAZI; - -use crate::{FileRef, Id, Iter, cached_field}; - -#[derive(Clone)] -pub struct Fetcher { - inner: Arc, - - v_name: Option, -} - -impl Deref for Fetcher { - type Target = yazi_config::plugin::Fetcher; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl Fetcher { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into(), v_name: None } - } -} - -impl UserData for Fetcher { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - - cached_field!(fields, name, |lua, me| lua.create_string(&*me.name)); - } -} - -// --- Matcher -pub struct FetcherMatcher(yazi_config::plugin::FetcherMatcher<'static>); - -impl FetcherMatcher { - pub fn new(inner: impl Into>) -> Self { - Self(inner.into()) - } -} - -impl TryFrom

for FetcherMatcher { - type Error = mlua::Error; - - fn try_from(value: Table) -> Result { - let id: Id = value.raw_get("id").unwrap_or_default(); - let file: Option = value.raw_get("file")?; - let mime: Option = value.raw_get("mime")?; - - Ok(Self(yazi_config::plugin::FetcherMatcher { - fetchers: YAZI.plugin.fetchers.load_full(), - id: id.0, - file: file.map(|f| f.inner.clone().into()), - mime: mime.map(Into::into), - ..Default::default() - })) - } -} - -impl FromLua for FetcherMatcher { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(t) => t.try_into(), - _ => Err("expected a table of FetcherMatcher".into_lua_err()), - } - } -} - -impl IntoLua for FetcherMatcher { - fn into_lua(self, lua: &Lua) -> mlua::Result { - Iter::new(self.0.map(Fetcher::new), None).into_lua(lua) - } -} diff --git a/yazi-binding/src/config/fetchers.rs b/yazi-binding/src/config/fetchers.rs deleted file mode 100644 index 66bc3fdb..00000000 --- a/yazi-binding/src/config/fetchers.rs +++ /dev/null @@ -1,17 +0,0 @@ -use mlua::{IntoLua, MetaMethod, UserData, UserDataMethods}; -use yazi_config::YAZI; - -use crate::config::FetcherMatcher; - -pub struct Fetchers; - -impl UserData for Fetchers { - fn add_methods>(methods: &mut M) { - methods.add_method("match", |lua, _, matcher: Option| match matcher { - Some(matcher) => matcher.into_lua(lua), - None => FetcherMatcher::new(&YAZI.plugin.fetchers).into_lua(lua), - }); - - methods.add_meta_method(MetaMethod::Len, |_, _, ()| Ok(YAZI.plugin.fetchers.load().len())); - } -} diff --git a/yazi-binding/src/config/mod.rs b/yazi-binding/src/config/mod.rs deleted file mode 100644 index 06de0823..00000000 --- a/yazi-binding/src/config/mod.rs +++ /dev/null @@ -1 +0,0 @@ -yazi_macro::mod_flat!(fetcher fetchers open_rule open_rules opener opener_rule opener_rules preloader preloaders previewer previewers spotter spotters); diff --git a/yazi-binding/src/config/open_rule.rs b/yazi-binding/src/config/open_rule.rs deleted file mode 100644 index 73acfaf7..00000000 --- a/yazi-binding/src/config/open_rule.rs +++ /dev/null @@ -1,85 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, Table, UserData, UserDataFields, Value}; -use yazi_config::YAZI; - -use crate::{FileRef, Id, Iter, cached_field}; - -pub struct OpenRule { - inner: Arc, - - v_use: Option, -} - -impl Deref for OpenRule { - type Target = Arc; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl From for Arc { - fn from(value: OpenRule) -> Self { value.inner } -} - -impl OpenRule { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into(), v_use: None } - } -} - -impl FromLua for OpenRule { - fn from_lua(value: Value, lua: &Lua) -> mlua::Result { - Ok(Self::new(lua.from_value::(value)?)) - } -} - -impl UserData for OpenRule { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - cached_field!(fields, use, |lua, me| { - lua.create_sequence_from(me.r#use.iter().map(|s| s.as_str())) - }); - } -} - -// --- Matcher -pub struct OpenRuleMatcher(pub(super) yazi_config::open::OpenRuleMatcher<'static>); - -impl OpenRuleMatcher { - pub fn new(inner: impl Into>) -> Self { - Self(inner.into()) - } -} - -impl TryFrom
for OpenRuleMatcher { - type Error = mlua::Error; - - fn try_from(value: Table) -> Result { - let id: Id = value.raw_get("id").unwrap_or_default(); - let file: Option = value.raw_get("file")?; - let mime: Option = value.raw_get("mime")?; - - Ok(Self(yazi_config::open::OpenRuleMatcher { - rules: YAZI.open.load_full(), - id: id.0, - file: file.map(|f| f.inner.clone().into()), - mime: mime.map(Into::into), - ..Default::default() - })) - } -} - -impl FromLua for OpenRuleMatcher { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(t) => t.try_into(), - _ => Err("expected a table of OpenRuleMatcher".into_lua_err()), - } - } -} - -impl IntoLua for OpenRuleMatcher { - fn into_lua(self, lua: &Lua) -> mlua::Result { - Iter::new(self.0.map(OpenRule::new), None).into_lua(lua) - } -} diff --git a/yazi-binding/src/config/open_rules.rs b/yazi-binding/src/config/open_rules.rs deleted file mode 100644 index 1f1f7689..00000000 --- a/yazi-binding/src/config/open_rules.rs +++ /dev/null @@ -1,39 +0,0 @@ -use mlua::{ExternalError, ExternalResult, IntoLua, MetaMethod, Table, UserData, UserDataMethods}; -use yazi_config::YAZI; -use yazi_shim::mlua::DeserializeOverLua; - -use crate::config::{OpenRule, OpenRuleMatcher}; - -pub struct OpenRules; - -impl UserData for OpenRules { - fn add_methods>(methods: &mut M) { - methods.add_method("match", |lua, _, matcher: Option| match matcher { - Some(matcher) => matcher.into_lua(lua), - None => OpenRuleMatcher::new(&*YAZI.open).into_lua(lua), - }); - - methods.add_method("insert", |_, _, (index, rule): (isize, OpenRule)| { - let index = match index { - 1.. => index - 1, - 0 => return Err("index must be 1-based or negative".into_lua_err()), - _ => index, - }; - - YAZI.open.insert(index, rule.clone()).into_lua_err()?; - Ok(rule) - }); - - methods.add_method("remove", |_, _, matcher: OpenRuleMatcher| { - YAZI.open.remove(matcher.0); - Ok(()) - }); - - methods.add_method("update", |_, _, (matcher, table): (OpenRuleMatcher, Table)| { - YAZI.open.update(matcher.0, |rule| rule.deserialize_over_lua(&table))?; - Ok(()) - }); - - methods.add_meta_method(MetaMethod::Len, |_, _, ()| Ok(YAZI.open.load().len())); - } -} diff --git a/yazi-binding/src/config/opener.rs b/yazi-binding/src/config/opener.rs deleted file mode 100644 index f3bbd76c..00000000 --- a/yazi-binding/src/config/opener.rs +++ /dev/null @@ -1,45 +0,0 @@ -use mlua::{ExternalError, FromLua, IntoLua, IntoLuaMulti, MetaMethod, UserData, UserDataMethods, Value}; -use yazi_config::{YAZI, opener::OpenerRulesMatcher}; - -use crate::config::OpenerRules; - -pub struct Opener; - -impl UserData for Opener { - fn add_methods>(methods: &mut M) { - methods.add_meta_method(MetaMethod::Index, |lua, _, key: mlua::String| { - let key = key.to_str()?; - match YAZI.opener.load().get(&*key) { - Some(rules) => OpenerRules::new(rules.clone()).into_lua(lua), - None => Ok(Value::Nil), - } - }); - - methods.add_meta_method(MetaMethod::NewIndex, |lua, _, (key, value): (mlua::String, Value)| { - let key = key.to_str()?; - match value { - t @ Value::Table(_) => { - YAZI.opener.insert(&key, &*OpenerRules::from_lua(t, lua)?); - } - Value::Nil => { - YAZI.opener.remove(&key); - } - _ => return Err("expected a table or nil".into_lua_err()), - } - Ok(()) - }); - - methods.add_meta_method(MetaMethod::Pairs, |lua, _, ()| { - let mut matcher = OpenerRulesMatcher::from(&YAZI.opener); - let iter = lua.create_function_mut(move |lua, ()| { - if let Some((name, rules)) = matcher.next() { - (name, OpenerRules::new(rules)).into_lua_multi(lua) - } else { - ().into_lua_multi(lua) - } - })?; - - Ok(iter) - }); - } -} diff --git a/yazi-binding/src/config/opener_rule.rs b/yazi-binding/src/config/opener_rule.rs deleted file mode 100644 index 0ce390f3..00000000 --- a/yazi-binding/src/config/opener_rule.rs +++ /dev/null @@ -1,81 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, Table, UserData, UserDataFields, Value}; - -use crate::{Id, Iter, cached_field}; - -pub struct OpenerRule { - inner: Arc, - - v_run: Option, - v_desc: Option, -} - -impl Deref for OpenerRule { - type Target = Arc; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl From for Arc { - fn from(value: OpenerRule) -> Self { value.inner } -} - -impl OpenerRule { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into(), v_run: None, v_desc: None } - } -} - -impl FromLua for OpenerRule { - fn from_lua(value: Value, lua: &Lua) -> mlua::Result { - let mut inner: yazi_config::opener::OpenerRule = lua.from_value(value)?; - inner.fill(); - - Ok(Self::new(inner)) - } -} - -impl UserData for OpenerRule { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - cached_field!(fields, run, |lua, me| lua.create_string(&*me.run)); - fields.add_field_method_get("block", |_, me| Ok(me.block)); - fields.add_field_method_get("orphan", |_, me| Ok(me.orphan)); - cached_field!(fields, desc, |lua, me| lua.create_string(&*me.desc)); - } -} - -// --- Matcher -pub struct OpenerRuleMatcher(pub(super) yazi_config::opener::OpenerRuleMatcher); - -impl OpenerRuleMatcher { - pub fn new(inner: impl Into) -> Self { - Self(inner.into()) - } -} - -impl TryFrom
for OpenerRuleMatcher { - type Error = mlua::Error; - - fn try_from(t: Table) -> Result { - let id: Id = t.raw_get("id").unwrap_or_default(); - - Ok(Self(yazi_config::opener::OpenerRuleMatcher { id: id.0, ..Default::default() })) - } -} - -impl FromLua for OpenerRuleMatcher { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(t) => t.try_into(), - _ => Err("expected a table of OpenerRuleMatcher".into_lua_err()), - } - } -} - -impl IntoLua for OpenerRuleMatcher { - fn into_lua(self, lua: &Lua) -> mlua::Result { - Iter::new(self.0.map(OpenerRule::new), None).into_lua(lua) - } -} diff --git a/yazi-binding/src/config/opener_rules.rs b/yazi-binding/src/config/opener_rules.rs deleted file mode 100644 index d694bdec..00000000 --- a/yazi-binding/src/config/opener_rules.rs +++ /dev/null @@ -1,57 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, ExternalResult, FromLua, IntoLua, Lua, LuaSerdeExt, MetaMethod, UserData, UserDataMethods, Value}; -use yazi_shim::toml::DeserializeOverHook; - -use crate::config::{OpenerRule, OpenerRuleMatcher}; - -pub struct OpenerRules { - inner: Arc, -} - -impl Deref for OpenerRules { - type Target = Arc; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl OpenerRules { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into() } - } -} - -impl FromLua for OpenerRules { - fn from_lua(value: Value, lua: &Lua) -> mlua::Result { - let inner: yazi_config::opener::OpenerRules = lua.from_value(value)?; - - Ok(Self::new(inner.deserialize_over_hook().into_lua_err()?)) - } -} - -impl UserData for OpenerRules { - fn add_methods>(methods: &mut M) { - methods.add_method("match", |lua, me, matcher: Option| match matcher { - Some(matcher) => matcher.into_lua(lua), - None => OpenerRuleMatcher::new(&*me.inner).into_lua(lua), - }); - - methods.add_method("insert", |_, me, (index, rule): (isize, OpenerRule)| { - let index = match index { - 1.. => index - 1, - 0 => return Err("index must be 1-based or negative".into_lua_err()), - _ => index, - }; - - me.inner.insert(index, rule.clone()).into_lua_err()?; - Ok(rule) - }); - - methods.add_method("remove", |_, me, matcher: OpenerRuleMatcher| { - me.inner.remove(matcher.0); - Ok(()) - }); - - methods.add_meta_method(MetaMethod::Len, |_, me, ()| Ok(me.inner.load().len())); - } -} diff --git a/yazi-binding/src/config/preloader.rs b/yazi-binding/src/config/preloader.rs deleted file mode 100644 index 1d81e0eb..00000000 --- a/yazi-binding/src/config/preloader.rs +++ /dev/null @@ -1,75 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, Value}; -use yazi_config::YAZI; - -use crate::{FileRef, Id, Iter, cached_field}; - -#[derive(Clone)] -pub struct Preloader { - inner: Arc, - - v_name: Option, -} - -impl Deref for Preloader { - type Target = yazi_config::plugin::Preloader; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl Preloader { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into(), v_name: None } - } -} - -impl UserData for Preloader { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - - cached_field!(fields, name, |lua, me| lua.create_string(&*me.name)); - } -} - -// --- Matcher -pub struct PreloaderMatcher(pub(super) yazi_config::plugin::PreloaderMatcher<'static>); - -impl PreloaderMatcher { - pub fn new(inner: impl Into>) -> Self { - Self(inner.into()) - } -} - -impl TryFrom
for PreloaderMatcher { - type Error = mlua::Error; - - fn try_from(value: Table) -> Result { - let id: Id = value.raw_get("id").unwrap_or_default(); - let file: Option = value.raw_get("file")?; - let mime: Option = value.raw_get("mime")?; - - Ok(Self(yazi_config::plugin::PreloaderMatcher { - preloaders: YAZI.plugin.preloaders.load_full(), - id: id.0, - file: file.map(|f| f.inner.clone().into()), - mime: mime.map(Into::into), - ..Default::default() - })) - } -} - -impl FromLua for PreloaderMatcher { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(t) => t.try_into(), - _ => Err("expected a table of PreloaderMatcher".into_lua_err()), - } - } -} - -impl IntoLua for PreloaderMatcher { - fn into_lua(self, lua: &Lua) -> mlua::Result { - Iter::new(self.0.map(Preloader::new), None).into_lua(lua) - } -} diff --git a/yazi-binding/src/config/preloaders.rs b/yazi-binding/src/config/preloaders.rs deleted file mode 100644 index f1c13769..00000000 --- a/yazi-binding/src/config/preloaders.rs +++ /dev/null @@ -1,17 +0,0 @@ -use mlua::{IntoLua, MetaMethod, UserData, UserDataMethods}; -use yazi_config::YAZI; - -use crate::config::PreloaderMatcher; - -pub struct Preloaders; - -impl UserData for Preloaders { - fn add_methods>(methods: &mut M) { - methods.add_method("match", |lua, _, matcher: Option| match matcher { - Some(matcher) => matcher.into_lua(lua), - None => PreloaderMatcher::new(&YAZI.plugin.preloaders).into_lua(lua), - }); - - methods.add_meta_method(MetaMethod::Len, |_, _, ()| Ok(YAZI.plugin.preloaders.load().len())); - } -} diff --git a/yazi-binding/src/config/previewer.rs b/yazi-binding/src/config/previewer.rs deleted file mode 100644 index 4863a972..00000000 --- a/yazi-binding/src/config/previewer.rs +++ /dev/null @@ -1,85 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, Table, UserData, UserDataFields, Value}; -use yazi_config::YAZI; - -use crate::{FileRef, Id, Iter, cached_field}; - -#[derive(Clone)] -pub struct Previewer { - inner: Arc, - - v_name: Option, -} - -impl Deref for Previewer { - type Target = yazi_config::plugin::Previewer; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl From for Arc { - fn from(value: Previewer) -> Self { value.inner } -} - -impl Previewer { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into(), v_name: None } - } -} - -impl FromLua for Previewer { - fn from_lua(value: Value, lua: &Lua) -> mlua::Result { - Ok(Self::new(lua.from_value::(value)?)) - } -} - -impl UserData for Previewer { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - - cached_field!(fields, name, |lua, me| lua.create_string(&*me.name)); - } -} - -// --- Matcher -pub struct PreviewerMatcher(pub(super) yazi_config::plugin::PreviewerMatcher<'static>); - -impl PreviewerMatcher { - pub fn new(inner: impl Into>) -> Self { - Self(inner.into()) - } -} - -impl TryFrom
for PreviewerMatcher { - type Error = mlua::Error; - - fn try_from(value: Table) -> Result { - let id: Id = value.raw_get("id").unwrap_or_default(); - let file: Option = value.raw_get("file")?; - let mime: Option = value.raw_get("mime")?; - - Ok(Self(yazi_config::plugin::PreviewerMatcher { - previewers: YAZI.plugin.previewers.load_full(), - id: id.0, - file: file.map(|f| f.inner.clone().into()), - mime: mime.map(Into::into), - ..Default::default() - })) - } -} - -impl FromLua for PreviewerMatcher { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(t) => t.try_into(), - _ => Err("expected a table of PreviewerMatcher".into_lua_err()), - } - } -} - -impl IntoLua for PreviewerMatcher { - fn into_lua(self, lua: &Lua) -> mlua::Result { - Iter::new(self.0.map(Previewer::new), None).into_lua(lua) - } -} diff --git a/yazi-binding/src/config/previewers.rs b/yazi-binding/src/config/previewers.rs deleted file mode 100644 index 66934839..00000000 --- a/yazi-binding/src/config/previewers.rs +++ /dev/null @@ -1,33 +0,0 @@ -use mlua::{ExternalError, ExternalResult, IntoLua, MetaMethod, UserData, UserDataMethods}; -use yazi_config::YAZI; - -use crate::config::{Previewer, PreviewerMatcher}; - -pub struct Previewers; - -impl UserData for Previewers { - fn add_methods>(methods: &mut M) { - methods.add_method("match", |lua, _, matcher: Option| match matcher { - Some(matcher) => matcher.into_lua(lua), - None => PreviewerMatcher::new(&YAZI.plugin.previewers).into_lua(lua), - }); - - methods.add_method("insert", |_, _, (index, previewer): (isize, Previewer)| { - let index = match index { - 1.. => index - 1, - 0 => return Err("index must be 1-based or negative".into_lua_err()), - _ => index, - }; - - YAZI.plugin.previewers.insert(index, previewer.clone().into()).into_lua_err()?; - Ok(previewer) - }); - - methods.add_method("remove", |_, _, matcher: PreviewerMatcher| { - YAZI.plugin.previewers.remove(matcher.0); - Ok(()) - }); - - methods.add_meta_method(MetaMethod::Len, |_, _, ()| Ok(YAZI.plugin.previewers.load().len())); - } -} diff --git a/yazi-binding/src/config/spotter.rs b/yazi-binding/src/config/spotter.rs deleted file mode 100644 index 719331ff..00000000 --- a/yazi-binding/src/config/spotter.rs +++ /dev/null @@ -1,75 +0,0 @@ -use std::{ops::Deref, sync::Arc}; - -use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, UserData, UserDataFields, Value}; -use yazi_config::YAZI; - -use crate::{FileRef, Id, Iter, cached_field}; - -#[derive(Clone)] -pub struct Spotter { - inner: Arc, - - v_name: Option, -} - -impl Deref for Spotter { - type Target = yazi_config::plugin::Spotter; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl Spotter { - pub fn new(inner: impl Into>) -> Self { - Self { inner: inner.into(), v_name: None } - } -} - -impl UserData for Spotter { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("id", |_, me| Ok(Id(me.id))); - - cached_field!(fields, name, |lua, me| lua.create_string(&*me.name)); - } -} - -// --- Matcher -pub struct SpotterMatcher(pub(super) yazi_config::plugin::SpotterMatcher<'static>); - -impl SpotterMatcher { - pub fn new(inner: impl Into>) -> Self { - Self(inner.into()) - } -} - -impl TryFrom
for SpotterMatcher { - type Error = mlua::Error; - - fn try_from(value: Table) -> Result { - let id: Id = value.raw_get("id").unwrap_or_default(); - let file: Option = value.raw_get("file")?; - let mime: Option = value.raw_get("mime")?; - - Ok(Self(yazi_config::plugin::SpotterMatcher { - spotters: YAZI.plugin.spotters.load_full(), - id: id.0, - file: file.map(|f| f.inner.clone().into()), - mime: mime.map(Into::into), - ..Default::default() - })) - } -} - -impl FromLua for SpotterMatcher { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(t) => t.try_into(), - _ => Err("expected a table of SpotterMatcher".into_lua_err()), - } - } -} - -impl IntoLua for SpotterMatcher { - fn into_lua(self, lua: &Lua) -> mlua::Result { - Iter::new(self.0.map(Spotter::new), None).into_lua(lua) - } -} diff --git a/yazi-binding/src/config/spotters.rs b/yazi-binding/src/config/spotters.rs deleted file mode 100644 index 8afda780..00000000 --- a/yazi-binding/src/config/spotters.rs +++ /dev/null @@ -1,17 +0,0 @@ -use mlua::{IntoLua, MetaMethod, UserData, UserDataMethods}; -use yazi_config::YAZI; - -use crate::config::SpotterMatcher; - -pub struct Spotters; - -impl UserData for Spotters { - fn add_methods>(methods: &mut M) { - methods.add_method("match", |lua, _, matcher: Option| match matcher { - Some(matcher) => matcher.into_lua(lua), - None => SpotterMatcher::new(&YAZI.plugin.spotters).into_lua(lua), - }); - - methods.add_meta_method(MetaMethod::Len, |_, _, ()| Ok(YAZI.plugin.spotters.load().len())); - } -} diff --git a/yazi-binding/src/elements/align.rs b/yazi-binding/src/elements/align.rs index 564cfa70..5d4a2a18 100644 --- a/yazi-binding/src/elements/align.rs +++ b/yazi-binding/src/elements/align.rs @@ -3,10 +3,10 @@ use std::ops::Deref; use mlua::{FromLua, IntoLua, Lua, Value}; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] -pub struct Align(pub(super) ratatui::layout::Alignment); +pub struct Align(pub(super) ratatui_core::layout::Alignment); impl Deref for Align { - type Target = ratatui::layout::Alignment; + type Target = ratatui_core::layout::Alignment; fn deref(&self) -> &Self::Target { &self.0 } } @@ -27,9 +27,9 @@ impl FromLua for Align { }); }; Ok(Self(match n { - 0 => ratatui::layout::Alignment::Left, - 1 => ratatui::layout::Alignment::Center, - 2 => ratatui::layout::Alignment::Right, + 0 => ratatui_core::layout::Alignment::Left, + 1 => ratatui_core::layout::Alignment::Center, + 2 => ratatui_core::layout::Alignment::Right, _ => Err(mlua::Error::FromLuaConversionError { from: value.type_name(), to: "Align".to_string(), diff --git a/yazi-binding/src/elements/area.rs b/yazi-binding/src/elements/area.rs index f2cf04cd..888f06e9 100644 --- a/yazi-binding/src/elements/area.rs +++ b/yazi-binding/src/elements/area.rs @@ -1,48 +1,63 @@ use std::fmt::Debug; use mlua::{AnyUserData, ExternalError, FromLua, IntoLua, Lua, Value}; +use yazi_shim::ratatui::Padable; -use super::{Pos, Rect}; +use super::Rect; +use crate::position::Position; const EXPECTED: &str = "expected a Pos or Rect"; #[derive(Clone, Copy)] pub enum Area { - Pos(Pos), Rect(Rect), + Pos(Position), } impl Default for Area { fn default() -> Self { Self::Rect(Default::default()) } } -impl Area { - pub fn size(self) -> ratatui::layout::Size { +impl Debug for Area { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Rect(rect) => write!(f, "{:?}", **rect), + Self::Pos(pos) => write!(f, "{:?}", **pos), + } + } +} + +impl From for Position { + fn from(value: Area) -> Self { + match value { + Area::Rect(rect) => Self::from(*rect), + Area::Pos(pos) => pos, + } + } +} + +impl Area { + pub fn size(self) -> ratatui_core::layout::Size { match self { - Self::Pos(pos) => { - ratatui::layout::Size { width: pos.offset.width, height: pos.offset.height } - } Self::Rect(rect) => (*rect).into(), + Self::Pos(pos) => ratatui_core::layout::Size { width: pos.width, height: pos.height }, } } - pub fn inner(self, padding: ratatui::widgets::Padding) -> Self { + pub fn padding(self, padding: ratatui_widgets::block::Padding) -> Self { match self { - Self::Pos(mut pos) => { - pos.pad += padding; - Self::Pos(pos) - } - Self::Rect(rect) => Self::Rect(rect.pad(padding.into())), + Self::Rect(rect) => Self::Rect(rect.padding(padding).into()), + Self::Pos(pos) => Self::Pos(pos.padding(padding)), } } pub fn transform( self, - f: impl FnOnce(yazi_config::popup::Position) -> ratatui::layout::Rect, - ) -> ratatui::layout::Rect { + f: impl FnOnce(Position) -> ratatui_core::layout::Rect, + ) -> ratatui_core::layout::Rect { match self { - Self::Pos(pos) => *Rect(f(*pos)).pad(pos.pad), Self::Rect(rect) => *rect, + Self::Pos(pos) => f(pos), } } } @@ -51,17 +66,21 @@ impl From for Area { fn from(rect: Rect) -> Self { Self::Rect(rect) } } -impl From for Area { - fn from(rect: ratatui::layout::Rect) -> Self { Self::Rect(rect.into()) } +impl From for Area { + fn from(rect: ratatui_core::layout::Rect) -> Self { Self::Rect(rect.into()) } } -impl TryFrom for Area { +impl From for Area { + fn from(value: Position) -> Self { Self::Pos(value) } +} + +impl TryFrom<&AnyUserData> for Area { type Error = mlua::Error; - fn try_from(value: AnyUserData) -> Result { + fn try_from(value: &AnyUserData) -> Result { Ok(if let Ok(rect) = value.borrow::() { Self::Rect(*rect) - } else if let Ok(pos) = value.borrow::() { + } else if let Ok(pos) = value.borrow::() { Self::Pos(*pos) } else { return Err(EXPECTED.into_lua_err()); @@ -72,7 +91,7 @@ impl TryFrom for Area { impl FromLua for Area { fn from_lua(value: Value, _: &Lua) -> mlua::Result { match value { - Value::UserData(ud) => Self::try_from(ud), + Value::UserData(ud) => Self::try_from(&ud), _ => Err(EXPECTED.into_lua_err()), } } @@ -81,17 +100,8 @@ impl FromLua for Area { impl IntoLua for Area { fn into_lua(self, lua: &Lua) -> mlua::Result { match self { - Self::Pos(pos) => pos.into_lua(lua), Self::Rect(rect) => rect.into_lua(lua), - } - } -} - -impl Debug for Area { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Pos(pos) => write!(f, "{:?}", **pos), - Self::Rect(rect) => write!(f, "{:?}", **rect), + Self::Pos(pos) => pos.into_lua(lua), } } } diff --git a/yazi-binding/src/elements/bar.rs b/yazi-binding/src/elements/bar.rs index eb94303b..e260747c 100644 --- a/yazi-binding/src/elements/bar.rs +++ b/yazi-binding/src/elements/bar.rs @@ -1,15 +1,17 @@ use mlua::{AnyUserData, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::{Borders, Widget}; +use ratatui_core::widgets::Widget; +use ratatui_widgets::borders::Borders; use super::{Area, Edge}; +use crate::elements::Spatial; #[derive(Clone, Debug, Default)] pub struct Bar { - pub(super) area: Area, + area: Area, edge: Edge, symbol: String, - style: ratatui::style::Style, + style: ratatui_core::style::Style, } impl Bar { @@ -23,17 +25,20 @@ impl Bar { } } -impl Widget for Bar { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - (&self).render(rect, buf); - } +impl TryFrom<&AnyUserData> for Bar { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { value.take() } +} + +impl Spatial for Bar { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } } impl Widget for &Bar { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { diff --git a/yazi-binding/src/elements/border.rs b/yazi-binding/src/elements/border.rs index a56ac58d..cbb76a2f 100644 --- a/yazi-binding/src/elements/border.rs +++ b/yazi-binding/src/elements/border.rs @@ -1,8 +1,9 @@ use mlua::{AnyUserData, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::{Borders, Widget}; +use ratatui_core::widgets::Widget; +use ratatui_widgets::borders::Borders; use super::{Area, Edge}; -use crate::elements::Line; +use crate::elements::{Line, Spatial}; // Type const PLAIN: u8 = 0; @@ -17,16 +18,17 @@ pub struct Border { pub area: Area, pub edge: Edge, - pub r#type: ratatui::widgets::BorderType, - pub style: ratatui::style::Style, + pub r#type: ratatui_widgets::borders::BorderType, + pub style: ratatui_core::style::Style, + pub merge: ratatui_core::symbols::merge::MergeStrategy, - pub titles: Vec<(ratatui::widgets::TitlePosition, ratatui::text::Line<'static>)>, + pub titles: Vec<(ratatui_widgets::block::TitlePosition, ratatui_core::text::Line<'static>)>, } impl Border { pub fn compose(lua: &Lua) -> mlua::Result { let new = lua.create_function(|_, (_, edge): (Table, Edge)| { - Ok(Self { edge, r#type: ratatui::widgets::BorderType::Rounded, ..Default::default() }) + Ok(Self { edge, r#type: ratatui_widgets::borders::BorderType::Rounded, ..Default::default() }) })?; let border = lua.create_table_from([ @@ -44,20 +46,33 @@ impl Border { } } +impl TryFrom<&AnyUserData> for Border { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { value.take() } +} + +impl Spatial for Border { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } +} + impl Widget for Border { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { - let mut block = ratatui::widgets::Block::default() + let mut block = ratatui_widgets::block::Block::default() .borders(self.edge.0) .border_type(self.r#type) - .border_style(self.style); + .border_style(self.style) + .merge_borders(self.merge); for title in self.titles { block = match title { - (ratatui::widgets::TitlePosition::Top, line) => block.title_top(line), - (ratatui::widgets::TitlePosition::Bottom, line) => block.title_bottom(line), + (ratatui_widgets::block::TitlePosition::Top, line) => block.title_top(line), + (ratatui_widgets::block::TitlePosition::Bottom, line) => block.title_bottom(line), }; } @@ -66,7 +81,7 @@ impl Widget for Border { } impl Widget for &Border { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { @@ -81,20 +96,20 @@ impl UserData for Border { methods.add_function("type", |_, (ud, value): (AnyUserData, u8)| { ud.borrow_mut::()?.r#type = match value { - ROUNDED => ratatui::widgets::BorderType::Rounded, - DOUBLE => ratatui::widgets::BorderType::Double, - THICK => ratatui::widgets::BorderType::Thick, - QUADRANT_INSIDE => ratatui::widgets::BorderType::QuadrantInside, - QUADRANT_OUTSIDE => ratatui::widgets::BorderType::QuadrantOutside, - _ => ratatui::widgets::BorderType::Plain, + ROUNDED => ratatui_widgets::borders::BorderType::Rounded, + DOUBLE => ratatui_widgets::borders::BorderType::Double, + THICK => ratatui_widgets::borders::BorderType::Thick, + QUADRANT_INSIDE => ratatui_widgets::borders::BorderType::QuadrantInside, + QUADRANT_OUTSIDE => ratatui_widgets::borders::BorderType::QuadrantOutside, + _ => ratatui_widgets::borders::BorderType::Plain, }; Ok(ud) }); methods.add_function("title", |_, (ud, line, position): (AnyUserData, Line, Option)| { let position = if position == Some(Borders::BOTTOM.bits()) { - ratatui::widgets::TitlePosition::Bottom + ratatui_widgets::block::TitlePosition::Bottom } else { - ratatui::widgets::TitlePosition::Top + ratatui_widgets::block::TitlePosition::Top }; ud.borrow_mut::()?.titles.push((position, line.inner)); @@ -104,5 +119,13 @@ impl UserData for Border { ud.borrow_mut::()?.edge = edge; Ok(ud) }); + methods.add_function("merge", |_, (ud, exact): (AnyUserData, bool)| { + ud.borrow_mut::()?.merge = if exact { + ratatui_core::symbols::merge::MergeStrategy::Exact + } else { + ratatui_core::symbols::merge::MergeStrategy::Fuzzy + }; + Ok(ud) + }); } } diff --git a/yazi-binding/src/elements/cell.rs b/yazi-binding/src/elements/cell.rs index 3b31b907..a75805ac 100644 --- a/yazi-binding/src/elements/cell.rs +++ b/yazi-binding/src/elements/cell.rs @@ -4,10 +4,10 @@ use super::Text; #[derive(Clone, Debug)] pub struct Cell { - pub(super) text: ratatui::text::Text<'static>, + pub(super) text: ratatui_core::text::Text<'static>, } -impl From for ratatui::widgets::Cell<'static> { +impl From for ratatui_widgets::table::Cell<'static> { fn from(value: Cell) -> Self { Self::new(value.text) } } diff --git a/yazi-binding/src/elements/clear.rs b/yazi-binding/src/elements/clear.rs deleted file mode 100644 index 5bcf0c2b..00000000 --- a/yazi-binding/src/elements/clear.rs +++ /dev/null @@ -1,44 +0,0 @@ -use mlua::{IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::Widget; - -use super::Area; - -#[derive(Clone, Copy, Debug, Default)] -pub struct Clear { - pub area: Area, -} - -impl Clear { - pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, (_, area): (Table, Area)| Ok(Self { area }))?; - - let clear = lua.create_table()?; - clear.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; - - clear.into_lua(lua) - } -} - -impl Widget for Clear { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - (&self).render(rect, buf); - } -} - -impl Widget for &Clear { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - yazi_widgets::Clear.render(rect, buf); - } -} - -impl UserData for Clear { - fn add_methods>(methods: &mut M) { - crate::impl_area_method!(methods); - } -} diff --git a/yazi-binding/src/elements/color.rs b/yazi-binding/src/elements/color.rs index 503f6d5d..a7bf7926 100644 --- a/yazi-binding/src/elements/color.rs +++ b/yazi-binding/src/elements/color.rs @@ -1,9 +1,9 @@ use std::str::FromStr; -use mlua::{ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, Value}; +use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, Value}; #[derive(Clone, Copy, Default)] -pub struct Color(pub ratatui::style::Color); +pub struct Color(pub ratatui_core::style::Color); impl Color { pub fn compose(lua: &Lua) -> mlua::Result { @@ -16,12 +16,18 @@ impl Color { } } +impl TryFrom<&AnyUserData> for Color { + type Error = mlua::Error; + + fn try_from(ud: &AnyUserData) -> Result { Ok(*ud.borrow()?) } +} + impl FromLua for Color { fn from_lua(value: Value, _: &Lua) -> mlua::Result { Ok(Self(match value { - Value::Nil => ratatui::style::Color::Reset, - Value::String(s) => ratatui::style::Color::from_str(&s.to_str()?).into_lua_err()?, - Value::UserData(ud) => ud.borrow::()?.0, + Value::Nil => ratatui_core::style::Color::Reset, + Value::String(s) => ratatui_core::style::Color::from_str(&s.to_str()?).into_lua_err()?, + Value::UserData(ud) => return Self::try_from(&ud), _ => Err("expected a Color".into_lua_err())?, })) } diff --git a/yazi-binding/src/elements/constraint.rs b/yazi-binding/src/elements/constraint.rs index c2ecad07..82fe300c 100644 --- a/yazi-binding/src/elements/constraint.rs +++ b/yazi-binding/src/elements/constraint.rs @@ -1,11 +1,11 @@ use mlua::{FromLua, IntoLua, Lua, UserData, Value}; #[derive(Clone, Copy, Default, FromLua)] -pub struct Constraint(pub(super) ratatui::layout::Constraint); +pub struct Constraint(pub(super) ratatui_core::layout::Constraint); impl Constraint { pub fn compose(lua: &Lua) -> mlua::Result { - use ratatui::layout::Constraint as C; + use ratatui_core::layout::Constraint as C; lua .create_table_from([ @@ -20,7 +20,7 @@ impl Constraint { } } -impl From for ratatui::layout::Constraint { +impl From for ratatui_core::layout::Constraint { fn from(value: Constraint) -> Self { value.0 } } diff --git a/yazi-binding/src/elements/edge.rs b/yazi-binding/src/elements/edge.rs index a239ae60..f0b6bcf3 100644 --- a/yazi-binding/src/elements/edge.rs +++ b/yazi-binding/src/elements/edge.rs @@ -1,7 +1,7 @@ use std::ops::Deref; use mlua::{FromLua, IntoLua, Lua, Value}; -use ratatui::widgets::Borders; +use ratatui_widgets::borders::Borders; #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct Edge(pub Borders); diff --git a/yazi-binding/src/elements/elements.rs b/yazi-binding/src/elements/elements.rs deleted file mode 100644 index 45971550..00000000 --- a/yazi-binding/src/elements/elements.rs +++ /dev/null @@ -1,59 +0,0 @@ -use mlua::{IntoLua, Lua, Value}; -use tracing::error; - -use super::Renderable; -use crate::{Composer, ComposerGet, ComposerSet}; - -pub fn compose(p_get: ComposerGet, p_set: ComposerSet) -> Composer { - fn get(lua: &Lua, key: &[u8]) -> mlua::Result { - match key { - b"Align" => super::Align::compose(lua)?, - b"Bar" => super::Bar::compose(lua)?, - b"Border" => super::Border::compose(lua)?, - b"Clear" => super::Clear::compose(lua)?, - b"Color" => super::Color::compose(lua)?, - b"Constraint" => super::Constraint::compose(lua)?, - b"Edge" => super::Edge::compose(lua)?, - b"Gauge" => super::Gauge::compose(lua)?, - b"Layout" => super::Layout::compose(lua)?, - b"Line" => super::Line::compose(lua)?, - b"List" => super::List::compose(lua)?, - b"Pad" => super::Pad::compose(lua)?, - b"Pos" => super::Pos::compose(lua)?, - b"Rect" => super::Rect::compose(lua)?, - b"Row" => super::Row::compose(lua)?, - b"Span" => super::Span::compose(lua)?, - b"Style" => crate::Style::compose(lua)?, - b"Table" => super::Table::compose(lua)?, - b"Text" => super::Text::compose(lua)?, - b"Wrap" => super::Wrap::compose(lua)?, - _ => return Ok(Value::Nil), - } - .into_lua(lua) - } - - fn set(_: &Lua, _: &[u8], value: Value) -> mlua::Result { Ok(value) } - - Composer::with_parent(get, set, p_get, p_set) -} - -pub fn render_once(value: Value, buf: &mut ratatui::buffer::Buffer, trans: F) -where - F: FnOnce(yazi_config::popup::Position) -> ratatui::layout::Rect + Copy, -{ - match value { - Value::Table(tbl) => { - for widget in tbl.sequence_values::() { - match widget { - Ok(w) => w.render_with(buf, trans), - Err(e) => error!("Failed to convert to renderable elements: {e}"), - } - } - } - Value::UserData(ud) => match Renderable::try_from(&ud) { - Ok(w) => w.render_with(buf, trans), - Err(e) => error!("Failed to convert to renderable element: {e}"), - }, - _ => error!("Expected a renderable element, or a table of them, got: {value:?}"), - } -} diff --git a/yazi-binding/src/elements/fill.rs b/yazi-binding/src/elements/fill.rs new file mode 100644 index 00000000..2ce66918 --- /dev/null +++ b/yazi-binding/src/elements/fill.rs @@ -0,0 +1,57 @@ +use mlua::{AnyUserData, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; +use ratatui_core::widgets::Widget; + +use super::Area; +use crate::elements::Spatial; + +#[derive(Clone, Copy, Debug, Default)] +pub struct Fill { + area: Area, + + style: ratatui_core::style::Style, +} + +impl Fill { + pub fn compose(lua: &Lua) -> mlua::Result { + let new = + lua.create_function(|_, (_, area): (Table, Area)| Ok(Self { area, ..Default::default() }))?; + + let fill = lua.create_table()?; + fill.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; + + fill.into_lua(lua) + } +} + +impl TryFrom<&AnyUserData> for Fill { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { Ok(*value.borrow()?) } +} + +impl Spatial for Fill { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } +} + +impl Widget for &Fill { + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) + where + Self: Sized, + { + if self.style == Default::default() { + return; + } + + for pos in rect.positions() { + buf[pos].set_style(self.style); + } + } +} + +impl UserData for Fill { + fn add_methods>(methods: &mut M) { + crate::impl_style_method!(methods, style); + } +} diff --git a/yazi-binding/src/elements/gauge.rs b/yazi-binding/src/elements/gauge.rs index d9eb611c..9c411748 100644 --- a/yazi-binding/src/elements/gauge.rs +++ b/yazi-binding/src/elements/gauge.rs @@ -1,17 +1,17 @@ use mlua::{AnyUserData, ExternalError, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::Widget; +use ratatui_core::widgets::Widget; use super::{Area, Span}; -use crate::Style; +use crate::{elements::Spatial, style::Style}; #[derive(Clone, Debug, Default)] pub struct Gauge { - pub(super) area: Area, + area: Area, ratio: f64, - label: Option>, - style: ratatui::style::Style, - gauge_style: ratatui::style::Style, + label: Option>, + style: ratatui_core::style::Style, + gauge_style: ratatui_core::style::Style, } impl Gauge { @@ -25,12 +25,24 @@ impl Gauge { } } +impl TryFrom<&AnyUserData> for Gauge { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { value.take() } +} + +impl Spatial for Gauge { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } +} + impl Widget for Gauge { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { - let mut gauge = ratatui::widgets::Gauge::default() + let mut gauge = ratatui_widgets::gauge::Gauge::default() .ratio(self.ratio) .style(self.style) .gauge_style(self.gauge_style); @@ -44,7 +56,7 @@ impl Widget for Gauge { } impl Widget for &Gauge { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { diff --git a/yazi-binding/src/elements/layout.rs b/yazi-binding/src/elements/layout.rs index bf499894..eca8187c 100644 --- a/yazi-binding/src/elements/layout.rs +++ b/yazi-binding/src/elements/layout.rs @@ -8,8 +8,8 @@ const VERTICAL: bool = false; #[derive(Clone, Default)] pub struct Layout { direction: bool, - margin: Option, - constraints: Vec, + margin: Option, + constraints: Vec, } impl Layout { @@ -30,7 +30,7 @@ impl UserData for Layout { Ok(ud) }); methods.add_function("margin", |_, (ud, value): (AnyUserData, u16)| { - ud.borrow_mut::()?.margin = Some(ratatui::layout::Margin::new(value, value)); + ud.borrow_mut::()?.margin = Some(ratatui_core::layout::Margin::new(value, value)); Ok(ud) }); methods.add_function("margin_h", |_, (ud, value): (AnyUserData, u16)| { @@ -39,7 +39,7 @@ impl UserData for Layout { if let Some(margin) = &mut me.margin { margin.horizontal = value; } else { - me.margin = Some(ratatui::layout::Margin::new(value, 0)); + me.margin = Some(ratatui_core::layout::Margin::new(value, 0)); } } Ok(ud) @@ -50,7 +50,7 @@ impl UserData for Layout { if let Some(margin) = &mut me.margin { margin.vertical = value; } else { - me.margin = Some(ratatui::layout::Margin::new(0, value)); + me.margin = Some(ratatui_core::layout::Margin::new(0, value)); } } Ok(ud) @@ -60,11 +60,11 @@ impl UserData for Layout { Ok(ud) }); methods.add_method("split", |lua, me, value: Rect| { - let mut layout = ratatui::layout::Layout::new( + let mut layout = ratatui_core::layout::Layout::new( if me.direction == VERTICAL { - ratatui::layout::Direction::Vertical + ratatui_core::layout::Direction::Vertical } else { - ratatui::layout::Direction::Horizontal + ratatui_core::layout::Direction::Horizontal }, &me.constraints, ); diff --git a/yazi-binding/src/elements/line.rs b/yazi-binding/src/elements/line.rs index 7a38dfcb..4bcc6048 100644 --- a/yazi-binding/src/elements/line.rs +++ b/yazi-binding/src/elements/line.rs @@ -1,24 +1,24 @@ use std::{borrow::Cow, mem, ops::{Deref, DerefMut}}; use ansi_to_tui::IntoText; -use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::Widget; +use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, Function, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; +use ratatui_core::widgets::Widget; use unicode_width::UnicodeWidthChar; use super::{Area, Span}; -use crate::elements::Align; +use crate::elements::{Align, Spatial}; const EXPECTED: &str = "expected a string, Span, Line, or a table of them"; #[derive(Clone, Debug, Default)] pub struct Line { - pub(super) area: Area, + area: Area, - pub(super) inner: ratatui::text::Line<'static>, + pub(super) inner: ratatui_core::text::Line<'static>, } impl Deref for Line { - type Target = ratatui::text::Line<'static>; + type Target = ratatui_core::text::Line<'static>; fn deref(&self) -> &Self::Target { &self.inner } } @@ -51,12 +51,26 @@ impl Line { } } -impl From> for Line { - fn from(value: ratatui::text::Line<'static>) -> Self { +impl From> for Line { + fn from(value: ratatui_core::text::Line<'static>) -> Self { Self { inner: value, ..Default::default() } } } +impl TryFrom<&AnyUserData> for Line { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { + Ok(if let Ok(line) = value.take() { + line + } else if let Ok(Span(span)) = value.take() { + Self { inner: span.into(), ..Default::default() } + } else { + Err(EXPECTED.into_lua_err())? + }) + } +} + impl TryFrom
for Line { type Error = mlua::Error; @@ -82,21 +96,18 @@ impl TryFrom
for Line { } } -impl From for ratatui::text::Line<'static> { +impl From for ratatui_core::text::Line<'static> { fn from(value: Line) -> Self { value.inner } } -impl Widget for Line { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - (&self).render(rect, buf); - } +impl Spatial for Line { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } } impl Widget for &Line { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { @@ -106,22 +117,11 @@ impl Widget for &Line { impl FromLua for Line { fn from_lua(value: Value, _: &Lua) -> mlua::Result { - Ok(Self { - inner: match value { - Value::Table(tb) => return Self::try_from(tb), - Value::String(s) => s.to_string_lossy().into(), - Value::UserData(ud) => { - if let Ok(Span(span)) = ud.take() { - span.into() - } else if let Ok(line) = ud.take() { - return Ok(line); - } else { - Err(EXPECTED.into_lua_err())? - } - } - _ => Err(EXPECTED.into_lua_err())?, - }, - ..Default::default() + Ok(match value { + Value::Table(tb) => Self::try_from(tb)?, + Value::String(s) => Self { inner: s.to_string_lossy().into(), ..Default::default() }, + Value::UserData(ud) => Self::try_from(&ud)?, + _ => Err(EXPECTED.into_lua_err())?, }) } } @@ -140,6 +140,13 @@ impl UserData for Line { methods.add_method("visible", |_, me, ()| { Ok(me.iter().flat_map(|s| s.content.chars()).any(|c| c.width().unwrap_or(0) > 0)) }); + methods.add_function("map", |_, (ud, f): (AnyUserData, Function)| { + let mut me = ud.borrow_mut::()?; + for span in &mut me.spans { + *span = f.call::(Span(mem::take(span)))?.0; + } + Ok(ud) + }); methods.add_function("truncate", |lua, (ud, t): (AnyUserData, Table)| { let mut me = ud.borrow_mut::()?; @@ -150,7 +157,7 @@ impl UserData for Line { } let ellipsis = match t.raw_get::("ellipsis")? { - Value::Nil => (1, ratatui::text::Span::raw("…")), + Value::Nil => (1, ratatui_core::text::Span::raw("…")), v => { let mut span = Span::from_lua(v, lua)?; (span.truncate(max), span.0) diff --git a/yazi-binding/src/elements/list.rs b/yazi-binding/src/elements/list.rs index 09f7b973..a4480d77 100644 --- a/yazi-binding/src/elements/list.rs +++ b/yazi-binding/src/elements/list.rs @@ -1,20 +1,21 @@ -use mlua::{IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::Widget; +use mlua::{AnyUserData, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; +use ratatui_core::widgets::Widget; use super::{Area, Text}; +use crate::elements::Spatial; // --- List #[derive(Clone, Debug, Default)] pub struct List { - pub(super) area: Area, + area: Area, - inner: ratatui::widgets::List<'static>, + inner: ratatui_widgets::list::List<'static>, } impl List { pub fn compose(lua: &Lua) -> mlua::Result { let new = lua.create_function(|_, (_, items): (Table, Vec)| { - Ok(Self { inner: ratatui::widgets::List::new(items), ..Default::default() }) + Ok(Self { inner: ratatui_widgets::list::List::new(items), ..Default::default() }) })?; let list = lua.create_table()?; @@ -24,17 +25,20 @@ impl List { } } -impl Widget for List { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - (&self).render(rect, buf); - } +impl TryFrom<&AnyUserData> for List { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { value.take() } +} + +impl Spatial for List { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } } impl Widget for &List { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { diff --git a/yazi-binding/src/elements/mod.rs b/yazi-binding/src/elements/mod.rs index 6e1066f1..1cdbbe83 100644 --- a/yazi-binding/src/elements/mod.rs +++ b/yazi-binding/src/elements/mod.rs @@ -1 +1 @@ -yazi_macro::mod_flat!(align area bar border cell clear color constraint edge highlight elements gauge layout line list pad pos rect renderable row span table text wrap); +yazi_macro::mod_flat!(align area bar border cell color constraint edge fill gauge highlight layout line list pad rect row span spatial table text wrap); diff --git a/yazi-binding/src/elements/pad.rs b/yazi-binding/src/elements/pad.rs index c7eb25b4..cd4b0376 100644 --- a/yazi-binding/src/elements/pad.rs +++ b/yazi-binding/src/elements/pad.rs @@ -3,46 +3,68 @@ use std::ops::{Add, AddAssign, Deref}; use mlua::{FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataFields, Value}; #[derive(Clone, Copy, Default, FromLua)] -pub struct Pad(ratatui::widgets::Padding); +pub struct Pad(ratatui_widgets::block::Padding); impl Deref for Pad { - type Target = ratatui::widgets::Padding; + type Target = ratatui_widgets::block::Padding; fn deref(&self) -> &Self::Target { &self.0 } } -impl From for Pad { - fn from(pad: ratatui::widgets::Padding) -> Self { Self(pad) } +impl From for Pad { + fn from(value: ratatui_widgets::block::Padding) -> Self { Self(value) } +} + +impl From for ratatui_widgets::block::Padding { + fn from(value: Pad) -> Self { value.0 } } impl Pad { pub fn compose(lua: &Lua) -> mlua::Result { let new = lua.create_function(|_, (_, top, right, bottom, left): (Table, u16, u16, u16, u16)| { - Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom))) + Ok(Self(ratatui_widgets::block::Padding::new(left, right, top, bottom))) })?; let pad = lua.create_table_from([ ( "left", - lua.create_function(|_, left: u16| Ok(Self(ratatui::widgets::Padding::left(left))))?, + lua + .create_function(|_, left: u16| Ok(Self(ratatui_widgets::block::Padding::left(left))))?, ), ( "right", - lua.create_function(|_, right: u16| Ok(Self(ratatui::widgets::Padding::right(right))))?, + lua.create_function(|_, right: u16| { + Ok(Self(ratatui_widgets::block::Padding::right(right))) + })?, + ), + ( + "top", + lua.create_function(|_, top: u16| Ok(Self(ratatui_widgets::block::Padding::top(top))))?, ), - ("top", lua.create_function(|_, top: u16| Ok(Self(ratatui::widgets::Padding::top(top))))?), ( "bottom", - lua - .create_function(|_, bottom: u16| Ok(Self(ratatui::widgets::Padding::bottom(bottom))))?, + lua.create_function(|_, bottom: u16| { + Ok(Self(ratatui_widgets::block::Padding::bottom(bottom))) + })?, + ), + ( + "x", + lua.create_function(|_, x: u16| { + Ok(Self(ratatui_widgets::block::Padding::new(x, x, 0, 0))) + })?, + ), + ( + "y", + lua.create_function(|_, y: u16| { + Ok(Self(ratatui_widgets::block::Padding::new(0, 0, y, y))) + })?, ), - ("x", lua.create_function(|_, x: u16| Ok(Self(ratatui::widgets::Padding::new(x, x, 0, 0))))?), - ("y", lua.create_function(|_, y: u16| Ok(Self(ratatui::widgets::Padding::new(0, 0, y, y))))?), ( "xy", - lua - .create_function(|_, xy: u16| Ok(Self(ratatui::widgets::Padding::new(xy, xy, xy, xy))))?, + lua.create_function(|_, xy: u16| { + Ok(Self(ratatui_widgets::block::Padding::new(xy, xy, xy, xy))) + })?, ), ])?; @@ -60,11 +82,11 @@ impl UserData for Pad { } } -impl Add for Pad { +impl Add for Pad { type Output = Self; - fn add(self, rhs: ratatui::widgets::Padding) -> Self::Output { - Self(ratatui::widgets::Padding::new( + fn add(self, rhs: ratatui_widgets::block::Padding) -> Self::Output { + Self(ratatui_widgets::block::Padding::new( self.left.saturating_add(rhs.left), self.right.saturating_add(rhs.right), self.top.saturating_add(rhs.top), @@ -73,6 +95,6 @@ impl Add for Pad { } } -impl AddAssign for Pad { - fn add_assign(&mut self, rhs: ratatui::widgets::Padding) { *self = *self + rhs; } +impl AddAssign for Pad { + fn add_assign(&mut self, rhs: ratatui_widgets::block::Padding) { *self = *self + rhs; } } diff --git a/yazi-binding/src/elements/pos.rs b/yazi-binding/src/elements/pos.rs deleted file mode 100644 index d509d945..00000000 --- a/yazi-binding/src/elements/pos.rs +++ /dev/null @@ -1,99 +0,0 @@ -use std::{ops::Deref, str::FromStr}; - -use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataFields, UserDataMethods, Value}; -use yazi_shim::strum::IntoStr; - -use super::Pad; - -const EXPECTED: &str = "expected a Pos"; - -#[derive(Clone, Copy, Default)] -pub struct Pos { - inner: yazi_config::popup::Position, - - pub(super) pad: Pad, -} - -impl Deref for Pos { - type Target = yazi_config::popup::Position; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl From for Pos { - fn from(value: yazi_config::popup::Position) -> Self { - Self { inner: value, ..Default::default() } - } -} - -impl From for yazi_config::popup::Position { - fn from(value: Pos) -> Self { value.inner } -} - -impl TryFrom
for Pos { - type Error = mlua::Error; - - fn try_from(t: Table) -> Result { - use yazi_config::popup::{Offset, Origin, Position}; - - Ok(Self::from(Position { - origin: Origin::from_str(&t.raw_get::(1)?.to_str()?).into_lua_err()?, - offset: Offset { - x: t.raw_get("x").unwrap_or_default(), - y: t.raw_get("y").unwrap_or_default(), - width: t.raw_get("w").unwrap_or_default(), - height: t.raw_get("h").unwrap_or_default(), - }, - })) - } -} - -impl FromLua for Pos { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - Ok(match value { - Value::Table(tbl) => Self::try_from(tbl)?, - Value::UserData(ud) => { - if let Ok(pos) = ud.borrow() { - *pos - } else { - Err(EXPECTED.into_lua_err())? - } - } - _ => Err(EXPECTED.into_lua_err())?, - }) - } -} - -impl Pos { - pub fn compose(lua: &Lua) -> mlua::Result { - let new = lua.create_function(|_, (_, t): (Table, Table)| Self::try_from(t))?; - - let position = lua.create_table()?; - position.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; - - position.into_lua(lua) - } - - pub fn with_height(mut self, height: u16) -> Self { - self.inner.offset.height = height; - self - } -} - -impl UserData for Pos { - fn add_fields>(fields: &mut F) { - // TODO: cache - fields.add_field_method_get("1", |_, me| Ok(me.origin.into_str())); - fields.add_field_method_get("x", |_, me| Ok(me.offset.x)); - fields.add_field_method_get("y", |_, me| Ok(me.offset.y)); - fields.add_field_method_get("w", |_, me| Ok(me.offset.width)); - fields.add_field_method_get("h", |_, me| Ok(me.offset.height)); - } - - fn add_methods>(methods: &mut M) { - methods.add_function("pad", |_, (ud, pad): (AnyUserData, Pad)| { - ud.borrow_mut::()?.pad = pad; - Ok(ud) - }); - } -} diff --git a/yazi-binding/src/elements/rect.rs b/yazi-binding/src/elements/rect.rs index 6c21d678..c39015a0 100644 --- a/yazi-binding/src/elements/rect.rs +++ b/yazi-binding/src/elements/rect.rs @@ -1,32 +1,38 @@ use std::ops::Deref; use mlua::{FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataFields, UserDataMethods, Value}; +use yazi_shim::ratatui::Padable; use super::Pad; #[derive(Clone, Copy, Debug, Default, FromLua)] -pub struct Rect(pub ratatui::layout::Rect); +pub struct Rect(pub ratatui_core::layout::Rect); impl Deref for Rect { - type Target = ratatui::layout::Rect; + type Target = ratatui_core::layout::Rect; fn deref(&self) -> &Self::Target { &self.0 } } -impl From for Rect { - fn from(rect: ratatui::layout::Rect) -> Self { Self(rect) } +impl From for Rect { + fn from(rect: ratatui_core::layout::Rect) -> Self { Self(rect) } } -impl From for Rect { - fn from(size: ratatui::layout::Size) -> Self { - Self(ratatui::layout::Rect { x: 0, y: 0, width: size.width, height: size.height }) +impl From for Rect { + fn from(size: ratatui_core::layout::Size) -> Self { + Self(ratatui_core::layout::Rect { + x: 0, + y: 0, + width: size.width, + height: size.height, + }) } } impl Rect { pub fn compose(lua: &Lua) -> mlua::Result { let new = lua.create_function(|_, (_, args): (Table, Table)| { - Ok(Self(ratatui::layout::Rect { + Ok(Self(ratatui_core::layout::Rect { x: args.raw_get("x").unwrap_or_default(), y: args.raw_get("y").unwrap_or_default(), width: args.raw_get("w").unwrap_or_default(), @@ -39,18 +45,8 @@ impl Rect { rect.into_lua(lua) } - pub(super) fn pad(self, pad: Pad) -> Self { - let mut r = *self; - r.x = r.x.saturating_add(pad.left); - r.y = r.y.saturating_add(pad.top); - - r.width = r.width.saturating_sub(pad.left + pad.right); - r.height = r.height.saturating_sub(pad.top + pad.bottom); - Self(r) - } - fn patch(self, t: Table) -> mlua::Result { - Ok(Self(ratatui::layout::Rect { + Ok(Self(ratatui_core::layout::Rect { x: t.raw_get::>("x")?.unwrap_or(self.x), y: t.raw_get::>("y")?.unwrap_or(self.y), width: t.raw_get::>("w")?.unwrap_or(self.width), @@ -78,7 +74,7 @@ impl UserData for Rect { } fn add_methods>(methods: &mut M) { - methods.add_method("pad", |_, me, pad: Pad| Ok(me.pad(pad))); + methods.add_method("pad", |_, me, pad: Pad| Ok(Self(me.padding(pad)))); methods.add_method("contains", |_, me, Self(rect)| Ok(me.contains(rect.into()))); methods.add_meta_method(MetaMethod::Call, |_, me, t: Table| me.patch(t)); diff --git a/yazi-binding/src/elements/renderable.rs b/yazi-binding/src/elements/renderable.rs deleted file mode 100644 index 7730edf5..00000000 --- a/yazi-binding/src/elements/renderable.rs +++ /dev/null @@ -1,130 +0,0 @@ -use std::any::TypeId; - -use mlua::{AnyUserData, ExternalError, FromLua, Lua, Value}; -use ratatui::widgets::Widget; - -use super::{Bar, Border, Clear, Gauge, Line, List, Table, Text}; -use crate::{Error, elements::Area}; - -#[derive(Clone, Debug)] -pub enum Renderable { - Line(Line), - Text(Text), - List(Box), - Bar(Bar), - Clear(Clear), - Border(Border), - Gauge(Box), - Table(Box
), -} - -impl Renderable { - pub fn area(&self) -> Area { - match self { - Self::Line(line) => line.area, - Self::Text(text) => text.area, - Self::List(list) => list.area, - Self::Bar(bar) => bar.area, - Self::Clear(clear) => clear.area, - Self::Border(border) => border.area, - Self::Gauge(gauge) => gauge.area, - Self::Table(table) => table.area, - } - } - - pub fn with_area(mut self, area: impl Into) -> Self { - let area = area.into(); - match &mut self { - Self::Line(line) => line.area = area, - Self::Text(text) => text.area = area, - Self::List(list) => list.area = area, - Self::Bar(bar) => bar.area = area, - Self::Clear(clear) => clear.area = area, - Self::Border(border) => border.area = area, - Self::Gauge(gauge) => gauge.area = area, - Self::Table(table) => table.area = area, - } - self - } - - pub fn render_with(self, buf: &mut ratatui::buffer::Buffer, trans: T) - where - T: FnOnce(yazi_config::popup::Position) -> ratatui::layout::Rect, - { - let rect = self.area().transform(trans); - self.render(rect, buf); - } -} - -impl TryFrom<&AnyUserData> for Renderable { - type Error = mlua::Error; - - fn try_from(ud: &AnyUserData) -> Result { - Ok(match ud.type_id() { - Some(t) if t == TypeId::of::() => Self::Line(ud.take()?), - Some(t) if t == TypeId::of::() => Self::Text(ud.take()?), - Some(t) if t == TypeId::of::() => Self::List(Box::new(ud.take()?)), - Some(t) if t == TypeId::of::() => Self::Bar(ud.take()?), - Some(t) if t == TypeId::of::() => Self::Clear(ud.take()?), - Some(t) if t == TypeId::of::() => Self::Border(ud.take()?), - Some(t) if t == TypeId::of::() => Self::Gauge(Box::new(ud.take()?)), - Some(t) if t == TypeId::of::
() => Self::Table(Box::new(ud.take()?)), - _ => Err(format!("expected a renderable userdata, not: {ud:#?}").into_lua_err())?, - }) - } -} - -impl From for Renderable { - fn from(error: Error) -> Self { - Self::Text(Text { - inner: error.into_string().into(), - wrap: ratatui::widgets::Wrap { trim: false }.into(), - ..Default::default() - }) - } -} - -impl Widget for Renderable { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - match self { - Self::Line(line) => line.render(rect, buf), - Self::Text(text) => text.render(rect, buf), - Self::List(list) => list.render(rect, buf), - Self::Bar(bar) => bar.render(rect, buf), - Self::Clear(clear) => clear.render(rect, buf), - Self::Border(border) => border.render(rect, buf), - Self::Gauge(gauge) => gauge.render(rect, buf), - Self::Table(table) => table.render(rect, buf), - } - } -} - -impl Widget for &Renderable { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) - where - Self: Sized, - { - match self { - Renderable::Line(line) => line.render(rect, buf), - Renderable::Text(text) => text.render(rect, buf), - Renderable::List(list) => (&**list).render(rect, buf), - Renderable::Bar(bar) => bar.render(rect, buf), - Renderable::Clear(clear) => clear.render(rect, buf), - Renderable::Border(border) => border.render(rect, buf), - Renderable::Gauge(gauge) => (&**gauge).render(rect, buf), - Renderable::Table(table) => (&**table).render(rect, buf), - } - } -} - -impl FromLua for Renderable { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::UserData(ud) => Self::try_from(&ud), - _ => Err(format!("expected a renderable userdata, not: {value:#?}").into_lua_err()), - } - } -} diff --git a/yazi-binding/src/elements/row.rs b/yazi-binding/src/elements/row.rs index 969f81ef..0d433a94 100644 --- a/yazi-binding/src/elements/row.rs +++ b/yazi-binding/src/elements/row.rs @@ -10,7 +10,7 @@ pub struct Row { height: u16, top_margin: u16, bottom_margin: u16, - style: ratatui::style::Style, + style: ratatui_core::style::Style, } impl Row { @@ -26,7 +26,7 @@ impl Row { } } -impl From for ratatui::widgets::Row<'static> { +impl From for ratatui_widgets::table::Row<'static> { fn from(value: Row) -> Self { Self::new(value.cells) .height(value.height.max(1)) @@ -36,18 +36,20 @@ impl From for ratatui::widgets::Row<'static> { } } +impl TryFrom<&AnyUserData> for Row { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { + if let Ok(row) = value.take() { Ok(row) } else { Err(EXPECTED.into_lua_err()) } + } +} + impl FromLua for Row { fn from_lua(value: Value, _: &Lua) -> mlua::Result { - Ok(match value { - Value::UserData(ud) => { - if let Ok(row) = ud.take() { - row - } else { - Err(EXPECTED.into_lua_err())? - } - } - _ => Err(EXPECTED.into_lua_err())?, - }) + match value { + Value::UserData(ud) => Self::try_from(&ud), + _ => Err(EXPECTED.into_lua_err()), + } } } diff --git a/yazi-binding/src/elements/span.rs b/yazi-binding/src/elements/span.rs index 717a0d73..4f57e6eb 100644 --- a/yazi-binding/src/elements/span.rs +++ b/yazi-binding/src/elements/span.rs @@ -5,10 +5,10 @@ use unicode_width::UnicodeWidthChar; const EXPECTED: &str = "expected a string or Span"; -pub struct Span(pub(super) ratatui::text::Span<'static>); +pub struct Span(pub(super) ratatui_core::text::Span<'static>); impl Deref for Span { - type Target = ratatui::text::Span<'static>; + type Target = ratatui_core::text::Span<'static>; fn deref(&self) -> &Self::Target { &self.0 } } @@ -58,19 +58,21 @@ impl Span { } } +impl TryFrom<&AnyUserData> for Span { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { + if let Ok(span) = value.take() { Ok(span) } else { Err(EXPECTED.into_lua_err()) } + } +} + impl FromLua for Span { fn from_lua(value: Value, _: &Lua) -> mlua::Result { - Ok(Self(match value { - Value::String(s) => s.to_string_lossy().into(), - Value::UserData(ud) => { - if let Ok(Self(span)) = ud.take() { - span - } else { - Err(EXPECTED.into_lua_err())? - } - } + Ok(match value { + Value::String(s) => Self(s.to_string_lossy().into()), + Value::UserData(ud) => Self::try_from(&ud)?, _ => Err(EXPECTED.into_lua_err())?, - })) + }) } } diff --git a/yazi-binding/src/elements/spatial.rs b/yazi-binding/src/elements/spatial.rs new file mode 100644 index 00000000..665e44d4 --- /dev/null +++ b/yazi-binding/src/elements/spatial.rs @@ -0,0 +1,7 @@ +use crate::elements::Area; + +pub trait Spatial { + fn area(&self) -> Area; + + fn set_area(&mut self, area: Area); +} diff --git a/yazi-binding/src/elements/table.rs b/yazi-binding/src/elements/table.rs index f7defacf..058259d5 100644 --- a/yazi-binding/src/elements/table.rs +++ b/yazi-binding/src/elements/table.rs @@ -1,32 +1,32 @@ use mlua::{AnyUserData, IntoLua, Lua, MetaMethod, UserData, UserDataMethods, Value}; -use ratatui::widgets::{StatefulWidget, Widget}; +use ratatui_core::widgets::{StatefulWidget, Widget}; use super::{Area, Row}; -use crate::{Style, elements::Constraint}; +use crate::{elements::{Constraint, Spatial}, style::Style}; // --- Table #[derive(Clone, Debug, Default)] pub struct Table { - pub area: Area, + area: Area, rows: Vec, - header: Option>, - footer: Option>, - widths: Vec, + header: Option>, + footer: Option>, + widths: Vec, column_spacing: u16, - block: Option>, // TODO + block: Option>, // TODO - style: ratatui::style::Style, - row_highlight_style: ratatui::style::Style, - column_highlight_style: ratatui::style::Style, - cell_highlight_style: ratatui::style::Style, + style: ratatui_core::style::Style, + row_highlight_style: ratatui_core::style::Style, + column_highlight_style: ratatui_core::style::Style, + cell_highlight_style: ratatui_core::style::Style, - highlight_symbol: ratatui::text::Text<'static>, // TODO - highlight_spacing: ratatui::widgets::HighlightSpacing, // TODO + highlight_symbol: ratatui_core::text::Text<'static>, // TODO + highlight_spacing: ratatui_widgets::table::HighlightSpacing, // TODO - flex: ratatui::layout::Flex, + flex: ratatui_core::layout::Flex, - state: ratatui::widgets::TableState, + state: ratatui_widgets::table::TableState, } impl Table { @@ -41,7 +41,7 @@ impl Table { table.into_lua(lua) } - pub fn selected_cell(&self) -> Option<&ratatui::text::Text<'_>> { + pub fn selected_cell(&self) -> Option<&ratatui_core::text::Text<'_>> { let row = &self.rows[self.selected()?]; let col = self.state.selected_column()?; if row.cells.is_empty() { None } else { Some(&row.cells[col.min(row.cells.len() - 1)].text) } @@ -60,18 +60,24 @@ impl Table { } } -impl TryFrom for Table { +impl TryFrom<&AnyUserData> for Table { type Error = mlua::Error; - fn try_from(value: AnyUserData) -> Result { value.take() } + fn try_from(value: &AnyUserData) -> Result { value.take() } +} + +impl Spatial for Table { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } } impl Widget for Table { - fn render(mut self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(mut self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { - let mut table = ratatui::widgets::Table::new(self.rows, self.widths) + let mut table = ratatui_widgets::table::Table::new(self.rows, self.widths) .column_spacing(self.column_spacing) .style(self.style) .row_highlight_style(self.row_highlight_style) @@ -96,7 +102,7 @@ impl Widget for Table { } impl Widget for &Table { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { diff --git a/yazi-binding/src/elements/text.rs b/yazi-binding/src/elements/text.rs index 64b0f8cf..fa511d2d 100644 --- a/yazi-binding/src/elements/text.rs +++ b/yazi-binding/src/elements/text.rs @@ -2,21 +2,22 @@ use std::{any::TypeId, mem}; use ansi_to_tui::IntoText; use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::widgets::Widget; +use ratatui_core::widgets::Widget; +use yazi_shim::SStr; use super::{Area, Line, Span, Wrap}; -use crate::{Error, elements::Align}; +use crate::{Error, elements::{Align, Spatial}}; const EXPECTED: &str = "expected a string, Line, Span, or a table of them"; #[derive(Clone, Debug, Default)] pub struct Text { - pub area: Area, + area: Area, // TODO: block - pub inner: ratatui::text::Text<'static>, + pub inner: ratatui_core::text::Text<'static>, pub wrap: Wrap, - pub scroll: ratatui::layout::Position, + pub scroll: ratatui_core::layout::Position, } impl Text { @@ -31,6 +32,19 @@ impl Text { text.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; text.into_lua(lua) } + + pub fn wrap(mut self, wrap: impl Into) -> Self { + self.wrap = wrap.into(); + self + } +} + +impl From> for Text { + fn from(inner: ratatui_core::text::Text<'static>) -> Self { Self { inner, ..Default::default() } } +} + +impl From for Text { + fn from(value: SStr) -> Self { Self { inner: value.into(), ..Default::default() } } } impl TryFrom
for Text { @@ -54,16 +68,16 @@ impl TryFrom
for Text { } } -impl From for ratatui::text::Text<'static> { +impl From for ratatui_core::text::Text<'static> { fn from(value: Text) -> Self { value.inner } } -impl From for ratatui::widgets::Paragraph<'static> { +impl From for ratatui_widgets::paragraph::Paragraph<'static> { fn from(mut value: Text) -> Self { let align = value.inner.alignment.take(); let style = mem::take(&mut value.inner.style); - let mut p = ratatui::widgets::Paragraph::new(value.inner).style(style); + let mut p = ratatui_widgets::paragraph::Paragraph::new(value.inner).style(style); if let Some(align) = align { p = p.alignment(align); } @@ -74,47 +88,62 @@ impl From for ratatui::widgets::Paragraph<'static> { } } +impl Spatial for Text { + fn area(&self) -> Area { self.area } + + fn set_area(&mut self, area: Area) { self.area = area; } +} + impl Widget for Text { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { if self.wrap.is_none() && self.scroll == Default::default() { self.inner.render(rect, buf); } else { - ratatui::widgets::Paragraph::from(self).render(rect, buf); + ratatui_widgets::paragraph::Paragraph::from(self).render(rect, buf); } } } impl Widget for &Text { - fn render(self, rect: ratatui::layout::Rect, buf: &mut ratatui::buffer::Buffer) + fn render(self, rect: ratatui_core::layout::Rect, buf: &mut ratatui_core::buffer::Buffer) where Self: Sized, { if self.wrap.is_none() && self.scroll == Default::default() { (&self.inner).render(rect, buf); } else { - ratatui::widgets::Paragraph::from(self.clone()).render(rect, buf); + ratatui_widgets::paragraph::Paragraph::from(self.clone()).render(rect, buf); } } } +impl TryFrom<&AnyUserData> for Text { + type Error = mlua::Error; + + fn try_from(value: &AnyUserData) -> Result { + let inner = match value.type_id() { + Some(t) if t == TypeId::of::() => return value.take(), + Some(t) if t == TypeId::of::() => value.take::()?.inner.into(), + Some(t) if t == TypeId::of::() => value.take::()?.0.into(), + Some(t) if t == TypeId::of::() => value.take::()?.into_string().into(), + _ => Err(EXPECTED.into_lua_err())?, + }; + + Ok(Self { inner, ..Default::default() }) + } +} + impl FromLua for Text { fn from_lua(value: Value, _: &Lua) -> mlua::Result { - let inner = match value { - Value::Table(tb) => return Self::try_from(tb), - Value::String(s) => s.to_string_lossy().into(), - Value::UserData(ud) => match ud.type_id() { - Some(t) if t == TypeId::of::() => ud.take::()?.inner.into(), - Some(t) if t == TypeId::of::() => ud.take::()?.0.into(), - Some(t) if t == TypeId::of::() => return ud.take(), - Some(t) if t == TypeId::of::() => ud.take::()?.into_string().into(), - _ => Err(EXPECTED.into_lua_err())?, - }, + Ok(match value { + Value::Table(tb) => Self::try_from(tb)?, + Value::String(s) => Self { inner: s.to_string_lossy().into(), ..Default::default() }, + Value::UserData(ud) => Self::try_from(&ud)?, _ => Err(EXPECTED.into_lua_err())?, - }; - Ok(Self { inner, ..Default::default() }) + }) } } @@ -133,7 +162,7 @@ impl UserData for Text { Ok(ud) }); methods.add_function("scroll", |_, (ud, x, y): (AnyUserData, u16, u16)| { - ud.borrow_mut::()?.scroll = ratatui::layout::Position { x, y }; + ud.borrow_mut::()?.scroll = ratatui_core::layout::Position { x, y }; Ok(ud) }); methods.add_method("max_width", |_, me, ()| { diff --git a/yazi-binding/src/elements/wrap.rs b/yazi-binding/src/elements/wrap.rs index 85f205f8..88a8e639 100644 --- a/yazi-binding/src/elements/wrap.rs +++ b/yazi-binding/src/elements/wrap.rs @@ -1,13 +1,12 @@ use std::ops::Deref; use mlua::{FromLua, IntoLua, Lua, Value}; -use yazi_config::preview::PreviewWrap; #[derive(Clone, Copy, Debug, Default)] -pub struct Wrap(pub(super) Option); +pub struct Wrap(pub Option); impl Deref for Wrap { - type Target = Option; + type Target = Option; fn deref(&self) -> &Self::Target { &self.0 } } @@ -18,21 +17,12 @@ impl Wrap { } } -impl From for Option { +impl From for Option { fn from(value: Wrap) -> Self { value.0 } } -impl From for Wrap { - fn from(value: ratatui::widgets::Wrap) -> Self { Self(Some(value)) } -} - -impl From for Wrap { - fn from(value: PreviewWrap) -> Self { - Self(match value { - PreviewWrap::No => None, - PreviewWrap::Yes => Some(ratatui::widgets::Wrap { trim: false }), - }) - } +impl From for Wrap { + fn from(value: ratatui_widgets::paragraph::Wrap) -> Self { Self(Some(value)) } } impl FromLua for Wrap { @@ -46,8 +36,8 @@ impl FromLua for Wrap { }; Ok(Self(match n { 0 => None, - 1 => Some(ratatui::widgets::Wrap { trim: false }), - 2 => Some(ratatui::widgets::Wrap { trim: true }), + 1 => Some(ratatui_widgets::paragraph::Wrap { trim: false }), + 2 => Some(ratatui_widgets::paragraph::Wrap { trim: true }), _ => Err(mlua::Error::FromLuaConversionError { from: value.type_name(), to: "Wrap".to_string(), @@ -61,8 +51,8 @@ impl IntoLua for Wrap { fn into_lua(self, lua: &Lua) -> mlua::Result { match self.0 { None => 0.into_lua(lua), - Some(ratatui::widgets::Wrap { trim: false }) => 1.into_lua(lua), - Some(ratatui::widgets::Wrap { trim: true }) => 2.into_lua(lua), + Some(ratatui_widgets::paragraph::Wrap { trim: false }) => 1.into_lua(lua), + Some(ratatui_widgets::paragraph::Wrap { trim: true }) => 2.into_lua(lua), } } } diff --git a/yazi-binding/src/error.rs b/yazi-binding/src/error.rs index ff075c4b..ddf5e52b 100644 --- a/yazi-binding/src/error.rs +++ b/yazi-binding/src/error.rs @@ -2,12 +2,12 @@ use std::{borrow::Cow, fmt::Display}; use mlua::{ExternalError, Lua, MetaMethod, UserData, UserDataFields, UserDataMethods, Value}; use yazi_codegen::FromLuaOwned; -use yazi_shared::SStr; +use yazi_shim::SStr; #[derive(FromLuaOwned)] pub enum Error { Io(std::io::Error), - Fs(yazi_fs::error::Error), + Fs(yazi_shim::fs::Error), Serde(serde_json::Error), Custom(SStr), } @@ -18,7 +18,7 @@ impl Error { let fs = lua.create_function(|_, value: Value| { Ok(Self::Fs(match value { - Value::Table(t) => yazi_fs::error::Error::custom( + Value::Table(t) => yazi_shim::fs::Error::custom( &t.raw_get::("kind")?.to_str()?, t.raw_get("code")?, &t.raw_get::("message")?.to_str()?, @@ -64,7 +64,7 @@ impl UserData for Error { }); fields.add_field_method_get("kind", |_, me| { Ok(match me { - Self::Io(e) => Some(yazi_fs::error::Error::from(e.kind()).kind_str()), + Self::Io(e) => Some(yazi_shim::fs::Error::from(e.kind()).kind_str()), Self::Fs(e) => Some(e.kind_str()), _ => None, }) diff --git a/yazi-binding/src/file.rs b/yazi-binding/src/file.rs deleted file mode 100644 index 0ef0b640..00000000 --- a/yazi-binding/src/file.rs +++ /dev/null @@ -1,97 +0,0 @@ -use std::ops::Deref; - -use mlua::{AnyUserData, ExternalError, FromLua, Lua, ObjectLike, Table, UserData, UserDataFields, UserDataMethods, UserDataRef, Value}; - -use crate::{Cha, Url, impl_file_fields, impl_file_methods}; - -pub type FileRef = UserDataRef; - -const EXPECTED: &str = "expected a table, File, or fs::File"; - -#[derive(Clone)] -pub struct File { - pub(crate) inner: yazi_fs::File, - - v_cha: Option, - v_url: Option, - v_link_to: Option, - - v_name: Option, - v_path: Option, - v_cache: Option, -} - -impl Deref for File { - type Target = yazi_fs::File; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl From for yazi_fs::File { - fn from(value: File) -> Self { value.inner } -} - -impl File { - pub fn new(inner: impl Into) -> Self { - Self { - inner: inner.into(), - v_cha: None, - v_url: None, - v_link_to: None, - - v_name: None, - v_path: None, - v_cache: None, - } - } - - pub fn install(lua: &Lua) -> mlua::Result<()> { - lua.globals().raw_set("File", lua.create_function(|_, file: Self| Ok(file))?) - } -} - -impl TryFrom
for File { - type Error = mlua::Error; - - fn try_from(value: Table) -> Result { - Ok(Self::new(yazi_fs::File { - url: value.raw_get::("url")?.into(), - cha: *value.raw_get::("cha")?, - ..Default::default() - })) - } -} - -impl TryFrom for File { - type Error = mlua::Error; - - fn try_from(value: AnyUserData) -> Result { - Ok(if let Ok(me) = value.take::() { me } else { value.get("bare")? }) - } -} - -impl FromLua for File { - fn from_lua(value: Value, _: &Lua) -> mlua::Result { - match value { - Value::Table(tbl) => Self::try_from(tbl), - Value::UserData(ud) => Self::try_from(ud), - _ => Err(EXPECTED.into_lua_err())?, - } - } -} - -impl UserData for File { - fn add_fields>(fields: &mut F) { - impl_file_fields!(fields); - } - - fn add_methods>(methods: &mut M) { - impl_file_methods!(methods); - - methods.add_method("icon", |_, me, ()| { - use crate::Icon; - // TODO: use a cache - Ok(yazi_config::THEME.icon.matches(me, false).map(Icon::from)) - }); - } -} diff --git a/yazi-binding/src/icon.rs b/yazi-binding/src/icon.rs deleted file mode 100644 index c0ddbb53..00000000 --- a/yazi-binding/src/icon.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::ops::Deref; - -use mlua::{IntoLua, Lua, Value}; - -use crate::Style; - -pub struct Icon { - inner: yazi_config::Icon, -} - -impl Deref for Icon { - type Target = yazi_config::Icon; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl From for Icon { - fn from(inner: yazi_config::Icon) -> Self { Self { inner } } -} - -impl IntoLua for Icon { - fn into_lua(self, lua: &Lua) -> mlua::Result { - lua - .create_table_from([ - ("text", self.inner.text.into_lua(lua)?), - ("style", Style::from(self.inner.style).into_lua(lua)?), - ])? - .into_lua(lua) - } -} diff --git a/yazi-binding/src/image.rs b/yazi-binding/src/image.rs index 4a5bdfa9..24944ff7 100644 --- a/yazi-binding/src/image.rs +++ b/yazi-binding/src/image.rs @@ -1,17 +1,43 @@ -use std::ops::Deref; +use std::path::PathBuf; +use image::{ImageDecoder, ImageError}; use mlua::{MetaMethod, UserData, UserDataFields, UserDataMethods}; -pub struct ImageInfo(yazi_adapter::ImageInfo); - -impl Deref for ImageInfo { - type Target = yazi_adapter::ImageInfo; - - fn deref(&self) -> &Self::Target { &self.0 } +// --- ImageInfo +#[derive(Clone, Copy)] +pub struct ImageInfo { + pub format: image::ImageFormat, + pub width: u32, + pub height: u32, + pub color: image::ColorType, + pub orientation: Option, } -impl From for ImageInfo { - fn from(value: yazi_adapter::ImageInfo) -> Self { Self(value) } +impl ImageInfo { + pub async fn new(path: PathBuf) -> image::ImageResult { + tokio::task::spawn_blocking(move || { + let reader = image::ImageReader::open(path)?.with_guessed_format()?; + + let Some(format) = reader.format() else { + return Err(ImageError::IoError(std::io::Error::new( + std::io::ErrorKind::InvalidData, + "unknown image format", + ))); + }; + + let mut decoder = reader.into_decoder()?; + let (width, height) = decoder.dimensions(); + Ok(Self { + format, + width, + height, + color: decoder.color_type(), + orientation: decoder.orientation().ok(), + }) + }) + .await + .map_err(|e| ImageError::IoError(e.into()))? + } } impl UserData for ImageInfo { @@ -25,12 +51,12 @@ impl UserData for ImageInfo { } // --- ImageFormat -struct ImageFormat(yazi_adapter::ImageFormat); +struct ImageFormat(image::ImageFormat); impl UserData for ImageFormat { fn add_methods>(methods: &mut M) { methods.add_meta_method(MetaMethod::ToString, |_, me, ()| { - use yazi_adapter::ImageFormat as F; + use image::ImageFormat as F; Ok(match me.0 { F::Png => "PNG", @@ -55,12 +81,12 @@ impl UserData for ImageFormat { } // --- ImageColor -struct ImageColor(yazi_adapter::ImageColor); +struct ImageColor(image::ColorType); impl UserData for ImageColor { fn add_methods>(methods: &mut M) { methods.add_meta_method(MetaMethod::ToString, |_, me, ()| { - use yazi_adapter::ImageColor as C; + use image::ColorType as C; Ok(match me.0 { C::L8 => "L8", diff --git a/yazi-binding/src/layer.rs b/yazi-binding/src/layer.rs deleted file mode 100644 index 1e85aa92..00000000 --- a/yazi-binding/src/layer.rs +++ /dev/null @@ -1,15 +0,0 @@ -use mlua::{MetaMethod, UserData, UserDataMethods}; -use yazi_shim::strum::IntoStr; - -#[derive(Clone, Copy)] -pub struct Layer(yazi_shared::Layer); - -impl From for Layer { - fn from(event: yazi_shared::Layer) -> Self { Self(event) } -} - -impl UserData for Layer { - fn add_methods>(methods: &mut M) { - methods.add_meta_method(MetaMethod::ToString, |_, me, ()| Ok(me.0.into_str())); - } -} diff --git a/yazi-binding/src/lib.rs b/yazi-binding/src/lib.rs index b1cfd06e..3e92c973 100644 --- a/yazi-binding/src/lib.rs +++ b/yazi-binding/src/lib.rs @@ -1,5 +1,5 @@ mod macros; -yazi_macro::mod_pub!(config elements process theme); +yazi_macro::mod_pub!(elements position process style); -yazi_macro::mod_flat!(access calculator cha chan chord_cow composer error fd file handle icon id image input iter layer mouse path permit range runtime scheme selector stage style url utils); +yazi_macro::mod_flat!(chan composer error handle image iter permit range runtime); diff --git a/yazi-binding/src/macros.rs b/yazi-binding/src/macros.rs index 94f7c220..b2fd3ac1 100644 --- a/yazi-binding/src/macros.rs +++ b/yazi-binding/src/macros.rs @@ -43,48 +43,6 @@ macro_rules! deprecate { }}; } -#[macro_export] -macro_rules! cached_field { - ($fields:ident, $key:ident, $value:expr) => { - $fields.add_field_function_get(stringify!($key), |lua, ud| { - use mlua::{Error::UserDataDestructed, IntoLua, Lua, Result, Value, Value::UserData}; - ud.borrow_mut_scoped::>(|me| match paste::paste! { &me.[] } { - Some(v) if !v.is_userdata() => Ok(v.clone()), - Some(v @ UserData(ud)) if !matches!(ud.borrow::<()>(), Err(UserDataDestructed)) => { - Ok(v.clone()) - } - _ => { - let v = ($value as fn(&Lua, &Self) -> Result<_>)(lua, me)?.into_lua(lua)?; - paste::paste! { me.[] = Some(v.clone()) }; - Ok(v) - } - })? - }); - }; -} - -#[macro_export] -macro_rules! cached_field_mut { - ($fields:ident, $key:ident, $value:expr) => { - $fields.add_field_function_get(stringify!($key), |lua, ud| { - use mlua::{Error::UserDataDestructed, IntoLua, Lua, Result, Value, Value::UserData}; - ud.borrow_mut_scoped::>(|me| match paste::paste! { &me.[] } { - Some(Ok(v)) if !v.is_userdata() => Ok(v.clone()), - Some(Ok(v @ UserData(ud))) if !matches!(ud.borrow::<()>(), Err(UserDataDestructed)) => { - Ok(v.clone()) - } - Some(Err(e)) => Err(e.clone()), - _ => { - let v = - ($value as fn(&Lua, &mut Self) -> Result<_>)(lua, me).and_then(|v| v.into_lua(lua)); - paste::paste! { me.[] = Some(v.clone()) }; - v - } - })? - }); - }; -} - #[macro_export] macro_rules! impl_area_method { ($methods:ident) => { @@ -92,11 +50,13 @@ macro_rules! impl_area_method { "area", |lua, (ud, area): (mlua::AnyUserData, Option)| { use mlua::IntoLua; + use $crate::elements::Spatial; + if let Some(v) = area { - ud.borrow_mut::()?.area = $crate::elements::Area::try_from(v)?; + ud.borrow_mut::()?.set_area((&v).try_into()?); ud.into_lua(lua) } else { - ud.borrow::()?.area.into_lua(lua) + ud.borrow::()?.area().into_lua(lua) } }, ); @@ -106,7 +66,7 @@ macro_rules! impl_area_method { #[macro_export] macro_rules! impl_style_method { ($methods:ident, $($field:tt).+) => { - $methods.add_function("style", |_, (ud, style): (mlua::AnyUserData, $crate::Style)| { + $methods.add_function("style", |_, (ud, style): (mlua::AnyUserData, $crate::style::Style)| { ud.borrow_mut::()?.$($field).+ = style.0; Ok(ud) }); @@ -119,7 +79,7 @@ macro_rules! impl_style_shorthands { $methods.add_function("fg", |lua, (ud, value): (mlua::AnyUserData, mlua::Value)| { use $crate::elements::Color; use mlua::FromLua; - use ratatui::style::Modifier; + use ratatui_core::style::Modifier; let me = &mut ud.borrow_mut::()?.$($field).+; match value { @@ -138,7 +98,7 @@ macro_rules! impl_style_shorthands { $methods.add_function("bg", |lua, (ud, value): (mlua::AnyUserData, mlua::Value)| { use $crate::elements::Color; use mlua::FromLua; - use ratatui::style::Modifier; + use ratatui_core::style::Modifier; let me = &mut ud.borrow_mut::()?.$($field).+; match value { @@ -157,86 +117,86 @@ macro_rules! impl_style_shorthands { $methods.add_function("bold", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::BOLD); + *me = me.remove_modifier(ratatui_core::style::Modifier::BOLD); } else { - *me = me.add_modifier(ratatui::style::Modifier::BOLD); + *me = me.add_modifier(ratatui_core::style::Modifier::BOLD); } Ok(ud) }); $methods.add_function("dim", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::DIM); + *me = me.remove_modifier(ratatui_core::style::Modifier::DIM); } else { - *me = me.add_modifier(ratatui::style::Modifier::DIM); + *me = me.add_modifier(ratatui_core::style::Modifier::DIM); } Ok(ud) }); $methods.add_function("italic", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::ITALIC); + *me = me.remove_modifier(ratatui_core::style::Modifier::ITALIC); } else { - *me = me.add_modifier(ratatui::style::Modifier::ITALIC); + *me = me.add_modifier(ratatui_core::style::Modifier::ITALIC); } Ok(ud) }); $methods.add_function("underline", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::UNDERLINED); + *me = me.remove_modifier(ratatui_core::style::Modifier::UNDERLINED); } else { - *me = me.add_modifier(ratatui::style::Modifier::UNDERLINED); + *me = me.add_modifier(ratatui_core::style::Modifier::UNDERLINED); } Ok(ud) }); $methods.add_function("blink", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::SLOW_BLINK); + *me = me.remove_modifier(ratatui_core::style::Modifier::SLOW_BLINK); } else { - *me = me.add_modifier(ratatui::style::Modifier::SLOW_BLINK); + *me = me.add_modifier(ratatui_core::style::Modifier::SLOW_BLINK); } Ok(ud) }); $methods.add_function("blink_rapid", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::RAPID_BLINK); + *me = me.remove_modifier(ratatui_core::style::Modifier::RAPID_BLINK); } else { - *me = me.add_modifier(ratatui::style::Modifier::RAPID_BLINK); + *me = me.add_modifier(ratatui_core::style::Modifier::RAPID_BLINK); } Ok(ud) }); $methods.add_function("reverse", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::REVERSED); + *me = me.remove_modifier(ratatui_core::style::Modifier::REVERSED); } else { - *me = me.add_modifier(ratatui::style::Modifier::REVERSED); + *me = me.add_modifier(ratatui_core::style::Modifier::REVERSED); } Ok(ud) }); $methods.add_function("hidden", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::HIDDEN); + *me = me.remove_modifier(ratatui_core::style::Modifier::HIDDEN); } else { - *me = me.add_modifier(ratatui::style::Modifier::HIDDEN); + *me = me.add_modifier(ratatui_core::style::Modifier::HIDDEN); } Ok(ud) }); $methods.add_function("crossed", |_, (ud, remove): (mlua::AnyUserData, bool)| { let me = &mut ud.borrow_mut::()?.$($field).+; if remove { - *me = me.remove_modifier(ratatui::style::Modifier::CROSSED_OUT); + *me = me.remove_modifier(ratatui_core::style::Modifier::CROSSED_OUT); } else { - *me = me.add_modifier(ratatui::style::Modifier::CROSSED_OUT); + *me = me.add_modifier(ratatui_core::style::Modifier::CROSSED_OUT); } Ok(ud) }); $methods.add_function("reset", |_, ud: mlua::AnyUserData| { - ud.borrow_mut::()?.$($field).+ = ratatui::style::Style::reset(); + ud.borrow_mut::()?.$($field).+ = ratatui_core::style::Style::reset(); Ok(ud) }); }; @@ -245,21 +205,24 @@ macro_rules! impl_style_shorthands { #[macro_export] macro_rules! impl_file_fields { ($fields:ident) => { - $crate::cached_field!($fields, cha, |_, me| Ok($crate::Cha(me.cha))); - $crate::cached_field!($fields, url, |_, me| Ok($crate::Url::new(me.url_owned()))); - $crate::cached_field!($fields, link_to, |_, me| Ok(me.link_to.as_ref().map($crate::Path::new))); + use yazi_shim::mlua::UserDataFieldsExt; - $crate::cached_field!($fields, name, |lua, me| { + $fields.add_cached_field("cha", |_, me| Ok(me.cha)); + $fields.add_cached_field("url", |_, me| Ok(me.url_owned())); + $fields.add_cached_field("link_to", |_, me| Ok(me.link_to.clone())); + + $fields.add_cached_field("name", |lua, me| { me.name().map(|s| lua.create_string(s.encoded_bytes())).transpose() }); - $crate::cached_field!($fields, path, |_, me| { + $fields.add_cached_field("path", |_, me| { use yazi_fs::FsUrl; - use yazi_shared::url::AsUrl; - Ok($crate::Path::new(me.url.as_url().unified_path())) + use yazi_shared::{path::PathBufDyn, url::AsUrl}; + Ok(PathBufDyn::from(me.url.as_url().unified_path())) }); - $crate::cached_field!($fields, cache, |_, me| { + $fields.add_cached_field("cache", |_, me| { use yazi_fs::FsUrl; - Ok(me.url.cache().map($crate::Path::new)) + use yazi_shared::path::PathBufDyn; + Ok(me.url.cache().map(PathBufDyn::from)) }); }; } diff --git a/yazi-binding/src/mouse.rs b/yazi-binding/src/mouse.rs deleted file mode 100644 index bc959bf5..00000000 --- a/yazi-binding/src/mouse.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::ops::Deref; - -use mlua::{UserData, UserDataFields}; -use yazi_term::event::{MouseButton, MouseEventKind}; - -#[derive(Clone, Copy)] -pub struct MouseEvent(yazi_term::event::MouseEvent); - -impl Deref for MouseEvent { - type Target = yazi_term::event::MouseEvent; - - fn deref(&self) -> &Self::Target { &self.0 } -} - -impl From for MouseEvent { - fn from(event: yazi_term::event::MouseEvent) -> Self { Self(event) } -} - -impl UserData for MouseEvent { - fn add_fields>(fields: &mut F) { - fields.add_field_method_get("x", |_, me| Ok(me.column)); - fields.add_field_method_get("y", |_, me| Ok(me.row)); - fields.add_field_method_get("is_left", |_, me| { - use MouseEventKind as K; - Ok(matches!(me.kind, K::Down(b) | K::Up(b) | K::Drag(b) if b == MouseButton::Left)) - }); - fields.add_field_method_get("is_right", |_, me| { - use MouseEventKind as K; - Ok(matches!(me.kind, K::Down(b) | K::Up(b) | K::Drag(b) if b == MouseButton::Right)) - }); - fields.add_field_method_get("is_middle", |_, me| { - use MouseEventKind as K; - Ok(matches!(me.kind, K::Down(b) | K::Up(b) | K::Drag(b) if b == MouseButton::Middle)) - }); - } -} diff --git a/yazi-binding/src/position/lua.rs b/yazi-binding/src/position/lua.rs new file mode 100644 index 00000000..c76ef309 --- /dev/null +++ b/yazi-binding/src/position/lua.rs @@ -0,0 +1,72 @@ +use std::str::FromStr; + +use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataFields, UserDataMethods, Value}; +use yazi_shim::strum::IntoStr; + +use crate::{elements::Pad, position::{Offset, Origin, Position}}; + +const EXPECTED: &str = "expected a Pos"; + +impl TryFrom<&AnyUserData> for Position { + type Error = mlua::Error; + + fn try_from(ud: &AnyUserData) -> Result { + if let Ok(pos) = ud.borrow() { Ok(*pos) } else { Err(EXPECTED.into_lua_err()) } + } +} + +impl TryFrom
for Position { + type Error = mlua::Error; + + fn try_from(t: Table) -> Result { + Ok(Self { + origin: Origin::from_str(&t.raw_get::(1)?.to_str()?).into_lua_err()?, + offset: Offset { + x: t.raw_get("x").unwrap_or_default(), + y: t.raw_get("y").unwrap_or_default(), + width: t.raw_get("w").unwrap_or_default(), + height: t.raw_get("h").unwrap_or_default(), + }, + padding: Default::default(), + }) + } +} + +impl FromLua for Position { + fn from_lua(value: Value, _: &Lua) -> mlua::Result { + match value { + Value::Table(tbl) => Self::try_from(tbl), + Value::UserData(ud) => Self::try_from(&ud), + _ => Err(EXPECTED.into_lua_err()), + } + } +} + +impl Position { + pub fn compose(lua: &Lua) -> mlua::Result { + let new = lua.create_function(|_, (_, t): (Table, Table)| Self::try_from(t))?; + + let pos = lua.create_table()?; + pos.set_metatable(Some(lua.create_table_from([(MetaMethod::Call.name(), new)])?))?; + + pos.into_lua(lua) + } +} + +impl UserData for Position { + fn add_fields>(fields: &mut F) { + // TODO: cache + fields.add_field_method_get("1", |_, me| Ok(me.origin.into_str())); + fields.add_field_method_get("x", |_, me| Ok(me.x)); + fields.add_field_method_get("y", |_, me| Ok(me.y)); + fields.add_field_method_get("w", |_, me| Ok(me.width)); + fields.add_field_method_get("h", |_, me| Ok(me.height)); + } + + fn add_methods>(methods: &mut M) { + methods.add_function("pad", |_, (ud, pad): (AnyUserData, Pad)| { + ud.borrow_mut::()?.padding = pad.into(); + Ok(ud) + }); + } +} diff --git a/yazi-binding/src/position/mod.rs b/yazi-binding/src/position/mod.rs new file mode 100644 index 00000000..75e14b31 --- /dev/null +++ b/yazi-binding/src/position/mod.rs @@ -0,0 +1 @@ +yazi_macro::mod_flat!(lua offset origin position); diff --git a/yazi-config/src/popup/offset.rs b/yazi-binding/src/position/offset.rs similarity index 77% rename from yazi-config/src/popup/offset.rs rename to yazi-binding/src/position/offset.rs index 23c4be2c..4cea9d6b 100644 --- a/yazi-config/src/popup/offset.rs +++ b/yazi-binding/src/position/offset.rs @@ -10,6 +10,17 @@ pub struct Offset { pub height: u16, } +impl From for Offset { + fn from(value: ratatui_core::layout::Rect) -> Self { + Self { + x: value.x as i16, + y: value.y as i16, + width: value.width, + height: value.height, + } + } +} + impl TryFrom<[i16; 4]> for Offset { type Error = anyhow::Error; @@ -32,8 +43,3 @@ impl TryFrom<[i16; 4]> for Offset { }) } } - -impl Offset { - #[inline] - pub fn line() -> Self { Self { x: 0, y: 0, width: u16::MAX, height: 1 } } -} diff --git a/yazi-config/src/popup/origin.rs b/yazi-binding/src/position/origin.rs similarity index 100% rename from yazi-config/src/popup/origin.rs rename to yazi-binding/src/position/origin.rs diff --git a/yazi-config/src/popup/position.rs b/yazi-binding/src/position/position.rs similarity index 52% rename from yazi-config/src/popup/position.rs rename to yazi-binding/src/position/position.rs index 3ea8bd89..2c649cce 100644 --- a/yazi-config/src/popup/position.rs +++ b/yazi-binding/src/position/position.rs @@ -1,18 +1,47 @@ -use ratatui::layout::Rect; -use yazi_term::Dimension; +use std::ops::{Deref, DerefMut}; + +use ratatui_core::layout::Rect; +use ratatui_widgets::block::Padding; +use yazi_shim::ratatui::Padable; use super::{Offset, Origin}; #[derive(Clone, Copy, Debug, Default)] pub struct Position { - pub origin: Origin, - pub offset: Offset, + pub origin: Origin, + pub offset: Offset, + pub padding: Padding, +} + +impl Deref for Position { + type Target = Offset; + + fn deref(&self) -> &Self::Target { &self.offset } +} + +impl DerefMut for Position { + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.offset } +} + +impl From for Position { + fn from(value: Rect) -> Self { Self::new(Origin::TopLeft, value.into()) } } impl Position { - pub const fn new(origin: Origin, offset: Offset) -> Self { Self { origin, offset } } + pub const fn new(origin: Origin, offset: Offset) -> Self { + Self { origin, offset, padding: Padding::ZERO } + } - pub fn rect(&self, Dimension { cols, rows, .. }: Dimension) -> Rect { + pub const fn hovered(offset: Offset) -> Self { + Self { origin: Origin::Hovered, offset, padding: Padding::ZERO } + } + + pub fn with_height(mut self, height: u16) -> Self { + self.height = height; + self + } + + pub fn rect(&self, (cols, rows): (u16, u16)) -> Rect { use Origin::*; let Offset { x, y, width, height } = self.offset; @@ -40,10 +69,11 @@ impl Position { width: width.min(cols.saturating_sub(new_x)), height: height.min(rows.saturating_sub(new_y)), } + .padding(self.padding) } - pub fn sticky(Dimension { cols, rows, .. }: Dimension, base: Rect, offset: Offset) -> Rect { - let Offset { x, y, width, height } = offset; + pub fn sticky(self, base: Rect, (cols, rows): (u16, u16)) -> Rect { + let Offset { x, y, width, height } = self.offset; let above = base.y.saturating_add(base.height).saturating_add(height).saturating_add_signed(y) > rows; @@ -61,5 +91,15 @@ impl Position { width: width.min(cols.saturating_sub(new_x)), height: height.min(rows.saturating_sub(new_y)), } + .padding(self.padding) + } + + pub fn padding(mut self, padding: impl Into) -> Self { + let p = padding.into(); + self.padding.left = self.padding.left.saturating_add(p.left); + self.padding.right = self.padding.right.saturating_add(p.right); + self.padding.top = self.padding.top.saturating_add(p.top); + self.padding.bottom = self.padding.bottom.saturating_add(p.bottom); + self } } diff --git a/yazi-binding/src/process/command.rs b/yazi-binding/src/process/command.rs index 519c6189..4949b266 100644 --- a/yazi-binding/src/process/command.rs +++ b/yazi-binding/src/process/command.rs @@ -2,7 +2,7 @@ use std::{any::TypeId, ffi::OsStr, io, process::Stdio}; use mlua::{AnyUserData, ExternalError, IntoLua, IntoLuaMulti, Lua, MetaMethod, Table, UserData, UserDataMethods, Value}; use tokio::process::{ChildStderr, ChildStdin, ChildStdout}; -use yazi_shared::wtf8::FromWtf8; +use yazi_shim::wtf8::FromWtf8; use super::{Child, output::Output}; use crate::{Error, process::Status}; diff --git a/yazi-binding/src/process/output.rs b/yazi-binding/src/process/output.rs index 97508849..7b0056cd 100644 --- a/yazi-binding/src/process/output.rs +++ b/yazi-binding/src/process/output.rs @@ -1,31 +1,25 @@ use std::mem; -use mlua::{UserData, UserDataFields, Value}; +use mlua::{UserData, UserDataFields}; +use yazi_shim::mlua::UserDataFieldsExt; use super::Status; -use crate::{cached_field, cached_field_mut}; pub struct Output { inner: std::process::Output, - - v_status: Option, - v_stdout: Option>, - v_stderr: Option>, } impl Output { - pub fn new(inner: std::process::Output) -> Self { - Self { inner, v_status: None, v_stdout: None, v_stderr: None } - } + pub fn new(inner: std::process::Output) -> Self { Self { inner } } } impl UserData for Output { fn add_fields>(fields: &mut F) { - cached_field!(fields, status, |_, me| Ok(Status::new(me.inner.status))); - cached_field_mut!(fields, stdout, |lua, me| { + fields.add_cached_field("status", |_, me| Ok(Status::new(me.inner.status))); + fields.add_cached_field_mut("stdout", |lua, me| { lua.create_external_string(mem::take(&mut me.inner.stdout)) }); - cached_field_mut!(fields, stderr, |lua, me| { + fields.add_cached_field_mut("stderr", |lua, me| { lua.create_external_string(mem::take(&mut me.inner.stderr)) }); } diff --git a/yazi-binding/src/scheme.rs b/yazi-binding/src/scheme.rs deleted file mode 100644 index 93bc9fd8..00000000 --- a/yazi-binding/src/scheme.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::ops::Deref; - -use mlua::{UserData, UserDataFields, Value}; -use yazi_fs::FsScheme; -use yazi_shared::scheme::SchemeLike; -use yazi_shim::strum::IntoStr; - -use crate::{Path, cached_field}; - -pub struct Scheme { - inner: yazi_shared::scheme::Scheme, - - v_kind: Option, - v_cache: Option, -} - -impl Deref for Scheme { - type Target = yazi_shared::scheme::Scheme; - - fn deref(&self) -> &Self::Target { &self.inner } -} - -impl Scheme { - pub fn new(scheme: impl Into) -> Self { - Self { inner: scheme.into(), v_kind: None, v_cache: None } - } -} - -impl UserData for Scheme { - fn add_fields>(fields: &mut F) { - cached_field!(fields, kind, |_, me| Ok(me.kind().into_str())); - cached_field!(fields, cache, |_, me| Ok(me.cache().map(Path::new))); - - fields.add_field_method_get("is_virtual", |_, me| Ok(me.is_virtual())); - } -} diff --git a/yazi-binding/src/selector.rs b/yazi-binding/src/selector.rs deleted file mode 100644 index d5d281ef..00000000 --- a/yazi-binding/src/selector.rs +++ /dev/null @@ -1,21 +0,0 @@ -use std::ops::Deref; - -use mlua::{FromLua, Lua, LuaSerdeExt, UserData, Value}; - -pub struct Selector(yazi_config::Selector); - -impl Deref for Selector { - type Target = yazi_config::Selector; - - fn deref(&self) -> &Self::Target { &self.0 } -} - -impl From for yazi_config::Selector { - fn from(value: Selector) -> Self { value.0 } -} - -impl FromLua for Selector { - fn from_lua(value: Value, lua: &Lua) -> mlua::Result { Ok(Self(lua.from_value(value)?)) } -} - -impl UserData for Selector {} diff --git a/yazi-binding/src/stage.rs b/yazi-binding/src/stage.rs deleted file mode 100644 index 9678175c..00000000 --- a/yazi-binding/src/stage.rs +++ /dev/null @@ -1,21 +0,0 @@ -use mlua::{IntoLuaMulti, MetaMethod, UserData, UserDataMethods}; - -pub struct FolderStage(yazi_fs::FolderStage); - -impl FolderStage { - pub fn new(inner: yazi_fs::FolderStage) -> Self { Self(inner) } -} - -impl UserData for FolderStage { - fn add_methods>(methods: &mut M) { - methods.add_meta_method(MetaMethod::Call, |lua, me, ()| { - use yazi_fs::FolderStage::*; - - match &me.0 { - Loading => false.into_lua_multi(lua), - Loaded => true.into_lua_multi(lua), - Failed(e) => (true, crate::Error::Fs(e.clone())).into_lua_multi(lua), - } - }); - } -} diff --git a/yazi-binding/src/style/mod.rs b/yazi-binding/src/style/mod.rs new file mode 100644 index 00000000..11ea7d99 --- /dev/null +++ b/yazi-binding/src/style/mod.rs @@ -0,0 +1 @@ +yazi_macro::mod_flat!(style style_flat); diff --git a/yazi-binding/src/style.rs b/yazi-binding/src/style/style.rs similarity index 85% rename from yazi-binding/src/style.rs rename to yazi-binding/src/style/style.rs index 45592ef2..efd87add 100644 --- a/yazi-binding/src/style.rs +++ b/yazi-binding/src/style/style.rs @@ -1,32 +1,32 @@ use std::ops::Deref; use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, MetaMethod, Table, UserData, UserDataMethods, Value}; -use ratatui::style::Modifier; -use yazi_shim::cell::SyncCell; +use ratatui_core::style::Modifier; +use yazi_shim::{cell::SyncCell, mlua::SER_OPT}; -use crate::{SER_OPT, elements::Color}; +use crate::{elements::Color, style::StyleFlat}; #[derive(Clone, Copy, Default)] -pub struct Style(pub ratatui::style::Style); +pub struct Style(pub ratatui_core::style::Style); impl Deref for Style { - type Target = ratatui::style::Style; + type Target = ratatui_core::style::Style; fn deref(&self) -> &Self::Target { &self.0 } } -impl From for Style { - fn from(value: yazi_config::Style) -> Self { Self(value.into()) } +impl From for Style { + fn from(value: StyleFlat) -> Self { Self(value.into()) } } -impl From