Add clipboard support for Windows (#8978)
Release Notes: - Added Read / Write clipboard support to Windows via copypasta --------- Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
866d791760
commit
aa7be4b5d8
3 changed files with 12 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -22,4 +22,4 @@ DerivedData/
|
||||||
**/*.db
|
**/*.db
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
.venv
|
.venv
|
||||||
.blob_store
|
.blob_store
|
|
@ -103,6 +103,7 @@ blade-macros.workspace = true
|
||||||
blade-rwh.workspace = true
|
blade-rwh.workspace = true
|
||||||
bytemuck = "1"
|
bytemuck = "1"
|
||||||
cosmic-text = "0.10.0"
|
cosmic-text = "0.10.0"
|
||||||
|
copypasta = "0.10.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
open = "5.0.1"
|
open = "5.0.1"
|
||||||
|
@ -116,7 +117,6 @@ xkbcommon = { version = "0.7", features = ["wayland", "x11"] }
|
||||||
as-raw-xcb-connection = "1"
|
as-raw-xcb-connection = "1"
|
||||||
calloop = "0.12.4"
|
calloop = "0.12.4"
|
||||||
calloop-wayland-source = "0.2.0"
|
calloop-wayland-source = "0.2.0"
|
||||||
copypasta = "0.10.1"
|
|
||||||
oo7 = "0.3.0"
|
oo7 = "0.3.0"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
@ -128,4 +128,4 @@ path = "examples/hello_world.rs"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "image"
|
name = "image"
|
||||||
path = "examples/image/image.rs"
|
path = "examples/image/image.rs"
|
|
@ -13,6 +13,7 @@ use std::{
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use async_task::Runnable;
|
use async_task::Runnable;
|
||||||
|
use copypasta::{ClipboardContext, ClipboardProvider};
|
||||||
use futures::channel::oneshot::Receiver;
|
use futures::channel::oneshot::Receiver;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use time::UtcOffset;
|
use time::UtcOffset;
|
||||||
|
@ -493,14 +494,18 @@ impl Platform for WindowsPlatform {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(windows)
|
|
||||||
fn write_to_clipboard(&self, item: ClipboardItem) {
|
fn write_to_clipboard(&self, item: ClipboardItem) {
|
||||||
unimplemented!()
|
let mut ctx = ClipboardContext::new().unwrap();
|
||||||
|
ctx.set_contents(item.text().to_owned()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(windows)
|
|
||||||
fn read_from_clipboard(&self) -> Option<ClipboardItem> {
|
fn read_from_clipboard(&self) -> Option<ClipboardItem> {
|
||||||
unimplemented!()
|
let mut ctx = ClipboardContext::new().unwrap();
|
||||||
|
let content = ctx.get_contents().unwrap();
|
||||||
|
Some(ClipboardItem {
|
||||||
|
text: content,
|
||||||
|
metadata: None,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue