aboutsummaryrefslogtreecommitdiffstats
path: root/src/clipboard_store.rs
diff options
context:
space:
mode:
authorTeddy Wing2016-09-05 02:44:11 -0400
committerTeddy Wing2016-09-05 02:44:11 -0400
commit07558bf1a6e681d5492f2e0112d94fd584aa8d0f (patch)
treeae4bf24f351db0dcc98e8b29b9854549d8f7a7f3 /src/clipboard_store.rs
parent426e7a89b6a00cdeab0dbbbb8b55eab37bc5c834 (diff)
downloadPassextract-07558bf1a6e681d5492f2e0112d94fd584aa8d0f.tar.bz2
ClipboardStore proof of concept
The new type `ClipboardStore` wraps `ClipboardContext`, allowing us to save the contents of the clipboard before resetting it. We will then be able to reset the clipboard to this original value. This commit includes some old code from when I was originally thinking about this problem before I decided to make a separate module for it. That code should be deleted. One caveat to think about in the future is how to reset the clipboard to the original value after a period of time. In other words, how to pass the original contents value to a spawned child process. Also, we need to make sure that we're only setting `last` once. Subsequent calls should not change the `last` value. And now that I think about that, "last" is probably the wrong name for this. It should be something like "original".
Diffstat (limited to 'src/clipboard_store.rs')
-rw-r--r--src/clipboard_store.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/clipboard_store.rs b/src/clipboard_store.rs
new file mode 100644
index 0000000..61f53b3
--- /dev/null
+++ b/src/clipboard_store.rs
@@ -0,0 +1,36 @@
+extern crate clipboard;
+
+use std::error::Error;
+
+use clipboard::ClipboardContext;
+
+pub struct ClipboardStore {
+ context: ClipboardContext,
+ last: String,
+}
+
+impl ClipboardStore {
+ pub fn new() -> Result<ClipboardStore, Box<Error>> {
+ let context = try!(ClipboardContext::new());
+
+ return Ok(
+ ClipboardStore {
+ context: context,
+ last: String::new(),
+ }
+ )
+ }
+
+ pub fn set_contents(&mut self, data: String) -> Result<(), Box<Error>> {
+ // Save last value
+ self.last = try!(self.context.get_contents());
+ println!("last: {}", self.last);
+
+ // Set new clipboard contents
+ // self.context.set_contents(data)
+ Ok(())
+ }
+
+ pub fn reset() {
+ }
+}