From 3bf4d9ed4d9e8d62695b1c7a47058040b2eb31b6 Mon Sep 17 00:00:00 2001 From: Artur Kovacs Date: Wed, 30 Dec 2020 17:09:43 +0100 Subject: [PATCH] Replace `clipboard` with `arboard` --- Cargo.lock | 235 +++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 2 +- src/app.rs | 18 ++-- 3 files changed, 211 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b0352e3..3a49bc5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,6 +15,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aho-corasick" version = "0.7.13" @@ -39,6 +45,26 @@ version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" +[[package]] +name = "arboard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85149eb4159516fbc261f362153822672e4bdb5b3accc863a5777627c6d9fe72" +dependencies = [ + "clipboard-win", + "core-graphics", + "image", + "lazy_static", + "libc", + "objc", + "objc-foundation", + "objc_id", + "scopeguard", + "thiserror", + "winapi 0.3.9", + "xcb", +] + [[package]] name = "arc-swap" version = "0.4.7" @@ -89,7 +115,7 @@ dependencies = [ "addr2line", "cfg-if 1.0.0", "libc", - "miniz_oxide", + "miniz_oxide 0.4.3", "object", "rustc-demangle", ] @@ -144,6 +170,12 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +[[package]] +name = "bytemuck" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac" + [[package]] name = "byteorder" version = "1.3.4" @@ -218,25 +250,14 @@ dependencies = [ "vec_map", ] -[[package]] -name = "clipboard" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7" -dependencies = [ - "clipboard-win", - "objc", - "objc-foundation", - "objc_id", - "x11-clipboard", -] - [[package]] name = "clipboard-win" -version = "2.2.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b" +checksum = "5123c6b97286809fea9e38d2c9bf530edbcb9fc0d8f8272c28b0c95f067fa92d" dependencies = [ + "error-code", + "str-buf", "winapi 0.3.9", ] @@ -258,6 +279,12 @@ dependencies = [ "bitflags", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -270,7 +297,17 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.7.0", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys 0.8.2", "libc", ] @@ -280,6 +317,33 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + +[[package]] +name = "core-graphics" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a67c4378cf203eace8fb6567847eb641fd6ff933c1145a115c6ee820ebb978" +dependencies = [ + "bitflags", + "core-foundation 0.9.1", + "foreign-types", + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -351,6 +415,16 @@ dependencies = [ "syn 0.15.44", ] +[[package]] +name = "deflate" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +dependencies = [ + "adler32", + "byteorder", +] + [[package]] name = "derive_builder" version = "0.7.2" @@ -441,6 +515,16 @@ dependencies = [ "termcolor", ] +[[package]] +name = "error-code" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49c94f66f2d2c5ee8685039e458b4e6c9f13af7c28736baf10ce42966a5ab52" +dependencies = [ + "libc", + "str-buf", +] + [[package]] name = "failure" version = "0.1.8" @@ -756,6 +840,22 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "image" +version = "0.23.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce04077ead78e39ae8610ad26216aed811996b043d47beed5090db674f9e9b5" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "num-iter", + "num-rational", + "num-traits", + "png", + "tiff", +] + [[package]] name = "indexmap" version = "1.5.0" @@ -799,6 +899,15 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +[[package]] +name = "jpeg-decoder" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc797adac5f083b8ff0ca6f6294a999393d76e197c36488e2ef732c4715f6fa3" +dependencies = [ + "byteorder", +] + [[package]] name = "js-sys" version = "0.3.42" @@ -893,11 +1002,21 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.0" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" +dependencies = [ + "adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", + "autocfg 1.0.0", ] [[package]] @@ -1026,6 +1145,28 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg 1.0.0", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg 1.0.0", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.12" @@ -1195,6 +1336,18 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +[[package]] +name = "png" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +dependencies = [ + "bitflags", + "crc32fast", + "deflate", + "miniz_oxide 0.3.7", +] + [[package]] name = "ppv-lite86" version = "0.2.8" @@ -1576,8 +1729,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" dependencies = [ "bitflags", - "core-foundation", - "core-foundation-sys", + "core-foundation 0.7.0", + "core-foundation-sys 0.7.0", "libc", "security-framework-sys", ] @@ -1588,7 +1741,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" dependencies = [ - "core-foundation-sys", + "core-foundation-sys 0.7.0", "libc", ] @@ -1697,9 +1850,9 @@ name = "spotify-tui" version = "0.22.0" dependencies = [ "anyhow", + "arboard", "backtrace", "clap", - "clipboard", "crossterm", "dirs", "rand 0.7.3", @@ -1712,6 +1865,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "str-buf" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" + [[package]] name = "strsim" version = "0.7.0" @@ -1819,6 +1978,17 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "tiff" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" +dependencies = [ + "jpeg-decoder", + "miniz_oxide 0.4.3", + "weezl", +] + [[package]] name = "time" version = "0.1.43" @@ -2148,6 +2318,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "weezl" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2bb9fc8309084dd7cd651336673844c1d47f8ef6d2091ec160b27f5c4aa277" + [[package]] name = "widestring" version = "0.4.2" @@ -2216,20 +2392,11 @@ dependencies = [ "winapi-build", ] -[[package]] -name = "x11-clipboard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea" -dependencies = [ - "xcb", -] - [[package]] name = "xcb" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" +checksum = "62056f63138b39116f82a540c983cc11f1c90cd70b3d492a70c25eaa50bd22a6" dependencies = [ "libc", "log", diff --git a/Cargo.toml b/Cargo.toml index f94ce3c4..46fe31ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ dirs = "3.0.1" clap = "2.33.3" unicode-width = "0.1.8" backtrace = "0.3.55" -clipboard = "0.5.0" +arboard = "1.1.0" crossterm = "0.18" tokio = { version = "0.2", features = ["full"] } rand = "0.7.3" diff --git a/src/app.rs b/src/app.rs index 2c2dfab2..055bd1e6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -27,7 +27,7 @@ use std::{ }; use tui::layout::Rect; -use clipboard::{ClipboardContext, ClipboardProvider}; +use arboard::Clipboard; pub const LIBRARY_OPTIONS: [&str; 6] = [ "Made For You", @@ -296,7 +296,7 @@ pub struct App { pub album_list_index: usize, pub made_for_you_index: usize, pub artists_list_index: usize, - pub clipboard_context: Option, + pub clipboard: Option, pub help_docs_size: u32, pub help_menu_page: u32, pub help_menu_max_lines: u32, @@ -376,7 +376,7 @@ impl Default for App { episode_table: Default::default(), user: None, instant_since_last_current_playback_poll: Instant::now(), - clipboard_context: clipboard::ClipboardProvider::new().ok(), + clipboard: Clipboard::new().ok(), help_docs_size: 0, help_menu_page: 0, help_menu_max_lines: 0, @@ -642,7 +642,7 @@ impl App { } pub fn copy_song_url(&mut self) { - let clipboard = match &mut self.clipboard_context { + let clipboard = match &mut self.clipboard { Some(ctx) => ctx, None => return, }; @@ -653,7 +653,7 @@ impl App { { match item { PlayingItem::Track(track) => { - if let Err(e) = clipboard.set_contents(format!( + if let Err(e) = clipboard.set_text(format!( "https://open.spotify.com/track/{}", track.id.to_owned().unwrap_or_default() )) { @@ -661,7 +661,7 @@ impl App { } } PlayingItem::Episode(episode) => { - if let Err(e) = clipboard.set_contents(format!( + if let Err(e) = clipboard.set_text(format!( "https://open.spotify.com/episode/{}", episode.id.to_owned() )) { @@ -673,7 +673,7 @@ impl App { } pub fn copy_album_url(&mut self) { - let clipboard = match &mut self.clipboard_context { + let clipboard = match &mut self.clipboard { Some(ctx) => ctx, None => return, }; @@ -684,7 +684,7 @@ impl App { { match item { PlayingItem::Track(track) => { - if let Err(e) = clipboard.set_contents(format!( + if let Err(e) = clipboard.set_text(format!( "https://open.spotify.com/album/{}", track.id.to_owned().unwrap_or_default() )) { @@ -692,7 +692,7 @@ impl App { } } PlayingItem::Episode(episode) => { - if let Err(e) = clipboard.set_contents(format!( + if let Err(e) = clipboard.set_text(format!( "https://open.spotify.com/show/{}", episode.show.id.to_owned() )) {