aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-12-01 01:48:07 -0800
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-12-01 01:48:07 -0800
commit8ad1d470a11dfe99d28a4f5228a3fef335f692d1 (patch)
tree07ea956bd16b31c29e5519ac12ef1ce08f3210a1 /src
parentb4fb36eff862aac3be64b3a15666184697350aea (diff)
basic info log scroll support. uses home/end right now
Diffstat (limited to 'src')
-rw-r--r--src/display/mod.rs10
-rw-r--r--src/main.rs9
2 files changed, 14 insertions, 5 deletions
diff --git a/src/display/mod.rs b/src/display/mod.rs
index 1fb101e..4a0f198 100644
--- a/src/display/mod.rs
+++ b/src/display/mod.rs
@@ -345,7 +345,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re
// draw input prompt
let mut i = 0;
let log_size = 4;
- let last_tail_log = display_info.log.len().saturating_sub(display_info.infos_seek as usize);
+ let last_tail_log = display_info.log.len().saturating_sub(display_info.log_seek as usize);
let first_tail_log = last_tail_log.saturating_sub(log_size);
{
let to_show = display_info.log[first_tail_log..last_tail_log].iter().rev();
@@ -361,6 +361,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re
// draw status lines
// draw tweets
let last_tail_twevent = display_info.infos.len().saturating_sub(display_info.infos_seek as usize);
+ let twevent_offset = display_info.infos.len() - last_tail_twevent;
let first_tail_twevent = last_tail_twevent.saturating_sub(height as usize - 4);
let last_few_twevent: Vec<Infos> = display_info.infos[first_tail_twevent..last_tail_twevent].iter().map(|x| x.clone()).rev().collect::<Vec<Infos>>();
@@ -372,7 +373,12 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re
let (cursor_x, cursor_y) = match display_info.mode.clone() {
None => {
let handle = tweeter.current_profile().map(|profile| profile.user.handle.to_owned()).unwrap_or("_default_".to_owned());
- print!("{}{}", cursor::Goto(1, height - 6), clear::CurrentLine);
+ print!("{}{}{}",
+ cursor::Goto(1, height - 6), clear::CurrentLine,
+ if twevent_offset != 0 {
+ format!("{} more below", twevent_offset)
+ } else { "".to_owned() }
+ );
print!("{}{}@{}>{}", cursor::Goto(1, height - 5), clear::CurrentLine, handle, display_info.input_buf.clone().into_iter().collect::<String>());
print!("{}{}", cursor::Goto(1, height - 4), clear::CurrentLine);
((1 + handle.len() + 2 + display_info.input_buf.len()) as u16, height as u16 - 5)
diff --git a/src/main.rs b/src/main.rs
index d8ef738..7595ea0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -334,15 +334,18 @@ fn handle_input(event: termion::event::Event, tweeter: &mut tw::TwitterCache, qu
}
}
},
- Event::Key(Key::End) => {
- display_info.infos_seek = 0;
- }
Event::Key(Key::PageUp) => {
display_info.infos_seek = display_info.infos_seek.saturating_add(1);
}
Event::Key(Key::PageDown) => {
display_info.infos_seek = display_info.infos_seek.saturating_sub(1);
}
+ Event::Key(Key::Home) => {
+ display_info.log_seek = display_info.log_seek.saturating_add(1);
+ }
+ Event::Key(Key::End) => {
+ display_info.log_seek = display_info.log_seek.saturating_sub(1);
+ }
Event::Key(Key::Esc) => {
display_info.mode = None;
}