});
}
+pub struct UserListEntry {
+ account_desc: String,
+}
+
+pub fn user_list_entry(account: &str, nameline: &str)
+ -> Box<dyn TextFragment> {
+ Box::new(UserListEntry {
+ account_desc: format!("{} ({})", nameline, account),
+ })
+}
+
+impl TextFragment for UserListEntry {
+ fn render(&self, width: usize) -> Vec<ColouredString> {
+ let mut para = Paragraph::new().set_indent(0, 2);
+ // FIXME: highlight account_desc if active
+ para.push_text(
+ &ColouredString::uniform(&self.account_desc, ' '), false);
+ para.render(width)
+ }
+}
+
+#[test]
+fn test_user_list_entry() {
+ assert_eq!(user_list_entry("foo@example.com", "Foo Bar").render(80), vec! {
+ ColouredString::general("Foo Bar (foo@example.com)",
+ " "),
+ });
+}
+
// TODO:
-// UserListEntry
// Media
// FileStatusLine, with priorities
// MenuKeypressLine