|
Karsten Hopp |
26e32e |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
26e32e |
Subject: Patch 7.4.757
|
|
Karsten Hopp |
26e32e |
Fcc: outbox
|
|
Karsten Hopp |
26e32e |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
26e32e |
Mime-Version: 1.0
|
|
Karsten Hopp |
26e32e |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
26e32e |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
26e32e |
------------
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
Patch 7.4.757
|
|
Karsten Hopp |
26e32e |
Problem: Cannot detect the background color of a terminal.
|
|
Karsten Hopp |
26e32e |
Solution: Add T_RBG to request the background color if possible. (Lubomir
|
|
Karsten Hopp |
26e32e |
Rintel)
|
|
Karsten Hopp |
26e32e |
Files: src/main.c, src/term.c, src/term.h, src/proto/term.pro
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
*** ../vim-7.4.756/src/main.c 2015-04-17 22:08:10.998772925 +0200
|
|
Karsten Hopp |
26e32e |
--- src/main.c 2015-06-25 17:01:47.917747345 +0200
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 837,844 ****
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
starttermcap(); /* start termcap if not done by wait_return() */
|
|
Karsten Hopp |
26e32e |
TIME_MSG("start termcap");
|
|
Karsten Hopp |
26e32e |
! #if defined(FEAT_TERMRESPONSE) && defined(FEAT_MBYTE)
|
|
Karsten Hopp |
26e32e |
may_req_ambiguous_char_width();
|
|
Karsten Hopp |
26e32e |
#endif
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
#ifdef FEAT_MOUSE
|
|
Karsten Hopp |
26e32e |
--- 837,847 ----
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
starttermcap(); /* start termcap if not done by wait_return() */
|
|
Karsten Hopp |
26e32e |
TIME_MSG("start termcap");
|
|
Karsten Hopp |
26e32e |
! #if defined(FEAT_TERMRESPONSE)
|
|
Karsten Hopp |
26e32e |
! # if defined(FEAT_MBYTE)
|
|
Karsten Hopp |
26e32e |
may_req_ambiguous_char_width();
|
|
Karsten Hopp |
26e32e |
+ # endif
|
|
Karsten Hopp |
26e32e |
+ may_req_bg_color();
|
|
Karsten Hopp |
26e32e |
#endif
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
#ifdef FEAT_MOUSE
|
|
Karsten Hopp |
26e32e |
*** ../vim-7.4.756/src/term.c 2015-03-31 18:30:09.139370916 +0200
|
|
Karsten Hopp |
26e32e |
--- src/term.c 2015-06-25 16:52:59.359131386 +0200
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 124,129 ****
|
|
Karsten Hopp |
26e32e |
--- 124,134 ----
|
|
Karsten Hopp |
26e32e |
# define U7_SENT 2 /* did send T_U7, waiting for answer */
|
|
Karsten Hopp |
26e32e |
# define U7_GOT 3 /* received T_U7 response */
|
|
Karsten Hopp |
26e32e |
static int u7_status = U7_GET;
|
|
Karsten Hopp |
26e32e |
+ /* Request background color report: */
|
|
Karsten Hopp |
26e32e |
+ # define RBG_GET 1 /* send T_RBG when switched to RAW mode */
|
|
Karsten Hopp |
26e32e |
+ # define RBG_SENT 2 /* did send T_RBG, waiting for answer */
|
|
Karsten Hopp |
26e32e |
+ # define RBG_GOT 3 /* received T_RBG response */
|
|
Karsten Hopp |
26e32e |
+ static int rbg_status = RBG_GET;
|
|
Karsten Hopp |
26e32e |
# endif
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
/*
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 949,954 ****
|
|
Karsten Hopp |
26e32e |
--- 954,960 ----
|
|
Karsten Hopp |
26e32e |
{(int)KS_CWP, IF_EB("\033[3;%d;%dt", ESC_STR "[3;%d;%dt")},
|
|
Karsten Hopp |
26e32e |
# endif
|
|
Karsten Hopp |
26e32e |
{(int)KS_CRV, IF_EB("\033[>c", ESC_STR "[>c")},
|
|
Karsten Hopp |
26e32e |
+ {(int)KS_RBG, IF_EB("\033]11;?\007", ESC_STR "]11;?\007")},
|
|
Karsten Hopp |
26e32e |
{(int)KS_U7, IF_EB("\033[6n", ESC_STR "[6n")},
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
{K_UP, IF_EB("\033O*A", ESC_STR "O*A")},
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 1240,1245 ****
|
|
Karsten Hopp |
26e32e |
--- 1246,1252 ----
|
|
Karsten Hopp |
26e32e |
# endif
|
|
Karsten Hopp |
26e32e |
{(int)KS_CRV, "[CRV]"},
|
|
Karsten Hopp |
26e32e |
{(int)KS_U7, "[U7]"},
|
|
Karsten Hopp |
26e32e |
+ {(int)KS_RBG, "[RBG]"},
|
|
Karsten Hopp |
26e32e |
{K_UP, "[KU]"},
|
|
Karsten Hopp |
26e32e |
{K_DOWN, "[KD]"},
|
|
Karsten Hopp |
26e32e |
{K_LEFT, "[KL]"},
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 3224,3230 ****
|
|
Karsten Hopp |
26e32e |
* doesn't work in Cooked mode, an external program may get
|
|
Karsten Hopp |
26e32e |
* them. */
|
|
Karsten Hopp |
26e32e |
if (tmode != TMODE_RAW && (crv_status == CRV_SENT
|
|
Karsten Hopp |
26e32e |
! || u7_status == U7_SENT))
|
|
Karsten Hopp |
26e32e |
(void)vpeekc_nomap();
|
|
Karsten Hopp |
26e32e |
check_for_codes_from_term();
|
|
Karsten Hopp |
26e32e |
}
|
|
Karsten Hopp |
26e32e |
--- 3231,3238 ----
|
|
Karsten Hopp |
26e32e |
* doesn't work in Cooked mode, an external program may get
|
|
Karsten Hopp |
26e32e |
* them. */
|
|
Karsten Hopp |
26e32e |
if (tmode != TMODE_RAW && (crv_status == CRV_SENT
|
|
Karsten Hopp |
26e32e |
! || u7_status == U7_SENT
|
|
Karsten Hopp |
26e32e |
! || rbg_status == RBG_SENT))
|
|
Karsten Hopp |
26e32e |
(void)vpeekc_nomap();
|
|
Karsten Hopp |
26e32e |
check_for_codes_from_term();
|
|
Karsten Hopp |
26e32e |
}
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 3285,3292 ****
|
|
Karsten Hopp |
26e32e |
if (!gui.in_use && !gui.starting)
|
|
Karsten Hopp |
26e32e |
# endif
|
|
Karsten Hopp |
26e32e |
{
|
|
Karsten Hopp |
26e32e |
! /* May need to discard T_CRV or T_U7 response. */
|
|
Karsten Hopp |
26e32e |
! if (crv_status == CRV_SENT || u7_status == U7_SENT)
|
|
Karsten Hopp |
26e32e |
{
|
|
Karsten Hopp |
26e32e |
# ifdef UNIX
|
|
Karsten Hopp |
26e32e |
/* Give the terminal a chance to respond. */
|
|
Karsten Hopp |
26e32e |
--- 3293,3301 ----
|
|
Karsten Hopp |
26e32e |
if (!gui.in_use && !gui.starting)
|
|
Karsten Hopp |
26e32e |
# endif
|
|
Karsten Hopp |
26e32e |
{
|
|
Karsten Hopp |
26e32e |
! /* May need to discard T_CRV, T_U7 or T_RBG response. */
|
|
Karsten Hopp |
26e32e |
! if (crv_status == CRV_SENT || u7_status == U7_SENT
|
|
Karsten Hopp |
26e32e |
! || rbg_status == RBG_SENT)
|
|
Karsten Hopp |
26e32e |
{
|
|
Karsten Hopp |
26e32e |
# ifdef UNIX
|
|
Karsten Hopp |
26e32e |
/* Give the terminal a chance to respond. */
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 3398,3403 ****
|
|
Karsten Hopp |
26e32e |
--- 3407,3447 ----
|
|
Karsten Hopp |
26e32e |
}
|
|
Karsten Hopp |
26e32e |
# endif
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
+ #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
|
|
Karsten Hopp |
26e32e |
+ /*
|
|
Karsten Hopp |
26e32e |
+ * Check how the terminal treats ambiguous character width (UAX #11).
|
|
Karsten Hopp |
26e32e |
+ * First, we move the cursor to (1, 0) and print a test ambiguous character
|
|
Karsten Hopp |
26e32e |
+ * \u25bd (WHITE DOWN-POINTING TRIANGLE) and query current cursor position.
|
|
Karsten Hopp |
26e32e |
+ * If the terminal treats \u25bd as single width, the position is (1, 1),
|
|
Karsten Hopp |
26e32e |
+ * or if it is treated as double width, that will be (1, 2).
|
|
Karsten Hopp |
26e32e |
+ * This function has the side effect that changes cursor position, so
|
|
Karsten Hopp |
26e32e |
+ * it must be called immediately after entering termcap mode.
|
|
Karsten Hopp |
26e32e |
+ */
|
|
Karsten Hopp |
26e32e |
+ void
|
|
Karsten Hopp |
26e32e |
+ may_req_bg_color()
|
|
Karsten Hopp |
26e32e |
+ {
|
|
Karsten Hopp |
26e32e |
+ if (rbg_status == RBG_GET
|
|
Karsten Hopp |
26e32e |
+ && cur_tmode == TMODE_RAW
|
|
Karsten Hopp |
26e32e |
+ && termcap_active
|
|
Karsten Hopp |
26e32e |
+ && p_ek
|
|
Karsten Hopp |
26e32e |
+ # ifdef UNIX
|
|
Karsten Hopp |
26e32e |
+ && isatty(1)
|
|
Karsten Hopp |
26e32e |
+ && isatty(read_cmd_fd)
|
|
Karsten Hopp |
26e32e |
+ # endif
|
|
Karsten Hopp |
26e32e |
+ && *T_RBG != NUL
|
|
Karsten Hopp |
26e32e |
+ && !option_was_set((char_u *)"bg"))
|
|
Karsten Hopp |
26e32e |
+ {
|
|
Karsten Hopp |
26e32e |
+ LOG_TR("Sending BG request");
|
|
Karsten Hopp |
26e32e |
+ out_str(T_RBG);
|
|
Karsten Hopp |
26e32e |
+ rbg_status = RBG_SENT;
|
|
Karsten Hopp |
26e32e |
+ /* check for the characters now, otherwise they might be eaten by
|
|
Karsten Hopp |
26e32e |
+ * get_keystroke() */
|
|
Karsten Hopp |
26e32e |
+ out_flush();
|
|
Karsten Hopp |
26e32e |
+ (void)vpeekc_nomap();
|
|
Karsten Hopp |
26e32e |
+ }
|
|
Karsten Hopp |
26e32e |
+ }
|
|
Karsten Hopp |
26e32e |
+ # endif
|
|
Karsten Hopp |
26e32e |
+
|
|
Karsten Hopp |
26e32e |
# ifdef DEBUG_TERMRESPONSE
|
|
Karsten Hopp |
26e32e |
static void
|
|
Karsten Hopp |
26e32e |
log_tr(char *msg)
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 4222,4233 ****
|
|
Karsten Hopp |
26e32e |
* - Cursor position report: <Esc>[{row};{col}R
|
|
Karsten Hopp |
26e32e |
* The final byte must be 'R'. It is used for checking the
|
|
Karsten Hopp |
26e32e |
* ambiguous-width character state.
|
|
Karsten Hopp |
26e32e |
*/
|
|
Karsten Hopp |
26e32e |
! p = tp[0] == CSI ? tp + 1 : tp + 2;
|
|
Karsten Hopp |
26e32e |
! if ((*T_CRV != NUL || *T_U7 != NUL)
|
|
Karsten Hopp |
26e32e |
&& ((tp[0] == ESC && tp[1] == '[' && len >= 3)
|
|
Karsten Hopp |
26e32e |
|| (tp[0] == CSI && len >= 2))
|
|
Karsten Hopp |
26e32e |
! && (VIM_ISDIGIT(*p) || *p == '>' || *p == '?'))
|
|
Karsten Hopp |
26e32e |
{
|
|
Karsten Hopp |
26e32e |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
26e32e |
int col;
|
|
Karsten Hopp |
26e32e |
--- 4266,4283 ----
|
|
Karsten Hopp |
26e32e |
* - Cursor position report: <Esc>[{row};{col}R
|
|
Karsten Hopp |
26e32e |
* The final byte must be 'R'. It is used for checking the
|
|
Karsten Hopp |
26e32e |
* ambiguous-width character state.
|
|
Karsten Hopp |
26e32e |
+ *
|
|
Karsten Hopp |
26e32e |
+ * - Background color response:
|
|
Karsten Hopp |
26e32e |
+ * <Esc>]11;rgb:{rrrr}/{gggg}/{bbbb}\007
|
|
Karsten Hopp |
26e32e |
+ * The final byte must be '\007'.
|
|
Karsten Hopp |
26e32e |
*/
|
|
Karsten Hopp |
26e32e |
! char_u *argp = tp[0] == CSI ? tp + 1 : tp + 2;
|
|
Karsten Hopp |
26e32e |
!
|
|
Karsten Hopp |
26e32e |
! if ((*T_CRV != NUL || *T_U7 != NUL || *T_RBG != NUL)
|
|
Karsten Hopp |
26e32e |
&& ((tp[0] == ESC && tp[1] == '[' && len >= 3)
|
|
Karsten Hopp |
26e32e |
+ || (tp[0] == ESC && tp[1] == ']' && len >= 24)
|
|
Karsten Hopp |
26e32e |
|| (tp[0] == CSI && len >= 2))
|
|
Karsten Hopp |
26e32e |
! && (VIM_ISDIGIT(*argp) || *argp == '>' || *argp == '?'))
|
|
Karsten Hopp |
26e32e |
{
|
|
Karsten Hopp |
26e32e |
#ifdef FEAT_MBYTE
|
|
Karsten Hopp |
26e32e |
int col;
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 4363,4368 ****
|
|
Karsten Hopp |
26e32e |
--- 4413,4439 ----
|
|
Karsten Hopp |
26e32e |
key_name[1] = (int)KE_IGNORE;
|
|
Karsten Hopp |
26e32e |
slen = i + 1;
|
|
Karsten Hopp |
26e32e |
}
|
|
Karsten Hopp |
26e32e |
+ else if (*T_RBG != NUL && len >= 24 - (tp[0] == CSI)
|
|
Karsten Hopp |
26e32e |
+ && argp[0] == '1' && argp[1] == '1'
|
|
Karsten Hopp |
26e32e |
+ && argp[2] == ';' && argp[3] == 'r' && argp[4] == 'g'
|
|
Karsten Hopp |
26e32e |
+ && argp[5] == 'b' && argp[6] == ':'
|
|
Karsten Hopp |
26e32e |
+ && argp[11] == '/' && argp[16] == '/'
|
|
Karsten Hopp |
26e32e |
+ && argp[21] == '\007')
|
|
Karsten Hopp |
26e32e |
+ {
|
|
Karsten Hopp |
26e32e |
+ LOG_TR("Received RBG");
|
|
Karsten Hopp |
26e32e |
+ rbg_status = RBG_GOT;
|
|
Karsten Hopp |
26e32e |
+ if (!option_was_set((char_u *)"bg"))
|
|
Karsten Hopp |
26e32e |
+ {
|
|
Karsten Hopp |
26e32e |
+ set_option_value((char_u *)"bg", 0L, (char_u *)(
|
|
Karsten Hopp |
26e32e |
+ (3 * '6' < argp[7] + argp[12] + argp[17])
|
|
Karsten Hopp |
26e32e |
+ ? "light" : "dark"), 0);
|
|
Karsten Hopp |
26e32e |
+ reset_option_was_set((char_u *)"bg");
|
|
Karsten Hopp |
26e32e |
+ redraw_asap(CLEAR);
|
|
Karsten Hopp |
26e32e |
+ }
|
|
Karsten Hopp |
26e32e |
+ key_name[0] = (int)KS_EXTRA;
|
|
Karsten Hopp |
26e32e |
+ key_name[1] = (int)KE_IGNORE;
|
|
Karsten Hopp |
26e32e |
+ slen = 24;
|
|
Karsten Hopp |
26e32e |
+ }
|
|
Karsten Hopp |
26e32e |
}
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
/* Check for '<Esc>P1+r<hex bytes><Esc>\'. A "0" instead of the
|
|
Karsten Hopp |
26e32e |
*** ../vim-7.4.756/src/term.h 2015-03-31 18:30:09.143370872 +0200
|
|
Karsten Hopp |
26e32e |
--- src/term.h 2015-06-25 16:21:55.222506530 +0200
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 79,84 ****
|
|
Karsten Hopp |
26e32e |
--- 79,85 ----
|
|
Karsten Hopp |
26e32e |
KS_CWP, /* set window position in pixels */
|
|
Karsten Hopp |
26e32e |
KS_CWS, /* set window size in characters */
|
|
Karsten Hopp |
26e32e |
KS_CRV, /* request version string */
|
|
Karsten Hopp |
26e32e |
+ KS_RBG, /* request background color */
|
|
Karsten Hopp |
26e32e |
KS_CSI, /* start insert mode (bar cursor) */
|
|
Karsten Hopp |
26e32e |
KS_CEI, /* end insert mode (block cursor) */
|
|
Karsten Hopp |
26e32e |
KS_CSR, /* start replace mode (underline cursor) */
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 162,167 ****
|
|
Karsten Hopp |
26e32e |
--- 163,169 ----
|
|
Karsten Hopp |
26e32e |
#define T_CEI (term_str(KS_CEI)) /* end insert mode */
|
|
Karsten Hopp |
26e32e |
#define T_CSR (term_str(KS_CSR)) /* start replace mode */
|
|
Karsten Hopp |
26e32e |
#define T_CRV (term_str(KS_CRV)) /* request version string */
|
|
Karsten Hopp |
26e32e |
+ #define T_RBG (term_str(KS_RBG)) /* request background RGB */
|
|
Karsten Hopp |
26e32e |
#define T_OP (term_str(KS_OP)) /* original color pair */
|
|
Karsten Hopp |
26e32e |
#define T_U7 (term_str(KS_U7)) /* request cursor position */
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
*** ../vim-7.4.756/src/proto/term.pro 2014-07-30 17:21:53.819518506 +0200
|
|
Karsten Hopp |
26e32e |
--- src/proto/term.pro 2015-06-25 16:39:46.095228111 +0200
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 36,41 ****
|
|
Karsten Hopp |
26e32e |
--- 36,42 ----
|
|
Karsten Hopp |
26e32e |
void stoptermcap __ARGS((void));
|
|
Karsten Hopp |
26e32e |
void may_req_termresponse __ARGS((void));
|
|
Karsten Hopp |
26e32e |
void may_req_ambiguous_char_width __ARGS((void));
|
|
Karsten Hopp |
26e32e |
+ void may_req_bg_color __ARGS((void));
|
|
Karsten Hopp |
26e32e |
int swapping_screen __ARGS((void));
|
|
Karsten Hopp |
26e32e |
void setmouse __ARGS((void));
|
|
Karsten Hopp |
26e32e |
int mouse_has __ARGS((int c));
|
|
Karsten Hopp |
26e32e |
*** ../vim-7.4.756/src/version.c 2015-06-25 16:13:37.779750062 +0200
|
|
Karsten Hopp |
26e32e |
--- src/version.c 2015-06-25 16:20:48.475209933 +0200
|
|
Karsten Hopp |
26e32e |
***************
|
|
Karsten Hopp |
26e32e |
*** 743,744 ****
|
|
Karsten Hopp |
26e32e |
--- 743,746 ----
|
|
Karsten Hopp |
26e32e |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
26e32e |
+ /**/
|
|
Karsten Hopp |
26e32e |
+ 757,
|
|
Karsten Hopp |
26e32e |
/**/
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
--
|
|
Karsten Hopp |
26e32e |
We are the Borg of GNU GPL. We will assimilate your source code.
|
|
Karsten Hopp |
26e32e |
Resistance is futile.
|
|
Karsten Hopp |
26e32e |
|
|
Karsten Hopp |
26e32e |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
26e32e |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
26e32e |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
26e32e |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|