diff --git a/Cargo.lock b/Cargo.lock index 1133672be..78b3a1015 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "ansi-to-tui" -version = "5.0.0-rc.1" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428c2992b874104caf39204b05bf89eab4ceefdd4fcb26caa6759906f547f8e8" +checksum = "00c4af0bef1b514c9b6a32a773caf604c1390fa7913f4eaa23bfe76f251d6a42" dependencies = [ "nom", "ratatui", @@ -153,7 +153,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -345,9 +345,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.13" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "jobserver", "libc", @@ -442,7 +442,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -474,13 +474,14 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "compact_str" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" dependencies = [ "castaway", "cfg-if", "itoa", + "rustversion", "ryu", "static_assertions", ] @@ -557,17 +558,18 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" -version = "0.27.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ "bitflags 2.6.0", "crossterm_winapi", "filedescriptor", "futures-core", "libc", - "mio 0.8.11", + "mio 1.0.2", "parking_lot", + "rustix", "signal-hook", "signal-hook-mio", "winapi", @@ -619,7 +621,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -630,7 +632,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -660,7 +662,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -670,7 +672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -916,7 +918,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -1167,6 +1169,16 @@ dependencies = [ "libc", ] +[[package]] +name = "instability" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" +dependencies = [ + "quote", + "syn 2.0.76", +] + [[package]] name = "instant" version = "0.1.13" @@ -1184,7 +1196,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -1348,9 +1360,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown", ] @@ -1435,6 +1447,7 @@ checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", + "log", "wasi", "windows-sys 0.52.0", ] @@ -1482,7 +1495,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -1575,7 +1588,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -1855,7 +1868,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd" dependencies = [ "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -1884,9 +1897,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1923,18 +1936,18 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.27.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16546c5b5962abf8ce6e2881e722b4e0ae3b6f1a08a26ae3573c55853ca68d3" +checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" dependencies = [ "bitflags 2.6.0", "cassowary", "compact_str", "crossterm", + "instability", "itertools 0.13.0", "lru", "paste", - "stability", "strum", "strum_macros", "unicode-segmentation", @@ -2092,9 +2105,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ "bitflags 2.6.0", "errno", @@ -2157,7 +2170,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2219,7 +2232,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio 0.8.11", + "mio 1.0.2", "signal-hook", ] @@ -2299,16 +2312,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "stability" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" -dependencies = [ - "quote", - "syn 2.0.74", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -2340,7 +2343,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2356,9 +2359,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.74" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2422,7 +2425,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2540,7 +2543,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2633,7 +2636,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2673,9 +2676,9 @@ dependencies = [ [[package]] name = "trash" -version = "5.1.0" +version = "5.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a154e8323dbd402514d5a3c0f12e0a5bddf72de674b565d58a5535500566428b" +checksum = "33caf2a9be1812a263a4bfce74d2de225fcde12ee7b77001361abd2b34ffdcc4" dependencies = [ "chrono", "libc", @@ -2815,7 +2818,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2893,34 +2896,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2928,22 +2932,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "weezl" @@ -3033,7 +3037,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -3044,7 +3048,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -3499,7 +3503,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9ce805b7f..ab0dc7ad8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,13 +10,13 @@ panic = "abort" strip = true [workspace.dependencies] -ansi-to-tui = "5.0.0-rc.1" +ansi-to-tui = "6.0.0" anyhow = "1.0.86" arc-swap = "1.7.1" base64 = "0.22.1" bitflags = "2.6.0" clap = { version = "4.5.16", features = [ "derive" ] } -crossterm = { version = "0.27.0", features = [ "event-stream" ] } +crossterm = { version = "0.28.1", features = [ "event-stream" ] } dirs = "5.0.1" futures = "0.3.30" globset = "0.4.14" @@ -24,7 +24,7 @@ libc = "0.2.158" md-5 = "0.10.6" mlua = { version = "0.9.9", features = [ "lua54", "serialize", "macros", "async" ] } parking_lot = "0.12.3" -ratatui = { version = "0.27.0", features = [ "unstable-rendered-line-info" ] } +ratatui = { version = "0.28.1", features = [ "unstable-rendered-line-info" ] } regex = "1.10.6" scopeguard = "1.2.0" serde = { version = "1.0.209", features = [ "derive" ] } diff --git a/README.md b/README.md index 7abd004bc..e0742a7f7 100644 --- a/README.md +++ b/README.md @@ -38,21 +38,22 @@ https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265 ## Image Preview -| Platform | Protocol | Support | -| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | -| [kitty](https://github.com/kovidgoyal/kitty) | [Kitty unicode placeholders](https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders) | ✅ Built-in | -| [Konsole](https://invent.kde.org/utilities/konsole) | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adapter/src/kitty_old.rs) | ✅ Built-in | -| [iTerm2](https://iterm2.com) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| [WezTerm](https://github.com/wez/wezterm) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| [Mintty](https://github.com/mintty/mintty) (Git Bash) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| [foot](https://codeberg.org/dnkl/foot) | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | -| [Ghostty](https://mitchellh.com/ghostty) | [Kitty unicode placeholders](https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders) | ✅ Built-in | -| [Black Box](https://gitlab.gnome.org/raggesilver/blackbox) | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | -| [VSCode](https://github.com/microsoft/vscode) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| [Tabby](https://github.com/Eugeny/tabby) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| [Hyper](https://github.com/vercel/hyper) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | -| X11 / Wayland | Window system protocol | ☑️ [Überzug++](https://github.com/jstkdng/ueberzugpp) required | -| Fallback | [ASCII art (Unicode block)](https://en.wikipedia.org/wiki/ASCII_art) | ☑️ [Chafa](https://hpjansson.org/chafa/) required | +| Platform | Protocol | Support | +| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | +| [kitty](https://github.com/kovidgoyal/kitty) | [Kitty unicode placeholders](https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders) | ✅ Built-in | +| [Konsole](https://invent.kde.org/utilities/konsole) | [Kitty old protocol](https://github.com/sxyazi/yazi/blob/main/yazi-adapter/src/kitty_old.rs) | ✅ Built-in | +| [iTerm2](https://iterm2.com) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| [WezTerm](https://github.com/wez/wezterm) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| [Mintty](https://github.com/mintty/mintty) (Git Bash) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| [foot](https://codeberg.org/dnkl/foot) | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | +| [Ghostty](https://mitchellh.com/ghostty) | [Kitty unicode placeholders](https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders) | ✅ Built-in | +| [Windows Terminal](https://github.com/microsoft/terminal) (>= v1.22.2362.0) | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | +| [Black Box](https://gitlab.gnome.org/raggesilver/blackbox) | [Sixel graphics format](https://www.vt100.net/docs/vt3xx-gp/chapter14.html) | ✅ Built-in | +| [VSCode](https://github.com/microsoft/vscode) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| [Tabby](https://github.com/Eugeny/tabby) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| [Hyper](https://github.com/vercel/hyper) | [Inline images protocol](https://iterm2.com/documentation-images.html) | ✅ Built-in | +| X11 / Wayland | Window system protocol | ☑️ [Überzug++](https://github.com/jstkdng/ueberzugpp) required | +| Fallback | [ASCII art (Unicode block)](https://en.wikipedia.org/wiki/ASCII_art) | ☑️ [Chafa](https://hpjansson.org/chafa/) required | See https://yazi-rs.github.io/docs/image-preview for details. diff --git a/yazi-adapter/Cargo.toml b/yazi-adapter/Cargo.toml index 9f4f037a3..a77bc10ea 100644 --- a/yazi-adapter/Cargo.toml +++ b/yazi-adapter/Cargo.toml @@ -29,4 +29,4 @@ tokio = { workspace = true } tracing = { workspace = true } [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } diff --git a/yazi-adapter/src/adapter.rs b/yazi-adapter/src/adapter.rs index 4f5234cb6..b9fdad1d4 100644 --- a/yazi-adapter/src/adapter.rs +++ b/yazi-adapter/src/adapter.rs @@ -82,8 +82,13 @@ impl Adapter { impl Adapter { pub fn matches() -> Self { - let mut protocols = Emulator::detect().adapters(); + let emulator = Emulator::detect(); + #[cfg(windows)] + if matches!(emulator, Emulator::Microsoft) { + return Self::Sixel; + } + let mut protocols = emulator.adapters(); #[cfg(windows)] protocols.retain(|p| *p == Self::Iterm2); if env_exists("ZELLIJ_SESSION_NAME") { diff --git a/yazi-adapter/src/emulator.rs b/yazi-adapter/src/emulator.rs index a201121ec..3a1e2ebe4 100644 --- a/yazi-adapter/src/emulator.rs +++ b/yazi-adapter/src/emulator.rs @@ -18,6 +18,7 @@ pub enum Emulator { WezTerm, Foot, Ghostty, + Microsoft, BlackBox, VSCode, Tabby, @@ -38,6 +39,7 @@ impl Emulator { Self::WezTerm => vec![Adapter::Iterm2, Adapter::Sixel], Self::Foot => vec![Adapter::Sixel], Self::Ghostty => vec![Adapter::Kitty], + Self::Microsoft => vec![Adapter::Sixel], Self::BlackBox => vec![Adapter::Sixel], Self::VSCode => vec![Adapter::Iterm2, Adapter::Sixel], Self::Tabby => vec![Adapter::Iterm2, Adapter::Sixel], @@ -62,6 +64,7 @@ impl Emulator { ("ITERM_SESSION_ID", Self::Iterm2), ("WEZTERM_EXECUTABLE", Self::WezTerm), ("GHOSTTY_RESOURCES_DIR", Self::Ghostty), + ("WT_Session", Self::Microsoft), ("VSCODE_INJECTION", Self::VSCode), ("TABBY_CONFIG_DIRECTORY", Self::Tabby), ]; diff --git a/yazi-cli/Cargo.toml b/yazi-cli/Cargo.toml index 90943a6df..8e057cc3e 100644 --- a/yazi-cli/Cargo.toml +++ b/yazi-cli/Cargo.toml @@ -35,7 +35,7 @@ serde_json = { workspace = true } vergen-gitcl = { version = "1.0.0", features = [ "build" ] } [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } [[bin]] name = "ya" diff --git a/yazi-config/Cargo.toml b/yazi-config/Cargo.toml index 4cad47dd7..78a6edb63 100644 --- a/yazi-config/Cargo.toml +++ b/yazi-config/Cargo.toml @@ -25,4 +25,4 @@ toml = { version = "0.8.19", features = [ "preserve_order" ] } validator = { version = "0.18.1", features = [ "derive" ] } [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } diff --git a/yazi-config/src/popup/options.rs b/yazi-config/src/popup/options.rs index 6e54c2470..dc669b5bc 100644 --- a/yazi-config/src/popup/options.rs +++ b/yazi-config/src/popup/options.rs @@ -121,19 +121,19 @@ impl ConfirmCfg { pub fn trash(urls: &[yazi_shared::fs::Url]) -> Self { Self::new( - Self::replace_number(&CONFIRM.trash_title, urls.len(), usize::MAX), + Self::replace_number(&CONFIRM.trash_title, urls.len()), (CONFIRM.trash_origin, CONFIRM.trash_offset), None, - Some(urls.iter().map(ToString::to_string).collect()), + Self::truncate_list(urls.iter(), urls.len(), 100), ) } pub fn delete(urls: &[yazi_shared::fs::Url]) -> Self { Self::new( - Self::replace_number(&CONFIRM.delete_title, urls.len(), usize::MAX), + Self::replace_number(&CONFIRM.delete_title, urls.len()), (CONFIRM.delete_origin, CONFIRM.delete_offset), None, - Some(urls.iter().map(ToString::to_string).collect()), + Self::truncate_list(urls.iter(), urls.len(), 100), ) } @@ -146,18 +146,33 @@ impl ConfirmCfg { ) } - pub fn quit(left: Vec) -> Self { + pub fn quit(len: usize, names: Vec) -> Self { Self::new( - Self::replace_number(&CONFIRM.quit_title, left.len(), 10), + Self::replace_number(&CONFIRM.quit_title, len), (CONFIRM.quit_origin, CONFIRM.quit_offset), Some(Text::raw(&CONFIRM.quit_content)), - Some(left.into_iter().collect()), + Self::truncate_list(names.into_iter(), len, 10), ) } - fn replace_number(tpl: &str, n: usize, max: usize) -> String { - let s = tpl.replace("{s}", if n > 1 { "s" } else { "" }); - s.replace("{n}", &if n > max { format!("{max}+") } else { n.to_string() }) + fn replace_number(tpl: &str, n: usize) -> String { + tpl.replace("{n}", &n.to_string()).replace("{s}", if n > 1 { "s" } else { "" }) + } + + fn truncate_list( + it: impl Iterator>, + len: usize, + max: usize, + ) -> Option> { + let mut lines = Vec::with_capacity(len.min(max + 1)); + for (i, s) in it.enumerate() { + if i >= max { + lines.push(format!("... and {} more", len - max)); + break; + } + lines.push(s.into()); + } + Some(Text::from_iter(lines)) } } diff --git a/yazi-core/Cargo.toml b/yazi-core/Cargo.toml index 3bd279632..49fe9db1a 100644 --- a/yazi-core/Cargo.toml +++ b/yazi-core/Cargo.toml @@ -40,4 +40,4 @@ unicode-width = { workspace = true } libc = { workspace = true } [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } diff --git a/yazi-core/src/manager/commands/quit.rs b/yazi-core/src/manager/commands/quit.rs index fbbdb929d..0442ffbdb 100644 --- a/yazi-core/src/manager/commands/quit.rs +++ b/yazi-core/src/manager/commands/quit.rs @@ -23,16 +23,19 @@ impl Manager { let opt = EventQuit { no_cwd_file: opt.into().no_cwd_file, ..Default::default() }; let ongoing = tasks.ongoing().clone(); - let left: Vec = ongoing.lock().values().take(11).map(|t| t.name.clone()).collect(); + let (left, left_names) = { + let ongoing = ongoing.lock(); + (ongoing.len(), ongoing.values().take(11).map(|t| t.name.clone()).collect()) + }; - if left.is_empty() { + if left == 0 { emit!(Quit(opt)); return; } tokio::spawn(async move { let mut i = 0; - let mut rx = ConfirmProxy::show_rx(ConfirmCfg::quit(left)); + let mut rx = ConfirmProxy::show_rx(ConfirmCfg::quit(left, left_names)); loop { select! { _ = time::sleep(Duration::from_millis(100)) => { diff --git a/yazi-core/src/manager/commands/tab_create.rs b/yazi-core/src/manager/commands/tab_create.rs index d3216b1c6..72d77c71b 100644 --- a/yazi-core/src/manager/commands/tab_create.rs +++ b/yazi-core/src/manager/commands/tab_create.rs @@ -35,7 +35,7 @@ impl Tabs { } let opt = opt.into() as Opt; - let mut tab = Tab::default(); + let mut tab = Tab { idx: self.cursor + 1, ..Default::default() }; if !opt.current { tab.cd(opt.url); diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index 0df8a13a4..32dad746a 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -23,9 +23,9 @@ pub struct Tab { pub history: HashMap, pub selected: Selected, - pub preview: Preview, - pub finder: Option, - pub(super) search: Option>>, + pub preview: Preview, + pub finder: Option, + pub search: Option>>, } impl Tab { diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 16a856725..da2f4bf47 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -46,7 +46,7 @@ libc = { workspace = true } signal-hook-tokio = { version = "0.3.1", features = [ "futures-v0_3" ] } [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } [target.'cfg(all(not(target_os = "macos"), not(target_os = "windows")))'.dependencies] tikv-jemallocator = "0.6.0" diff --git a/yazi-fm/src/app/commands/render.rs b/yazi-fm/src/app/commands/render.rs index 5ed72eb08..589ad476b 100644 --- a/yazi-fm/src/app/commands/render.rs +++ b/yazi-fm/src/app/commands/render.rs @@ -19,10 +19,10 @@ impl App { let collision = COLLISION.swap(false, Ordering::Relaxed); let frame = term .draw(|f| { - _ = Lives::scope(&self.cx, |_| Ok(f.render_widget(Root::new(&self.cx), f.size()))); + _ = Lives::scope(&self.cx, |_| Ok(f.render_widget(Root::new(&self.cx), f.area()))); - if let Some((x, y)) = self.cx.cursor() { - f.set_cursor(x, y); + if let Some(pos) = self.cx.cursor() { + f.set_cursor_position(pos); } }) .unwrap(); @@ -51,10 +51,10 @@ impl App { let frame = term .draw_partial(|f| { - f.render_widget(crate::notify::Layout::new(&self.cx), f.size()); + f.render_widget(crate::notify::Layout::new(&self.cx), f.area()); - if let Some((x, y)) = self.cx.cursor() { - f.set_cursor(x, y); + if let Some(pos) = self.cx.cursor() { + f.set_cursor_position(pos); } }) .unwrap(); @@ -69,20 +69,20 @@ impl App { let mut new = Buffer::empty(frame.area); for y in new.area.top()..new.area.bottom() { for x in new.area.left()..new.area.right() { - let cell = frame.buffer.get(x, y); + let cell = &frame.buffer[(x, y)]; if cell.skip { - *new.get_mut(x, y) = cell.clone(); + new[(x, y)] = cell.clone(); } - new.get_mut(x, y).set_skip(!cell.skip); + new[(x, y)].set_skip(!cell.skip); } } let patches = frame.buffer.diff(&new); let mut backend = CrosstermBackend::new(BufWriter::new(stderr().lock())); backend.draw(patches.into_iter()).ok(); - if let Some((x, y)) = cursor { + if let Some(pos) = cursor { backend.show_cursor().ok(); - backend.set_cursor(x, y).ok(); + backend.set_cursor_position(pos).ok(); } backend.flush().ok(); } diff --git a/yazi-fm/src/app/commands/update_progress.rs b/yazi-fm/src/app/commands/update_progress.rs index 21a626902..2e9cf93ec 100644 --- a/yazi-fm/src/app/commands/update_progress.rs +++ b/yazi-fm/src/app/commands/update_progress.rs @@ -46,9 +46,9 @@ impl App { _ = Lives::scope(&self.cx, |_| { for patch in Progress::partial_render(term.current_buffer_mut()) { term.backend_mut().draw(patch.iter().map(|(x, y, cell)| (*x, *y, cell)))?; - if let Some((x, y)) = self.cx.cursor() { + if let Some(pos) = self.cx.cursor() { term.show_cursor()?; - term.set_cursor(x, y)?; + term.set_cursor_position(pos)?; } term.backend_mut().flush()?; } diff --git a/yazi-fm/src/components/progress.rs b/yazi-fm/src/components/progress.rs index 6bb093334..568a82750 100644 --- a/yazi-fm/src/components/progress.rs +++ b/yazi-fm/src/components/progress.rs @@ -22,7 +22,7 @@ impl Progress { let mut patch = Vec::with_capacity(area.width as usize * area.height as usize); for y in area.top()..area.bottom() { for x in area.left()..area.right() { - patch.push((x, y, mem::take(buf.get_mut(x, y)))); + patch.push((x, y, mem::take(&mut buf[(x, y)]))); } } diff --git a/yazi-fm/src/lives/tab.rs b/yazi-fm/src/lives/tab.rs index 6f64c3711..df622d012 100644 --- a/yazi-fm/src/lives/tab.rs +++ b/yazi-fm/src/lives/tab.rs @@ -1,6 +1,7 @@ use std::ops::Deref; use mlua::{AnyUserData, Lua, UserDataFields, UserDataMethods}; +use yazi_plugin::url::UrlRef; use super::{Config, Finder, Folder, Mode, Preview, Selected, SCOPE}; @@ -41,6 +42,9 @@ impl Tab { me.parent.as_ref().map(|f| Folder::make(None, f, me)).transpose() }); + reg.add_method("history", |_, me, url: UrlRef| { + me.history.get(&url).map(|f| Folder::make(None, f, me)).transpose() + }); reg.add_field_method_get("selected", |_, me| Selected::make(&me.selected)); reg.add_field_method_get("preview", |_, me| Preview::make(me)); diff --git a/yazi-fm/src/term.rs b/yazi-fm/src/term.rs index e7490cbea..3f266f92c 100644 --- a/yazi-fm/src/term.rs +++ b/yazi-fm/src/term.rs @@ -118,9 +118,9 @@ impl Term { let buffer = frame.buffer_mut(); for y in self.last_area.top()..self.last_area.bottom() { for x in self.last_area.left()..self.last_area.right() { - let mut cell = self.last_buffer.get(x, y).clone(); + let mut cell = self.last_buffer[(x, y)].clone(); cell.skip = false; - *buffer.get_mut(x, y) = cell; + buffer[(x, y)] = cell; } } @@ -130,7 +130,7 @@ impl Term { #[inline] pub(super) fn can_partial(&mut self) -> bool { - self.inner.autoresize().is_ok() && self.last_area == self.inner.get_frame().size() + self.inner.autoresize().is_ok() && self.last_area == self.inner.get_frame().area() } #[inline] diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index 357f095bc..523ac229b 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -47,4 +47,4 @@ uzers = { workspace = true } clipboard-win = "5.4.0" [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } diff --git a/yazi-plugin/preset/components/linemode.lua b/yazi-plugin/preset/components/linemode.lua index ecdf6c9b1..2ca2b8814 100644 --- a/yazi-plugin/preset/components/linemode.lua +++ b/yazi-plugin/preset/components/linemode.lua @@ -24,7 +24,12 @@ end function Linemode:size() local size = self._file:size() - return ui.Line(size and ya.readable_size(size) or "") + if size then + return ui.Line(ya.readable_size(size)) + else + local folder = cx.active:history(self._file.url) + return ui.Line(folder and tostring(#folder.files) or "") + end end function Linemode:ctime() diff --git a/yazi-plugin/src/bindings/range.rs b/yazi-plugin/src/bindings/range.rs index 5d7a37dbe..516c26076 100644 --- a/yazi-plugin/src/bindings/range.rs +++ b/yazi-plugin/src/bindings/range.rs @@ -10,7 +10,7 @@ impl<'lua, T> IntoLua<'lua> for Range where T: IntoLua<'lua>, { - fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result { + fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result> { lua.create_sequence_from([self.0.start, self.0.end])?.into_lua(lua) } } diff --git a/yazi-plugin/src/elements/bar.rs b/yazi-plugin/src/elements/bar.rs index c75627531..4807d8eba 100644 --- a/yazi-plugin/src/elements/bar.rs +++ b/yazi-plugin/src/elements/bar.rs @@ -81,7 +81,7 @@ impl Renderable for Bar { if self.direction.contains(Borders::LEFT) { for y in self.area.top()..self.area.bottom() { - let cell = buf.get_mut(self.area.left(), y).set_symbol(symbol); + let cell = buf[(self.area.left(), y)].set_symbol(symbol); if let Some(style) = self.style { cell.set_style(style); } @@ -89,7 +89,7 @@ impl Renderable for Bar { } if self.direction.contains(Borders::TOP) { for x in self.area.left()..self.area.right() { - let cell = buf.get_mut(x, self.area.top()).set_symbol(symbol); + let cell = buf[(x, self.area.top())].set_symbol(symbol); if let Some(style) = self.style { cell.set_style(style); } @@ -98,7 +98,7 @@ impl Renderable for Bar { if self.direction.contains(Borders::RIGHT) { let x = self.area.right() - 1; for y in self.area.top()..self.area.bottom() { - let cell = buf.get_mut(x, y).set_symbol(symbol); + let cell = buf[(x, y)].set_symbol(symbol); if let Some(style) = self.style { cell.set_style(style); } @@ -107,7 +107,7 @@ impl Renderable for Bar { if self.direction.contains(Borders::BOTTOM) { let y = self.area.bottom() - 1; for x in self.area.left()..self.area.right() { - let cell = buf.get_mut(x, y).set_symbol(symbol); + let cell = buf[(x, y)].set_symbol(symbol); if let Some(style) = self.style { cell.set_style(style); } diff --git a/yazi-plugin/src/elements/clear.rs b/yazi-plugin/src/elements/clear.rs index 1eff79788..424f879d6 100644 --- a/yazi-plugin/src/elements/clear.rs +++ b/yazi-plugin/src/elements/clear.rs @@ -39,7 +39,7 @@ impl ratatui::widgets::Widget for Clear { COLLISION.store(true, Ordering::Relaxed); for y in r.top()..r.bottom() { for x in r.left()..r.right() { - buf.get_mut(x, y).set_skip(true); + buf[(x, y)].set_skip(true); } } } diff --git a/yazi-plugin/src/elements/rect.rs b/yazi-plugin/src/elements/rect.rs index 74b160980..a74d18063 100644 --- a/yazi-plugin/src/elements/rect.rs +++ b/yazi-plugin/src/elements/rect.rs @@ -18,7 +18,8 @@ impl Rect { }) })?; - let rect = lua.create_table_from([("default", Rect::cast(lua, Default::default())?)])?; + let rect = + lua.create_table_from([("default", Rect::cast(lua, ratatui::layout::Rect::default())?)])?; rect.set_metatable(Some(lua.create_table_from([("__call", new)])?)); @@ -57,3 +58,14 @@ impl Cast for Rect { lua.create_any_userdata(data) } } + +impl Cast for Rect { + fn cast(lua: &Lua, data: ratatui::layout::Size) -> mlua::Result { + lua.create_any_userdata(ratatui::layout::Rect { + x: 0, + y: 0, + width: data.width, + height: data.height, + }) + } +} diff --git a/yazi-scheduler/Cargo.toml b/yazi-scheduler/Cargo.toml index 54d99d496..108e9c297 100644 --- a/yazi-scheduler/Cargo.toml +++ b/yazi-scheduler/Cargo.toml @@ -28,4 +28,4 @@ tracing = { workspace = true } libc = { workspace = true } [target.'cfg(not(target_os = "android"))'.dependencies] -trash = "5.1.0" +trash = "5.1.1" diff --git a/yazi-shared/Cargo.toml b/yazi-shared/Cargo.toml index aba1c8c75..627354e04 100644 --- a/yazi-shared/Cargo.toml +++ b/yazi-shared/Cargo.toml @@ -31,4 +31,4 @@ uzers = { workspace = true } windows-sys = { version = "0.59.0", features = [ "Win32_Storage_FileSystem", "Win32_UI_Shell" ] } [target.'cfg(target_os = "macos")'.dependencies] -crossterm = { workspace = true, features = [ "use-dev-tty" ] } +crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] } diff --git a/yazi-shared/src/fs/url.rs b/yazi-shared/src/fs/url.rs index 68aaebd25..274931f2b 100644 --- a/yazi-shared/src/fs/url.rs +++ b/yazi-shared/src/fs/url.rs @@ -118,6 +118,10 @@ impl Display for Url { } } +impl From<&Url> for String { + fn from(url: &Url) -> Self { url.to_string() } +} + impl Url { #[inline] pub fn join(&self, path: impl AsRef) -> Self {