def text_for_thread_at line
t, size_widget = @mutex.synchronize { [@threads[line], @size_widgets[line]] }
date = t.date.to_nice_s
starred = t.has_label? :starred
cur_width = 0
ann = author_names_and_newness_for_thread t, AUTHOR_LIMIT
from = []
ann.each_with_index do |(name, newness), i|
break if cur_width >= from_width
last = i == ann.length - 1
abbrev =
if cur_width + name.display_length > from_width
name[0 ... (from_width - cur_width - 1)] + "."
elsif cur_width + name.display_length == from_width
name[0 ... (from_width - cur_width)]
else
if last
name[0 ... (from_width - cur_width)]
else
name[0 ... (from_width - cur_width - 1)] + ","
end
end
cur_width += abbrev.display_length
if last && from_width > cur_width
abbrev += " " * (from_width - cur_width)
end
from << [(newness ? :index_new_color : (starred ? :index_starred_color : :index_old_color)), abbrev]
end
dp = t.direct_participants.any? { |p| AccountManager.is_account? p }
p = dp || t.participants.any? { |p| AccountManager.is_account? p }
subj_color =
if t.has_label?(:draft)
:index_draft_color
elsif t.has_label?(:unread)
:index_new_color
elsif starred
:index_starred_color
else
:index_old_color
end
snippet = t.snippet + (t.snippet.empty? ? "" : "...")
size_widget_text = sprintf "%#{ @size_widget_width}s", size_widget
[
[:tagged_color, @tags.tagged?(t) ? ">" : " "],
[:date_color, sprintf("%#{@date_width}s", date)],
(starred ? [:starred_color, "*"] : [:none, " "]),
] +
from +
[
[subj_color, size_widget_text],
[:to_me_color, t.labels.member?(:attachment) ? "@" : " "],
[:to_me_color, dp ? ">" : (p ? '+' : " ")],
] +
(t.labels - @hidden_labels).map { |label| [:label_color, "#{label} "] } +
[
[subj_color, t.subj + (t.subj.empty? ? "" : " ")],
[:snippet_color, snippet],
]
end