From 77d36ff5a57311cc99c7e4c3bb3d8ec935544063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Sat, 27 Dec 2025 17:52:15 +0800 Subject: [PATCH] feat: new `fs.copy()` and `fs.rename()` APIs (#3467) --- CHANGELOG.md | 2 + Cargo.lock | 745 ++++++++++++++++++++----- Cargo.toml | 8 +- yazi-binding/src/elements/border.rs | 10 +- yazi-fm/src/tasks/tasks.rs | 4 +- yazi-fs/src/provider/attrs.rs | 40 +- yazi-fs/src/provider/local/copier.rs | 10 +- yazi-plugin/src/fs/fs.rs | 22 +- yazi-plugin/src/utils/spot.rs | 2 +- yazi-sftp/src/fs/attrs.rs | 4 +- yazi-vfs/src/provider/rw_file.rs | 16 +- yazi-vfs/src/provider/sftp/gate.rs | 2 +- yazi-vfs/src/provider/sftp/metadata.rs | 18 +- yazi-vfs/src/provider/sftp/sftp.rs | 7 +- 14 files changed, 711 insertions(+), 179 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7571d4..e5a33417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): - Zoom in or out of the preview image ([#2864]) - Improve the UX of the pick and input components ([#2906], [#2935]) - Show progress of each task in task manager ([#3121], [#3131], [#3134]) +- New `fs.copy()` and `fs.rename()` APIs ([#3467]) - New experimental `ya.async()` API ([#3422]) - New `overall` option to set the overall background color ([#3317]) - Rounded corners for indicator bar ([#3419]) @@ -1560,3 +1561,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/): [#3422]: https://github.com/sxyazi/yazi/pull/3422 [#3429]: https://github.com/sxyazi/yazi/pull/3429 [#3456]: https://github.com/sxyazi/yazi/pull/3456 +[#3467]: https://github.com/sxyazi/yazi/pull/3467 diff --git a/Cargo.lock b/Cargo.lock index 49f9d3a7..933ca3dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,15 +96,15 @@ dependencies = [ [[package]] name = "ansi-to-tui" -version = "7.0.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67555e1f1ece39d737e28c8a017721287753af3f93225e4a445b29ccb0f5912c" +checksum = "fdfd3cbf4843347ca072771a797484f1c3434a14d57f39d31c92dfb93a8799a8" dependencies = [ - "nom 7.1.3", - "ratatui", + "nom 8.0.0", + "ratatui-core", "simdutf8", "smallvec", - "thiserror 1.0.69", + "thiserror 2.0.17", ] [[package]] @@ -186,7 +186,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -225,6 +225,15 @@ 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" @@ -343,6 +352,21 @@ 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" @@ -476,7 +500,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -497,12 +521,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" -[[package]] -name = "cassowary" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" - [[package]] name = "castaway" version = "0.2.4" @@ -523,9 +541,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.50" +version = "1.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f50d563227a1c37cc0a263f64eca3334388c01c5e4c4861a9def205c614383c" +checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203" dependencies = [ "find-msvc-tools", "jobserver", @@ -639,7 +657,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -671,9 +689,9 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "compact_str" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32" +checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" dependencies = [ "castaway", "cfg-if", @@ -815,6 +833,7 @@ dependencies = [ "mio", "parking_lot", "rustix 0.38.44", + "serde", "signal-hook", "signal-hook-mio", "winapi", @@ -836,6 +855,7 @@ dependencies = [ "mio", "parking_lot", "rustix 1.1.3", + "serde", "signal-hook", "signal-hook-mio", "winapi", @@ -893,9 +913,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.2.0-rc.5" +version = "0.2.0-rc.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919bd05924682a5480aec713596b9e2aabed3a0a6022fab6847f85a99e5f190a" +checksum = "29c52310bbf9ce8ad2f05bf8a9b0aa3585532884c31b4f191badfe7d7c7ed127" dependencies = [ "hybrid-array", ] @@ -911,6 +931,16 @@ dependencies = [ "rand_core 0.10.0-rc-3", ] +[[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.9.2" @@ -944,7 +974,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -968,7 +998,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.111", ] [[package]] @@ -979,7 +1009,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1017,9 +1047,15 @@ checksum = "780eb241654bf097afb00fc5f054a09b687dad862e485fdcf8399bb056565370" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] +[[package]] +name = "deltae" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5729f5117e208430e437df2f4843f5e5952997175992d1414f94c57d61e270b4" + [[package]] name = "der" version = "0.7.10" @@ -1069,7 +1105,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1079,7 +1115,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn", + "syn 2.0.111", ] [[package]] @@ -1101,7 +1137,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 2.0.111", ] [[package]] @@ -1124,7 +1160,7 @@ checksum = "ea390c940e465846d64775e55e3115d5dc934acb953de6f6e6360bc232fe2bf7" dependencies = [ "block-buffer 0.11.0", "const-oid 0.10.1", - "crypto-common 0.2.0-rc.5", + "crypto-common 0.2.0-rc.7", ] [[package]] @@ -1238,7 +1274,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1264,7 +1300,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1300,6 +1336,15 @@ version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59" +[[package]] +name = "euclid" +version = "0.22.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad9cdb4b747e485a12abb0e6566612956c7a1bafa3bdb8d682c5b6d403589e48" +dependencies = [ + "num-traits", +] + [[package]] name = "event-listener" version = "4.0.3" @@ -1325,6 +1370,16 @@ 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" @@ -1379,9 +1434,21 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff" + +[[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" @@ -1399,12 +1466,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" @@ -1482,7 +1543,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1623,17 +1684,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" @@ -1642,7 +1692,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", + "foldhash", "serde", "serde_core", ] @@ -1668,7 +1718,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1819,7 +1869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", - "hashbrown 0.16.1", + "hashbrown", "serde", "serde_core", ] @@ -1873,7 +1923,7 @@ dependencies = [ "indoc", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1915,7 +1965,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -1968,6 +2018,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kasuari" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fe90c1150662e858c7d5f945089b7517b0a80d8bf7ba4b1b5ffc984e7230a5b" +dependencies = [ + "hashbrown", + "portable-atomic", + "thiserror 2.0.17", +] + [[package]] name = "kqueue" version = "1.1.1" @@ -1988,6 +2049,12 @@ dependencies = [ "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" @@ -2101,6 +2168,15 @@ dependencies = [ "libc", ] +[[package]] +name = "line-clipping" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4de44e98ddbf09375cbf4d17714d18f39195f4f4894e8524501726fd9a8a4a" +dependencies = [ + "bitflags 2.10.0", +] + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -2143,22 +2219,13 @@ dependencies = [ "imgref", ] -[[package]] -name = "lru" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" -dependencies = [ - "hashbrown 0.15.5", -] - [[package]] name = "lru" version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96051b46fc183dc9cd4a223960ef37b9af631b55191852a8274bfef064cda20f" dependencies = [ - "hashbrown 0.16.1", + "hashbrown", ] [[package]] @@ -2180,6 +2247,16 @@ dependencies = [ "which", ] +[[package]] +name = "mac_address" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0aeb26bf5e836cc1c341c8106051b573f1766dfa05aa87f0b98be5e51b02303" +dependencies = [ + "nix", + "winapi", +] + [[package]] name = "matchers" version = "0.2.0" @@ -2210,6 +2287,21 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +[[package]] +name = "memmem" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64a92489e2744ce060c349162be1c5f33c6969234104dbd99ddb5feb08b8c15" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2285,7 +2377,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 2.0.111", ] [[package]] @@ -2314,6 +2406,7 @@ dependencies = [ "cfg-if", "cfg_aliases", "libc", + "memoffset", ] [[package]] @@ -2415,7 +2508,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2478,6 +2571,12 @@ 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.3" @@ -2567,6 +2666,15 @@ 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.1.0" @@ -2656,7 +2764,7 @@ dependencies = [ "by_address", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2745,6 +2853,101 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "pest" +version = "2.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbcfd20a6d4eeba40179f05735784ad32bdaef05ce8e8af05f180d45bb3e7e22" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f72981ade67b1ca6adc26ec221be9f463f2b5839c7508998daa17c23d94d7f" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee9efd8cdb50d719a80088b76f81aec7c41ed6d522ee750178f83883d271625" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "pest_meta" +version = "2.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf1d70880e76bdc13ba52eafa6239ce793d85c8e43896507e43dd8984ff05b82" +dependencies = [ + "pest", + "sha2 0.10.9", +] + +[[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.5", +] + +[[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.111", +] + +[[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.16" @@ -2859,6 +3062,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd" + [[package]] name = "powerfmt" version = "0.2.0" @@ -2902,7 +3111,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -2930,7 +3139,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3072,24 +3281,103 @@ checksum = "f66ee92bc15280519ef199a274fe0cafff4245d31bc39aaa31c011ad56cb1f05" [[package]] name = "ratatui" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" +checksum = "d1ce67fb8ba4446454d1c8dbaeda0557ff5e94d39d5e5ed7f10a65eb4c8266bc" +dependencies = [ + "instability", + "ratatui-core", + "ratatui-crossterm", + "ratatui-macros", + "ratatui-termion", + "ratatui-termwiz", + "ratatui-widgets", + "serde", +] + +[[package]] +name = "ratatui-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef8dea09a92caaf73bff7adb70b76162e5937524058a7e5bff37869cbbec293" dependencies = [ "bitflags 2.10.0", - "cassowary", "compact_str", - "crossterm 0.28.1", + "hashbrown", "indoc", - "instability", - "itertools 0.13.0", - "lru 0.12.5", - "paste", + "itertools 0.14.0", + "kasuari", + "lru", "serde", "strum", + "thiserror 2.0.17", "unicode-segmentation", "unicode-truncate", - "unicode-width 0.2.0", + "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-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f1342a13e83e4bb9d0b793d0ea762be633f9582048c892ae9041ef39c936f4" +dependencies = [ + "ratatui-core", + "ratatui-widgets", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7dbfa023cd4e604c2553483820c5fe8aa9d71a42eea5aa77c6e7f35756612db" +dependencies = [ + "bitflags 2.10.0", + "hashbrown", + "indoc", + "instability", + "itertools 0.14.0", + "line-clipping", + "ratatui-core", + "serde", + "strum", + "time", + "unicode-segmentation", + "unicode-width", ] [[package]] @@ -3198,7 +3486,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3526,20 +3814,20 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] name = "serde_json" -version = "1.0.146" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "217ca874ae0207aac254aa02c957ded05585a90892cc8d87f9e5fa49669dadd8" +checksum = "6af14725505314343e673e9ecb7cd7e8a36aa9791eb936235a3567cc31447ae4" dependencies = [ "itoa", "memchr", - "ryu", "serde", "serde_core", + "zmij", ] [[package]] @@ -3643,10 +3931,11 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.7" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7664a098b8e616bdfcc2dc0e9ac44eb231eedf41db4e9fe95d8d32ec728dedad" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] @@ -3703,6 +3992,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "slab" version = "0.4.11" @@ -3800,24 +4095,23 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.26.3" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.26.4" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ "heck", "proc-macro2", "quote", - "rustversion", - "syn", + "syn 2.0.111", ] [[package]] @@ -3826,6 +4120,17 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.111" @@ -3863,6 +4168,81 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "terminfo" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ea810f0692f9f51b382fff5893887bb4580f5fa246fde546e0b13e7fcee662" +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.10.0", + "fancy-regex", + "filedescriptor", + "finl_unicode", + "fixedbitset", + "hex", + "lazy_static", + "libc", + "log", + "memmem", + "nix", + "num-derive", + "num-traits", + "ordered-float 4.6.0", + "pest", + "pest_derive", + "phf", + "serde", + "sha2 0.10.9", + "signal-hook", + "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", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -3889,7 +4269,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3900,7 +4280,7 @@ checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -3983,7 +4363,7 @@ checksum = "2d2e76690929402faae40aebdda620a2c0e25dd6d3b9afe48867dfd95991f4bd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4011,7 +4391,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4108,7 +4488,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4195,6 +4575,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "unicode-ident" version = "1.0.22" @@ -4209,26 +4595,20 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-truncate" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" +checksum = "8fbf03860ff438702f3910ca5f28f8dac63c1c11e7efb5012b8b175493606330" dependencies = [ "itertools 0.13.0", "unicode-segmentation", - "unicode-width 0.1.14", + "unicode-width", ] [[package]] name = "unicode-width" -version = "0.1.14" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - -[[package]] -name = "unicode-width" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "universal-hash" @@ -4264,8 +4644,10 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ + "atomic", "getrandom 0.3.4", "js-sys", + "serde_core", "wasm-bindgen", ] @@ -4341,6 +4723,15 @@ 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" @@ -4411,7 +4802,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.111", "wasm-bindgen-shared", ] @@ -4440,6 +4831,80 @@ 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.0" @@ -4567,7 +5032,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4578,7 +5043,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4589,7 +5054,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4600,7 +5065,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4860,7 +5325,7 @@ dependencies = [ "anyhow", "crossterm 0.29.0", "futures", - "hashbrown 0.16.1", + "hashbrown", "libc", "mlua", "paste", @@ -4914,14 +5379,14 @@ version = "25.9.15" dependencies = [ "ansi-to-tui", "futures", - "hashbrown 0.16.1", + "hashbrown", "mlua", "paste", "ratatui", "serde_json", "tokio", "tracing", - "unicode-width 0.2.0", + "unicode-width", "yazi-adapter", "yazi-config", "yazi-fs", @@ -4938,7 +5403,7 @@ dependencies = [ "clap_complete_fig", "clap_complete_nushell", "futures", - "hashbrown 0.16.1", + "hashbrown", "regex", "vergen-gitcl", "yazi-adapter", @@ -4984,7 +5449,7 @@ name = "yazi-codegen" version = "25.9.15" dependencies = [ "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -4996,7 +5461,7 @@ dependencies = [ "crossterm 0.29.0", "dirs", "globset", - "hashbrown 0.16.1", + "hashbrown", "indexmap", "ratatui", "regex", @@ -5017,7 +5482,7 @@ version = "25.9.15" dependencies = [ "anyhow", "crossterm 0.29.0", - "hashbrown 0.16.1", + "hashbrown", "indexmap", "parking_lot", "ratatui", @@ -5025,7 +5490,7 @@ dependencies = [ "tokio-stream", "tokio-util", "tracing", - "unicode-width 0.2.0", + "unicode-width", "yazi-adapter", "yazi-config", "yazi-dds", @@ -5046,7 +5511,7 @@ name = "yazi-dds" version = "25.9.15" dependencies = [ "anyhow", - "hashbrown 0.16.1", + "hashbrown", "mlua", "ordered-float 5.1.0", "parking_lot", @@ -5126,8 +5591,8 @@ dependencies = [ "bitflags 2.10.0", "core-foundation-sys", "dirs", - "foldhash 0.2.0", - "hashbrown 0.16.1", + "foldhash", + "hashbrown", "libc", "objc2", "parking_lot", @@ -5163,7 +5628,7 @@ dependencies = [ "anyhow", "bitflags 2.10.0", "crossterm 0.29.0", - "hashbrown 0.16.1", + "hashbrown", "mlua", "ordered-float 5.1.0", "serde", @@ -5184,7 +5649,7 @@ dependencies = [ "anyhow", "crossterm 0.29.0", "futures", - "hashbrown 0.16.1", + "hashbrown", "libc", "mlua", "parking_lot", @@ -5197,7 +5662,7 @@ dependencies = [ "tokio-util", "tracing", "twox-hash", - "unicode-width 0.2.0", + "unicode-width", "uzers", "windows-sys 0.61.2", "yazi-adapter", @@ -5240,10 +5705,10 @@ version = "25.9.15" dependencies = [ "anyhow", "async-priority-channel", - "foldhash 0.2.0", - "hashbrown 0.16.1", + "foldhash", + "hashbrown", "libc", - "lru 0.16.2", + "lru", "mlua", "ordered-float 5.1.0", "parking_lot", @@ -5281,9 +5746,9 @@ version = "25.9.15" dependencies = [ "anyhow", "crossterm 0.29.0", - "foldhash 0.2.0", + "foldhash", "futures", - "hashbrown 0.16.1", + "hashbrown", "libc", "memchr", "ordered-float 5.1.0", @@ -5326,7 +5791,7 @@ dependencies = [ "anyhow", "deadpool", "futures", - "hashbrown 0.16.1", + "hashbrown", "parking_lot", "russh", "tokio", @@ -5344,7 +5809,7 @@ name = "yazi-watcher" version = "25.9.15" dependencies = [ "anyhow", - "hashbrown 0.16.1", + "hashbrown", "notify", "parking_lot", "percent-encoding", @@ -5372,7 +5837,7 @@ dependencies = [ "parking_lot", "ratatui", "tokio", - "unicode-width 0.2.0", + "unicode-width", "yazi-binding", "yazi-config", "yazi-macro", @@ -5398,7 +5863,7 @@ checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] [[package]] @@ -5418,9 +5883,15 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.111", ] +[[package]] +name = "zmij" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4af59da1029247450b54ba43e0b62c8e376582464bbe5504dd525fe521e7e8fd" + [[package]] name = "zune-core" version = "0.5.0" diff --git a/Cargo.toml b/Cargo.toml index e0c15cb8..9a582034 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ lto = false debug = false [workspace.dependencies] -ansi-to-tui = "7.0.0" +ansi-to-tui = "8.0.0" anyhow = "1.0.100" base64 = "0.22.1" bitflags = { version = "2.10.0", features = [ "serde" ] } @@ -48,12 +48,12 @@ parking_lot = "0.12.5" paste = "1.0.15" percent-encoding = "2.3.2" rand = { version = "0.9.2", default-features = false, features = [ "os_rng", "small_rng", "std" ] } -ratatui = { version = "0.29.0", features = [ "serde", "unstable-rendered-line-info", "unstable-widget-ref" ] } +ratatui = { version = "0.30.0", features = [ "serde", "unstable-rendered-line-info", "unstable-widget-ref" ] } regex = "1.12.2" russh = { version = "0.56.0", default-features = false, features = [ "ring", "rsa" ] } scopeguard = "1.2.0" serde = { version = "1.0.228", features = [ "derive" ] } -serde_json = "1.0.146" +serde_json = "1.0.147" syntect = { version = "5.3.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] } thiserror = "2.0.17" tokio = { version = "1.48.0", features = [ "full" ] } @@ -63,7 +63,7 @@ toml = { version = "0.9.10" } tracing = { version = "0.1.44", features = [ "max_level_debug", "release_max_level_debug" ] } twox-hash = { version = "2.1.2", default-features = false, features = [ "std", "random", "xxhash3_128" ] } typed-path = "0.12.0" -unicode-width = { version = "0.2.0", default-features = false } +unicode-width = { version = "0.2.2", default-features = false } uzers = "0.12.2" [workspace.lints.clippy] diff --git a/yazi-binding/src/elements/border.rs b/yazi-binding/src/elements/border.rs index ab9866f7..2460c33c 100644 --- a/yazi-binding/src/elements/border.rs +++ b/yazi-binding/src/elements/border.rs @@ -20,7 +20,7 @@ pub struct Border { pub r#type: ratatui::widgets::BorderType, pub style: ratatui::style::Style, - pub titles: Vec<(ratatui::widgets::block::Position, ratatui::text::Line<'static>)>, + pub titles: Vec<(ratatui::widgets::TitlePosition, ratatui::text::Line<'static>)>, } impl Border { @@ -51,8 +51,8 @@ impl Border { for title in self.titles { block = match title { - (ratatui::widgets::block::Position::Top, line) => block.title(line), - (ratatui::widgets::block::Position::Bottom, line) => block.title(line), + (ratatui::widgets::TitlePosition::Top, line) => block.title(line), + (ratatui::widgets::TitlePosition::Bottom, line) => block.title(line), }; } @@ -80,9 +80,9 @@ impl UserData for Border { "title", |_, (ud, line, position): (AnyUserData, Value, Option)| { let position = if position == Some(Borders::BOTTOM.bits()) { - ratatui::widgets::block::Position::Bottom + ratatui::widgets::TitlePosition::Bottom } else { - ratatui::widgets::block::Position::Top + ratatui::widgets::TitlePosition::Top }; ud.borrow_mut::()?.titles.push((position, Line::try_from(line)?.inner)); diff --git a/yazi-fm/src/tasks/tasks.rs b/yazi-fm/src/tasks/tasks.rs index d334065e..f13297fb 100644 --- a/yazi-fm/src/tasks/tasks.rs +++ b/yazi-fm/src/tasks/tasks.rs @@ -1,4 +1,4 @@ -use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Rect}, text::Line, widgets::{Block, BorderType, Widget, WidgetRef}}; +use ratatui::{buffer::Buffer, layout::{self, Alignment, Constraint, Rect}, text::Line, widgets::{Block, BorderType, Widget}}; use yazi_config::THEME; use yazi_core::{Core, tasks::TASKS_PERCENT}; @@ -39,7 +39,7 @@ impl Widget for Tasks<'_> { .title_alignment(Alignment::Center) .border_type(BorderType::Rounded) .border_style(THEME.tasks.border); - block.render_ref(area, buf); + (&block).render(area, buf); List::new(self.core).render(block.inner(area), buf); } diff --git a/yazi-fs/src/provider/attrs.rs b/yazi-fs/src/provider/attrs.rs index 8f4955a1..0746fa4d 100644 --- a/yazi-fs/src/provider/attrs.rs +++ b/yazi-fs/src/provider/attrs.rs @@ -2,7 +2,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use crate::cha::{Cha, ChaMode}; -#[derive(Clone, Copy, Debug, Default)] +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct Attrs { pub mode: Option, pub atime: Option, @@ -16,35 +16,57 @@ impl From for Attrs { } } -impl From for std::fs::FileTimes { - fn from(attrs: Attrs) -> Self { - let mut t = Self::new(); +impl TryFrom for std::fs::FileTimes { + type Error = (); - if let Some(atime) = attrs.atime { + fn try_from(value: Attrs) -> Result { + if !value.has_times() { + return Err(()); + } + + let mut t = Self::new(); + if let Some(atime) = value.atime { t = t.set_accessed(atime); } #[cfg(target_os = "macos")] - if let Some(btime) = attrs.btime { + if let Some(btime) = value.btime { use std::os::macos::fs::FileTimesExt; t = t.set_created(btime); } #[cfg(windows)] - if let Some(btime) = attrs.btime { + if let Some(btime) = value.btime { use std::os::windows::fs::FileTimesExt; t = t.set_created(btime); } - if let Some(mtime) = attrs.mtime { + if let Some(mtime) = value.mtime { t = t.set_modified(mtime); } - t + Ok(t) + } +} + +impl TryFrom for std::fs::Permissions { + type Error = (); + + fn try_from(value: Attrs) -> Result { + #[cfg(unix)] + if let Some(mode) = value.mode { + return Ok(mode.into()); + } + + Err(()) } } impl Attrs { + pub fn has_times(self) -> bool { + self.atime.is_some() || self.btime.is_some() || self.mtime.is_some() + } + pub fn atime_dur(self) -> Option { self.atime?.duration_since(UNIX_EPOCH).ok() } pub fn btime_dur(self) -> Option { self.btime?.duration_since(UNIX_EPOCH).ok() } diff --git a/yazi-fs/src/provider/local/copier.rs b/yazi-fs/src/provider/local/copier.rs index 8102019e..e95ddd69 100644 --- a/yazi-fs/src/provider/local/copier.rs +++ b/yazi-fs/src/provider/local/copier.rs @@ -22,7 +22,9 @@ pub(super) async fn copy_impl(from: PathBuf, to: PathBuf, attrs: Attrs) -> io::R if let Some(mode) = attrs.mode { writer.set_permissions(mode.into()).ok(); } - writer.set_times(attrs.into()).ok(); + if let Ok(times) = attrs.try_into() { + writer.set_times(times).ok(); + } Ok(written) }) @@ -34,8 +36,10 @@ pub(super) async fn copy_impl(from: PathBuf, to: PathBuf, attrs: Attrs) -> io::R tokio::task::spawn_blocking(move || { let written = std::fs::copy(from, &to)?; - if let Ok(file) = std::fs::File::options().write(true).open(to) { - file.set_times(attrs.into()).ok(); + if let Ok(times) = attrs.try_into() + && let Ok(file) = std::fs::File::options().write(true).open(to) + { + file.set_times(times).ok(); } Ok(written) diff --git a/yazi-plugin/src/fs/fs.rs b/yazi-plugin/src/fs/fs.rs index 8d12b10a..2cc15b77 100644 --- a/yazi-plugin/src/fs/fs.rs +++ b/yazi-plugin/src/fs/fs.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use mlua::{ExternalError, Function, IntoLua, IntoLuaMulti, Lua, Table, Value}; use yazi_binding::{Cha, Composer, ComposerGet, ComposerSet, Error, File, Url, UrlRef}; use yazi_config::Pattern; -use yazi_fs::{mounts::PARTITIONS, provider::{DirReader, FileHolder}}; +use yazi_fs::{mounts::PARTITIONS, provider::{Attrs, DirReader, FileHolder}}; use yazi_shared::url::{UrlCow, UrlLike}; use yazi_vfs::{VfsFile, provider}; @@ -15,9 +15,11 @@ pub fn compose() -> Composer { b"op" => op(lua)?, b"cwd" => cwd(lua)?, b"cha" => cha(lua)?, + b"copy" => copy(lua)?, b"write" => write(lua)?, b"create" => create(lua)?, b"remove" => remove(lua)?, + b"rename" => rename(lua)?, b"read_dir" => read_dir(lua)?, b"calc_size" => calc_size(lua)?, b"expand_url" => expand_url(lua)?, @@ -64,6 +66,15 @@ fn cha(lua: &Lua) -> mlua::Result { }) } +fn copy(lua: &Lua) -> mlua::Result { + lua.create_async_function(|lua, (from, to): (UrlRef, UrlRef)| async move { + match provider::copy(&*from, &*to, Attrs::default()).await { + Ok(len) => len.into_lua_multi(&lua), + Err(e) => (Value::Nil, Error::Io(e)).into_lua_multi(&lua), + } + }) +} + fn write(lua: &Lua) -> mlua::Result { lua.create_async_function(|lua, (url, data): (UrlRef, mlua::String)| async move { match provider::write(&*url, data.as_bytes()).await { @@ -105,6 +116,15 @@ fn remove(lua: &Lua) -> mlua::Result { }) } +fn rename(lua: &Lua) -> mlua::Result { + lua.create_async_function(|lua, (from, to): (UrlRef, UrlRef)| async move { + match provider::rename(&*from, &*to).await { + Ok(()) => true.into_lua_multi(&lua), + Err(e) => (false, Error::Io(e)).into_lua_multi(&lua), + } + }) +} + fn read_dir(lua: &Lua) -> mlua::Result { lua.create_async_function(|lua, (dir, options): (UrlRef, Table)| async move { let pat = if let Ok(s) = options.raw_get::("glob") { diff --git a/yazi-plugin/src/utils/spot.rs b/yazi-plugin/src/utils/spot.rs index e75b7a84..056c1bc5 100644 --- a/yazi-plugin/src/utils/spot.rs +++ b/yazi-plugin/src/utils/spot.rs @@ -23,7 +23,7 @@ impl Utils { r#type: ratatui::widgets::BorderType::Rounded, style: THEME.spot.border.into(), titles: vec![( - ratatui::widgets::block::Position::Top, + ratatui::widgets::TitlePosition::Top, ratatui::text::Line::raw("Spot").centered().style(THEME.spot.title), )], }), diff --git a/yazi-sftp/src/fs/attrs.rs b/yazi-sftp/src/fs/attrs.rs index 24e6b582..d60acbb2 100644 --- a/yazi-sftp/src/fs/attrs.rs +++ b/yazi-sftp/src/fs/attrs.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, fmt}; use serde::{Deserialize, Deserializer, Serialize, de::Visitor, ser::SerializeStruct}; -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct Attrs { pub size: Option, pub uid: Option, @@ -14,6 +14,8 @@ pub struct Attrs { } impl Attrs { + pub fn is_empty(&self) -> bool { *self == Self::default() } + pub fn len(&self) -> usize { let mut len = 4; if let Some(size) = self.size { diff --git a/yazi-vfs/src/provider/rw_file.rs b/yazi-vfs/src/provider/rw_file.rs index 47fce3c7..0b4e6e0d 100644 --- a/yazi-vfs/src/provider/rw_file.rs +++ b/yazi-vfs/src/provider/rw_file.rs @@ -28,18 +28,22 @@ impl RwFile { pub async fn set_attrs(&self, attrs: Attrs) -> io::Result<()> { match self { Self::Tokio(f) => { + let (perm, times) = (attrs.try_into(), attrs.try_into()); + if perm.is_err() && times.is_err() { + return Ok(()); + } + let std = f.try_clone().await?.into_std().await; tokio::task::spawn_blocking(move || { - #[cfg(unix)] - if let Some(mode) = attrs.mode { - std.set_permissions(mode.into()).ok(); - } - std.set_times(attrs.into()).ok(); + perm.map(|p| std.set_permissions(p)).ok(); + times.map(|t| std.set_times(t)).ok(); }) .await?; } Self::Sftp(f) => { - f.fsetstat(&super::sftp::Attrs(attrs).into()).await?; + if let Ok(attrs) = super::sftp::Attrs(attrs).try_into() { + f.fsetstat(&attrs).await?; + } } } diff --git a/yazi-vfs/src/provider/sftp/gate.rs b/yazi-vfs/src/provider/sftp/gate.rs index 16c4048a..c0588d5d 100644 --- a/yazi-vfs/src/provider/sftp/gate.rs +++ b/yazi-vfs/src/provider/sftp/gate.rs @@ -69,7 +69,7 @@ impl FileBuilder for Gate { }; let flags = Flags::from(*self); - let attrs = super::Attrs(self.0.attrs).into(); + let attrs = super::Attrs(self.0.attrs).try_into().unwrap_or_default(); Ok(Conn { name, config }.roll().await?.open(path, flags, &attrs).await?) } diff --git a/yazi-vfs/src/provider/sftp/metadata.rs b/yazi-vfs/src/provider/sftp/metadata.rs index 82473e94..4f6cbfc2 100644 --- a/yazi-vfs/src/provider/sftp/metadata.rs +++ b/yazi-vfs/src/provider/sftp/metadata.rs @@ -5,17 +5,21 @@ use yazi_fs::cha::ChaKind; // --- Attrs pub(crate) struct Attrs(pub(crate) yazi_fs::provider::Attrs); -impl From for yazi_sftp::fs::Attrs { - fn from(attrs: Attrs) -> Self { - Self { +impl TryFrom for yazi_sftp::fs::Attrs { + type Error = (); + + fn try_from(value: Attrs) -> Result { + let attrs = Self { size: None, uid: None, gid: None, - perm: attrs.0.mode.map(|m| m.bits() as u32), - atime: attrs.0.atime_dur().map(|d| d.as_secs() as u32), - mtime: attrs.0.mtime_dur().map(|d| d.as_secs() as u32), + perm: value.0.mode.map(|m| m.bits() as u32), + atime: value.0.atime_dur().map(|d| d.as_secs() as u32), + mtime: value.0.mtime_dur().map(|d| d.as_secs() as u32), extended: Default::default(), - } + }; + + if attrs.is_empty() { Err(()) } else { Ok(attrs) } } } diff --git a/yazi-vfs/src/provider/sftp/sftp.rs b/yazi-vfs/src/provider/sftp/sftp.rs index b499d1ae..2678bffe 100644 --- a/yazi-vfs/src/provider/sftp/sftp.rs +++ b/yazi-vfs/src/provider/sftp/sftp.rs @@ -78,7 +78,7 @@ impl<'a> Provider for Sftp<'a> { P: AsPath, { let to = to.as_path().as_unix()?; - let attrs = Attrs::from(super::Attrs(attrs)); + let attrs = super::Attrs(attrs).try_into().unwrap_or_default(); let op = self.op().await?; let from = op.open(self.path, Flags::READ, &Attrs::default()).await?; @@ -89,7 +89,10 @@ impl<'a> Provider for Sftp<'a> { let written = tokio::io::copy(&mut reader, &mut writer).await?; writer.flush().await?; - writer.get_ref().fsetstat(&attrs).await.ok(); + if !attrs.is_empty() { + writer.get_ref().fsetstat(&attrs).await.ok(); + } + writer.shutdown().await.ok(); Ok(written) }