bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reset color palette entry/entries to default?


From: Thomas Dickey
Subject: Re: Reset color palette entry/entries to default?
Date: Fri, 30 Jul 2021 21:07:14 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri, Jul 30, 2021 at 05:40:42PM -0400, Bill Gray wrote:
>    ncurses provides,  as extensions,  free_pair() and
> reset_color_pairs() to free up one or all color pairs.  I've
> had a couple of situations where I'd like to do something
> similar for palette entries.

ncurses doesn't have a special function for this.

xterm supports a control sequence for resetting the palette to its default.

            Ps = 1 0 4 ; c -> Reset Color Number c.  It is reset to the
          color specified by the corresponding X resource.  Any number
          of c parameters may be given.  These parameters correspond to
          the ANSI colors 0-7, their bright versions 8-15, and if
          supported, the remainder of the 88-color or 256-color table.
          If no parameters are given, the entire table will be reset.

ncurses' terminal description for xterm uses that in the original-colors and
reset strings:

        oc=\E]104\007,
        rs1=\Ec\E]104\007,

(of course, terminals setting $TERM to "xterm", etc., without implementing
this are defective and bug reports should be addressed to _their_ developers).

xterm also has control sequences for loading palettes quickly,
but since ncurses is targeted toward commonly-used features,
there's as yet no reason to add a function to use that in ncurses.

>    You _can_ simply read in the defaults and store them for later
> use,  of course,  as in...
> 
> int default_r, default_g, default_b;
> 
> extended_color_content( palette_idx, &default_r, &default_g, &default_b);
> init_extended_color( palette_idx, new_r, new_b, new_g);
> /* do various stuff,  then return to original color : */
> init_extended_color( palette_idx, default_r, default_g, default_b);
> 
>    with these being arrays if you're dealing with multiple palette
> indices.  I am hoping that ncurses provides something such as
> 
> void reset_color( const int palette_idx);
> void reset_all_colors( void);
> 
>    to set one or all colors back to their defaults.
> 
>    I am the maintainer for PDCursesMod,  and will probably add such
> functions to that library.  My interest is partly in making sure
> anything I do is compatible with ncurses,  if possible.
> 
> Thanks!           -- Bill
> 

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]