Add support for primary clipboard

This commit is contained in:
Mattias Eriksson 2024-02-07 17:25:40 +01:00 committed by Héctor Ramón Jiménez
parent 7615b2240c
commit 4155edab8d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
7 changed files with 96 additions and 1 deletions

View file

@ -51,3 +51,17 @@ pub fn read<Message>(
pub fn write<Message>(contents: String) -> Command<Message> {
Command::single(command::Action::Clipboard(Action::Write(contents)))
}
/// Read the current contents of primary.
pub fn read_primary<Message>(
f: impl Fn(Option<String>) -> Message + 'static,
) -> Command<Message> {
Command::single(command::Action::ClipboardPrimary(Action::Read(Box::new(
f,
))))
}
/// Write the given contents to primary.
pub fn write_primary<Message>(contents: String) -> Command<Message> {
Command::single(command::Action::ClipboardPrimary(Action::Write(contents)))
}