diff options
author | Nao Pross <np@0hm.ch> | 2021-03-09 17:45:51 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-03-09 17:45:51 +0100 |
commit | 1be2d1296f6bf8fc19e9ee089189c1917ef23cb5 (patch) | |
tree | 669efca2a25fb63c2f158936e899dfd55c447312 /src/support/clipboard.rs | |
download | testbench-ui-1be2d1296f6bf8fc19e9ee089189c1917ef23cb5.tar.gz testbench-ui-1be2d1296f6bf8fc19e9ee089189c1917ef23cb5.zip |
Start version control
Diffstat (limited to '')
-rw-r--r-- | src/support/clipboard.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/support/clipboard.rs b/src/support/clipboard.rs new file mode 100644 index 0000000..d970b29 --- /dev/null +++ b/src/support/clipboard.rs @@ -0,0 +1,17 @@ +use clipboard::{ClipboardContext, ClipboardProvider}; +use imgui::{ClipboardBackend, ImStr, ImString}; + +pub struct ClipboardSupport(ClipboardContext); + +pub fn init() -> Option<ClipboardSupport> { + ClipboardContext::new().ok().map(ClipboardSupport) +} + +impl ClipboardBackend for ClipboardSupport { + fn get(&mut self) -> Option<ImString> { + self.0.get_contents().ok().map(|text| text.into()) + } + fn set(&mut self, text: &ImStr) { + let _ = self.0.set_contents(text.to_str().to_owned()); + } +} |