fn push_fragment(lines: &mut Vec<ColouredString>, frag: Vec<ColouredString>) {
lines.extend(frag.iter().map(|line| line.to_owned()));
}
+fn push_fragment_highlighted(lines: &mut Vec<ColouredString>,
+ frag: Vec<ColouredString>) {
+ lines.extend(frag.iter().map(|line| line.recolour('*')));
+}
impl TextFragment for StatusDisplay {
fn render_highlighted(&self, width: usize, highlight: Option<Highlight>)
let mut lines = Vec::new();
let mut highlight = highlight;
+ let highlighting_this_status =
+ highlight.consume(HighlightType::Status, 1) == Some(0) ||
+ highlight.consume(HighlightType::WholeStatus, 1) == Some(0);
+ let push_fragment_opt_highlight = if highlighting_this_status {
+ push_fragment_highlighted
+ } else {
+ push_fragment
+ };
+
push_fragment(&mut lines, self.sep.render(width));
push_fragment(&mut lines, self.from.render_highlighted_update(
width, &mut highlight));
width, &mut highlight));
push_fragment(&mut lines, self.irt.render(width));
push_fragment(&mut lines, self.blank.render(width));
- let mut rendered_content = self.content.render(width);
- if highlight.consume(HighlightType::Status, 1) == Some(0) ||
- highlight.consume(HighlightType::WholeStatus, 1) == Some(0)
- {
- rendered_content = rendered_content.iter()
- .map(|s| s.recolour('*')).collect();
- }
+ let rendered_content = self.content.render(width);
let content_empty = rendered_content.len() == 0;
- push_fragment(&mut lines, rendered_content);
+ push_fragment_opt_highlight(&mut lines, rendered_content);
if !content_empty {
push_fragment(&mut lines, self.blank.render(width));
}
for m in &self.media {
- push_fragment(&mut lines, m.render(width));
- push_fragment(&mut lines, self.blank.render(width));
+ push_fragment_opt_highlight(&mut lines, m.render(width));
+ push_fragment_opt_highlight(&mut lines, self.blank.render(width));
}
lines