From 0439c3a6373b7d80b83f2f56173293c351f7773c Mon Sep 17 00:00:00 2001 From: kageru Date: Thu, 23 Apr 2020 14:06:45 +0200 Subject: [PATCH] Allow yanking an entry with y --- src/listview.rs | 5 +++++ src/tracc.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/listview.rs b/src/listview.rs index 5a97a36..057ba13 100644 --- a/src/listview.rs +++ b/src/listview.rs @@ -49,6 +49,11 @@ pub trait ListView { } } + fn yank(&mut self) { + let index = *self.selection_pointer(); + *self.register() = self.list()[index].clone().into(); + } + // printing fn printable(&mut self) -> Vec { self.list().iter().map(T::to_string).collect() diff --git a/src/tracc.rs b/src/tracc.rs index 60f352c..fdccfd4 100644 --- a/src/tracc.rs +++ b/src/tracc.rs @@ -75,6 +75,12 @@ impl Tracc { with_focused!(ListView::remove_current); } } + // yy + Key::Char('y') => { + if let Some(Ok(Key::Char('y'))) = inputs.next() { + with_focused!(ListView::yank); + } + } Key::Char('p') => with_focused!(ListView::paste), Key::Char('\t') => { self.focus = match self.focus {