Laurent Dufresne 27f7d2fa57 Replaced crate "clipboard" by "copypasta"
The crate clipboard is not maintained anymore and has a dependency with
multiple security issues.
2023-03-08 17:52:22 +01:00

19 lines
490 B
Rust

use copypasta::{ClipboardContext, ClipboardProvider};
use imgui::ClipboardBackend;
pub struct ClipboardSupport(pub ClipboardContext);
pub fn init() -> Option<ClipboardSupport> {
ClipboardContext::new().ok().map(ClipboardSupport)
}
impl ClipboardBackend for ClipboardSupport {
fn get(&mut self) -> Option<String> {
self.0.get_contents().ok()
}
fn set(&mut self, text: &str) {
// ignore errors?
let _ = self.0.set_contents(text.to_owned());
}
}