From 36296f647dc30dd961a7e511394921448e3eeadd Mon Sep 17 00:00:00 2001 From: ardocrat Date: Thu, 17 Aug 2023 16:45:46 +0300 Subject: [PATCH] desktop: add arboard dependency to manage clipboard --- Cargo.lock | 27 +++++++++++++++++++++++++++ Cargo.toml | 1 + src/gui/platform/desktop/mod.rs | 8 ++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 514846c..3ad1384 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,6 +265,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854" dependencies = [ "clipboard-win", + "core-graphics", + "image", "log", "objc", "objc-foundation", @@ -2266,6 +2268,7 @@ version = "0.1.0" dependencies = [ "android-activity", "android_logger", + "arboard", "built", "chrono", "dirs 5.0.1", @@ -3103,6 +3106,7 @@ dependencies = [ "num-rational 0.4.1", "num-traits 0.2.16", "png", + "tiff", ] [[package]] @@ -3254,6 +3258,12 @@ dependencies = [ "libc", ] +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" + [[package]] name = "js-sys" version = "0.3.64" @@ -5791,6 +5801,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiff" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + [[package]] name = "time" version = "0.1.45" @@ -6556,6 +6577,12 @@ dependencies = [ "webpki", ] +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + [[package]] name = "wgpu" version = "0.16.3" diff --git a/Cargo.toml b/Cargo.toml index 9c04d96..d771e83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ built = { version = "0.6.0", features = ["git2"]} env_logger = "0.10.0" winit = { version = "0.28" } eframe = { version = "0.22.0", features = [ "wgpu" ] } +arboard = "3.2.0" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.13.1" diff --git a/src/gui/platform/desktop/mod.rs b/src/gui/platform/desktop/mod.rs index 553255f..da522ae 100644 --- a/src/gui/platform/desktop/mod.rs +++ b/src/gui/platform/desktop/mod.rs @@ -22,9 +22,13 @@ impl PlatformCallbacks for Desktop { fn hide_keyboard(&self) {} - fn copy_string_to_buffer(&self, data: String) {} + fn copy_string_to_buffer(&self, data: String) { + let mut clipboard = arboard::Clipboard::new().unwrap(); + clipboard.set_text(data).unwrap(); + } fn get_string_from_buffer(&self) -> String { - "".to_string() + let mut clipboard = arboard::Clipboard::new().unwrap(); + clipboard.get_text().unwrap() } }