pub struct UserListEntry {
account_desc: String,
+ account_id: String,
}
impl UserListEntry {
- pub fn new(account: &str, nameline: &str)
- -> Self {
+ pub fn new(account: &str, nameline: &str, account_id: &str) -> Self {
UserListEntry {
account_desc: format!("{} ({})", nameline, account),
+ account_id: account_id.to_owned(),
}
}
pub fn from_account(ac: &Account, client: &mut Client) -> Self {
- Self::new(&client.fq(&ac.acct), &ac.display_name)
+ Self::new(&client.fq(&ac.acct), &ac.display_name, &ac.id)
}
}
impl TextFragment for UserListEntry {
- fn render_highlighted(&self, width: usize, _highlight: Option<Highlight>)
+ fn render_highlighted(&self, width: usize, highlight: Option<Highlight>)
-> Vec<ColouredString>
{
let mut para = Paragraph::new().set_indent(0, 2);
- // FIXME: highlight account_desc if active
+ let colour = match highlight {
+ Some(Highlight(HighlightType::User, 0)) => '*',
+ _ => ' ',
+ };
para.push_text(
- &ColouredString::uniform(&self.account_desc, ' '), false);
+ &ColouredString::uniform(&self.account_desc, colour), false);
para.render(width)
}
+
+ fn can_highlight(htype: HighlightType) -> bool where Self : Sized {
+ htype == HighlightType::User
+ }
+
+ fn count_highlightables(&self, htype: HighlightType) -> usize {
+ match htype {
+ HighlightType::User => 1,
+ _ => 0,
+ }
+ }
+
+ fn highlighted_id(&self, highlight: Option<Highlight>) -> Option<String> {
+ match highlight {
+ Some(Highlight(HighlightType::User, 0)) =>
+ Some(self.account_id.clone()),
+ _ => None,
+ }
+ }
}
#[test]