comparison src/term.c @ 16926:bcc25f1a264d v8.1.1464

patch 8.1.1464: only 4-digit rgb termresponse is recognized commit https://github.com/vim/vim/commit/cea254f5a793bf447d6ea2eb926cba38e73adece Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 4 21:41:28 2019 +0200 patch 8.1.1464: only 4-digit rgb termresponse is recognized Problem: Only 4-digit rgb termresponse is recognized. Solution: Also recognize 2-digit rgb response. (closes https://github.com/vim/vim/issues/4486)
author Bram Moolenaar <Bram@vim.org>
date Tue, 04 Jun 2019 21:45:05 +0200
parents ce04ebdf26b8
children 73e6ed2f69a2
comparison
equal deleted inserted replaced
16925:fe06c620ee5c 16926:bcc25f1a264d
4960 } 4960 }
4961 4961
4962 /* Check for fore/background color response from the terminal: 4962 /* Check for fore/background color response from the terminal:
4963 * 4963 *
4964 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} 4964 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail}
4965 * or {lead}{code};rgb:{rr}/{gg}/{bb}{tail}
4965 * 4966 *
4966 * {code} is 10 for foreground, 11 for background 4967 * {code} is 10 for foreground, 11 for background
4967 * {lead} can be <Esc>] or OSC 4968 * {lead} can be <Esc>] or OSC
4968 * {tail} can be '\007', <Esc>\ or STERM. 4969 * {tail} can be '\007', <Esc>\ or STERM.
4969 * 4970 *
4983 for (i = j; i < len; ++i) 4984 for (i = j; i < len; ++i)
4984 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM 4985 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM
4985 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) 4986 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')))
4986 { 4987 {
4987 int is_bg = argp[1] == '1'; 4988 int is_bg = argp[1] == '1';
4988 4989 int is_4digit = i - j >= 21 && tp[j + 11] == '/'
4989 if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 4990 && tp[j + 16] == '/';
4990 && tp[j + 11] == '/' && tp[j + 16] == '/') 4991
4992 if (i - j >= 14 && STRNCMP(tp + j + 3, "rgb:", 4) == 0
4993 && (is_4digit
4994 || (tp[j + 9] == '/' && tp[i + 12 == '/'])))
4991 { 4995 {
4992 # ifdef FEAT_TERMINAL 4996 # ifdef FEAT_TERMINAL
4993 int rval = hexhex2nr(tp + j + 7); 4997 int rval, gval, bval;
4994 int gval = hexhex2nr(tp + j + 12); 4998
4995 int bval = hexhex2nr(tp + j + 17); 4999 rval = hexhex2nr(tp + j + 7);
5000 gval = hexhex2nr(tp + j + (is_4digit ? 12 : 10));
5001 bval = hexhex2nr(tp + j + (is_4digit ? 17 : 13));
4996 # endif 5002 # endif
4997 if (is_bg) 5003 if (is_bg)
4998 { 5004 {
4999 char *newval = (3 * '6' < tp[j+7] + tp[j+12] 5005 char *newval = (3 * '6' < tp[j+7] + tp[j+12]
5000 + tp[j+17]) ? "light" : "dark"; 5006 + tp[j+17]) ? "light" : "dark";