From 3f64deb152c31f2a04612d9c525537a72605d678 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 22 Jul 2020 21:00:38 +0530 Subject: remove `d` keybind, add tab completion --- src/app/impl_self.rs | 4 ++++ src/app/impl_view.rs | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/app') diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 95f1871..7eae853 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -37,6 +37,10 @@ impl App { self.habits.push(h); } + pub fn list_habits(&self) -> Vec { + self.habits.iter().map(|x| x.name()).collect::>() + } + pub fn delete_by_name(&mut self, name: &str) { let old_len = self.habits.len(); self.habits.retain(|h| h.name() != name); diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index 892b00c..b8c4589 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs @@ -102,14 +102,6 @@ impl View for App { self.set_focus(Absolute::Down); return EventResult::Consumed(None); } - Event::Char('d') => { - if self.habits.is_empty() { - return EventResult::Consumed(None); - } - self.habits.remove(self.focus); - self.focus = self.focus.checked_sub(1).unwrap_or(0); - return EventResult::Consumed(None); - } Event::Char('w') => { // helper bind to test write to file let j = serde_json::to_string_pretty(&self.habits).unwrap(); -- cgit v1.2.3