diff options
author | Andy Wortman <ixineeringeverywhere@gmail.com> | 2017-12-01 01:47:18 -0800 |
---|---|---|
committer | Andy Wortman <ixineeringeverywhere@gmail.com> | 2017-12-01 01:47:18 -0800 |
commit | b4fb36eff862aac3be64b3a15666184697350aea (patch) | |
tree | 6930c7bd0b80cbaa625e1268bdd3e68e6af4acac /src | |
parent | 3c042afe7872d5488fd91c2b1a42036953f604eb (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/display/mod.rs | 22 |
1 files changed, 14 insertions, 8 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<String> = 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::<String>())); 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::<String>(), termion::style::Reset + line //, std::iter::repeat(" ").take((width as usize).saturating_sub(line.len() + 2)).collect::<String>() ); 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<String> = 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::<String>())); 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::<String>())); 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::<String>(), termion::style::Reset + line //, std::iter::repeat(" ").take((width as usize).saturating_sub(line.len() + 2)).collect::<String>() ); lines_drawn += 1; } |