aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2017-11-13 01:49:46 -0800
committeriximeow <me@iximeow.net>2017-11-13 01:49:46 -0800
commitfcc94f8705ee0b604af25958668c30f79c3dec1d (patch)
treeaf9a6c6a552d9a2e551a7004af1d32dbbd682fce /src
parent63056a669de831ee7cd42517028657c4a23bf3e7 (diff)
fix pageup/pagedown seeking through twitter events
Diffstat (limited to 'src')
-rw-r--r--src/display/mod.rs5
-rw-r--r--src/main.rs2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/display/mod.rs b/src/display/mod.rs
index 1c26678..8760f4a 100644
--- a/src/display/mod.rs
+++ b/src/display/mod.rs
@@ -108,8 +108,9 @@ pub fn paint(tweeter: &mut ::tw::TwitterCache) -> Result<(), std::io::Error> {
}
// draw status lines
// draw tweets
- let last_twevent = tweeter.display_info.infos.len().saturating_sub(height as usize - 4).saturating_sub(tweeter.display_info.infos_seek as usize);
- let last_few_twevent: Vec<Infos> = tweeter.display_info.infos[last_twevent..].iter().map(|x| x.clone()).rev().collect::<Vec<Infos>>();
+ let last_tail_twevent = tweeter.display_info.infos.len().saturating_sub(tweeter.display_info.infos_seek as usize);
+ let first_tail_twevent = last_tail_twevent.saturating_sub(height as usize - 4);
+ let last_few_twevent: Vec<Infos> = tweeter.display_info.infos[first_tail_twevent..last_tail_twevent].iter().map(|x| x.clone()).rev().collect::<Vec<Infos>>();
let mut h = tweeter.display_info.ui_height();
diff --git a/src/main.rs b/src/main.rs
index 6bed875..ecac646 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -324,7 +324,7 @@ fn handle_input(event: termion::event::Event, tweeter: &mut tw::TwitterCache, qu
}
},
Event::Key(Key::PageUp) => {
- tweeter.display_info.infos_seek += 1;
+ tweeter.display_info.infos_seek = tweeter.display_info.infos_seek.saturating_add(1);
}
Event::Key(Key::PageDown) => {
tweeter.display_info.infos_seek = tweeter.display_info.infos_seek.saturating_sub(1);