Re: [misc] [PATCH] Default colour as foreground colour

On Thu, 07 Dec 2017 at 16:36:01, Lars Henriksen wrote:
> In the default colour setup (white on black), white could only
> with great difficulty be used as customized foreground colour,
> because the colour pair COLR_CUSTOM then was identical to
> COLR_DEFAULT (default on default). This made it impossible to
> distinguish the selected element in lists.
> 
> The patch turns on the video attribute bold when default is chosen
> as foreground colour.
> ---
> Apart from not treating white exceptionally, some comments were
> clarified (hopefully).
> 
>  src/calcurse.h |  6 +++++-
>  src/config.c   |  1 +
>  src/custom.c   | 15 ++++++++++++---
>  src/utils.c    |  6 ++++++
>  4 files changed, 24 insertions(+), 4 deletions(-)
> [...]
> diff --git a/src/custom.c b/src/custom.c
> index 65b4d4d..6961e38 100644
> --- a/src/custom.c
> +++ b/src/custom.c
> @@ -58,7 +58,13 @@ static struct attribute attr;
>   */
>  void custom_init_attr(void)
>  {
> -       attr.color[ATTR_HIGHEST] = COLOR_PAIR(COLR_CUSTOM);
> +       short col_fg;
> +       pair_content(COLR_CUSTOM, &col_fg, NULL);
> [...]

I merged you recently submitted patches to pu and this line is causing
some issues (segmentation faults) when using recent ncurses versions. As
far as I know, there isn't any specification that allows you to pass a
NULL pointer for either of the output locations to pair_content(). You
need to use a dummy variable if you don't care about the background
color. We use a similar workaround in other parts of the code, see
commit 5722d2e (Fix segmentation fault when changing colors, 2017-07-28)
for details.

Regards,
Lukas

Links