[hackers] Re: [st][PATCH] Fix crash when cursor color is truecolor

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 15 Jul 2018 18:23:04 +0200

On Sun, Jul 15, 2018 at 01:53:37PM +0200, Jules Maselbas wrote:
> Reported-by: Ivan Tham <pickfire_AT_riseup.net>
> ---
> x.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/x.c b/x.c
> index b51821d..4155a70 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -1404,6 +1404,7 @@ void
> xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
> {
> Color drawcol;
> + uint32_t cc;
>
> /* remove the old cursor */
> if (selected(ox, oy))
> _AT_@ -1419,14 +1420,22 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
> g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE;
>
> if (selected(cx, cy)) {
> - drawcol = dc.col[g.bg];
> + cc = g.bg;
> } else {
> g.mode |= ATTR_REVERSE;
> -
> if (g.mode & ATTR_BOLD && BETWEEN(g.fg, 0, 7))
> - drawcol = dc.col[g.fg + 8];
> + cc = g.fg + 8;
> else
> - drawcol = dc.col[g.fg];
> + cc = g.fg;
> + }
> +
> + if (IS_TRUECOL(cc)) {
> + drawcol.color.alpha = 0xffff;
> + drawcol.color.red = TRUERED(cc);
> + drawcol.color.green = TRUEGREEN(cc);
> + drawcol.color.blue = TRUEBLUE(cc);
> + } else {
> + drawcol = dc.col[cc];
> }
>
> if (IS_SET(MODE_REVERSE)) {
> --
> 2.18.0
>

Thanks,

For future reference and testing:

Defining a truecolor, in this example forecolor black:
        printf '\x1b[38;2;0;0;0m'

used to crash st.

-- 
Kind regards,
Hiltjo
Received on Sun Jul 15 2018 - 18:23:04 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 15 2018 - 18:24:21 CEST