Print secondary labels as notes in old skool mode

This commit is contained in:
Jonathan Turner 2016-05-16 08:50:01 -04:00
parent 5743564f2d
commit ae1e73affe
2 changed files with 26 additions and 0 deletions

View File

@ -524,6 +524,9 @@ impl Destination {
}
Style::Quotation => {
}
Style::OldSkoolNote => {
self.start_attr(term::Attr::Bold)?;
}
Style::UnderlinePrimary | Style::LabelPrimary => {
self.start_attr(term::Attr::Bold)?;
self.start_attr(term::Attr::ForegroundColor(lvl.color()))?;

View File

@ -90,6 +90,7 @@ pub enum Style {
UnderlineSecondary,
LabelPrimary,
LabelSecondary,
OldSkoolNote,
NoStyle,
}
@ -497,6 +498,28 @@ impl FileInfo {
match self.primary_span {
Some(span) => {
let lo = codemap.lookup_char_pos(span.lo);
//Before each secondary line in old skool-mode, print the label
//as an old-style note
if !line.annotations[0].is_primary {
if let Some(ann) = line.annotations[0].label.clone() {
output.push(RenderedLine {
text: vec![StyledString {
text: lo.file.name.clone(),
style: Style::FileNameStyle,
}, StyledString {
text: format!(":{}:{}: ", lo.line, lo.col.0 + 1),
style: Style::LineAndColumn,
}, StyledString {
text: format!("note: "),
style: Style::LabelSecondary,
}, StyledString {
text: format!("{}", ann),
style: Style::OldSkoolNote,
}],
kind: RenderedLineKind::Annotations,
});
}
}
rendered_lines[0].text.insert(0, StyledString {
text: format!(":{} ", lo.line),
style: Style::LineAndColumn,