From b4fb36eff862aac3be64b3a15666184697350aea Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Fri, 1 Dec 2017 01:47:18 -0800 Subject: rework compose display, coloring background causes Problems if a handle is the same color as the background it becomes invisible counting ansi string lengths is not supported, so that would be work --- src/display/mod.rs | 22 ++++++++++++++-------- todo | 2 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/display/mod.rs b/src/display/mod.rs index 8d1f725..1fb101e 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -381,18 +381,20 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re let mut lines: Vec = vec![]; let msg_lines = into_display_lines(x.split("\n").map(|x| x.to_owned()).collect(), width - 2); let cursor_idx = msg_lines.last().map(|x| x.len()).unwrap_or(0); + lines.push(std::iter::repeat("-").take((width as usize).saturating_sub(2)).collect()); lines.extend(msg_lines); if lines.len() == 0 { lines.push("".to_owned()); } // TODO: properly probe tweet length lim - lines.push(format!("{}/{}", x.len(), 140)); + let counter = format!("{}/{}", x.len(), 280); + lines.push(format!("{}{}", counter, std::iter::repeat("-").take((width as usize).saturating_sub(counter.len() + 2)).collect::())); lines.insert(0, "".to_owned()); let mut lines_drawn: u16 = 0; for line in lines.into_iter().rev() { - print!("{}{} {}{}{}{}", + print!("{}{} {}", cursor::Goto(1, height - 4 - lines_drawn), clear::CurrentLine, - color::Bg(color::Blue), line, std::iter::repeat(" ").take((width as usize).saturating_sub(line.len() + 2)).collect::(), termion::style::Reset + line //, std::iter::repeat(" ").take((width as usize).saturating_sub(line.len() + 2)).collect::() ); lines_drawn += 1; } @@ -400,8 +402,11 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re (cursor_idx as u16 + 3, height as u16 - 5) // TODO: panic on underflow } Some(DisplayMode::Reply(twid, msg)) => { - let mut lines = render_twete(&twid, tweeter, display_info, Some(width)); - lines.push(" -------- ".to_owned()); + 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))); + 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); let cursor_idx = msg_lines.last().map(|x| x.len()).unwrap_or(0); if msg_lines.len() == 0 { @@ -409,13 +414,14 @@ pub fn paint(tweeter: &::tw::TwitterCache, display_info: &mut DisplayInfo) -> Re } lines.extend(msg_lines); // TODO: properly probe tweet length lim - lines.push(format!("{}/{}", msg.len(), 140)); + let counter = format!("{}/{}", msg.len(), 280); + lines.push(format!("{}{}", counter, std::iter::repeat("-").take((width as usize).saturating_sub(counter.len() + 2)).collect::())); lines.insert(0, "".to_owned()); let mut lines_drawn: u16 = 0; for line in lines.into_iter().rev() { - print!("{}{} {}{}{}{}", + print!("{}{} {}", cursor::Goto(1, height - 4 - lines_drawn), clear::CurrentLine, - color::Bg(color::Blue), line, std::iter::repeat(" ").take((width as usize).saturating_sub(line.len() + 2)).collect::(), termion::style::Reset + line //, std::iter::repeat(" ").take((width as usize).saturating_sub(line.len() + 2)).collect::() ); lines_drawn += 1; } diff --git a/todo b/todo index 2855d44..98f8c56 100644 --- a/todo +++ b/todo @@ -15,8 +15,6 @@ recursively display quoted tweets? ratio -dated tweet ids - history per-account activity info -- cgit v1.1