Skip to content

Commit b779c43

Browse files
committed
Almost done with list display
1 parent 4e12725 commit b779c43

File tree

6 files changed

+260
-213
lines changed

6 files changed

+260
-213
lines changed

src/list.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()>
3838
KeyCode::Home | KeyCode::Char('g') => list_state.select_first(),
3939
KeyCode::End | KeyCode::Char('G') => list_state.select_last(),
4040
KeyCode::Char('d') => {
41-
let message = if list_state.filter() == Filter::Done {
41+
if list_state.filter() == Filter::Done {
4242
list_state.set_filter(Filter::None);
43-
"Disabled filter DONE"
43+
list_state.message.push_str("Disabled filter DONE");
4444
} else {
4545
list_state.set_filter(Filter::Done);
46-
"Enabled filter DONE │ Press d again to disable the filter"
47-
};
48-
49-
list_state.message.push_str(message);
46+
list_state.message.push_str(
47+
"Enabled filter DONE │ Press d again to disable the filter",
48+
);
49+
}
5050
}
5151
KeyCode::Char('p') => {
5252
let message = if list_state.filter() == Filter::Pending {
@@ -71,23 +71,20 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()>
7171
KeyCode::Esc => (),
7272
_ => continue,
7373
}
74-
75-
list_state.redraw(stdout)?;
7674
}
77-
Event::Mouse(event) => {
78-
match event.kind {
79-
MouseEventKind::ScrollDown => list_state.select_next(),
80-
MouseEventKind::ScrollUp => list_state.select_previous(),
81-
_ => continue,
82-
}
83-
84-
list_state.redraw(stdout)?;
75+
Event::Mouse(event) => match event.kind {
76+
MouseEventKind::ScrollDown => list_state.select_next(),
77+
MouseEventKind::ScrollUp => list_state.select_previous(),
78+
_ => continue,
79+
},
80+
Event::Resize(width, height) => {
81+
list_state.set_term_size(width, height);
8582
}
86-
// Redraw
87-
Event::Resize(_, _) => list_state.redraw(stdout)?,
8883
// Ignore
89-
Event::FocusGained | Event::FocusLost => (),
84+
Event::FocusGained | Event::FocusLost => continue,
9085
}
86+
87+
list_state.redraw(stdout)?;
9188
}
9289
}
9390

0 commit comments

Comments
 (0)