From 75b398ed87c4be384b1fcd614fbcfcf49d297bc0 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 24 Dec 2017 22:06:20 -0800 Subject: adjust line clearing behavior to alleviate flickering --- src/display/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/mod.rs b/src/display/mod.rs index 37de481..e747eec 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -561,7 +561,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re } }; for line in to_draw { - print!("{}{}{}", cursor::Goto(1, height - h), clear::CurrentLine, line); + print!("{}{}{}", cursor::Goto(1, height - h), line, clear::UntilNewline); h = h + 1; if h >= height { break; -- cgit v1.1 From 2e2cee3357bc667ff2b2a0eeeb0a0ddb94fd8d93 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 24 Dec 2017 22:24:50 -0800 Subject: fix line wrapping bug when composing, and wrapping bug for long status lines --- src/display/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/mod.rs b/src/display/mod.rs index e747eec..6115472 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -412,7 +412,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re { let to_show = display_info.log[first_tail_log..last_tail_log].iter().rev(); for line in to_show { - print!("{}{}{}/{}: {}", cursor::Goto(1, height - i), clear::CurrentLine, display_info.log.len() - 1 - i as usize, display_info.log.len() - 1, line); + print!("{}{}{}/{}: {}", cursor::Goto(1, height - i), clear::CurrentLine, display_info.log.len() - 1 - i as usize, display_info.log.len() - 1, line.chars().take(width.saturating_sub(7) as usize).collect::()); i = i + 1; } } @@ -472,7 +472,7 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re Some(DisplayMode::Reply(twid, msg)) => { let mut lines: Vec = vec![]; lines.push(std::iter::repeat("-").take((width as usize).saturating_sub(2)).collect()); - lines.extend(render_twete(&twid, tweeter, display_info, Some(width))); + lines.extend(render_twete(&twid, tweeter, display_info, Some(width - 2))); let reply_delineator = "--------reply"; lines.push(format!("{}{}", reply_delineator, std::iter::repeat("-").take((width as usize).saturating_sub(reply_delineator.len() + 2)).collect::())); let msg_lines = into_display_lines(msg.split("\n").map(|x| x.to_owned()).collect(), width - 2); -- cgit v1.1 From 1039160d4e4400e248afcbce2903c2696c2e0679 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 24 Dec 2017 23:01:16 -0800 Subject: remove dependence on nightly and remove_item (turns out remove_item was wrong anyway, i wanted to remove all instances of a string, it only removed the first) this sneaks in a big change on self-replies, now removes the @ mention of you if you reply to yourself --- src/commands/twete.rs | 31 +++++++++++++++++++------------ src/main.rs | 1 - 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/commands/twete.rs b/src/commands/twete.rs index d727b9e..450c225 100644 --- a/src/commands/twete.rs +++ b/src/commands/twete.rs @@ -155,24 +155,31 @@ fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self // get handles to reply to... let author_handle = tweeter.retrieve_user(&twete.author_id).unwrap().handle.to_owned(); - let mut ats: Vec = twete.get_mentions(); //std::collections::HashSet::new(); - ats.remove_item(&author_handle); - ats.insert(0, author_handle); + let raw_ats: Vec = twete.get_mentions(); //std::collections::HashSet::new(); + let mut reordered_ats: Vec = Vec::new(); + if &author_handle != &user_profile.user.handle { + reordered_ats.push(author_handle); + } + for handle in raw_ats.into_iter() { + if &handle != &user_profile.user.handle { + reordered_ats.push(handle); + } + } if let Some(rt_tweet) = twete.rt_tweet.and_then(|id| tweeter.retrieve_tweet(&TweetId::Twitter(id))).map(|x| x.clone()) { let rt_author_handle = tweeter.retrieve_user(&rt_tweet.author_id).unwrap().handle.to_owned(); - ats.remove_item(&rt_author_handle); - ats.insert(1, rt_author_handle); + let mut reordered_with_rt = Vec::new(); + for mention in reordered_ats { + if mention != rt_author_handle { + reordered_with_rt.push(mention); + } + } + reordered_with_rt.insert(1, rt_author_handle); + reordered_ats = reordered_with_rt; } - // if you're directly replying to yourself, i trust you know what you're doing and - // want to @ yourself again (this keeps self-replies from showing up on your - // profile as threaded tweets, f.ex) - if !(ats.len() > 0 && &ats[0] == &user_profile.user.handle) { - ats.remove_item(&user_profile.user.handle); - } //let ats_vec: Vec<&str> = ats.into_iter().collect(); //let full_reply = format!("{} {}", ats_vec.join(" "), reply); - let decorated_ats: Vec = ats.into_iter().map(|x| format!("@{}", x)).collect(); + let decorated_ats: Vec = reordered_ats.into_iter().map(|x| format!("@{}", x)).collect(); let full_reply = format!("{} {}", decorated_ats.join(" "), reply); if reply.len() > 0 { diff --git a/src/main.rs b/src/main.rs index e5c3910..603108c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#![feature(vec_remove_item)] extern crate serde_json; extern crate chrono; -- cgit v1.1