@@ -1369,9 +1369,7 @@ static int need_gather = FALSE; /* need to fill termleader[] */
13691369static char_u termleader [256 + 1 ]; /* for check_termcode() */
13701370#ifdef FEAT_TERMRESPONSE
13711371static int check_for_codes = FALSE; /* check for key code response */
1372- # ifdef MACOS
1373- static int is_terminal_app = FALSE; /* recognized Terminal.app */
1374- # endif
1372+ static int is_not_xterm = FALSE; /* recognized not-really-xterm */
13751373#endif
13761374
13771375 static struct builtin_term *
@@ -3506,13 +3504,10 @@ may_req_ambiguous_char_width(void)
35063504/*
35073505 * Similar to requesting the version string: Request the terminal background
35083506 * color when it is the right moment.
3509- * Also request the cursor shape, if possible.
35103507 */
35113508 void
35123509may_req_bg_color (void )
35133510{
3514- int did_one = FALSE;
3515-
35163511 if (can_get_termresponse () && starting == 0 )
35173512 {
35183513 /* Only request background if t_RB is set and 'background' wasn't
@@ -3524,20 +3519,7 @@ may_req_bg_color(void)
35243519 LOG_TR ("Sending BG request" );
35253520 out_str (T_RBG );
35263521 rbg_status = STATUS_SENT ;
3527- did_one = TRUE;
3528- }
3529-
3530- /* Only request cursor blinking mode if t_RC is set. */
3531- if (rbm_status == STATUS_GET && * T_CRC != NUL )
3532- {
3533- LOG_TR ("Sending BC request" );
3534- out_str (T_CRC );
3535- rbm_status = STATUS_SENT ;
3536- did_one = TRUE;
3537- }
35383522
3539- if (did_one )
3540- {
35413523 /* check for the characters now, otherwise they might be eaten by
35423524 * get_keystroke() */
35433525 out_flush ();
@@ -4505,6 +4487,9 @@ check_termcode(
45054487 key_name [0 ] = (int )KS_EXTRA ;
45064488 key_name [1 ] = (int )KE_IGNORE ;
45074489 slen = i + 1 ;
4490+ # ifdef FEAT_EVAL
4491+ set_vim_var_string (VV_TERMU7RESP , tp , slen );
4492+ # endif
45084493 }
45094494 else
45104495#endif
@@ -4530,6 +4515,8 @@ check_termcode(
45304515
45314516 if (tp [1 + (tp [0 ] != CSI )] == '>' && semicols == 2 )
45324517 {
4518+ int need_flush = FALSE;
4519+
45334520 /* Only set 'ttymouse' automatically if it was not set
45344521 * by the user already. */
45354522 if (!option_was_set ((char_u * )"ttym" ))
@@ -4566,43 +4553,60 @@ check_termcode(
45664553 may_adjust_color_count (256 );
45674554 }
45684555
4556+ /* Detect terminals that set $TERM to something like
4557+ * "xterm-256colors" but are not fully xterm
4558+ * compatible. */
45694559# ifdef MACOS
45704560 /* Mac Terminal.app sends 1;95;0 */
45714561 if (col == 95
45724562 && STRNCMP (tp + extra - 2 , "1;95;0c" , 7 ) == 0 )
4573- {
4574- /* Terminal.app sets $TERM to "xterm-256colors",
4575- * but it's not fully xterm compatible. */
4576- is_terminal_app = TRUE;
4577- }
4563+ is_not_xterm = TRUE;
45784564# endif
4565+ /* Gnome Terminal.app sends 1;4402;0, assuming any
4566+ * version number over 4000 is not an xterm. */
4567+ if (col >= 4000 )
4568+ is_not_xterm = TRUE;
45794569
45804570 /* Only request the cursor style if t_SH and t_RS are
45814571 * set. Not for Terminal.app, it can't handle t_RS, it
45824572 * echoes the characters to the screen. */
45834573 if (rcs_status == STATUS_GET
4584- # ifdef MACOS
4585- && !is_terminal_app
4586- # endif
4574+ && !is_not_xterm
45874575 && * T_CSH != NUL
45884576 && * T_CRS != NUL )
45894577 {
45904578 LOG_TR ("Sending cursor style request" );
45914579 out_str (T_CRS );
45924580 rcs_status = STATUS_SENT ;
4593- out_flush () ;
4581+ need_flush = TRUE ;
45944582 }
4583+
4584+ /* Only request the cursor blink mode if t_RC set. Not
4585+ * for Gnome terminal, it can't handle t_RC, it
4586+ * echoes the characters to the screen. */
4587+ if (rbm_status == STATUS_GET
4588+ && !is_not_xterm
4589+ && * T_CRC != NUL )
4590+ {
4591+ LOG_TR ("Sending cursor blink mode request" );
4592+ out_str (T_CRC );
4593+ rbm_status = STATUS_SENT ;
4594+ need_flush = TRUE;
4595+ }
4596+
4597+ if (need_flush )
4598+ out_flush ();
45954599 }
4600+ slen = i + 1 ;
45964601# ifdef FEAT_EVAL
4597- set_vim_var_string (VV_TERMRESPONSE , tp , i + 1 );
4602+ set_vim_var_string (VV_TERMRESPONSE , tp , slen );
45984603# endif
45994604# ifdef FEAT_AUTOCMD
46004605 apply_autocmds (EVENT_TERMRESPONSE ,
46014606 NULL , NULL , FALSE, curbuf );
46024607# endif
46034608 key_name [0 ] = (int )KS_EXTRA ;
46044609 key_name [1 ] = (int )KE_IGNORE ;
4605- slen = i + 1 ;
46064610 }
46074611
46084612 /* Check blinking cursor from xterm:
@@ -4626,6 +4630,9 @@ check_termcode(
46264630 key_name [0 ] = (int )KS_EXTRA ;
46274631 key_name [1 ] = (int )KE_IGNORE ;
46284632 slen = i + 1 ;
4633+ # ifdef FEAT_EVAL
4634+ set_vim_var_string (VV_TERMBLINKRESP , tp , slen );
4635+ # endif
46294636 }
46304637
46314638 /*
@@ -4714,6 +4721,9 @@ check_termcode(
47144721 /* Sometimes the 0x07 is followed by 0x18, unclear
47154722 * when this happens. */
47164723 ++ slen ;
4724+ # ifdef FEAT_EVAL
4725+ set_vim_var_string (VV_TERMRGBRESP , tp , slen );
4726+ # endif
47174727 break ;
47184728 }
47194729 if (i == len )
@@ -4788,6 +4798,9 @@ check_termcode(
47884798 key_name [0 ] = (int )KS_EXTRA ;
47894799 key_name [1 ] = (int )KE_IGNORE ;
47904800 slen = i + 1 + (tp [i ] == ESC );
4801+ # ifdef FEAT_EVAL
4802+ set_vim_var_string (VV_TERMSTYLERESP , tp , slen );
4803+ # endif
47914804 }
47924805 }
47934806
0 commit comments