From 6e5ceb63f4a47f830d1dfdd2ff138fdebefe9575 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Dec 2016 11:03:02 +0530 Subject: [PATCH] Implement escape codes for setting underline color and underline style \E[6m for underline style = curl \E[58m for underline color can be one of 5;i where 0 <= i < 256 or 2;r;g;b where 0 <= r,g,b < 256 --- kitty/fonts.py | 2 +- kitty/screen.c | 4 ++++ kitty/sprites.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kitty/fonts.py b/kitty/fonts.py index 3df58d506..9c59309d9 100644 --- a/kitty/fonts.py +++ b/kitty/fonts.py @@ -265,7 +265,7 @@ def render_cell(text=' ', bold=False, italic=False, underline=0, strikethrough=F if underline: t = underline_thickness if underline == 2: - t = min(cell_height - underline_position - 1, t) + t = max(1, min(cell_height - underline_position - 1, t)) dl(add_curl if underline == 2 else add_line, underline_position, t) if strikethrough: pos = int(0.65 * baseline) diff --git a/kitty/screen.c b/kitty/screen.c index d141fca36..e781af760 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -281,6 +281,8 @@ void select_graphic_rendition(Screen *self, unsigned int *params, unsigned int c self->cursor->italic = true; break; case 4: self->cursor->decoration = 1; break; + case 6: + self->cursor->decoration = 2; break; case 7: self->cursor->reverse = true; break; case 9: @@ -313,6 +315,8 @@ END_ALLOW_CASE_RANGE SET_COLOR(fg); case 48: SET_COLOR(bg); + case 58: + SET_COLOR(decoration_fg); } } } diff --git a/kitty/sprites.c b/kitty/sprites.c index 89b1a88f3..7b7706c59 100644 --- a/kitty/sprites.c +++ b/kitty/sprites.c @@ -162,7 +162,7 @@ update_cell_range_data(ScreenModes *modes, SpriteMap *self, Line *line, unsigned data[offset+2] = sp->z; data[offset+(reverse ? 4 : 3)] = to_color(color_profile, line->colors[i] & COL_MASK, default_fg); data[offset+(reverse ? 3 : 4)] = to_color(color_profile, line->colors[i] >> COL_SHIFT, default_bg); - unsigned int decoration_fg = decoration > 1 ? to_color(color_profile, line->decoration_fg[i] & COL_MASK, data[offset+3]) : data[offset+3]; + unsigned int decoration_fg = to_color(color_profile, line->decoration_fg[i] & COL_MASK, data[offset+3]); data[offset+5] = (decoration_fg & COL_MASK) | (decoration << 24) | (strikethrough << 26); previous_ch = ch; previous_width = (attrs) & WIDTH_MASK; }