diff --git a/Cargo.lock b/Cargo.lock index f2aa41cc..15a5d348 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1211,9 +1211,9 @@ dependencies = [ [[package]] name = "mlua" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9bed6bce296397a9d6a86f995dd10a547a4e6949825d45225906bdcbfe7367" +checksum = "e340c022072f3208a4105458286f4985ba5355bfe243c3073afe45cbe9ecf491" dependencies = [ "bstr", "erased-serde", @@ -1229,9 +1229,9 @@ dependencies = [ [[package]] name = "mlua-sys" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16a9ba1dd2c6ac971b204262d434c24d65067038598f0638b64e5dca28d52b8" +checksum = "5552e7e4e22ada0463dfdeee6caf6dc057a189fdc83136408a8f950a5e5c5540" dependencies = [ "cc", "cfg-if", @@ -1242,9 +1242,9 @@ dependencies = [ [[package]] name = "mlua_derive" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaade5f94e5829db58791664ba98f35fea6a3ffebc783becb51dc97c7a21abee" +checksum = "09697a6cec88e7f58a02c7ab5c18c611c6907c8654613df9cc0192658a4fb859" dependencies = [ "itertools", "once_cell", @@ -1704,9 +1704,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] @@ -1723,9 +1723,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", @@ -1745,9 +1745,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -2113,9 +2113,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" dependencies = [ "indexmap", "serde", @@ -2126,18 +2126,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.12" +version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ "indexmap", "serde", diff --git a/yazi-adaptor/src/emulator.rs b/yazi-adaptor/src/emulator.rs index 2275681e..3b8bf9ce 100644 --- a/yazi-adaptor/src/emulator.rs +++ b/yazi-adaptor/src/emulator.rs @@ -32,7 +32,7 @@ impl Emulator { match self { Self::Unknown(adapters) => adapters, Self::Kitty => vec![Adaptor::Kitty], - Self::Konsole => vec![Adaptor::KittyOld, Adaptor::Iterm2, Adaptor::Sixel], + Self::Konsole => vec![Adaptor::Iterm2, Adaptor::KittyOld, Adaptor::Sixel], Self::Iterm2 => vec![Adaptor::Iterm2, Adaptor::Sixel], Self::WezTerm => vec![Adaptor::Iterm2, Adaptor::Sixel], Self::Foot => vec![Adaptor::Sixel], diff --git a/yazi-boot/Cargo.toml b/yazi-boot/Cargo.toml index 56c34d56..38160f2b 100644 --- a/yazi-boot/Cargo.toml +++ b/yazi-boot/Cargo.toml @@ -15,7 +15,7 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies clap = { version = "4.5.4", features = [ "derive" ] } -serde = { version = "1.0.201", features = [ "derive" ] } +serde = { version = "1.0.202", features = [ "derive" ] } [build-dependencies] clap = { version = "4.5.4", features = [ "derive" ] } diff --git a/yazi-cli/Cargo.toml b/yazi-cli/Cargo.toml index 93d7cdf7..37c6b86c 100644 --- a/yazi-cli/Cargo.toml +++ b/yazi-cli/Cargo.toml @@ -19,7 +19,7 @@ crossterm = "0.27.0" md-5 = "0.10.6" serde_json = "1.0.117" tokio = { version = "1.37.0", features = [ "full" ] } -toml_edit = "0.22.12" +toml_edit = "0.22.13" [build-dependencies] anyhow = "1.0.83" diff --git a/yazi-config/Cargo.toml b/yazi-config/Cargo.toml index 11b67051..86ad1138 100644 --- a/yazi-config/Cargo.toml +++ b/yazi-config/Cargo.toml @@ -18,7 +18,7 @@ crossterm = "0.27.0" globset = "0.4.14" indexmap = "2.2.6" ratatui = "=0.26.1" -serde = { version = "1.0.201", features = [ "derive" ] } +serde = { version = "1.0.202", features = [ "derive" ] } shell-words = "1.1.0" -toml = { version = "0.8.12", features = [ "preserve_order" ] } +toml = { version = "0.8.13", features = [ "preserve_order" ] } validator = { version = "0.18.1", features = [ "derive" ] } diff --git a/yazi-config/preset/theme.toml b/yazi-config/preset/theme.toml index e5c40381..c8d48043 100644 --- a/yazi-config/preset/theme.toml +++ b/yazi-config/preset/theme.toml @@ -303,6 +303,11 @@ rules = [ { name = "*.xlsx", text = "", fg = "#207245" }, { name = "*.xlt" , text = "", fg = "#207245" }, + # Fonts + { name = "*.eot", text = "", fg = "#ececec" }, + { name = "*.[ot]tf", text = "", fg = "#ececec" }, + { name = "*.{woff,woff2}", text = "", fg = "#ececec" }, + # Lockfiles { name = "*.lock", text = "", fg = "#bbbbbb" }, diff --git a/yazi-config/preset/yazi.toml b/yazi-config/preset/yazi.toml index ae7b439c..2338b4d5 100644 --- a/yazi-config/preset/yazi.toml +++ b/yazi-config/preset/yazi.toml @@ -87,6 +87,9 @@ preloaders = [ { mime = "video/*", run = "video" }, # PDF { mime = "application/pdf", run = "pdf" }, + # Font + { mime = "font/*", run = "font" }, + { mime = "application/vnd.ms-opentype", run = "font" }, ] previewers = [ { name = "*/", run = "folder", sync = true }, @@ -105,6 +108,9 @@ previewers = [ # Archive { mime = "application/*zip", run = "archive" }, { mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", run = "archive" }, + # Font + { mime = "font/*", run = "font" }, + { mime = "application/vnd.ms-opentype", run = "font" }, # Fallback { name = "*", run = "file" }, ] diff --git a/yazi-core/Cargo.toml b/yazi-core/Cargo.toml index 5c44a58b..982fb9ab 100644 --- a/yazi-core/Cargo.toml +++ b/yazi-core/Cargo.toml @@ -28,7 +28,7 @@ parking_lot = "0.12.2" ratatui = "=0.26.1" regex = "1.10.4" scopeguard = "1.2.0" -serde = "1.0.201" +serde = "1.0.202" tokio = { version = "1.37.0", features = [ "full" ] } tokio-stream = "0.1.15" tokio-util = "0.7.11" diff --git a/yazi-dds/Cargo.toml b/yazi-dds/Cargo.toml index 5c6590e1..ee016479 100644 --- a/yazi-dds/Cargo.toml +++ b/yazi-dds/Cargo.toml @@ -18,9 +18,9 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies anyhow = "1.0.83" -mlua = { version = "0.9.7", features = [ "lua54" ] } +mlua = { version = "0.9.8", features = [ "lua54" ] } parking_lot = "0.12.2" -serde = { version = "1.0.201", features = [ "derive" ] } +serde = { version = "1.0.202", features = [ "derive" ] } serde_json = "1.0.117" tokio = { version = "1.37.0", features = [ "full" ] } tokio-stream = "0.1.15" diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index f6410dfe..7a376924 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -28,7 +28,7 @@ better-panic = "0.3.0" crossterm = { version = "0.27.0", features = [ "event-stream" ] } fdlimit = "0.3.0" futures = "0.3.30" -mlua = { version = "0.9.7", features = [ "lua54" ] } +mlua = { version = "0.9.8", features = [ "lua54" ] } ratatui = "=0.26.1" scopeguard = "1.2.0" syntect = { version = "5.2.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] } diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index 0ea6f64a..e1808d2f 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -27,10 +27,10 @@ base64 = "0.22.1" crossterm = "0.27.0" futures = "0.3.30" md-5 = "0.10.6" -mlua = { version = "0.9.7", features = [ "lua54", "serialize", "macros", "async" ] } +mlua = { version = "0.9.8", features = [ "lua54", "serialize", "macros", "async" ] } parking_lot = "0.12.2" ratatui = "=0.26.1" -serde = "1.0.201" +serde = "1.0.202" serde_json = "1.0.117" shell-escape = "0.1.5" shell-words = "1.1.0" diff --git a/yazi-plugin/preset/plugins/font.lua b/yazi-plugin/preset/plugins/font.lua new file mode 100644 index 00000000..69cd82ff --- /dev/null +++ b/yazi-plugin/preset/plugins/font.lua @@ -0,0 +1,52 @@ +local TEXT = "ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n1234567890\n!$&*()[]{}" + +local M = {} + +function M:peek() + local cache = ya.file_cache(self) + if not cache then + return + end + + if self:preload() == 1 then + ya.image_show(cache, self.area) + ya.preview_widgets(self, {}) + end +end + +function M:seek() end + +function M:preload() + local cache = ya.file_cache(self) + if not cache or fs.cha(cache) then + return 1 + end + + local child, code = Command("convert"):args({ + "-size", + "800x560", + "-gravity", + "center", + "-font", + tostring(self.file.url), + "-pointsize", + "64", + "xc:white", + "-fill", + "black", + "-annotate", + "+0+0", + TEXT, + "JPG:" .. tostring(cache), + }):spawn() + + if not child then + ya.err("spawn `convert` command returns " .. tostring(code)) + return 0 + end + + local status = child:wait() + return status and status:success() and 1 or 2 +end + +return M diff --git a/yazi-plugin/src/loader/loader.rs b/yazi-plugin/src/loader/loader.rs index 55e8d0d5..eb059c3b 100644 --- a/yazi-plugin/src/loader/loader.rs +++ b/yazi-plugin/src/loader/loader.rs @@ -40,6 +40,7 @@ impl Loader { "code" => include_bytes!("../../preset/plugins/code.lua"), "file" => include_bytes!("../../preset/plugins/file.lua"), "folder" => include_bytes!("../../preset/plugins/folder.lua"), + "font" => include_bytes!("../../preset/plugins/font.lua"), "fzf" => include_bytes!("../../preset/plugins/fzf.lua"), "image" => include_bytes!("../../preset/plugins/image.lua"), "json" => include_bytes!("../../preset/plugins/json.lua"), diff --git a/yazi-proxy/Cargo.toml b/yazi-proxy/Cargo.toml index d37998af..374a663f 100644 --- a/yazi-proxy/Cargo.toml +++ b/yazi-proxy/Cargo.toml @@ -18,5 +18,5 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" } # External dependencies anyhow = "1.0.83" -mlua = { version = "0.9.7", features = [ "lua54" ] } +mlua = { version = "0.9.8", features = [ "lua54" ] } tokio = { version = "1.37.0", features = [ "full" ] } diff --git a/yazi-shared/Cargo.toml b/yazi-shared/Cargo.toml index 098b132d..d177a061 100644 --- a/yazi-shared/Cargo.toml +++ b/yazi-shared/Cargo.toml @@ -19,7 +19,7 @@ parking_lot = "0.12.2" percent-encoding = "2.3.1" ratatui = "=0.26.1" regex = "1.10.4" -serde = { version = "1.0.201", features = [ "derive" ] } +serde = { version = "1.0.202", features = [ "derive" ] } tokio = { version = "1.37.0", features = [ "full" ] } # Logging