aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/display/mod.rs18
-rw-r--r--src/main.rs3
-rw-r--r--src/tw/mod.rs6
3 files changed, 17 insertions, 10 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());
diff --git a/src/main.rs b/src/main.rs
index ecac646..bfb60f9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -323,6 +323,9 @@ fn handle_input(event: termion::event::Event, tweeter: &mut tw::TwitterCache, qu
}
}
},
+ Event::Key(Key::End) => {
+ tweeter.display_info.infos_seek = 0;
+ }
Event::Key(Key::PageUp) => {
tweeter.display_info.infos_seek = tweeter.display_info.infos_seek.saturating_add(1);
}
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index 7024260..acee0c2 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -286,6 +286,9 @@ impl TwitterCache {
key: "".to_owned(),
secret: "".to_owned()
},
+ // So, supporting multiple profiles will be ... interesting?
+ // how do we support a variable number of channels? which will be necessary as we'll
+ // have one channel up per twitter stream...
profile: None, // this will become a HashMap when multiple profiles are supported
following: HashSet::new(),
following_history: HashMap::new(),
@@ -345,7 +348,6 @@ impl TwitterCache {
fn cache_tweet(&mut self, tweet: Tweet) {
if !self.tweets.contains_key(&tweet.id) {
-
let mut file =
OpenOptions::new()
.create(true)
@@ -706,12 +708,14 @@ fn handle_twitter_delete(
structure: serde_json::Map<String, serde_json::Value>,
tweeter: &mut TwitterCache,
_queryer: &mut ::Queryer) {
+ /*
tweeter.display_info.recv(display::Infos::Event(
events::Event::Deleted {
user_id: structure["delete"]["status"]["user_id_str"].as_str().unwrap().to_string(),
twete_id: structure["delete"]["status"]["id_str"].as_str().unwrap().to_string()
}
));
+ */
}
fn handle_twitter_twete(