summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-13 03:14:08 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-13 03:15:21 +0100
commit508b3fe1f1405bdb8b860d0d63e2c7adfbbd51ca (patch)
tree0419f7eb42b0647a47d71ba3615eb15ad456aa3e /core
parent4155edab8d123b767ddad67e24ca2d4c50f31ece (diff)
downloadiced-508b3fe1f1405bdb8b860d0d63e2c7adfbbd51ca.tar.gz
iced-508b3fe1f1405bdb8b860d0d63e2c7adfbbd51ca.tar.bz2
iced-508b3fe1f1405bdb8b860d0d63e2c7adfbbd51ca.zip
Introduce `Kind` in `core::clipboard`
Diffstat (limited to 'core')
-rw-r--r--core/src/clipboard.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/core/src/clipboard.rs b/core/src/clipboard.rs
index ff2e31d0..5df3e267 100644
--- a/core/src/clipboard.rs
+++ b/core/src/clipboard.rs
@@ -4,16 +4,21 @@
/// applications.
pub trait Clipboard {
/// Reads the current content of the [`Clipboard`] as text.
- fn read(&self) -> Option<String>;
+ fn read(&self, kind: Kind) -> Option<String>;
/// Writes the given text contents to the [`Clipboard`].
- fn write(&mut self, contents: String);
-
- /// Reads the current content of Primary as text.
- fn read_primary(&self) -> Option<String>;
+ fn write(&mut self, kind: Kind, contents: String);
+}
- /// Writes the given text contents to Primary.
- fn write_primary(&mut self, contents: String);
+/// The kind of [`Clipboard`].
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Kind {
+ /// The standard clipboard.
+ Standard,
+ /// The primary clipboard.
+ ///
+ /// Normally only present in X11 and Wayland.
+ Primary,
}
/// A null implementation of the [`Clipboard`] trait.
@@ -21,15 +26,9 @@ pub trait Clipboard {
pub struct Null;
impl Clipboard for Null {
- fn read(&self) -> Option<String> {
- None
- }
-
- fn write(&mut self, _contents: String) {}
-
- fn read_primary(&self) -> Option<String> {
+ fn read(&self, _kind: Kind) -> Option<String> {
None
}
- fn write_primary(&mut self, _contents: String) {}
+ fn write(&mut self, _kind: Kind, _contents: String) {}
}