aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-22 16:30:38 +0100
committerAkshay <[email protected]>2020-07-22 16:30:38 +0100
commit3f64deb152c31f2a04612d9c525537a72605d678 (patch)
treeddab742cce4422f8f3da43d4ebd0535b1d7814f1 /src/app
parent9102dc72be19f87ec9e2893a35f5020957135c1c (diff)
remove `d` keybind, add tab completion
Diffstat (limited to 'src/app')
-rw-r--r--src/app/impl_self.rs4
-rw-r--r--src/app/impl_view.rs8
2 files changed, 4 insertions, 8 deletions
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 {
37 self.habits.push(h); 37 self.habits.push(h);
38 } 38 }
39 39
40 pub fn list_habits(&self) -> Vec<String> {
41 self.habits.iter().map(|x| x.name()).collect::<Vec<_>>()
42 }
43
40 pub fn delete_by_name(&mut self, name: &str) { 44 pub fn delete_by_name(&mut self, name: &str) {
41 let old_len = self.habits.len(); 45 let old_len = self.habits.len();
42 self.habits.retain(|h| h.name() != name); 46 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 {
102 self.set_focus(Absolute::Down); 102 self.set_focus(Absolute::Down);
103 return EventResult::Consumed(None); 103 return EventResult::Consumed(None);
104 } 104 }
105 Event::Char('d') => {
106 if self.habits.is_empty() {
107 return EventResult::Consumed(None);
108 }
109 self.habits.remove(self.focus);
110 self.focus = self.focus.checked_sub(1).unwrap_or(0);
111 return EventResult::Consumed(None);
112 }
113 Event::Char('w') => { 105 Event::Char('w') => {
114 // helper bind to test write to file 106 // helper bind to test write to file
115 let j = serde_json::to_string_pretty(&self.habits).unwrap(); 107 let j = serde_json::to_string_pretty(&self.habits).unwrap();