Only allow toggling for todo items
This commit is contained in:
parent
32590fbfd6
commit
a94d8b77ea
@ -10,7 +10,6 @@ pub trait ListView<T: fmt::Display + Clone> {
|
|||||||
fn backspace(&mut self);
|
fn backspace(&mut self);
|
||||||
fn append_to_current(&mut self, chr: char);
|
fn append_to_current(&mut self, chr: char);
|
||||||
fn normal_mode(&mut self);
|
fn normal_mode(&mut self);
|
||||||
fn toggle_current(&mut self);
|
|
||||||
|
|
||||||
// selection manipulation
|
// selection manipulation
|
||||||
fn selection_up(&mut self) {
|
fn selection_up(&mut self) {
|
||||||
|
@ -9,7 +9,6 @@ pub struct TimeSheet {
|
|||||||
pub times: Vec<TimePoint>,
|
pub times: Vec<TimePoint>,
|
||||||
pub selected: usize,
|
pub selected: usize,
|
||||||
pub register: Option<TimePoint>,
|
pub register: Option<TimePoint>,
|
||||||
pub editing_time: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PAUSE_TEXTS: [&str; 3] = ["lunch", "mittag", "pause"];
|
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")]),
|
times: read_times(path).unwrap_or_else(|| vec![TimePoint::new("start")]),
|
||||||
selected: 0,
|
selected: 0,
|
||||||
register: None,
|
register: None,
|
||||||
editing_time: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,10 +138,6 @@ impl ListView<TimePoint> for TimeSheet {
|
|||||||
self.times.sort_by_key(|t| t.time);
|
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) {
|
fn append_to_current(&mut self, chr: char) {
|
||||||
self.times[self.selected].text.push(chr);
|
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 {
|
fn current(&self) -> &Todo {
|
||||||
&self.todos[self.selected]
|
&self.todos[self.selected]
|
||||||
}
|
}
|
||||||
@ -80,8 +84,4 @@ impl ListView<Todo> for TodoList {
|
|||||||
fn backspace(&mut self) {
|
fn backspace(&mut self) {
|
||||||
self.todos[self.selected].text.pop();
|
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)?;
|
self.set_mode(Mode::Insert)?;
|
||||||
}
|
}
|
||||||
Key::Char('a') | Key::Char('A') => 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
|
// dd
|
||||||
Key::Char('d') => {
|
Key::Char('d') => {
|
||||||
if let Some(Ok(Key::Char('d'))) = inputs.next() {
|
if let Some(Ok(Key::Char('d'))) = inputs.next() {
|
||||||
|
Loading…
Reference in New Issue
Block a user