mirror of
https://github.com/MedzikUser/imgurs
synced 2024-08-15 00:03:19 +00:00
fix clipboard
This commit is contained in:
parent
329263edb0
commit
a4a17a4fc5
3 changed files with 12 additions and 90 deletions
75
Cargo.lock
generated
75
Cargo.lock
generated
|
@ -44,7 +44,7 @@ version = "2.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d76e1fe0171b6d0857afca5671db12a44e71e80823db13ab39f776fb09ad079"
|
checksum = "1d76e1fe0171b6d0857afca5671db12a44e71e80823db13ab39f776fb09ad079"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clipboard-win 4.4.1",
|
"clipboard-win",
|
||||||
"core-graphics",
|
"core-graphics",
|
||||||
"image",
|
"image",
|
||||||
"log",
|
"log",
|
||||||
|
@ -328,40 +328,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clipboard"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7"
|
|
||||||
dependencies = [
|
|
||||||
"clipboard-win 2.2.0",
|
|
||||||
"objc",
|
|
||||||
"objc-foundation",
|
|
||||||
"objc_id",
|
|
||||||
"x11-clipboard",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clipboard-ext"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ac0b9a9fdf4e6100bfcdc6587c9c26a6a1d1d8247e74684c18a113d635d3dc78"
|
|
||||||
dependencies = [
|
|
||||||
"clipboard",
|
|
||||||
"libc",
|
|
||||||
"which",
|
|
||||||
"x11-clipboard",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clipboard-win"
|
|
||||||
version = "2.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clipboard-win"
|
name = "clipboard-win"
|
||||||
version = "4.4.1"
|
version = "4.4.1"
|
||||||
|
@ -588,15 +554,6 @@ version = "2.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
|
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "failure"
|
|
||||||
version = "0.1.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
|
|
||||||
dependencies = [
|
|
||||||
"backtrace",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
|
@ -901,7 +858,6 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"clipboard-ext",
|
|
||||||
"colored",
|
"colored",
|
||||||
"dirs 4.0.0",
|
"dirs 4.0.0",
|
||||||
"log",
|
"log",
|
||||||
|
@ -2129,16 +2085,6 @@ dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "which"
|
|
||||||
version = "3.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
|
|
||||||
dependencies = [
|
|
||||||
"failure",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
@ -2235,15 +2181,6 @@ dependencies = [
|
||||||
"xml-rs",
|
"xml-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "x11-clipboard"
|
|
||||||
version = "0.3.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea"
|
|
||||||
dependencies = [
|
|
||||||
"xcb",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x11rb"
|
name = "x11rb"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
@ -2256,16 +2193,6 @@ dependencies = [
|
||||||
"winapi-wsapoll",
|
"winapi-wsapoll",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xcb"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"log",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml-rs"
|
name = "xml-rs"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
|
|
@ -33,9 +33,6 @@ better-panic = "0.3.0"
|
||||||
validator = "0.14.0"
|
validator = "0.14.0"
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
|
|
||||||
[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten"))))'.dependencies]
|
|
||||||
clipboard-ext = "0.2.0"
|
|
||||||
|
|
||||||
[target.'cfg(not(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten")))))'.dependencies]
|
[target.'cfg(not(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten")))))'.dependencies]
|
||||||
arboard = "2.0.1"
|
arboard = "2.0.1"
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
#[cfg(all(
|
|
||||||
unix,
|
|
||||||
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
|
|
||||||
))]
|
|
||||||
use clipboard_ext::prelude::*;
|
|
||||||
#[cfg(all(
|
|
||||||
unix,
|
|
||||||
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
|
|
||||||
))]
|
|
||||||
use clipboard_ext::x11_fork::ClipboardContext;
|
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
unix,
|
unix,
|
||||||
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
|
not(any(target_os = "macos", target_os = "android", target_os = "emscripten"))
|
||||||
))]
|
))]
|
||||||
pub fn set_clipboard(content: String) {
|
pub fn set_clipboard(content: String) {
|
||||||
let mut ctx = ClipboardContext::new().expect("init clipboard");
|
use std::{process::{Command, Stdio}, io::Write};
|
||||||
ctx.set_contents(content).expect("set clipboard");
|
|
||||||
|
let mut child = Command::new("xsel")
|
||||||
|
.arg("--input")
|
||||||
|
.arg("--clipboard")
|
||||||
|
.stdin(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.expect("execute command xsel");
|
||||||
|
|
||||||
|
child.stdin.as_mut().unwrap().write_all(content.as_bytes()).expect("execute command");
|
||||||
|
child.wait_with_output().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(all(
|
#[cfg(not(all(
|
||||||
|
|
Loading…
Reference in a new issue