From 0d506d577c7483c4a7225beb3983a27f87a76e16 Mon Sep 17 00:00:00 2001 From: Noah Too Date: Mon, 30 Sep 2024 08:06:15 +0300 Subject: [PATCH] chore: bump silicon and lock to ref --- Cargo.lock | 233 +++++++++++++++-------------------------------- Cargo.toml | 4 +- src/clipboard.rs | 22 +++-- src/error.rs | 4 +- src/lib.rs | 8 +- src/utils.rs | 4 +- 6 files changed, 100 insertions(+), 175 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a87cbe7..b604e42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,9 +25,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.62" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "approx" @@ -182,24 +182,13 @@ dependencies = [ "winapi", ] -[[package]] -name = "clipboard-win" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ab1b92798304eedc095b53942963240037c0516452cb11aeba709d420b2219" -dependencies = [ - "error-code 2.3.1", - "str-buf", - "winapi", -] - [[package]] name = "clipboard-win" version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" dependencies = [ - "error-code 3.2.0", + "error-code", ] [[package]] @@ -248,12 +237,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" -[[package]] -name = "const-cstr" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6" - [[package]] name = "conv" version = "0.3.3" @@ -337,16 +320,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.2" @@ -382,6 +355,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "cstr" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68523903c8ae5aacfa32a0d9ae60cadeb764e1da14ee0d26b1f3089f13a54636" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "custom_derive" version = "0.1.7" @@ -390,9 +373,9 @@ checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" [[package]] name = "dirs" -version = "4.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] @@ -409,13 +392,14 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -466,16 +450,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "error-code" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" -dependencies = [ - "libc", - "str-buf", -] - [[package]] name = "error-code" version = "3.2.0" @@ -484,12 +458,9 @@ checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" [[package]] name = "fastrand" -version = "1.8.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "flate2" @@ -503,9 +474,9 @@ dependencies = [ [[package]] name = "float-ord" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" +checksum = "8ce81f49ae8a0482e4c55ea62ebbd7e5a686af544c00b9d090bba3ff9be97b3d" [[package]] name = "fnv" @@ -515,11 +486,11 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "font-kit" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21fe28504d371085fae9ac7a3450f0b289ab71e07c8e57baa3fb68b9e57d6ce5" +checksum = "b0504fc23a34d36352540ae5eedcec2623c86607a4efe25494ca9641845c5a50" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "byteorder", "core-foundation", "core-graphics 0.22.3", @@ -659,15 +630,14 @@ dependencies = [ [[package]] name = "image" -version = "0.24.5" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b7ea949b537b0fd0af141fff8c77690f2ce96f4f41f042ccb6c69c6c965945" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", "color_quant", "jpeg-decoder", - "num-rational", "num-traits", "png", ] @@ -693,7 +663,7 @@ checksum = "b6aee993351d466301a29655d628bfc6f5a35a0d062b6160ca0808f425805fd7" dependencies = [ "approx", "conv", - "image 0.24.5", + "image 0.24.9", "itertools", "nalgebra", "num", @@ -713,15 +683,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "itertools" version = "0.10.5" @@ -801,12 +762,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "malloc_buf" @@ -944,16 +902,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "num_threads" version = "0.1.6" @@ -1178,6 +1126,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "os_info" version = "3.5.0" @@ -1251,23 +1205,13 @@ dependencies = [ [[package]] name = "pathfinder_simd" -version = "0.5.1" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff" +checksum = "5cf07ef4804cfa9aea3b04a7bbdd5a40031dbb6b4f2cbaf2b011666c80c5b4f2" dependencies = [ "rustc_version", ] -[[package]] -name = "pest" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0560d531d1febc25a3c9398a62a71256c0178f2e3443baedd9ad4bb8c9deb4" -dependencies = [ - "thiserror", - "ucd-trie", -] - [[package]] name = "pkg-config" version = "0.3.25" @@ -1406,26 +1350,22 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.5.3" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -1459,24 +1399,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rustc_version" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -1542,21 +1473,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.10.2" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" @@ -1602,21 +1521,22 @@ dependencies = [ [[package]] name = "silicon" -version = "0.5.1" -source = "git+https://github.com/Aloxaf/silicon#cf3668c9ee43ebdae608db3f7b3449c588b8411f" +version = "0.5.2" +source = "git+https://github.com/Aloxaf/silicon?rev=7837ec85#7837ec85e40a368d5fe0a61c47b5ad0be60359dd" dependencies = [ "anyhow", "clipboard", - "clipboard-win 4.4.2", + "clipboard-win 5.4.0", "conv", "dirs", "font-kit", - "image 0.24.5", + "image 0.24.9", "imageproc", "lazy_static", "log", "pasteboard", "pathfinder_geometry", + "pathfinder_simd", "rayon", "syntect", "tempfile", @@ -1628,7 +1548,7 @@ version = "0.5.1" dependencies = [ "anyhow", "arboard", - "image 0.24.5", + "image 0.24.9", "nvim-oxi", "serde", "silicon", @@ -1656,12 +1576,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "str-buf" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" - [[package]] name = "strsim" version = "0.8.0" @@ -1716,15 +1630,14 @@ dependencies = [ [[package]] name = "syntect" -version = "5.0.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c454c27d9d7d9a84c7803aaa3c50cd088d2906fe3c6e42da3209aa623576a8" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" dependencies = [ "bincode", "bitflags 1.3.2", "flate2", "fnv", - "lazy_static", "once_cell", "onig", "plist", @@ -1739,16 +1652,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.3.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", - "libc", - "redox_syscall 0.2.16", - "remove_dir_all", - "winapi", + "once_cell", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -1832,12 +1744,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" -[[package]] -name = "ucd-trie" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" - [[package]] name = "unicode-ident" version = "1.0.3" @@ -1956,6 +1862,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -2139,11 +2054,11 @@ dependencies = [ [[package]] name = "yeslogic-fontconfig-sys" -version = "3.2.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2bbd69036d397ebbff671b1b8e4d918610c181c5a16073b96f984a38d08c386" +checksum = "ffb6b23999a8b1a997bf47c7bb4d19ad4029c3327bb3386ebe0a5ff584b33c7a" dependencies = [ - "const-cstr", + "cstr", "dlib", "once_cell", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index df0e161..2d6dc17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib"] anyhow = "1" nvim-oxi = { version = "0.5.1", features = ["neovim-0-10"] } serde = { version = '1.0.209', features = ["derive"] } -silicon = { version = '0.5', default-features = false, features = ["anyhow"] } +silicon = { version = '0.5.2', default-features = false, features = ["anyhow"] } time = { version = "0.3", features = ["formatting", "local-offset"] } thiserror = "1.0.40" arboard = "3.4.0" @@ -30,4 +30,4 @@ features = ["jpeg", "png", "jpeg_rayon"] [patch.crates-io] # nvim-oxi = { git = "https://github.com/noib3/nvim-oxi", rev = "51dd4734" } -silicon = { git = "https://github.com/Aloxaf/silicon" } \ No newline at end of file +silicon = { git = "https://github.com/Aloxaf/silicon", rev = "7837ec85" } \ No newline at end of file diff --git a/src/clipboard.rs b/src/clipboard.rs index 996af24..8719305 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -1,9 +1,12 @@ -use std::{borrow::Cow, time::{Duration, Instant}}; +use std::{ + borrow::Cow, + time::{Duration, Instant}, +}; -use image::DynamicImage; +use image::{DynamicImage, RgbaImage}; use nvim_oxi::api::{self, opts::NotifyOpts, types::LogLevel}; -pub fn dump_image_to_clipboard(image: DynamicImage) { +pub fn dump_image_to_clipboard(image: RgbaImage) { // using a thread so as not to block neovim while holding // clipboard content long enough for the user to paste // when there is no clipboard manager. @@ -31,7 +34,7 @@ pub fn dump_image_to_clipboard(image: DynamicImage) { let img_data = ImageData { width: image.width() as usize, height: image.height() as usize, - bytes: Cow::from(image.as_rgba8().unwrap().as_raw()), + bytes: Cow::from(image.as_raw()), }; let set = ctx.set(); #[cfg(target_os = "linux")] @@ -45,6 +48,13 @@ pub fn dump_image_to_clipboard(image: DynamicImage) { ) .unwrap(); - set.image(img_data).unwrap(); + if let Err(e) = set.image(img_data) { + api::notify( + &format!("Failed to copy to clipboard: {e}"), + LogLevel::Error, + &NotifyOpts::default(), + ) + .unwrap(); + }; }); -} \ No newline at end of file +} diff --git a/src/error.rs b/src/error.rs index 208fafc..9f40d4c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -16,5 +16,5 @@ pub enum Error { Parse(#[from] time::error::InvalidFormatDescription), Lua(#[from] nvim_oxi::lua::Error), Image(#[from] image::ImageError), - Io(#[from] io::Error) -} \ No newline at end of file + Io(#[from] io::Error), +} diff --git a/src/lib.rs b/src/lib.rs index 9138800..b90ddbc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -120,8 +120,8 @@ fn save_image(opts: Opts) -> Result<(), Error> { let font = FontCollection::new(fonts.as_slice())?; let (x, y) = ( - image.to_rgba8().width() - (font.get_text_len(&text) + font.get_text_len(" ")), - image.to_rgba8().height() - (font.get_font_height() * 2), + image.width() - (font.get_text_len(&text) + font.get_text_len(" ")), + image.height() - (font.get_font_height() * 2), ); font.draw_text_mut( @@ -171,12 +171,12 @@ fn get_formatter( fonts: &[(String, f32)], opts: &Opts, adder: ShadowAdder, -) -> Result { +) -> Result, Error> { let title = match opts.window_title.clone() { Some(f) => Some(f.call(())?), None => None, }; - Ok(ImageFormatterBuilder::new() + Ok(ImageFormatterBuilder::<_>::new() .font(fonts.to_owned()) .tab_width(opts.tab_width.unwrap_or(4)) .line_pad(opts.line_pad.unwrap_or(2)) diff --git a/src/utils.rs b/src/utils.rs index c554e8f..e09a259 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,8 +2,8 @@ use image::Rgba; use nvim_oxi::api; use silicon::{font::FontStyle, utils::ToRgba}; -use super::error::Error; use super::config::Opts; +use super::error::Error; pub trait IntoFont { fn to_font(self) -> Vec<(String, f32)>; @@ -90,4 +90,4 @@ fn get_globble_len(line: &str) -> usize { } } len -} \ No newline at end of file +}