Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add clipboard support for Windows (#8978)

EricApostalaa7be4b5d859
diff --git a/.gitignore b/.gitignore
index 584337b8402..a382f992378 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,4 +22,4 @@ DerivedData/
**/*.db
.pytest_cache
.venv
-.blob_store
+.blob_store
\ No newline at end of file
diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml
index c4a2432ecea..26fe0b6501f 100644
--- a/crates/gpui/Cargo.toml
+++ b/crates/gpui/Cargo.toml
@@ -103,6 +103,7 @@ blade-macros.workspace = true
blade-rwh.workspace = true
bytemuck = "1"
cosmic-text = "0.10.0"
+copypasta = "0.10.1"
[target.'cfg(target_os = "linux")'.dependencies]
open = "5.0.1"
@@ -116,7 +117,6 @@ xkbcommon = { version = "0.7", features = ["wayland", "x11"] }
as-raw-xcb-connection = "1"
calloop = "0.12.4"
calloop-wayland-source = "0.2.0"
-copypasta = "0.10.1"
oo7 = "0.3.0"
[target.'cfg(windows)'.dependencies]
@@ -128,4 +128,4 @@ path = "examples/hello_world.rs"
[[example]]
name = "image"
-path = "examples/image/image.rs"
+path = "examples/image/image.rs"
\ No newline at end of file
diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs
index 6ead99dd2c0..91dc956d406 100644
--- a/crates/gpui/src/platform/windows/platform.rs
+++ b/crates/gpui/src/platform/windows/platform.rs
@@ -13,6 +13,7 @@ use std::{
use anyhow::{anyhow, Result};
use async_task::Runnable;
+use copypasta::{ClipboardContext, ClipboardProvider};
use futures::channel::oneshot::Receiver;
use parking_lot::Mutex;
use time::UtcOffset;
@@ -493,14 +494,18 @@ impl Platform for WindowsPlatform {
false
}
- // todo(windows)
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> {
- unimplemented!()
+ let mut ctx = ClipboardContext::new().unwrap();
+ let content = ctx.get_contents().unwrap();
+ Some(ClipboardItem {
+ text: content,
+ metadata: None,
+ })
}
// todo(windows)