Only allow toggling for todo items

This commit is contained in:
kageru 2020-04-27 12:34:58 +02:00
parent 32590fbfd6
commit a94d8b77ea
4 changed files with 5 additions and 12 deletions

@ -10,7 +10,6 @@ pub trait ListView<T: fmt::Display + Clone> {
fn backspace(&mut self);
fn append_to_current(&mut self, chr: char);
fn normal_mode(&mut self);
fn toggle_current(&mut self);
// selection manipulation
fn selection_up(&mut self) {

@ -9,7 +9,6 @@ pub struct TimeSheet {
pub times: Vec<TimePoint>,
pub selected: usize,
pub register: Option<TimePoint>,
pub editing_time: bool,
}
const PAUSE_TEXTS: [&str; 3] = ["lunch", "mittag", "pause"];
@ -71,7 +70,6 @@ impl TimeSheet {
times: read_times(path).unwrap_or_else(|| vec![TimePoint::new("start")]),
selected: 0,
register: None,
editing_time: false,
}
}
@ -140,10 +138,6 @@ impl ListView<TimePoint> for TimeSheet {
self.times.sort_by_key(|t| t.time);
}
fn toggle_current(&mut self) {
self.editing_time = !self.editing_time;
}
fn append_to_current(&mut self, chr: char) {
self.times[self.selected].text.push(chr);
}

@ -48,6 +48,10 @@ impl TodoList {
}
}
pub fn toggle_current(&mut self) {
self.todos[self.selected].done = !self.todos[self.selected].done;
}
fn current(&self) -> &Todo {
&self.todos[self.selected]
}
@ -80,8 +84,4 @@ impl ListView<Todo> for TodoList {
fn backspace(&mut self) {
self.todos[self.selected].text.pop();
}
fn toggle_current(&mut self) {
self.todos[self.selected].done = !self.todos[self.selected].done;
}
}

@ -68,7 +68,7 @@ impl Tracc {
self.set_mode(Mode::Insert)?;
}
Key::Char('a') | Key::Char('A') => self.set_mode(Mode::Insert)?,
Key::Char(' ') => with_focused!(ListView::toggle_current),
Key::Char(' ') if self.focus == Focus::Top => self.todos.toggle_current(),
// dd
Key::Char('d') => {
if let Some(Ok(Key::Char('d'))) = inputs.next() {