summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-04 21:41:28 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-04 21:41:28 +0200
commitcea254f5a793bf447d6ea2eb926cba38e73adece (patch)
treed45eaf362ac75df840894f5886195ca6e2a773dd /src/term.c
parent277e79adc4d2b62556ce8a3720684e4b3e1e6d42 (diff)
downloadvim-git-cea254f5a793bf447d6ea2eb926cba38e73adece.tar.gz
patch 8.1.1464: only 4-digit rgb termresponse is recognizedv8.1.1464
Problem: Only 4-digit rgb termresponse is recognized. Solution: Also recognize 2-digit rgb response. (closes #4486)
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/term.c b/src/term.c
index cd0e7d31e..bcd2184f4 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4962,6 +4962,7 @@ check_termcode(
/* Check for fore/background color response from the terminal:
*
* {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail}
+ * or {lead}{code};rgb:{rr}/{gg}/{bb}{tail}
*
* {code} is 10 for foreground, 11 for background
* {lead} can be <Esc>] or OSC
@@ -4985,14 +4986,19 @@ check_termcode(
: (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')))
{
int is_bg = argp[1] == '1';
+ int is_4digit = i - j >= 21 && tp[j + 11] == '/'
+ && tp[j + 16] == '/';
- if (i - j >= 21 && STRNCMP(tp + j + 3, "rgb:", 4) == 0
- && tp[j + 11] == '/' && tp[j + 16] == '/')
+ if (i - j >= 14 && STRNCMP(tp + j + 3, "rgb:", 4) == 0
+ && (is_4digit
+ || (tp[j + 9] == '/' && tp[i + 12 == '/'])))
{
# ifdef FEAT_TERMINAL
- int rval = hexhex2nr(tp + j + 7);
- int gval = hexhex2nr(tp + j + 12);
- int bval = hexhex2nr(tp + j + 17);
+ int rval, gval, bval;
+
+ rval = hexhex2nr(tp + j + 7);
+ gval = hexhex2nr(tp + j + (is_4digit ? 12 : 10));
+ bval = hexhex2nr(tp + j + (is_4digit ? 17 : 13));
# endif
if (is_bg)
{