Skip to content

Commit

Permalink
Add workarounds for weird termion escape code handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dflemstr authored and fdehau committed Mar 10, 2019
1 parent b7664a4 commit a25bbea
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/backend/termion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ impl fmt::Display for ModifierDiff {
write!(f, "{}", termion::style::NoInvert)?;
}
if remove.contains(style::Modifier::BOLD) {
write!(f, "{}", termion::style::NoBold)?;
// XXX: the termion NoBold flag actually enables double-underline on ECMA-48 compliant
// terminals, and NoFaint additionally disables bold... so we use this trick to get
// the right semantics.
write!(f, "{}", termion::style::NoFaint)?;

if self.to.contains(style::Modifier::DIM) {
write!(f, "{}", termion::style::Faint)?;
}
}
if remove.contains(style::Modifier::ITALIC) {
write!(f, "{}", termion::style::NoItalic)?;
Expand All @@ -216,6 +223,12 @@ impl fmt::Display for ModifierDiff {
}
if remove.contains(style::Modifier::DIM) {
write!(f, "{}", termion::style::NoFaint)?;

// XXX: the NoFaint flag additionally disables bold as well, so we need to re-enable it
// here if we want it.
if self.to.contains(style::Modifier::BOLD) {
write!(f, "{}", termion::style::Bold)?;
}
}
if remove.contains(style::Modifier::CROSSED_OUT) {
write!(f, "{}", termion::style::NoCrossedOut)?;
Expand Down

0 comments on commit a25bbea

Please sign in to comment.