Re: [hackers] [st][PATCH] Apply ATTR_REVERSE after ATTR_FAINT

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Tue, 26 Dec 2017 22:57:12 +0100

On Tue, Dec 26, 2017 at 04:38:27PM +0100, Benno Fünfstück wrote:
> An example where the new behaviour makes more sense:
>
> Suppose some text is formatted with ATTR_FAINT for red for the foreground, so it
> is rendered in a dark red. In that case, when selected with the mouse, the
> intended behaviour is that foreground and background color are swapped: so the
> selection should be rendered in dark red and the text in the default background
> color.
>
> Before this patch, what happened was that the selection would be in normal red
> and the text in the darkened background color, making it almost unreadable.
>
> For an example application that uses the FAINT attribute, try dmesg from
> util-linux with color support, it uses FAINT for segfault messages.
> ---
> x.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/x.c b/x.c
> index c6956ad..3d1b877 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -1205,12 +1205,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
> }
> }
>
> - if (base.mode & ATTR_REVERSE) {
> - temp = fg;
> - fg = bg;
> - bg = temp;
> - }
> -
> if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) {
> colfg.red = fg->color.red / 2;
> colfg.green = fg->color.green / 2;
> _AT_@ -1220,6 +1214,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
> fg = &revfg;
> }
>
> +
> + if (base.mode & ATTR_REVERSE) {
> + temp = fg;
> + fg = bg;
> + bg = temp;
> + }
> +
> if (base.mode & ATTR_BLINK && term.mode & MODE_BLINK)
> fg = bg;
>
> --
> 2.15.1
>
>

Thanks, applied.

A simple test-case script would be helpful next time. I did this:

#!/bin/sh
# reverse, faint
printf '\x1b[7m\x1b[2m'
# red
printf '\x1b[31m'
# text
printf 'hello world\n'
# reset
printf '\x1b[0m'

-- 
Kind regards,
Hiltjo
Received on Tue Dec 26 2017 - 22:57:12 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 26 2017 - 23:00:40 CET