Re: [PATCH v2 2/2] curses: correctly pass the color pair to setcchar()

2019-10-13 Thread Samuel Thibault
Matthew Kilgore, le jeu. 03 oct. 2019 23:53:38 -0400, a ecrit:
> The current code does not correctly pass the color pair information to
> setcchar(), it instead always passes zero. This results in the curses
> output always being in white on black.
> 
> This patch fixes this by using PAIR_NUMBER() to retrieve the color pair
> number from the chtype value, and then passes that value as an argument
> to setcchar().
> 
> Signed-off-by: Matthew Kilgore 

Reviewed-by: Samuel Thibault 
Tested-by: Samuel Thibault 

Thanks!

> ---
>  ui/curses.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/ui/curses.c b/ui/curses.c
> index 84003f56a323..3a1b71451c93 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -77,12 +77,14 @@ static void curses_update(DisplayChangeListener *dcl,
>  for (x = 0; x < width; x++) {
>  chtype ch = line[x] & A_CHARTEXT;
>  chtype at = line[x] & A_ATTRIBUTES;
> +short color_pair = PAIR_NUMBER(line[x]);
> +
>  ret = getcchar(_to_curses[ch], wch, , , NULL);
>  if (ret == ERR || wch[0] == 0) {
>  wch[0] = ch;
>  wch[1] = 0;
>  }
> -setcchar(_line[x], wch, at, 0, NULL);
> +setcchar(_line[x], wch, at, color_pair, NULL);
>  }
>  mvwadd_wchnstr(screenpad, y, 0, curses_line, width);
>  }
> -- 
> 2.23.0
> 

-- 
Samuel
 bash: ls: Computer bought the farm
 THAT frightens ppl! :P
 id rather see: "bash: ls: Initialization of googol(AWAX)
disengaged in HYPER32/64 mode due to faulty page request at
AX:12A34F84B"
 at least that would give me the feeling that the
*programmers* knows what is going on :P
(lovely Hurd...)



[PATCH v2 2/2] curses: correctly pass the color pair to setcchar()

2019-10-03 Thread Matthew Kilgore
The current code does not correctly pass the color pair information to
setcchar(), it instead always passes zero. This results in the curses
output always being in white on black.

This patch fixes this by using PAIR_NUMBER() to retrieve the color pair
number from the chtype value, and then passes that value as an argument
to setcchar().

Signed-off-by: Matthew Kilgore 
---
 ui/curses.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ui/curses.c b/ui/curses.c
index 84003f56a323..3a1b71451c93 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -77,12 +77,14 @@ static void curses_update(DisplayChangeListener *dcl,
 for (x = 0; x < width; x++) {
 chtype ch = line[x] & A_CHARTEXT;
 chtype at = line[x] & A_ATTRIBUTES;
+short color_pair = PAIR_NUMBER(line[x]);
+
 ret = getcchar(_to_curses[ch], wch, , , NULL);
 if (ret == ERR || wch[0] == 0) {
 wch[0] = ch;
 wch[1] = 0;
 }
-setcchar(_line[x], wch, at, 0, NULL);
+setcchar(_line[x], wch, at, color_pair, NULL);
 }
 mvwadd_wchnstr(screenpad, y, 0, curses_line, width);
 }
-- 
2.23.0