Skip to content
Snippets Groups Projects
Commit 43abe2a7 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add support for 90-97 and 100-107 SGR parameters

This allows directly setting bright foreground and background colours
rather than using bold and blink to indirectly modify them.

These do not have an effect if the desired mode is not possible
(ie: no bright background, no bright foreground).
parent 236064ee
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4599 passed
......@@ -2457,6 +2457,30 @@ set_bgattr(struct cterminal *cterm, unsigned char colour)
set_attr(cterm, colour, true ^ cterm->negative);
}
static void
set_bright_fg(struct cterminal *cterm, unsigned char colour, int flags)
{
if (!(flags & CIOLIB_VIDEO_NOBRIGHT)) {
set_fgattr(cterm, colour);
if (!cterm->skypix)
cterm->attr|=8;
attr2palette(cterm->attr, cterm->negative ? NULL : &cterm->fg_color, cterm->negative ? &cterm->fg_color : NULL);
FREE_AND_NULL(cterm->fg_tc_str);
}
}
static void
set_bright_bg(struct cterminal *cterm, unsigned char colour, int flags)
{
if (flags & CIOLIB_VIDEO_BGBRIGHT) {
set_attr(cterm, colour, true ^ cterm->negative);
if (!cterm->skypix)
cterm->attr|=128;
attr2palette(cterm->attr, cterm->negative ? &cterm->bg_color : NULL, cterm->negative ? NULL : &cterm->bg_color);
FREE_AND_NULL(cterm->bg_tc_str);
}
}
static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *speed, char last)
{
char *p;
......@@ -3966,6 +3990,54 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case 48:
parse_extended_colour(seq, &i, cterm, false ^ cterm->negative);
break;
case 90:
set_bright_fg(cterm, BLACK, flags);
break;
case 91:
set_bright_fg(cterm, RED, flags);
break;
case 92:
set_bright_fg(cterm, GREEN, flags);
break;
case 93:
set_bright_fg(cterm, BROWN, flags);
break;
case 94:
set_bright_fg(cterm, BLUE, flags);
break;
case 95:
set_bright_fg(cterm, MAGENTA, flags);
break;
case 96:
set_bright_fg(cterm, CYAN, flags);
break;
case 97:
set_bright_fg(cterm, LIGHTGRAY, flags);
break;
case 100:
set_bright_bg(cterm, BLACK, flags);
break;
case 101:
set_bright_bg(cterm, RED, flags);
break;
case 102:
set_bright_bg(cterm, GREEN, flags);
break;
case 103:
set_bright_bg(cterm, BROWN, flags);
break;
case 104:
set_bright_bg(cterm, BLUE, flags);
break;
case 105:
set_bright_bg(cterm, MAGENTA, flags);
break;
case 106:
set_bright_bg(cterm, CYAN, flags);
break;
case 107:
set_bright_bg(cterm, LIGHTGRAY, flags);
break;
}
}
TEXTATTR(cterm->attr);
......
......@@ -1033,43 +1033,58 @@ CSI Ps... m (SGR)
Sets or clears one or more text attributes. Unlimited parameters are
supported and are applied in received order. The following are
supported:
Blink Bold FG BG TF TB (Modified)
0 - Default attribute, white on black X X X X X X
1 - Bright Intensity X X
2 - Dim intensity X X
5 - Blink (By definition, slow blink) X X
6 - Blink (By definition, fast blink) X X
NOTE: Both blinks are the same speed.
7 - Negative Image - Reverses FG and BG X X X X
8 - Concealed characters, sets the X X X
foreground colour to the background
colour.
22 - Normal intensity X X
25 - Steady (Not blinking) X X
27 - Positive Image - Restores FG and BG X X X X
NOTE: This should be a separate
attribute than 7 but this
implementation makes them equal
30 - Black foreground X X
31 - Red foreground X X
32 - Green foreground X X
33 - Yellow foreground X X
34 - Blue foreground X X
35 - Magenta foreground X X
36 - Cyan foreground X X
37 - White foreground X X
38 - Extended Foreground (see notes) X
39 - Default foreground (same as white) X X
40 - Black background X X
41 - Red background X X
42 - Green background X X
43 - Yellow background X X
44 - Blue background X X
45 - Magenta background X X
46 - Cyan background X X
47 - White background X X
48 - Extended Background (see notes) X
49 - Default background (same as black) X X
Blink Bold FG BG TF TB (Modified)
0 - Default attribute, white on black X X X X X X
1 - Bright Intensity X X
2 - Dim intensity X X
5 - Blink (By definition, slow blink) X X
6 - Blink (By definition, fast blink) X X
NOTE: Both blinks are the same speed.
7 - Negative Image - Reverses FG and BG X X X X
8 - Concealed characters, sets the X X X
foreground colour to the background
colour.
22 - Normal intensity X X
25 - Steady (Not blinking) X X
27 - Positive Image - Restores FG and BG X X X X
NOTE: This should be a separate
attribute than 7 but this
implementation makes them equal
30 - Black foreground X X
31 - Red foreground X X
32 - Green foreground X X
33 - Yellow foreground X X
34 - Blue foreground X X
35 - Magenta foreground X X
36 - Cyan foreground X X
37 - White foreground X X
38 - Extended Foreground (see notes) X
39 - Default foreground (same as white) X X
40 - Black background X X
41 - Red background X X
42 - Green background X X
43 - Yellow background X X
44 - Blue background X X
45 - Magenta background X X
46 - Cyan background X X
47 - White background X X
48 - Extended Background (see notes) X
49 - Default background (same as black) X X
91 - Bright Red foreground X X X
92 - Bright Green foreground X X X
93 - Bright Yellow foreground X X X
94 - Bright Blue foreground X X X
95 - Bright Magenta foreground X X X
96 - Bright Cyan foreground X X X
97 - Bright White foreground X X X
100 - Bright Black background X X X
101 - Bright Red background X X X
102 - Bright Green background X X X
103 - Bright Yellow background X X X
104 - Bright Blue background X X X
105 - Bright Magenta background X X X
106 - Bright Cyan background X X X
107 - Bright White background X X X
All others are ignored.
......@@ -1080,6 +1095,12 @@ CSI Ps... m (SGR)
TF indicates that the Tru Colour foreground is changed.
TB indicates that the Tru Colour background is changed.
NOTE: For 90-97, there is no effect unless bright foreground colours
are enabled.
NOTE: For 100-107, there is no effect unless bright background colours
are enabled.
NOTE: For 38 and 48, two additional formats are supported, a palette
selection and a direct colour selection.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment