From 8ce4846a07e1362c61d8f3c7ae969c0fe4f76c95 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 6 Aug 2016 02:09:53 -0400 Subject: Copy line value to clipboard when Enter key is pressed --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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 @ _ => { } } -- cgit v1.2.3