aboutsummaryrefslogtreecommitdiff
path: root/src/display/mod.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2017-11-18 16:49:23 -0800
committeriximeow <me@iximeow.net>2017-11-18 16:49:23 -0800
commit69afc6b85c28b3f6ae857b369d09dea7d1b4f14e (patch)
tree10ce6f47ba5ef8641aab53052dd69e958df3af3a /src/display/mod.rs
parent780ccc569fee0eeb21069575bd88dd8f94aeb424 (diff)
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)
Diffstat (limited to 'src/display/mod.rs')
-rw-r--r--src/display/mod.rs9
1 files changed, 5 insertions, 4 deletions
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::<String>());
+ print!("{}{}@{}>{}", cursor::Goto(1, height - 5), clear::CurrentLine, handle, tweeter.display_info.input_buf.clone().into_iter().collect::<String>());
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<String> = 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
}
};