blob: a7be4f27c4c5eed873883e56139d98e4ad0f3e60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
extern crate clipboard;
use std::error::Error;
use clipboard::ClipboardContext;
pub struct ClipboardStore {
context: ClipboardContext,
original: String,
}
impl ClipboardStore {
pub fn new() -> Result<ClipboardStore, Box<Error>> {
let context = try!(ClipboardContext::new());
return Ok(
ClipboardStore {
context: context,
original: String::new(),
}
)
}
/// Set the contents of the system clipboard. Stores the original contents
/// of the clipboard the first time the function is run.
pub fn set_contents(&mut self, data: String) -> Result<(), Box<Error>> {
if self.original.is_empty() {
self.original = try!(self.context.get_contents())
}
self.context.set_contents(data)
}
pub fn reset() {
}
}
|