diff options
author | iximeow <me@iximeow.net> | 2017-11-17 00:50:11 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-11-17 00:50:45 -0800 |
commit | 780ccc569fee0eeb21069575bd88dd8f94aeb424 (patch) | |
tree | ff4a2802ed25d9d691851232a244fb269cfe5fa6 /src/display | |
parent | d831cff595f5c30b11320c0f653b6cceabd16a4c (diff) |
fix rendering issues with events, support End key
also disable rendering of delete events
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/mod.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/display/mod.rs b/src/display/mod.rs index 2b0bed0..954ed38 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -213,7 +213,7 @@ pub fn paint(tweeter: &mut ::tw::TwitterCache) -> Result<(), std::io::Error> { lines.into_iter().rev().collect() }, Infos::Event(e) => { - let pre_split = e.clone().render(tweeter); + let pre_split = e.clone().render(tweeter, width); let total_length: usize = pre_split.iter().map(|x| x.len()).sum(); let wrapped = if total_length <= 1024 { into_display_lines(pre_split, width) @@ -282,11 +282,11 @@ fn color_for(handle: &String) -> termion::color::Fg<&color::Color> { } pub trait Render { - fn render(self, tweeter: &mut ::tw::TwitterCache) -> Vec<String>; + fn render(self, tweeter: &mut ::tw::TwitterCache, width: u16) -> Vec<String>; } impl Render for tw::events::Event { - fn render(self, tweeter: &mut ::tw::TwitterCache) -> Vec<String> { + fn render(self, tweeter: &mut ::tw::TwitterCache, width: u16) -> Vec<String> { let mut result = Vec::new(); match self { tw::events::Event::Quoted { user_id, twete_id } => { @@ -295,13 +295,13 @@ impl Render for tw::events::Event { let user = tweeter.retrieve_user(&user_id).unwrap(); result.push(format!(" quoted_tweet : {} (@{})", user.name, user.handle)); } - render_twete(&TweetId::Twitter(twete_id), tweeter, None); + render_twete(&TweetId::Twitter(twete_id), tweeter, Some(width)); } tw::events::Event::Deleted { user_id, twete_id } => { if let Some(handle) = tweeter.retrieve_user(&user_id).map(|x| &x.handle).map(|x| x.clone()) { if let Some(_tweet) = tweeter.retrieve_tweet(&TweetId::Twitter(twete_id.to_owned())).map(|x| x.clone()) { result.push(format!("-------------DELETED------------------")); - result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, None)); + result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, Some(width))); result.push(format!("-------------DELETED------------------")); } else { result.push(format!("dunno what, but do know who: {} - {}", user_id, handle)); @@ -316,7 +316,7 @@ impl Render for tw::events::Event { let user = tweeter.retrieve_user(&user_id).unwrap(); result.push(format!(" +rt_rt : {} (@{})", user.name, user.handle)); } - result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, None)); + result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, Some(width))); }, tw::events::Event::Fav_RT { user_id, twete_id } => { result.push("---------------------------------".to_string()); @@ -325,7 +325,7 @@ impl Render for tw::events::Event { } else { result.push(format!(" +rt_fav but don't know who {} is", user_id)); } - result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, None)); + result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, Some(width))); }, tw::events::Event::Fav { user_id, twete_id } => { result.push("---------------------------------".to_string()); @@ -333,7 +333,7 @@ impl Render for tw::events::Event { let user = tweeter.retrieve_user(&user_id).unwrap(); result.push(format!("{} +fav : {} (@{}){}", color::Fg(color::Yellow), user.name, user.handle, color::Fg(color::Reset))); } - result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, None)); + result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, Some(width))); }, tw::events::Event::Unfav { user_id, twete_id } => { result.push("---------------------------------".to_string()); @@ -341,7 +341,7 @@ impl Render for tw::events::Event { let user = tweeter.retrieve_user(&user_id).unwrap(); result.push(format!("{} -fav : {} (@{}){}", color::Fg(color::Yellow), user.name, user.handle, color::Fg(color::Reset))); } - result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, None)); + result.extend(render_twete(&TweetId::Twitter(twete_id), tweeter, Some(width))); }, tw::events::Event::Followed { user_id } => { result.push("---------------------------------".to_string()); |