Implement escape codes for setting underline color and underline style

\E[6m for underline style = curl
\E[58<color spec>m for underline color

<color spec> can be one of 5;i where 0 <= i < 256
or 2;r;g;b where 0 <= r,g,b < 256
This commit is contained in:
Kovid Goyal 2016-12-05 11:03:02 +05:30
parent ee7f25c9ba
commit 6e5ceb63f4
3 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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);
}
}
}

View File

@ -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;
}