Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCHv2] gdb/tui: use init_extended_color where possible
Date: Wed, 12 Aug 2026 13:44:11 -0600	[thread overview]
Message-ID: <87qzk3w2d0.fsf@tromey.com> (raw)
In-Reply-To: <5da7a3fea6997922a87508807efc3cadd119ff7c.1785930494.git.aburgess@redhat.com> (Andrew Burgess's message of "Wed, 5 Aug 2026 12:50:53 +0100")

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> The motivation for using init_extended_color is slightly less than
Andrew> init_extended_pair.  Assuming the terminal supports it the standard
Andrew> init_color API supports up to SHRT_MAX (32767) different colors,
Andrew> switching to init_extended_color removes the SHRT_MAX limit on color
Andrew> indices, allowing us to support the full range of COLORS.

First, I think the patch is fine.
Approved-By: Tom Tromey <tom@tromey.com>

However I have a question

Andrew>  	  /* We store RGB as 0..255, but curses wants 0..1000.  */
Andrew> -	  if (init_color (next, rgb[0] * 1000 / 255, rgb[1] * 1000 / 255,
Andrew> -			  rgb[2] * 1000 / 255) == ERR)
Andrew> +	  short r = rgb[0] * 1000 / 255;
Andrew> +	  short g = rgb[1] * 1000 / 255;
Andrew> +	  short b = rgb[2] * 1000 / 255;
Andrew> +
Andrew> +	  /* If init_extended_pair is not available then we fallback to
Andrew> +	     using init_pair.  However, init_pair can only handle 'short'
Andrew> +	     color indices so there is no point using init_extended_color
Andrew> +	     to allow for the generation of longer 'int' color indices.  */
Andrew> +#if defined HAVE_INIT_EXTENDED_COLOR && defined HAVE_INIT_EXTENDED_PAIR
Andrew> +	  if (init_extended_color (next, r, g, b) == ERR)
Andrew>  	    return false;
Andrew> +#else
Andrew> +	  /* NEXT is an int, but is passed as a short.  If COLORS is
Andrew> +	     more than SHRT_MAX then NEXT will be truncated and end up
Andrew> +	     redefining a color entry that we don't expect.  */
Andrew> +	  if (next > SHRT_MAX
Andrew> +	      || init_color (next, r, g, b) == ERR)
Andrew> +	    return false;
Andrew> +#endif

IIUC init_extended_color allows a bigger range for 'next' but also for
the RGB components.  However despite the text above, I think we don't
actually use the bigger RGB range.  And, perhaps we don't really care
to, I don't know.

Tom

  parent reply	other threads:[~2026-08-12 19:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 14:24 [PATCH] " Andrew Burgess
2026-08-05 11:50 ` [PATCHv2] " Andrew Burgess
2026-08-12 19:26   ` Simon Marchi
2026-08-12 19:44   ` Tom Tromey [this message]
2026-08-13  9:53     ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87qzk3w2d0.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox