Support setrgbb/setrgbf for setting 24-bit color

* src/term.c (turn_on_face): Account for TF_rgb_separate.
(init_tty): Support setrgbf/setrrgbb and set TF_rgb_separate
accordingly.
* src/termchar.h: Update commentary.
(Bug#70941)
This commit is contained in:
Tim Ruffing 2021-11-12 20:37:39 +01:00 committed by Eli Zaretskii
parent 84ae97f865
commit 8aa7f6a501
2 changed files with 28 additions and 10 deletions

View file

@ -2074,7 +2074,10 @@ turn_on_face (struct frame *f, struct face *face)
ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
if (face_tty_specified_color (fg) && ts)
{
p = tparam (ts, NULL, 0, fg, 0, 0, 0);
if (tty->TF_rgb_separate)
p = tparam (ts, NULL, 0, fg >> 16, (fg >> 8) & 0xFF, fg & 0xFF, 0);
else
p = tparam (ts, NULL, 0, fg, 0, 0, 0);
OUTPUT (tty, p);
xfree (p);
}
@ -2082,7 +2085,10 @@ turn_on_face (struct frame *f, struct face *face)
ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
if (face_tty_specified_color (bg) && ts)
{
p = tparam (ts, NULL, 0, bg, 0, 0, 0);
if (tty->TF_rgb_separate)
p = tparam (ts, NULL, 0, bg >> 16, (bg >> 8) & 0xFF, bg & 0xFF, 0);
else
p = tparam (ts, NULL, 0, bg, 0, 0, 0);
OUTPUT (tty, p);
xfree (p);
}
@ -4587,10 +4593,10 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
#ifdef TERMINFO
{
const char *fg = tigetstr ("setf24");
const char *bg = tigetstr ("setb24");
/* Non-standard support for 24-bit colors. */
if (fg && bg
const char *fg;
const char *bg;
/* Our own non-standard support for 24-bit colors. */
if ((fg = tigetstr ("setf24")) && (bg = tigetstr ("setb24"))
&& fg != (char *) (intptr_t) -1
&& bg != (char *) (intptr_t) -1)
{
@ -4598,6 +4604,16 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
tty->TS_set_background = bg;
tty->TN_max_colors = 16777216;
}
/* Other non-standard support for 24-bit colors. */
else if ((fg = tigetstr ("setrgbf")) && (bg = tigetstr ("setrgbb"))
&& fg != (char *) (intptr_t) -1
&& bg != (char *) (intptr_t) -1)
{
tty->TS_set_foreground = fg;
tty->TS_set_background = bg;
tty->TN_max_colors = 16777216;
tty->TF_rgb_separate = 1;
}
/* Standard support for 24-bit colors. */
else if (tigetflag ("RGB") > 0)
{

View file

@ -159,10 +159,12 @@ struct tty_display_info
/* "op" -- SVr4 set default pair to its original value. */
const char *TS_orig_pair;
/* "AF"/"AB" or "Sf"/"Sb"-- set ANSI or SVr4 foreground/background color.
1 param, the color index. */
const char *TS_set_foreground;
const char *TS_set_background;
const char *TS_set_foreground; /* "AF"/"Sf"/"setrgbf" -- set foreground color. */
const char *TS_set_background; /* "AB"/"Sb"/"setrgbb" -- set background color. */
/* If set, TS_set_foreground and TS_set_background take 3 separate
params for R, G, and B values ("setrgbf"/"setrgbb" -- non-standard).
If unset, they take 1 param ("AF"/"AB" or "Sf"/"Sb" -- ANSI or SVr4r). */
int TF_rgb_separate;
int TF_hazeltine; /* termcap hz flag. */
int TF_insmode_motion; /* termcap mi flag: can move while in insert mode. */