aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-09-15 00:12:07 -0600
committerJosh Rahm <rahm@google.com>2021-09-15 00:12:07 -0600
commitd2b578e011d62311125033d895060986a96d3c88 (patch)
tree00df698df2700c2a752f37a23858d1ce2a8c0a88 /alacritty_terminal/src
parent990f3f81f064f572aa0e6a528cfb3eb5215b88a4 (diff)
downloadr-alacritty-d2b578e011d62311125033d895060986a96d3c88.tar.gz
r-alacritty-d2b578e011d62311125033d895060986a96d3c88.tar.bz2
r-alacritty-d2b578e011d62311125033d895060986a96d3c88.zip
Added a rudimentary undercurl to Alacritty. Currently does not support setting the color. That is the next task
Diffstat (limited to 'alacritty_terminal/src')
-rw-r--r--alacritty_terminal/src/ansi.rs13
-rw-r--r--alacritty_terminal/src/config/mod.rs2
-rw-r--r--alacritty_terminal/src/term/cell.rs2
-rw-r--r--alacritty_terminal/src/term/mod.rs10
4 files changed, 26 insertions, 1 deletions
diff --git a/alacritty_terminal/src/ansi.rs b/alacritty_terminal/src/ansi.rs
index 55492d36..35a46549 100644
--- a/alacritty_terminal/src/ansi.rs
+++ b/alacritty_terminal/src/ansi.rs
@@ -768,6 +768,8 @@ pub enum Attr {
Underline,
/// Underlined twice.
DoubleUnderline,
+ /// Underlined twice.
+ Undercurl,
/// Blink cursor slowly.
BlinkSlow,
/// Blink cursor fast.
@@ -798,6 +800,8 @@ pub enum Attr {
Foreground(Color),
/// Set indexed background color.
Background(Color),
+ /// Set indexed special color (for underlines).
+ Special(Color),
}
/// Identifiers which can be assigned to a graphic character set.
@@ -1316,6 +1320,7 @@ fn attrs_from_sgr_parameters(params: &mut ParamsIter<'_>) -> Vec<Option<Attr>> {
[3] => Some(Attr::Italic),
[4, 0] => Some(Attr::CancelUnderline),
[4, 2] => Some(Attr::DoubleUnderline),
+ [4, 3] => Some(Attr::Undercurl),
[4, ..] => Some(Attr::Underline),
[5] => Some(Attr::BlinkSlow),
[6] => Some(Attr::BlinkFast),
@@ -1370,6 +1375,14 @@ fn attrs_from_sgr_parameters(params: &mut ParamsIter<'_>) -> Vec<Option<Attr>> {
parse_sgr_color(&mut iter).map(Attr::Background)
},
[49] => Some(Attr::Background(Color::Named(NamedColor::Background))),
+ [58, params @ ..] => {
+ let rgb_start = if params.len() > 4 { 2 } else { 1 };
+ let rgb_iter = params[rgb_start..].iter().copied();
+ let mut iter = iter::once(params[0]).chain(rgb_iter);
+
+ parse_sgr_color(&mut iter).map(Attr::Special)
+ },
+ [59] => Some(Attr::Special(Color::Named(NamedColor::Foreground))),
[90] => Some(Attr::Foreground(Color::Named(NamedColor::BrightBlack))),
[91] => Some(Attr::Foreground(Color::Named(NamedColor::BrightRed))),
[92] => Some(Attr::Foreground(Color::Named(NamedColor::BrightGreen))),
diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs
index 0b313598..382314bd 100644
--- a/alacritty_terminal/src/config/mod.rs
+++ b/alacritty_terminal/src/config/mod.rs
@@ -66,6 +66,7 @@ pub struct Cursor {
pub style: ConfigCursorStyle,
pub vi_mode_style: Option<ConfigCursorStyle>,
pub unfocused_hollow: bool,
+ pub cursor_crosshairs: bool,
thickness: Percentage,
blink_interval: u64,
@@ -79,6 +80,7 @@ impl Default for Cursor {
blink_interval: 750,
style: Default::default(),
vi_mode_style: Default::default(),
+ cursor_crosshairs: false,
}
}
}
diff --git a/alacritty_terminal/src/term/cell.rs b/alacritty_terminal/src/term/cell.rs
index 64de5492..2191ced2 100644
--- a/alacritty_terminal/src/term/cell.rs
+++ b/alacritty_terminal/src/term/cell.rs
@@ -24,6 +24,7 @@ bitflags! {
const STRIKEOUT = 0b0000_0010_0000_0000;
const LEADING_WIDE_CHAR_SPACER = 0b0000_0100_0000_0000;
const DOUBLE_UNDERLINE = 0b0000_1000_0000_0000;
+ const UNDERCURL = 0b0001_0000_0000_0000;
}
}
@@ -119,6 +120,7 @@ impl GridCell for Cell {
Flags::INVERSE
| Flags::UNDERLINE
| Flags::DOUBLE_UNDERLINE
+ | Flags::UNDERCURL
| 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 1808f3aa..367f39f9 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -1509,14 +1509,22 @@ impl<T: EventListener> Handler for Term<T> {
Attr::CancelItalic => cursor.template.flags.remove(Flags::ITALIC),
Attr::Underline => {
cursor.template.flags.remove(Flags::DOUBLE_UNDERLINE);
+ cursor.template.flags.remove(Flags::UNDERCURL);
cursor.template.flags.insert(Flags::UNDERLINE);
},
Attr::DoubleUnderline => {
cursor.template.flags.remove(Flags::UNDERLINE);
+ cursor.template.flags.remove(Flags::UNDERCURL);
cursor.template.flags.insert(Flags::DOUBLE_UNDERLINE);
},
+ Attr::Undercurl => {
+ cursor.template.flags.remove(Flags::UNDERLINE);
+ cursor.template.flags.remove(Flags::DOUBLE_UNDERLINE);
+ cursor.template.flags.insert(Flags::UNDERCURL);
+ },
Attr::CancelUnderline => {
- cursor.template.flags.remove(Flags::UNDERLINE | Flags::DOUBLE_UNDERLINE);
+ cursor.template.flags.remove(
+ Flags::UNDERLINE | Flags::DOUBLE_UNDERLINE | Flags::UNDERCURL);
},
Attr::Hidden => cursor.template.flags.insert(Flags::HIDDEN),
Attr::CancelHidden => cursor.template.flags.remove(Flags::HIDDEN),