From b904207b1979bb86f86c2a7db1720ce04571508a Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Wed, 12 Aug 2020 16:05:22 +0000 Subject: Add support for double underlines This adds support for double underlines using the colon separated escape sequence `CSI 4 : 2 m`. Alacritty will now also always fallback to the normal underline in case any of the other underlines like the undercurl are specified. The escape sequence `CSI 4 : 0 m` can now be used to clear all underlines. Some terminals support `CSI 21 m` for double underline, but since Alacritty already uses that as cancel bold which is a little more consistent, that behavior has not changed. So the colon separated variant must be used. --- alacritty_terminal/src/term/cell.rs | 28 +++++++++++++++------------- alacritty_terminal/src/term/mod.rs | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'alacritty_terminal/src/term') diff --git a/alacritty_terminal/src/term/cell.rs b/alacritty_terminal/src/term/cell.rs index 3fdd8cea..ee95fcba 100644 --- a/alacritty_terminal/src/term/cell.rs +++ b/alacritty_terminal/src/term/cell.rs @@ -12,19 +12,20 @@ pub const MAX_ZEROWIDTH_CHARS: usize = 5; bitflags! { #[derive(Serialize, Deserialize)] pub struct Flags: u16 { - const INVERSE = 0b000_0000_0001; - const BOLD = 0b000_0000_0010; - const ITALIC = 0b000_0000_0100; - const BOLD_ITALIC = 0b000_0000_0110; - const UNDERLINE = 0b000_0000_1000; - const WRAPLINE = 0b000_0001_0000; - const WIDE_CHAR = 0b000_0010_0000; - const WIDE_CHAR_SPACER = 0b000_0100_0000; - const DIM = 0b000_1000_0000; - const DIM_BOLD = 0b000_1000_0010; - const HIDDEN = 0b001_0000_0000; - const STRIKEOUT = 0b010_0000_0000; - const LEADING_WIDE_CHAR_SPACER = 0b100_0000_0000; + const INVERSE = 0b0000_0000_0000_0001; + const BOLD = 0b0000_0000_0000_0010; + const ITALIC = 0b0000_0000_0000_0100; + const BOLD_ITALIC = 0b0000_0000_0000_0110; + const UNDERLINE = 0b0000_0000_0000_1000; + const WRAPLINE = 0b0000_0000_0001_0000; + const WIDE_CHAR = 0b0000_0000_0010_0000; + const WIDE_CHAR_SPACER = 0b0000_0000_0100_0000; + const DIM = 0b0000_0000_1000_0000; + const DIM_BOLD = 0b0000_0000_1000_0010; + const HIDDEN = 0b0000_0001_0000_0000; + const STRIKEOUT = 0b0000_0010_0000_0000; + const LEADING_WIDE_CHAR_SPACER = 0b0000_0100_0000_0000; + const DOUBLE_UNDERLINE = 0b0000_1000_0000_0000; } } @@ -58,6 +59,7 @@ impl GridCell for Cell { && !self.flags.intersects( Flags::INVERSE | Flags::UNDERLINE + | Flags::DOUBLE_UNDERLINE | Flags::STRIKEOUT | Flags::WRAPLINE | Flags::WIDE_CHAR_SPACER diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 7a409e2e..993e6918 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -311,7 +311,7 @@ impl RenderableCell { fn is_empty(&self) -> bool { self.bg_alpha == 0. - && !self.flags.intersects(Flags::UNDERLINE | Flags::STRIKEOUT) + && !self.flags.intersects(Flags::UNDERLINE | Flags::STRIKEOUT | Flags::DOUBLE_UNDERLINE) && self.inner == RenderableCellContent::Chars([' '; cell::MAX_ZEROWIDTH_CHARS + 1]) } @@ -2017,8 +2017,17 @@ impl Handler for Term { Attr::CancelBoldDim => cursor.template.flags.remove(Flags::BOLD | Flags::DIM), Attr::Italic => cursor.template.flags.insert(Flags::ITALIC), Attr::CancelItalic => cursor.template.flags.remove(Flags::ITALIC), - Attr::Underline => cursor.template.flags.insert(Flags::UNDERLINE), - Attr::CancelUnderline => cursor.template.flags.remove(Flags::UNDERLINE), + Attr::Underline => { + cursor.template.flags.remove(Flags::DOUBLE_UNDERLINE); + cursor.template.flags.insert(Flags::UNDERLINE); + }, + Attr::DoubleUnderline => { + cursor.template.flags.remove(Flags::UNDERLINE); + cursor.template.flags.insert(Flags::DOUBLE_UNDERLINE); + }, + Attr::CancelUnderline => { + cursor.template.flags.remove(Flags::UNDERLINE | Flags::DOUBLE_UNDERLINE); + }, Attr::Hidden => cursor.template.flags.insert(Flags::HIDDEN), Attr::CancelHidden => cursor.template.flags.remove(Flags::HIDDEN), Attr::Strike => cursor.template.flags.insert(Flags::STRIKEOUT), -- cgit v1.2.3-54-g00ecf