mirror of
https://github.com/vim/vim.git
synced 2025-08-22 19:27:53 -04:00
patch 8.1.1471: 'background' not correctly set for 2-digit rgb termresponse
Problem: 'background' not correctly set for 2-digit rgb termresponse. Solution: Adjust what digit to use. (closes #4495)
This commit is contained in:
parent
6d718c4c38
commit
32e1977012
17
src/term.c
17
src/term.c
@ -4994,17 +4994,20 @@ check_termcode(
|
|||||||
&& (is_4digit
|
&& (is_4digit
|
||||||
|| (tp[j + 9] == '/' && tp[i + 12 == '/'])))
|
|| (tp[j + 9] == '/' && tp[i + 12 == '/'])))
|
||||||
{
|
{
|
||||||
|
char_u *tp_r = tp + j + 7;
|
||||||
|
char_u *tp_g = tp + j + (is_4digit ? 12 : 10);
|
||||||
|
char_u *tp_b = tp + j + (is_4digit ? 17 : 13);
|
||||||
# ifdef FEAT_TERMINAL
|
# ifdef FEAT_TERMINAL
|
||||||
int rval, gval, bval;
|
int rval, gval, bval;
|
||||||
|
|
||||||
rval = hexhex2nr(tp + j + 7);
|
rval = hexhex2nr(tp_r);
|
||||||
gval = hexhex2nr(tp + j + (is_4digit ? 12 : 10));
|
gval = hexhex2nr(tp_b);
|
||||||
bval = hexhex2nr(tp + j + (is_4digit ? 17 : 13));
|
bval = hexhex2nr(tp_g);
|
||||||
# endif
|
# endif
|
||||||
if (is_bg)
|
if (is_bg)
|
||||||
{
|
{
|
||||||
char *newval = (3 * '6' < tp[j+7] + tp[j+12]
|
char *new_bg_val = (3 * '6' < *tp_r + *tp_g +
|
||||||
+ tp[j+17]) ? "light" : "dark";
|
*tp_b) ? "light" : "dark";
|
||||||
|
|
||||||
LOG_TR(("Received RBG response: %s", tp));
|
LOG_TR(("Received RBG response: %s", tp));
|
||||||
rbg_status.tr_progress = STATUS_GOT;
|
rbg_status.tr_progress = STATUS_GOT;
|
||||||
@ -5014,11 +5017,11 @@ check_termcode(
|
|||||||
bg_b = bval;
|
bg_b = bval;
|
||||||
# endif
|
# endif
|
||||||
if (!option_was_set((char_u *)"bg")
|
if (!option_was_set((char_u *)"bg")
|
||||||
&& STRCMP(p_bg, newval) != 0)
|
&& STRCMP(p_bg, new_bg_val) != 0)
|
||||||
{
|
{
|
||||||
/* value differs, apply it */
|
/* value differs, apply it */
|
||||||
set_option_value((char_u *)"bg", 0L,
|
set_option_value((char_u *)"bg", 0L,
|
||||||
(char_u *)newval, 0);
|
(char_u *)new_bg_val, 0);
|
||||||
reset_option_was_set((char_u *)"bg");
|
reset_option_was_set((char_u *)"bg");
|
||||||
redraw_asap(CLEAR);
|
redraw_asap(CLEAR);
|
||||||
}
|
}
|
||||||
|
@ -647,21 +647,49 @@ func Test_term_rgb_response()
|
|||||||
call feedkeys(seq, 'Lx!')
|
call feedkeys(seq, 'Lx!')
|
||||||
call assert_equal(seq, v:termrfgresp)
|
call assert_equal(seq, v:termrfgresp)
|
||||||
|
|
||||||
" response to t_RB, 4 digits
|
" response to t_RB, 4 digits, dark
|
||||||
let red = 0x21
|
set background=light
|
||||||
let green = 0x43
|
call test_option_not_set('background')
|
||||||
|
let red = 0x29
|
||||||
|
let green = 0x4a
|
||||||
|
let blue = 0x6b
|
||||||
|
let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
|
||||||
|
call feedkeys(seq, 'Lx!')
|
||||||
|
call assert_equal(seq, v:termrbgresp)
|
||||||
|
call assert_equal('dark', &background)
|
||||||
|
|
||||||
|
" response to t_RB, 4 digits, light
|
||||||
|
set background=dark
|
||||||
|
call test_option_not_set('background')
|
||||||
|
let red = 0x81
|
||||||
|
let green = 0x63
|
||||||
let blue = 0x65
|
let blue = 0x65
|
||||||
let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
|
let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
|
||||||
call feedkeys(seq, 'Lx!')
|
call feedkeys(seq, 'Lx!')
|
||||||
call assert_equal(seq, v:termrbgresp)
|
call assert_equal(seq, v:termrbgresp)
|
||||||
|
call assert_equal('light', &background)
|
||||||
|
|
||||||
" response to t_RB, 2 digits
|
" response to t_RB, 2 digits, dark
|
||||||
let red = 0x87
|
set background=light
|
||||||
let green = 0xa9
|
call test_option_not_set('background')
|
||||||
let blue = 0xcb
|
let red = 0x47
|
||||||
|
let green = 0x59
|
||||||
|
let blue = 0x5b
|
||||||
let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
|
let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
|
||||||
call feedkeys(seq, 'Lx!')
|
call feedkeys(seq, 'Lx!')
|
||||||
call assert_equal(seq, v:termrbgresp)
|
call assert_equal(seq, v:termrbgresp)
|
||||||
|
call assert_equal('dark', &background)
|
||||||
|
|
||||||
|
" response to t_RB, 2 digits, light
|
||||||
|
set background=dark
|
||||||
|
call test_option_not_set('background')
|
||||||
|
let red = 0x83
|
||||||
|
let green = 0xa4
|
||||||
|
let blue = 0xc2
|
||||||
|
let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
|
||||||
|
call feedkeys(seq, 'Lx!')
|
||||||
|
call assert_equal(seq, v:termrbgresp)
|
||||||
|
call assert_equal('light', &background)
|
||||||
|
|
||||||
set t_RF= t_RB=
|
set t_RF= t_RB=
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1471,
|
||||||
/**/
|
/**/
|
||||||
1470,
|
1470,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user