repl: Set up a way to copy output from the REPL (#16649)

Closes #15494

Simple copy button to copy an individual output since selection is a bit
more work.

<img width="790" alt="image"
src="https://github.com/user-attachments/assets/4a7d8b69-70cc-428e-8fe3-b95386d341ee">


Release Notes:

- repl: Copy output from the REPL using a button

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Kyle Kelley 2024-08-22 15:03:42 -07:00 committed by GitHub
parent 26f2369fa6
commit 80c25960dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 231 additions and 23 deletions

View file

@ -30,7 +30,7 @@ impl AssetSource for () {
/// A unique identifier for the image cache
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ImageId(usize);
pub struct ImageId(pub usize);
#[derive(PartialEq, Eq, Hash, Clone)]
pub(crate) struct RenderImageParams {

View file

@ -1016,6 +1016,13 @@ impl ClipboardItem {
}
}
/// Create a new ClipboardItem::Image with the given image with no associated metadata
pub fn new_image(image: &Image) -> Self {
Self {
entries: vec![ClipboardEntry::Image(image.clone())],
}
}
/// Concatenates together all the ClipboardString entries in the item.
/// Returns None if there were no ClipboardString entries.
pub fn text(&self) -> Option<String> {
@ -1084,10 +1091,11 @@ pub enum ImageFormat {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Image {
/// The image format the bytes represent (e.g. PNG)
format: ImageFormat,
pub format: ImageFormat,
/// The raw image bytes
bytes: Vec<u8>,
id: u64,
pub bytes: Vec<u8>,
/// The unique ID for the image
pub id: u64,
}
impl Hash for Image {