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:
EricApostal 2024-03-07 23:16:38 -05:00 committed by GitHub
parent 866d791760
commit aa7be4b5d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View file

@ -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)