From a3966446bab8bf849457c24a9a6d05216f950e11 Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Sat, 18 Nov 2017 16:49:23 -0800 Subject: groundwork for multi-account use add connection state tracked per-stream, add explicit TwitterProfile mapped to names that can be used for accounts. default names are the handle of the corresponding twitter account. partition out user Credential to be per TwitterProfile, so fav, reply, etc, all come from the selected account. Multiplex twitter connections and message streams across chan (instead of earlier plan, which was to have one chan per thread) --- src/display/mod.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/display') diff --git a/src/display/mod.rs b/src/display/mod.rs index 954ed38..88722cc 100644 --- a/src/display/mod.rs +++ b/src/display/mod.rs @@ -119,10 +119,11 @@ pub fn paint(tweeter: &mut ::tw::TwitterCache) -> Result<(), std::io::Error> { */ let (cursor_x, cursor_y) = match tweeter.display_info.mode.clone() { None => { + let handle = tweeter.current_profile().map(|profile| profile.user.handle.to_owned()).unwrap_or("_default_".to_owned()); print!("{}{}", cursor::Goto(1, height - 6), clear::CurrentLine); - print!("{}{}@{}>{}", cursor::Goto(1, height - 5), clear::CurrentLine, tweeter.current_user.handle, tweeter.display_info.input_buf.clone().into_iter().collect::()); + print!("{}{}@{}>{}", cursor::Goto(1, height - 5), clear::CurrentLine, handle, tweeter.display_info.input_buf.clone().into_iter().collect::()); print!("{}{}", cursor::Goto(1, height - 4), clear::CurrentLine); - ((1 + tweeter.current_user.handle.len() + 2 + tweeter.display_info.input_buf.len()) as u16, height as u16 - 5) + ((1 + handle.len() + 2 + tweeter.display_info.input_buf.len()) as u16, height as u16 - 5) } Some(DisplayMode::Compose(x)) => { let mut lines: Vec = vec![]; @@ -143,7 +144,7 @@ pub fn paint(tweeter: &mut ::tw::TwitterCache) -> Result<(), std::io::Error> { ); lines_drawn += 1; } - h += (lines_drawn - 3); + h += lines_drawn - 3; (cursor_idx as u16 + 3, height as u16 - 5) // TODO: panic on underflow } Some(DisplayMode::Reply(twid, msg)) => { @@ -166,7 +167,7 @@ pub fn paint(tweeter: &mut ::tw::TwitterCache) -> Result<(), std::io::Error> { ); lines_drawn += 1; } - h += (lines_drawn - 3); + h += lines_drawn - 3; (cursor_idx as u16 + 3, height as u16 - 5) // TODO: panic on underflow } }; -- cgit v1.1