summaryrefslogtreecommitdiffstats
path: root/native/src/clipboard.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2021-03-10 21:13:07 +0100
committerLibravatar GitHub <noreply@github.com>2021-03-10 21:13:07 +0100
commit7eb512774862d44772c43f9843f586bfcfa2aa89 (patch)
tree34d64096302f59f8cb6daf35a131d8ba42f46905 /native/src/clipboard.rs
parent939fcfe9dbe8c08a286c6328da6053b5fd577adf (diff)
parent17dcfa8faf68afe3cbad1151f41eb35230ef83e1 (diff)
downloadiced-7eb512774862d44772c43f9843f586bfcfa2aa89.tar.gz
iced-7eb512774862d44772c43f9843f586bfcfa2aa89.tar.bz2
iced-7eb512774862d44772c43f9843f586bfcfa2aa89.zip
Merge pull request #770 from hecrj/feature/clipboard-write
Write clipboard support and `TextInput` copy and cut behavior
Diffstat (limited to 'native/src/clipboard.rs')
-rw-r--r--native/src/clipboard.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/native/src/clipboard.rs b/native/src/clipboard.rs
index ecdccabf..081b4004 100644
--- a/native/src/clipboard.rs
+++ b/native/src/clipboard.rs
@@ -1,6 +1,23 @@
+//! Access the clipboard.
+
/// A buffer for short-term storage and transfer within and between
/// applications.
pub trait Clipboard {
- /// Returns the current content of the [`Clipboard`] as text.
- fn content(&self) -> Option<String>;
+ /// Reads the current content of the [`Clipboard`] as text.
+ fn read(&self) -> Option<String>;
+
+ /// Writes the given text contents to the [`Clipboard`].
+ fn write(&mut self, contents: String);
+}
+
+/// A null implementation of the [`Clipboard`] trait.
+#[derive(Debug, Clone, Copy)]
+pub struct Null;
+
+impl Clipboard for Null {
+ fn read(&self) -> Option<String> {
+ None
+ }
+
+ fn write(&mut self, _contents: String) {}
}