Patch update. (a bit modified)

--
Best regards,
Hirohito Higashi

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -r bfc3682510d6 src/ascii.h
--- a/src/ascii.h	Sat Jul 04 15:05:14 2015 +0200
+++ b/src/ascii.h	Thu Jul 09 14:17:50 2015 +0900
@@ -37,6 +37,7 @@
 #define CSI		0x9b	/* Control Sequence Introducer */
 #define CSI_STR		"\233"
 #define DCS		0x90	/* Device Control String */
+#define OSC		0x9d	/* Operating System Command */
 #define STERM		0x9c	/* String Terminator */
 
 #define POUND		0xA3
@@ -121,6 +122,7 @@
 #define CSI		0x9b	/* Control Sequence Introducer */
 #define CSI_STR		"\233"
 #define DCS		0x90	/* Device Control String */
+#define OSC		0x9d	/* Operating System Command */
 #define STERM		0x9c	/* String Terminator */
 
 #define POUND		0xB1
diff -r bfc3682510d6 src/term.c
--- a/src/term.c	Sat Jul 04 15:05:14 2015 +0200
+++ b/src/term.c	Thu Jul 09 14:17:50 2015 +0900
@@ -2364,7 +2364,7 @@
 	if (p[1] == '[')
 	    return CSI;
 	if (p[1] == ']')
-	    return 0x9d;
+	    return OSC;
 	if (p[1] == 'O')
 	    return 0x8f;
     }
@@ -4261,18 +4261,11 @@
 	     * - Cursor position report: <Esc>[{row};{col}R
 	     *   The final byte must be 'R'. It is used for checking the
 	     *   ambiguous-width character state.
-	     *
-	     * - Background color response:
-	     *       <Esc>]11;rgb:{rrrr}/{gggg}/{bbbb}\007
-	     *   Or
-	     *       <Esc>]11;rgb:{rrrr}/{gggg}/{bbbb}ST
-	     *   The final byte must be '\007' or ST(0x9c or ESC\).
 	     */
 	    char_u *argp = tp[0] == CSI ? tp + 1 : tp + 2;
 
-	    if ((*T_CRV != NUL || *T_U7 != NUL || *T_RBG != NUL)
+	    if ((*T_CRV != NUL || *T_U7 != NUL)
 			&& ((tp[0] == ESC && tp[1] == '[' && len >= 3)
-			    || (tp[0] == ESC && tp[1] == ']' && len >= 24)
 			    || (tp[0] == CSI && len >= 2))
 			&& (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?'))
 	    {
@@ -4410,34 +4403,57 @@
 		    key_name[1] = (int)KE_IGNORE;
 		    slen = i + 1;
 		}
-		else if (*T_RBG != NUL
-			&& len >= 24 - (tp[0] == CSI)
-			&& len >= 24 - (tp[0] == CSI) + (argp[21] == ESC)
-			&& argp[0] == '1' && argp[1] == '1'
-			&& argp[2] == ';' && argp[3] == 'r' && argp[4] == 'g'
-			&& argp[5] == 'b' && argp[6] == ':'
-			&& argp[11] == '/' && argp[16] == '/'
-			&& (argp[21] == '\007' || argp[21] == STERM
-			    || (argp[21] == ESC && argp[22] == '\\')))
+	    }
+
+	    /* Check for some responses from the terminal starting with
+	     * "<Esc>]" or OSC:
+	     *
+	     * - Background color response:
+	     *       <Esc>]11;rgb:{rrrr}/{gggg}/{bbbb}\007
+	     *   Or
+	     *       <Esc>]11;rgb:{rrrr}/{gggg}/{bbbb}ST
+	     *   The final byte must be '\007' or ST(0x9c or ESC\).
+	     */
+	    else if (*T_RBG != NUL
+			&& ((tp[0] == ESC && tp[1] == ']' && len >= 2)
+			    || tp[0] == OSC))
+	    {
+		j = 1 + (tp[0] != OSC);
+		for (i = j; i < len; ++i)
+		    if ((tp[i] == ESC && tp[i + 1] == '\\' && i + 1 < len)
+			    || tp[i] == STERM)
+		    {
+			if (i - j >= 21 && STRNCMP(tp + j, "11;rgb:", 7) == 0
+			    && tp[j + 11] == '/' && tp[j + 16] == '/'
+			    && !option_was_set((char_u *)"bg"))
+			{
+			    LOG_TR("Received RBG");
+			    rbg_status = RBG_GOT;
+			    set_option_value((char_u *)"bg", 0L, (char_u *)(
+				    (3 * '6' < tp[j+7] + tp[j+12] + tp[j+17])
+				    ? "light" : "dark"), 0);
+			    reset_option_was_set((char_u *)"bg");
+			    redraw_asap(CLEAR);
+			}
+
+			key_name[0] = (int)KS_EXTRA;
+			key_name[1] = (int)KE_IGNORE;
+			slen = i + 1 + (tp[i] == ESC);
+			break;
+		    }
+		if (i == len)
 		{
-		    LOG_TR("Received RBG");
-		    rbg_status = RBG_GOT;
-		    if (!option_was_set((char_u *)"bg"))
-		    {
-			set_option_value((char_u *)"bg", 0L, (char_u *)(
-				    (3 * '6' < argp[7] + argp[12] + argp[17])
-						      ? "light" : "dark"), 0);
-			reset_option_was_set((char_u *)"bg");
-			redraw_asap(CLEAR);
-		    }
-		    key_name[0] = (int)KS_EXTRA;
-		    key_name[1] = (int)KE_IGNORE;
-		    slen = 24 - (tp[0] == CSI) + (argp[21] == ESC);
+		    LOG_TR("not enough characters for RB");
+		    return -1;		/* not enough characters */
 		}
 	    }
 
-	    /* Check for '<Esc>P1+r<hex bytes><Esc>\'.  A "0" instead of the
-	     * "1" means an invalid request. */
+	    /* Check for some responses from the terminal starting with
+	     * "<Esc>P" or DCS:
+	     *
+	     * - key code response from xterm: <Esc>P1+r<name>=<string><Esc>\
+	     *   "0" instead of the "1" means an invalid request.
+	     */
 	    else if (check_for_codes
 		    && ((tp[0] == ESC && tp[1] == 'P' && len >= 2)
 			|| tp[0] == DCS))

Raspunde prin e-mail lui