diff --git a/Cargo.lock b/Cargo.lock index ec370fff..348c7b50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,6 +38,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" + [[package]] name = "allocator-api2" version = "0.2.16" @@ -120,9 +126,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" [[package]] name = "arc-swap" @@ -130,6 +142,23 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b3d0060af21e8d11a926981cc00c6c1541aa91dd64b9f881985c3da1094425f" +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "async-priority-channel" version = "0.2.0" @@ -145,6 +174,29 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "av1-grain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876c75a42f6364451a033496a14c44bffe41f5f4a8236f697391f11024e596d2" +dependencies = [ + "arrayvec", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -209,6 +261,12 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "bitstream-io" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c9989a51171e2e81038ab168b6ae22886fe9ded214430dbb4f41c28cf176da" + [[package]] name = "block-buffer" version = "0.10.4" @@ -228,6 +286,12 @@ dependencies = [ "serde", ] +[[package]] +name = "built" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d17f4d6e4dc36d1a02fbedc2753a096848e7c1b0772f7654eab8e2c927dd53" + [[package]] name = "bumpalo" version = "3.15.4" @@ -236,9 +300,9 @@ checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "byteorder" @@ -272,6 +336,20 @@ name = "cc" version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cfg-expr" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" +dependencies = [ + "smallvec", + "target-lexicon", +] [[package]] name = "cfg-if" @@ -603,9 +681,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erased-serde" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388979d208a049ffdfb22fa33b9c81942215b940910bccfe258caeb25d125cb3" +checksum = "2b73807008a3c7f171cc40312f37d95ef0396e048b5848d775f54b1a4dd4a0d3" dependencies = [ "serde", ] @@ -945,20 +1023,35 @@ dependencies = [ [[package]] name = "image" -version = "0.24.9" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "a9b4f005360d32e9325029b38ba47ebd7a56f3316df09249368939562d518645" dependencies = [ "bytemuck", "byteorder", "color_quant", "exr", "gif", - "jpeg-decoder", + "image-webp", "num-traits", "png", "qoi", + "ravif", + "rayon", + "rgb", "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6107a25f04af48ceeb4093eebc9b405ee5a1813a0bab5ecf1805d3eabb3337" +dependencies = [ + "byteorder", + "thiserror", ] [[package]] @@ -967,6 +1060,12 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" +[[package]] +name = "imgref" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" + [[package]] name = "indexmap" version = "2.2.5" @@ -1003,6 +1102,17 @@ dependencies = [ "libc", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "itertools" version = "0.12.1" @@ -1018,14 +1128,20 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jobserver" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +dependencies = [ + "libc", +] + [[package]] name = "jpeg-decoder" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" -dependencies = [ - "rayon", -] [[package]] name = "js-sys" @@ -1083,6 +1199,17 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libfuzzer-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96cfd5557eb82f2b83fed4955246c988d331975a002961b07c81584d107e7f7" +dependencies = [ + "arbitrary", + "cc", + "once_cell", +] + [[package]] name = "libredox" version = "0.0.1" @@ -1125,6 +1252,15 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "lru" version = "0.12.3" @@ -1162,6 +1298,16 @@ dependencies = [ "libc", ] +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "md-5" version = "0.10.6" @@ -1258,6 +1404,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nom" version = "7.1.3" @@ -1268,6 +1420,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + [[package]] name = "notify" version = "6.1.1" @@ -1296,12 +1454,55 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -1489,6 +1690,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1515,13 +1722,32 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" +dependencies = [ + "quote", + "syn 2.0.52", +] + [[package]] name = "qoi" version = "0.4.1" @@ -1531,6 +1757,12 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quick-xml" version = "0.31.0" @@ -1549,6 +1781,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "ratatui" version = "0.26.1" @@ -1569,6 +1831,56 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "system-deps", + "thiserror", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc13288f5ab39e6d7c9d501759712e6969fcc9734220846fc9ed26cae2cc4234" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "rayon" version = "1.9.0" @@ -1638,6 +1950,15 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rgb" +version = "0.8.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +dependencies = [ + "bytemuck", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1815,6 +2136,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "slab" version = "0.4.9" @@ -1885,18 +2215,18 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck", "proc-macro2", @@ -1949,19 +2279,38 @@ dependencies = [ ] [[package]] -name = "thiserror" -version = "1.0.57" +name = "system-deps" +version = "6.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "e8e9199467bcbc77c6a13cc6e32a6af21721ab8c96aa0261856c4fda5a4433f0" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml", + "version-compare", +] + +[[package]] +name = "target-lexicon" +version = "0.12.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" + +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", @@ -2113,9 +2462,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" +checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" dependencies = [ "indexmap", "serde", @@ -2135,9 +2484,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" dependencies = [ "indexmap", "serde", @@ -2297,6 +2646,17 @@ dependencies = [ "log", ] +[[package]] +name = "v_frame" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + [[package]] name = "validator" version = "0.17.0" @@ -2345,6 +2705,12 @@ dependencies = [ "time", ] +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + [[package]] name = "version_check" version = "0.9.4" @@ -2911,6 +3277,12 @@ dependencies = [ "syn 2.0.52", ] +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + [[package]] name = "zune-inflate" version = "0.2.54" @@ -2919,3 +3291,12 @@ checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" dependencies = [ "simd-adler32", ] + +[[package]] +name = "zune-jpeg" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec866b44a2a1fd6133d363f073ca1b179f438f99e7e5bfb1e33f7181facfe448" +dependencies = [ + "zune-core", +] diff --git a/yazi-adaptor/src/emulator.rs b/yazi-adaptor/src/emulator.rs index 30702fff..43d66929 100644 --- a/yazi-adaptor/src/emulator.rs +++ b/yazi-adaptor/src/emulator.rs @@ -110,8 +110,8 @@ impl Emulator { pub fn via_csi() -> Result { enable_raw_mode()?; - std::io::stdout().write_all(b"\x1b[>q\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c")?; - std::io::stdout().flush()?; + std::io::stderr().write_all(b"\x1b[>q\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c")?; + std::io::stderr().flush()?; let mut stdin = std::io::stdin().lock(); let mut buf = String::with_capacity(200); diff --git a/yazi-adaptor/src/image.rs b/yazi-adaptor/src/image.rs index 8db29c18..3fbb3b9f 100644 --- a/yazi-adaptor/src/image.rs +++ b/yazi-adaptor/src/image.rs @@ -39,7 +39,7 @@ impl Image { img.as_bytes(), img.width(), img.height(), - img.color(), + img.color().into(), )?; Ok::<_, anyhow::Error>(buf) }) diff --git a/yazi-adaptor/src/iterm2.rs b/yazi-adaptor/src/iterm2.rs index 6e0e00e4..796f6f63 100644 --- a/yazi-adaptor/src/iterm2.rs +++ b/yazi-adaptor/src/iterm2.rs @@ -1,4 +1,4 @@ -use std::{io::{stdout, BufWriter, Write}, path::Path}; +use std::{io::{stderr, BufWriter, Write}, path::Path}; use anyhow::Result; use base64::{engine::general_purpose, Engine}; @@ -19,19 +19,19 @@ impl Iterm2 { Adaptor::Iterm2.image_hide()?; Adaptor::shown_store(rect, size); - Term::move_lock(stdout().lock(), (rect.x, rect.y), |stdout| { - stdout.write_all(&b)?; + Term::move_lock(stderr().lock(), (rect.x, rect.y), |stderr| { + stderr.write_all(&b)?; Ok(size) }) } pub(super) fn image_erase(rect: Rect) -> Result<()> { - let stdout = BufWriter::new(stdout().lock()); + let stderr = BufWriter::new(stderr().lock()); let s = " ".repeat(rect.width as usize); - Term::move_lock(stdout, (0, 0), |stdout| { + Term::move_lock(stderr, (0, 0), |stderr| { for y in rect.top()..rect.bottom() { - Term::move_to(stdout, rect.x, y)?; - stdout.write_all(s.as_bytes())?; + Term::move_to(stderr, rect.x, y)?; + stderr.write_all(s.as_bytes())?; } Ok(()) }) diff --git a/yazi-adaptor/src/kitty.rs b/yazi-adaptor/src/kitty.rs index 07579528..966b84e7 100644 --- a/yazi-adaptor/src/kitty.rs +++ b/yazi-adaptor/src/kitty.rs @@ -1,4 +1,4 @@ -use std::{io::{stdout, BufWriter, Write}, path::Path}; +use std::{io::{stderr, BufWriter, Write}, path::Path}; use anyhow::Result; use base64::{engine::general_purpose, Engine}; @@ -319,12 +319,12 @@ impl Kitty { Adaptor::Kitty.image_hide()?; Adaptor::shown_store(rect, size); - Term::move_lock(stdout().lock(), (rect.x, rect.y), |stdout| { - stdout.write_all(&b)?; + Term::move_lock(stderr().lock(), (rect.x, rect.y), |stderr| { + stderr.write_all(&b)?; let mut buf = String::with_capacity(rect.width as usize * 3 + 20); for y in 0..rect.height { - Term::move_to(stdout, rect.x, rect.y + y)?; + Term::move_to(stderr, rect.x, rect.y + y)?; buf.clear(); buf.push_str("\x1b[38;5;1m"); @@ -334,7 +334,7 @@ impl Kitty { buf.push(*DIACRITICS.get(x as usize).unwrap_or(&DIACRITICS[0])); } buf.push_str("\x1b[0m"); - stdout.write_all(buf.as_bytes())?; + stderr.write_all(buf.as_bytes())?; } Ok(size) @@ -342,15 +342,15 @@ impl Kitty { } pub(super) fn image_erase(rect: Rect) -> Result<()> { - let stdout = BufWriter::new(stdout().lock()); + let stderr = BufWriter::new(stderr().lock()); let s = " ".repeat(rect.width as usize); - Term::move_lock(stdout, (0, 0), |stdout| { + Term::move_lock(stderr, (0, 0), |stderr| { for y in rect.top()..rect.bottom() { - Term::move_to(stdout, rect.x, y)?; - stdout.write_all(s.as_bytes())?; + Term::move_to(stderr, rect.x, y)?; + stderr.write_all(s.as_bytes())?; } - stdout.write_all(format!("{}_Gq=1,a=d,d=A{}\\{}", START, ESCAPE, CLOSE).as_bytes())?; + stderr.write_all(format!("{}_Gq=1,a=d,d=A{}\\{}", START, ESCAPE, CLOSE).as_bytes())?; Ok(()) }) } diff --git a/yazi-adaptor/src/kitty_old.rs b/yazi-adaptor/src/kitty_old.rs index 3c422277..553f4e9b 100644 --- a/yazi-adaptor/src/kitty_old.rs +++ b/yazi-adaptor/src/kitty_old.rs @@ -1,4 +1,4 @@ -use std::{io::{stdout, Write}, path::Path}; +use std::{io::{stderr, Write}, path::Path}; use anyhow::Result; use base64::{engine::general_purpose, Engine}; @@ -19,17 +19,17 @@ impl KittyOld { Adaptor::KittyOld.image_hide()?; Adaptor::shown_store(rect, size); - Term::move_lock(stdout().lock(), (rect.x, rect.y), |stdout| { - stdout.write_all(&b)?; + Term::move_lock(stderr().lock(), (rect.x, rect.y), |stderr| { + stderr.write_all(&b)?; Ok(size) }) } #[inline] pub(super) fn image_erase() -> Result<()> { - let mut stdout = stdout().lock(); - stdout.write_all(format!("{}_Gq=1,a=d,d=A{}\\{}", START, ESCAPE, CLOSE).as_bytes())?; - stdout.flush()?; + let mut stderr = stderr().lock(); + stderr.write_all(format!("{}_Gq=1,a=d,d=A{}\\{}", START, ESCAPE, CLOSE).as_bytes())?; + stderr.flush()?; Ok(()) } diff --git a/yazi-adaptor/src/sixel.rs b/yazi-adaptor/src/sixel.rs index 75bb4fb8..3e0e6702 100644 --- a/yazi-adaptor/src/sixel.rs +++ b/yazi-adaptor/src/sixel.rs @@ -1,4 +1,4 @@ -use std::{io::{stdout, BufWriter, Write}, path::Path}; +use std::{io::{stderr, BufWriter, Write}, path::Path}; use anyhow::{bail, Result}; use color_quant::NeuQuant; @@ -19,19 +19,19 @@ impl Sixel { Adaptor::Sixel.image_hide()?; Adaptor::shown_store(rect, size); - Term::move_lock(stdout().lock(), (rect.x, rect.y), |stdout| { - stdout.write_all(&b)?; + Term::move_lock(stderr().lock(), (rect.x, rect.y), |stderr| { + stderr.write_all(&b)?; Ok(size) }) } pub(super) fn image_erase(rect: Rect) -> Result<()> { - let stdout = BufWriter::new(stdout().lock()); + let stderr = BufWriter::new(stderr().lock()); let s = " ".repeat(rect.width as usize); - Term::move_lock(stdout, (0, 0), |stdout| { + Term::move_lock(stderr, (0, 0), |stderr| { for y in rect.top()..rect.bottom() { - Term::move_to(stdout, rect.x, y)?; - stdout.write_all(s.as_bytes())?; + Term::move_to(stderr, rect.x, y)?; + stderr.write_all(s.as_bytes())?; } Ok(()) }) diff --git a/yazi-boot/src/boot.rs b/yazi-boot/src/boot.rs index d4f1f530..9d427c3b 100644 --- a/yazi-boot/src/boot.rs +++ b/yazi-boot/src/boot.rs @@ -92,6 +92,18 @@ impl Boot { ); println!("You can find it in the {:?} directory.", Xdg::state_dir()); } + + fn action_clear_cache() { + if PREVIEW.cache_dir == Xdg::cache_dir() { + println!("Clearing cache directory: \n{:?}", PREVIEW.cache_dir); + std::fs::remove_dir_all(&PREVIEW.cache_dir).unwrap(); + } else { + println!( + "You've changed the default cache directory, for your data's safety, please clear it manually: \n{:?}", + PREVIEW.cache_dir + ); + } + } } impl Default for Boot { @@ -129,15 +141,7 @@ impl Default for Args { } if args.clear_cache { - if PREVIEW.cache_dir == Xdg::cache_dir() { - println!("Clearing cache directory: \n{:?}", PREVIEW.cache_dir); - std::fs::remove_dir_all(&PREVIEW.cache_dir).unwrap(); - } else { - println!( - "You've changed the default cache directory, for your data's safety, please clear it manually: \n{:?}", - PREVIEW.cache_dir - ); - } + Boot::action_clear_cache(); process::exit(0); } diff --git a/yazi-config/src/lib.rs b/yazi-config/src/lib.rs index 385ca369..5c699292 100644 --- a/yazi-config/src/lib.rs +++ b/yazi-config/src/lib.rs @@ -70,7 +70,7 @@ pub fn init() { // TODO: remove this once Yazi 0.3 is released -- if !HEADSUP.disable_exec_warn && DEPRECATED_EXEC.load(std::sync::atomic::Ordering::Relaxed) { - println!( + eprintln!( r#" WARNING: `exec` will be deprecated in the next major version v0.3 and replaced by `run`. diff --git a/yazi-config/src/validation.rs b/yazi-config/src/validation.rs index a0346eb9..b71e150a 100644 --- a/yazi-config/src/validation.rs +++ b/yazi-config/src/validation.rs @@ -10,14 +10,14 @@ pub fn check_validation(res: Result<(), ValidationErrors>) { ValidationErrorsKind::Struct(errors) => check_validation(Err(*errors)), ValidationErrorsKind::List(errors) => { for (i, errors) in errors { - print!("Config `{field}[{i}]` format error: "); + eprint!("Config `{field}[{i}]` format error: "); check_validation(Err(*errors)); - println!(); + eprintln!(); } } ValidationErrorsKind::Field(error) => { for e in error { - println!( + eprintln!( "Config `{field}` format error: {}\n", e.message.unwrap_or(Cow::Borrowed("unknown error")) ); diff --git a/yazi-core/src/clipboard.rs b/yazi-core/src/clipboard.rs index fb3a9bcd..fe329de7 100644 --- a/yazi-core/src/clipboard.rs +++ b/yazi-core/src/clipboard.rs @@ -54,7 +54,7 @@ impl Clipboard { #[cfg(unix)] pub async fn set(&self, s: impl AsRef) { - use std::{io::stdout, process::Stdio}; + use std::{io::stderr, process::Stdio}; use crossterm::execute; use tokio::{io::AsyncWriteExt, process::Command}; @@ -62,7 +62,7 @@ impl Clipboard { *self.content.lock() = s.as_ref().to_owned(); if in_ssh_connection() { - execute!(stdout(), osc52::SetClipboard::new(s.as_ref())).ok(); + execute!(stderr(), osc52::SetClipboard::new(s.as_ref())).ok(); } let all = [ diff --git a/yazi-core/src/manager/commands/bulk_rename.rs b/yazi-core/src/manager/commands/bulk_rename.rs index 23f6be96..8d3e31cc 100644 --- a/yazi-core/src/manager/commands/bulk_rename.rs +++ b/yazi-core/src/manager/commands/bulk_rename.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, collections::HashMap, ffi::{OsStr, OsString}, io::{stdout, BufWriter, Write}, path::PathBuf}; +use std::{borrow::Cow, collections::HashMap, ffi::{OsStr, OsString}, io::{stderr, BufWriter, Write}, path::PathBuf}; use anyhow::{anyhow, Result}; use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}}; @@ -50,9 +50,9 @@ impl Manager { old: Vec, new: Vec, ) -> Result<()> { - Term::clear(&mut stdout())?; + Term::clear(&mut stderr())?; if old.len() != new.len() { - println!("Number of old and new differ, press ENTER to exit"); + eprintln!("Number of old and new differ, press ENTER to exit"); stdin().read_exact(&mut [0]).await?; return Ok(()); } @@ -63,12 +63,12 @@ impl Manager { } { - let mut stdout = BufWriter::new(stdout().lock()); + let mut stderr = BufWriter::new(stderr().lock()); for (o, n) in &todo { - writeln!(stdout, "{} -> {}", o.display(), n.display())?; + writeln!(stderr, "{} -> {}", o.display(), n.display())?; } - write!(stdout, "Continue to rename? (y/N): ")?; - stdout.flush()?; + write!(stderr, "Continue to rename? (y/N): ")?; + stderr.flush()?; } let mut buf = [0; 10]; @@ -105,16 +105,16 @@ impl Manager { } async fn output_failed(failed: Vec<(PathBuf, PathBuf, anyhow::Error)>) -> Result<()> { - Term::clear(&mut stdout())?; + Term::clear(&mut stderr())?; { - let mut stdout = BufWriter::new(stdout().lock()); - writeln!(stdout, "Failed to rename:")?; + let mut stderr = BufWriter::new(stderr().lock()); + writeln!(stderr, "Failed to rename:")?; for (o, n, e) in failed { - writeln!(stdout, "{} -> {}: {e}", o.display(), n.display())?; + writeln!(stderr, "{} -> {}: {e}", o.display(), n.display())?; } - writeln!(stdout, "\nPress ENTER to exit")?; - stdout.flush()?; + writeln!(stderr, "\nPress ENTER to exit")?; + stderr.flush()?; } stdin().read_exact(&mut [0]).await?; diff --git a/yazi-core/src/tasks/commands/inspect.rs b/yazi-core/src/tasks/commands/inspect.rs index 3d92c5e7..2fa8495e 100644 --- a/yazi-core/src/tasks/commands/inspect.rs +++ b/yazi-core/src/tasks/commands/inspect.rs @@ -1,4 +1,4 @@ -use std::io::{stdout, Write}; +use std::io::{stderr, Write}; use crossterm::terminal::{disable_raw_mode, enable_raw_mode}; use tokio::{io::{stdin, AsyncReadExt}, select, sync::mpsc, time}; @@ -32,8 +32,8 @@ impl Tasks { AppProxy::resume(); }); - Term::clear(&mut stdout()).ok(); - stdout().write_all(buffered.as_bytes()).ok(); + Term::clear(&mut stderr()).ok(); + stderr().write_all(buffered.as_bytes()).ok(); enable_raw_mode().ok(); let mut stdin = stdin(); @@ -41,13 +41,13 @@ impl Tasks { loop { select! { Some(line) = rx.recv() => { - let mut stdout = stdout().lock(); - stdout.write_all(line.as_bytes()).ok(); - stdout.write_all(b"\r\n").ok(); + let mut stderr = stderr().lock(); + stderr.write_all(line.as_bytes()).ok(); + stderr.write_all(b"\r\n").ok(); } _ = time::sleep(time::Duration::from_millis(500)) => { if scheduler.ongoing.lock().get(id).is_none() { - stdout().write_all(b"Task finished, press `q` to quit\r\n").ok(); + stderr().write_all(b"Task finished, press `q` to quit\r\n").ok(); break; } }, diff --git a/yazi-fm/src/app/commands/render.rs b/yazi-fm/src/app/commands/render.rs index b2350cff..6940560a 100644 --- a/yazi-fm/src/app/commands/render.rs +++ b/yazi-fm/src/app/commands/render.rs @@ -71,7 +71,7 @@ impl App { } } - let mut backend = CrosstermBackend::new(std::io::stdout().lock()); + let mut backend = CrosstermBackend::new(std::io::stderr().lock()); backend.draw(patches.into_iter()).ok(); if let Some((x, y)) = cursor { backend.show_cursor().ok(); diff --git a/yazi-plugin/src/external/fd.rs b/yazi-plugin/src/external/fd.rs index 55f7d72f..4fced261 100644 --- a/yazi-plugin/src/external/fd.rs +++ b/yazi-plugin/src/external/fd.rs @@ -20,11 +20,9 @@ pub fn fd(opt: FdOpt) -> Result> { .arg(&opt.subject) .kill_on_drop(true) .stdout(Stdio::piped()) - .stderr(Stdio::piped()) + .stderr(Stdio::null()) .spawn()?; - drop(child.stderr.take()); - let mut it = BufReader::new(child.stdout.take().unwrap()).lines(); let (tx, rx) = mpsc::unbounded_channel(); diff --git a/yazi-plugin/src/external/rg.rs b/yazi-plugin/src/external/rg.rs index 3367f53c..b37a3235 100644 --- a/yazi-plugin/src/external/rg.rs +++ b/yazi-plugin/src/external/rg.rs @@ -18,11 +18,9 @@ pub fn rg(opt: RgOpt) -> Result> { .arg(&opt.subject) .kill_on_drop(true) .stdout(Stdio::piped()) - .stderr(Stdio::piped()) + .stderr(Stdio::null()) .spawn()?; - drop(child.stderr.take()); - let mut it = BufReader::new(child.stdout.take().unwrap()).lines(); let (tx, rx) = mpsc::unbounded_channel(); diff --git a/yazi-shared/src/term/cursor.rs b/yazi-shared/src/term/cursor.rs index 94d0a5ae..7b97fa99 100644 --- a/yazi-shared/src/term/cursor.rs +++ b/yazi-shared/src/term/cursor.rs @@ -1,4 +1,4 @@ -use std::io::{stdout, Write}; +use std::io::{stderr, Write}; use anyhow::Result; use crossterm::{cursor::{MoveTo, RestorePosition, SavePosition, SetCursorStyle}, execute, queue}; @@ -7,12 +7,11 @@ use super::Term; impl Term { #[inline] - pub fn move_to(stdout: &mut impl Write, x: u16, y: u16) -> Result<()> { - Ok(queue!(stdout, MoveTo(x, y))?) - } + pub fn move_to(w: &mut impl Write, x: u16, y: u16) -> Result<()> { Ok(queue!(w, MoveTo(x, y))?) } + // FIXME: remove this function #[inline] - pub fn move_lock(mut stdout: W, (x, y): (u16, u16), cb: F) -> Result + pub fn move_lock(mut w: W, (x, y): (u16, u16), cb: F) -> Result where W: Write, F: FnOnce(&mut W) -> Result, @@ -22,31 +21,31 @@ impl Term { use std::{thread, time::Duration}; use crossterm::cursor::{Hide, Show}; - queue!(&mut stdout, SavePosition, MoveTo(x, y), Show)?; + queue!(&mut w, SavePosition, MoveTo(x, y), Show)?; // I really don't want to add this, // but on Windows the cursor position will not synchronize in time occasionally - stdout.flush()?; + w.flush()?; thread::sleep(Duration::from_millis(1)); - let result = cb(&mut stdout); - queue!(&mut stdout, Hide, RestorePosition)?; - stdout.flush()?; + let result = cb(&mut w); + queue!(&mut w, Hide, RestorePosition)?; + w.flush()?; result } #[cfg(unix)] { - queue!(&mut stdout, SavePosition, MoveTo(x, y))?; - let result = cb(&mut stdout); - queue!(&mut stdout, RestorePosition)?; - stdout.flush()?; + queue!(&mut w, SavePosition, MoveTo(x, y))?; + let result = cb(&mut w); + queue!(&mut w, RestorePosition)?; + w.flush()?; result } } #[inline] - pub fn set_cursor_block() -> Result<()> { Ok(execute!(stdout(), SetCursorStyle::BlinkingBlock)?) } + pub fn set_cursor_block() -> Result<()> { Ok(execute!(stderr(), SetCursorStyle::BlinkingBlock)?) } #[inline] - pub fn set_cursor_bar() -> Result<()> { Ok(execute!(stdout(), SetCursorStyle::BlinkingBar)?) } + pub fn set_cursor_bar() -> Result<()> { Ok(execute!(stderr(), SetCursorStyle::BlinkingBar)?) } } diff --git a/yazi-shared/src/term/term.rs b/yazi-shared/src/term/term.rs index ea0bf0d9..22e1a1bb 100644 --- a/yazi-shared/src/term/term.rs +++ b/yazi-shared/src/term/term.rs @@ -1,4 +1,4 @@ -use std::{io::{self, stdout, Stdout, Write}, mem, ops::{Deref, DerefMut}, sync::atomic::{AtomicBool, Ordering}}; +use std::{io::{self, stderr, Stderr, Write}, mem, ops::{Deref, DerefMut}, sync::atomic::{AtomicBool, Ordering}}; use anyhow::Result; use crossterm::{event::{DisableBracketedPaste, DisableFocusChange, EnableBracketedPaste, EnableFocusChange, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}, execute, queue, terminal::{disable_raw_mode, enable_raw_mode, supports_keyboard_enhancement, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen, WindowSize}}; @@ -7,7 +7,7 @@ use ratatui::{backend::CrosstermBackend, buffer::Buffer, layout::Rect, Completed static CSI_U: AtomicBool = AtomicBool::new(false); pub struct Term { - inner: Terminal>, + inner: Terminal>, last_area: Rect, last_buffer: Buffer, } @@ -15,17 +15,17 @@ pub struct Term { impl Term { pub fn start() -> Result { let mut term = Self { - inner: Terminal::new(CrosstermBackend::new(stdout()))?, + inner: Terminal::new(CrosstermBackend::new(stderr()))?, last_area: Default::default(), last_buffer: Default::default(), }; enable_raw_mode()?; - queue!(stdout(), EnterAlternateScreen, EnableBracketedPaste, EnableFocusChange)?; + queue!(stderr(), EnterAlternateScreen, EnableBracketedPaste, EnableFocusChange)?; if let Ok(true) = supports_keyboard_enhancement() { queue!( - stdout(), + stderr(), PushKeyboardEnhancementFlags( KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS @@ -42,11 +42,11 @@ impl Term { fn stop(&mut self) -> Result<()> { if CSI_U.swap(false, Ordering::Relaxed) { - execute!(stdout(), PopKeyboardEnhancementFlags)?; + execute!(stderr(), PopKeyboardEnhancementFlags)?; } execute!( - stdout(), + stderr(), DisableFocusChange, DisableBracketedPaste, LeaveAlternateScreen, @@ -59,11 +59,11 @@ impl Term { pub fn goodbye(f: impl FnOnce() -> bool) -> ! { if CSI_U.swap(false, Ordering::Relaxed) { - execute!(stdout(), PopKeyboardEnhancementFlags).ok(); + execute!(stderr(), PopKeyboardEnhancementFlags).ok(); } execute!( - stdout(), + stderr(), DisableFocusChange, DisableBracketedPaste, LeaveAlternateScreen, @@ -132,10 +132,10 @@ impl Term { } #[inline] - pub fn clear(stdout: &mut impl Write) -> Result<()> { - queue!(stdout, Clear(ClearType::All))?; - writeln!(stdout)?; - Ok(stdout.flush()?) + pub fn clear(w: &mut impl Write) -> Result<()> { + queue!(w, Clear(ClearType::All))?; + writeln!(w)?; + Ok(w.flush()?) } } @@ -144,7 +144,7 @@ impl Drop for Term { } impl Deref for Term { - type Target = Terminal>; + type Target = Terminal>; fn deref(&self) -> &Self::Target { &self.inner } }