mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-22 09:40:25 +01:00
Support background and attributes for wide chars
Supports setting background color and attributes for wide characters (i.e. more than 1 cell wide). Previously only the first cell had its background and attribute set.
This commit is contained in:
parent
fd2c33c486
commit
8e5fbe72cd
1 changed files with 7 additions and 5 deletions
|
@ -223,15 +223,14 @@ int Terminal::_draw_cb(struct tsm_screen *con,
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update attributes.
|
// Collect attributes.
|
||||||
int attr_flags = 0;
|
int attr_flags = 0;
|
||||||
if (attr->inverse)
|
if (attr->inverse)
|
||||||
attr_flags |= AttrFlag::INVERSE;
|
attr_flags |= AttrFlag::INVERSE;
|
||||||
if (attr->blink)
|
if (attr->blink)
|
||||||
attr_flags |= AttrFlag::BLINK;
|
attr_flags |= AttrFlag::BLINK;
|
||||||
term->attr_image->set_pixel(posx, posy, Color(attr_flags / 255.0f, 0, 0, 0));
|
|
||||||
|
|
||||||
// Colors.
|
// Collect colors.
|
||||||
Color fgcol = std::min(attr->fccode, (int8_t)TSM_COLOR_FOREGROUND) >= 0
|
Color fgcol = std::min(attr->fccode, (int8_t)TSM_COLOR_FOREGROUND) >= 0
|
||||||
? term->palette[attr->fccode]
|
? term->palette[attr->fccode]
|
||||||
: Color(attr->fr / 255.0f, attr->fg / 255.0f, attr->fb / 255.0f);
|
: Color(attr->fr / 255.0f, attr->fg / 255.0f, attr->fb / 255.0f);
|
||||||
|
@ -243,8 +242,11 @@ int Terminal::_draw_cb(struct tsm_screen *con,
|
||||||
if (attr->inverse && term->inverse_mode == InverseMode::INVERSE_MODE_SWAP)
|
if (attr->inverse && term->inverse_mode == InverseMode::INVERSE_MODE_SWAP)
|
||||||
std::swap(fgcol, bgcol);
|
std::swap(fgcol, bgcol);
|
||||||
|
|
||||||
// Draw background.
|
// Update images (accounting for ultra-wide characters).
|
||||||
term->back_image->set_pixel(posx, posy, bgcol);
|
for (int i = 0; i < width && (posx + i) < term->cols; i++) {
|
||||||
|
term->back_image->set_pixel(posx + i, posy, bgcol);
|
||||||
|
term->attr_image->set_pixel(posx + i, posy, Color(attr_flags / 255.0f, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
if (len < 1)
|
if (len < 1)
|
||||||
{ // No foreground to draw.
|
{ // No foreground to draw.
|
||||||
|
|
Loading…
Reference in a new issue