On Wed, Aug 27, 2025 at 10:46:05PM -0400, Bill Gray wrote:
> 
> 
> On 8/25/25 18:28, Thomas Dickey wrote:
> > On Tue, Aug 26, 2025 at 01:17:01AM +0200, Jakub Horký wrote:
> > > po 25. 8. 2025 v 23:20 odesílatel Thomas Dickey <[email protected]> napsal:
> > > > I have in mind a different scheme, which would allow for RGB when 
> > > > available
> > > > to be used explicitly.  No compatibility layer.
> > > > 
> > > 
> > > May I ask what scheme you have in mind?
> > 
> > There are several parts, taking into account ABI compatibility with plans
> > for a new ABI 7.  Changing the size of attr_t requires a new ABI, which
> > takes more time than most people can imagine.
> > 
> > In the existing ABI 6, seeing that there are no existing uses of sgr1,
> > to use the corresponding A_xxx bits to support a color palette for
> > the 24-bit colors.  This chunk in curses.h was more convenient to
> > add, a few months ago, than keeping it in a branch:
> > 
> >     #if 1   /* NCURSES_EXT_FUNCS */
> >     #define A_ITALIC        NCURSES_BITS(1U,23)     /* ncurses extension */
> >     #if 0   /* NCURSES_RGB_COLORS */
> >     #define A_FOREGROUND    NCURSES_BITS(1U,17)     /* ncurses extension */
> >     #define A_BACKGROUND    NCURSES_BITS(1U,18)     /* ncurses extension */
> >     #define A_DIRECT        (A_FOREGROUND|A_BACKGROUND)
> >     #endif /* NCURSES_RGB_COLORS */
> >     #endif /* NCURSES_EXT_FUNCS */
> > 
> > It would have to be a (limited-size) palette, for both compatibility and
> > performance reasons.  Aside from people playing with pictures, a limited
> > size is fine.
> 
>    I'm unclear on how this actually works.  I gather the idea is that you'll
> have plenty of "traditional" color pairs and colors,  and can still use
> init_pair() and friends.  But you can also mix in,  say,
> 
> attrset( A_FOREGROUND);
> 
>    and then (if direct color is available) you can,  through suitable
> legerdemain,  set the foreground color to a particular RGB triplet.  Or
> attrset( A_DIRECT);  and then set both foreground and background.  And then
> return to traditional color pairs and a palette.  Is that correct?

Something like that.  I did say "which presents some problems to work on".
Down in vid_attr/vid_puts, it doesn't seem that messy, because it's doing
foreground and background colors separately, and "only" has to decode the
attributes.

But thinking about the extensions to the API, it isn't as simple.

+ it has to support mixing indexed colors and direct colors, so that one
  can have ANSI blue on top of rgb whatever.

+ without lots of interface changes, it needs functions to map to/from the
  rgb triple vs a direct-color number, e.g., using a different range of
  values to make checking simple.

So there's no mode-switching contemplated, but a goal of a small set of
functions to incorporate direct-colors along with attributes to remind
caller/called which is used.

-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature

Reply via email to