diff options
author | Teddy Wing | 2016-08-06 02:09:53 -0400 |
---|---|---|
committer | Teddy Wing | 2016-08-06 02:10:31 -0400 |
commit | 8ce4846a07e1362c61d8f3c7ae969c0fe4f76c95 (patch) | |
tree | 9757af2a4a3f430c282ad303791b43d5953c3580 | |
parent | 38b760f62751d8ed595498a7926f39180fdc1a26 (diff) | |
download | Passextract-8ce4846a07e1362c61d8f3c7ae969c0fe4f76c95.tar.bz2 |
Copy line value to clipboard when Enter key is pressed
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 19c2ab7..443acdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ +extern crate clipboard; extern crate rustty; +use clipboard::ClipboardContext; + use rustty::{Terminal, Event, Cell, Color, Attr}; use rustty::ui::Painter; @@ -23,6 +26,8 @@ fn main() { let mut selection = Point { x: 0, y: 2 }; + let mut clipboard_ctx = ClipboardContext::new().unwrap(); + loop { term.printline(0, 0, "Passextract (Press q or Ctrl-C to quit)"); @@ -67,6 +72,9 @@ fn main() { term.set_cursor(selection.x + 2, selection.y).unwrap(); } } + '\x0D' => { + clipboard_ctx.set_contents(strip_key(options[selection.y - 3]).to_owned()).unwrap() + } c @ _ => { } } |