Pumpkin/pumpkin-text/src/click.rs
Snowiiii a6d9ed216d Use Cow's in TextComponent
We now don't always convert &str to Strings allowing us to use stack allocations
2024-08-19 20:05:18 +02:00

22 lines
734 B
Rust

use std::borrow::Cow;
use serde::{Deserialize, Serialize};
/// Action to take on click of the text.
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[serde(tag = "action", content = "value", rename_all = "snake_case")]
pub enum ClickEvent<'a> {
/// Opens a URL
OpenUrl(Cow<'a, str>),
/// Works in signs, but only on the root text component
RunCommand(Cow<'a, str>),
/// Replaces the contents of the chat box with the text, not necessarily a
/// command.
SuggestCommand(Cow<'a, str>),
/// Only usable within written books. Changes the page of the book. Indexing
/// starts at 1.
ChangePage(i32),
/// Copies the given text to system clipboard
CopyToClipboard(Cow<'a, str>),
}