mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-12 14:08:37 +00:00
The crate clipboard is not maintained anymore and has a dependency with multiple security issues.
19 lines
490 B
Rust
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());
|
|
}
|
|
}
|