comparison src/term.c @ 16625:d4e74f9f7ae9 v8.1.1315

patch 8.1.1315: there is always a delay if a termrequest is never answered commit https://github.com/vim/vim/commit/afd78266c5096574ec057c36fb4a0e56912e9a71 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 10 23:10:31 2019 +0200 patch 8.1.1315: there is always a delay if a termrequest is never answered Problem: There is always a delay if a termrequest is never answered. Solution: When the response is not received within two seconds consider the request to have failed.
author Bram Moolenaar <Bram@vim.org>
date Fri, 10 May 2019 23:15:05 +0200
parents 5ebb2c87d1f5
children e73daa5741d1
comparison
equal deleted inserted replaced
16624:5c53e2a20f0d 16625:d4e74f9f7ae9
108 # define LOG_TR(msg) log_tr msg 108 # define LOG_TR(msg) log_tr msg
109 # else 109 # else
110 # define LOG_TR(msg) do { /**/ } while (0) 110 # define LOG_TR(msg) do { /**/ } while (0)
111 # endif 111 # endif
112 112
113 # define STATUS_GET 1 /* send request when switching to RAW mode */ 113 typedef enum {
114 # define STATUS_SENT 2 /* did send request, waiting for response */ 114 STATUS_GET, // send request when switching to RAW mode
115 # define STATUS_GOT 3 /* received response */ 115 STATUS_SENT, // did send request, checking for response
116 116 STATUS_GOT, // received response
117 /* Request Terminal Version status: */ 117 STATUS_FAIL // timed out
118 static int crv_status = STATUS_GET; 118 } request_progress_T;
119 119
120 /* Request Cursor position report: */ 120 typedef struct {
121 static int u7_status = STATUS_GET; 121 request_progress_T tr_progress;
122 time_t tr_start; // when request was sent, -1 for never
123 } termrequest_T;
124
125 # define TERMREQUEST_INIT {STATUS_GET, -1}
126
127 // Request Terminal Version status:
128 static termrequest_T crv_status = TERMREQUEST_INIT;
129
130 // Request Cursor position report:
131 static termrequest_T u7_status = TERMREQUEST_INIT;
122 132
123 # ifdef FEAT_TERMINAL 133 # ifdef FEAT_TERMINAL
124 /* Request foreground color report: */ 134 // Request foreground color report:
125 static int rfg_status = STATUS_GET; 135 static termrequest_T rfg_status = TERMREQUEST_INIT;
126 static int fg_r = 0; 136 static int fg_r = 0;
127 static int fg_g = 0; 137 static int fg_g = 0;
128 static int fg_b = 0; 138 static int fg_b = 0;
129 static int bg_r = 255; 139 static int bg_r = 255;
130 static int bg_g = 255; 140 static int bg_g = 255;
131 static int bg_b = 255; 141 static int bg_b = 255;
132 # endif 142 # endif
133 143
134 /* Request background color report: */ 144 /* Request background color report: */
135 static int rbg_status = STATUS_GET; 145 static termrequest_T rbg_status = TERMREQUEST_INIT;
136 146
137 /* Request cursor blinking mode report: */ 147 /* Request cursor blinking mode report: */
138 static int rbm_status = STATUS_GET; 148 static termrequest_T rbm_status = TERMREQUEST_INIT;
139 149
140 /* Request cursor style report: */ 150 /* Request cursor style report: */
141 static int rcs_status = STATUS_GET; 151 static termrequest_T rcs_status = TERMREQUEST_INIT;
142 152
143 /* Request windos position report: */ 153 /* Request windos position report: */
144 static int winpos_status = STATUS_GET; 154 static termrequest_T winpos_status = TERMREQUEST_INIT;
155
156 static termrequest_T *all_termrequests[] = {
157 &crv_status,
158 &u7_status,
159 # ifdef FEAT_TERMINAL
160 &rfg_status,
161 # endif
162 &rbg_status,
163 &rbm_status,
164 &rcs_status,
165 &winpos_status,
166 NULL
167 };
145 # endif 168 # endif
146 169
147 /* 170 /*
148 * Don't declare these variables if termcap.h contains them. 171 * Don't declare these variables if termcap.h contains them.
149 * Autoconf checks if these variables should be declared extern (not all 172 * Autoconf checks if these variables should be declared extern (not all
2009 2032
2010 full_screen = TRUE; /* we can use termcap codes from now on */ 2033 full_screen = TRUE; /* we can use termcap codes from now on */
2011 set_term_defaults(); /* use current values as defaults */ 2034 set_term_defaults(); /* use current values as defaults */
2012 #ifdef FEAT_TERMRESPONSE 2035 #ifdef FEAT_TERMRESPONSE
2013 LOG_TR(("setting crv_status to STATUS_GET")); 2036 LOG_TR(("setting crv_status to STATUS_GET"));
2014 crv_status = STATUS_GET; /* Get terminal version later */ 2037 crv_status.tr_progress = STATUS_GET; // Get terminal version later
2015 #endif 2038 #endif
2016 2039
2017 /* 2040 /*
2018 * Initialize the terminal with the appropriate termcap codes. 2041 * Initialize the terminal with the appropriate termcap codes.
2019 * Set the mouse and window title if possible. 2042 * Set the mouse and window title if possible.
2831 static int 2854 static int
2832 can_get_termresponse() 2855 can_get_termresponse()
2833 { 2856 {
2834 return cur_tmode == TMODE_RAW 2857 return cur_tmode == TMODE_RAW
2835 && termcap_active 2858 && termcap_active
2836 # ifdef UNIX 2859 # ifdef UNIX
2837 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) 2860 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd)))
2838 # endif 2861 # endif
2839 && p_ek; 2862 && p_ek;
2863 }
2864
2865 /*
2866 * Set "status" to STATUS_SENT.
2867 */
2868 static void
2869 termrequest_sent(termrequest_T *status)
2870 {
2871 status->tr_progress = STATUS_SENT;
2872 status->tr_start = time(NULL);
2873 }
2874
2875 /*
2876 * Return TRUE if any of the requests are in STATUS_SENT.
2877 */
2878 static int
2879 termrequest_any_pending()
2880 {
2881 int i;
2882 time_t now = time(NULL);
2883
2884 for (i = 0; all_termrequests[i] != NULL; ++i)
2885 {
2886 if (all_termrequests[i]->tr_progress == STATUS_SENT)
2887 {
2888 if (all_termrequests[i]->tr_start > 0 && now > 0
2889 && all_termrequests[i]->tr_start + 2 < now)
2890 // Sent the request more than 2 seconds ago and didn't get a
2891 // response, assume it failed.
2892 all_termrequests[i]->tr_progress = STATUS_FAIL;
2893 else
2894 return TRUE;
2895 }
2896 }
2897 return FALSE;
2840 } 2898 }
2841 2899
2842 static int winpos_x = -1; 2900 static int winpos_x = -1;
2843 static int winpos_y = -1; 2901 static int winpos_y = -1;
2844 static int did_request_winpos = 0; 2902 static int did_request_winpos = 0;
2858 if (*T_CGP == NUL || !can_get_termresponse()) 2916 if (*T_CGP == NUL || !can_get_termresponse())
2859 return FAIL; 2917 return FAIL;
2860 winpos_x = -1; 2918 winpos_x = -1;
2861 winpos_y = -1; 2919 winpos_y = -1;
2862 ++did_request_winpos; 2920 ++did_request_winpos;
2863 winpos_status = STATUS_SENT; 2921 termrequest_sent(&winpos_status);
2864 OUT_STR(T_CGP); 2922 OUT_STR(T_CGP);
2865 out_flush(); 2923 out_flush();
2866 2924
2867 /* Try reading the result for "timeout" msec. */ 2925 /* Try reading the result for "timeout" msec. */
2868 while (count++ <= timeout / 10 && !got_int) 2926 while (count++ <= timeout / 10 && !got_int)
3476 #ifdef FEAT_TERMRESPONSE 3534 #ifdef FEAT_TERMRESPONSE
3477 # ifdef FEAT_GUI 3535 # ifdef FEAT_GUI
3478 if (!gui.in_use && !gui.starting) 3536 if (!gui.in_use && !gui.starting)
3479 # endif 3537 # endif
3480 { 3538 {
3481 /* May need to check for T_CRV response and termcodes, it 3539 // May need to check for T_CRV response and termcodes, it
3482 * doesn't work in Cooked mode, an external program may get 3540 // doesn't work in Cooked mode, an external program may get
3483 * them. */ 3541 // them.
3484 if (tmode != TMODE_RAW && (crv_status == STATUS_SENT 3542 if (tmode != TMODE_RAW && termrequest_any_pending())
3485 || u7_status == STATUS_SENT
3486 #ifdef FEAT_TERMINAL
3487 || rfg_status == STATUS_SENT
3488 #endif
3489 || rbg_status == STATUS_SENT
3490 || rbm_status == STATUS_SENT
3491 || rcs_status == STATUS_SENT
3492 || winpos_status == STATUS_SENT))
3493 (void)vpeekc_nomap(); 3543 (void)vpeekc_nomap();
3494 check_for_codes_from_term(); 3544 check_for_codes_from_term();
3495 } 3545 }
3496 #endif 3546 #endif
3497 #ifdef FEAT_MOUSE_TTY 3547 #ifdef FEAT_MOUSE_TTY
3538 # endif 3588 # endif
3539 { 3589 {
3540 may_req_termresponse(); 3590 may_req_termresponse();
3541 /* Immediately check for a response. If t_Co changes, we don't 3591 /* Immediately check for a response. If t_Co changes, we don't
3542 * want to redraw with wrong colors first. */ 3592 * want to redraw with wrong colors first. */
3543 if (crv_status == STATUS_SENT) 3593 if (crv_status.tr_progress == STATUS_SENT)
3544 check_for_codes_from_term(); 3594 check_for_codes_from_term();
3545 } 3595 }
3546 #endif 3596 #endif
3547 } 3597 }
3548 } 3598 }
3557 #ifdef FEAT_TERMRESPONSE 3607 #ifdef FEAT_TERMRESPONSE
3558 # ifdef FEAT_GUI 3608 # ifdef FEAT_GUI
3559 if (!gui.in_use && !gui.starting) 3609 if (!gui.in_use && !gui.starting)
3560 # endif 3610 # endif
3561 { 3611 {
3562 /* May need to discard T_CRV, T_U7 or T_RBG response. */ 3612 // May need to discard T_CRV, T_U7 or T_RBG response.
3563 if (crv_status == STATUS_SENT 3613 if (termrequest_any_pending())
3564 || u7_status == STATUS_SENT
3565 # ifdef FEAT_TERMINAL
3566 || rfg_status == STATUS_SENT
3567 # endif
3568 || rbg_status == STATUS_SENT
3569 || rbm_status == STATUS_SENT
3570 || rcs_status == STATUS_SENT
3571 || winpos_status == STATUS_SENT)
3572 { 3614 {
3573 # ifdef UNIX 3615 # ifdef UNIX
3574 /* Give the terminal a chance to respond. */ 3616 // Give the terminal a chance to respond.
3575 mch_delay(100L, FALSE); 3617 mch_delay(100L, FALSE);
3576 # endif 3618 # endif
3577 # ifdef TCIFLUSH 3619 # ifdef TCIFLUSH
3578 /* Discard data received but not read. */ 3620 // Discard data received but not read.
3579 if (exiting) 3621 if (exiting)
3580 tcflush(fileno(stdin), TCIFLUSH); 3622 tcflush(fileno(stdin), TCIFLUSH);
3581 # endif 3623 # endif
3582 } 3624 }
3583 /* Check for termcodes first, otherwise an external program may 3625 /* Check for termcodes first, otherwise an external program may
3612 * The result is caught in check_termcode(). 3654 * The result is caught in check_termcode().
3613 */ 3655 */
3614 void 3656 void
3615 may_req_termresponse(void) 3657 may_req_termresponse(void)
3616 { 3658 {
3617 if (crv_status == STATUS_GET 3659 if (crv_status.tr_progress == STATUS_GET
3618 && can_get_termresponse() 3660 && can_get_termresponse()
3619 && starting == 0 3661 && starting == 0
3620 && *T_CRV != NUL) 3662 && *T_CRV != NUL)
3621 { 3663 {
3622 LOG_TR(("Sending CRV request")); 3664 LOG_TR(("Sending CRV request"));
3623 out_str(T_CRV); 3665 out_str(T_CRV);
3624 crv_status = STATUS_SENT; 3666 termrequest_sent(&crv_status);
3625 /* check for the characters now, otherwise they might be eaten by 3667 /* check for the characters now, otherwise they might be eaten by
3626 * get_keystroke() */ 3668 * get_keystroke() */
3627 out_flush(); 3669 out_flush();
3628 (void)vpeekc_nomap(); 3670 (void)vpeekc_nomap();
3629 } 3671 }
3639 * it must be called immediately after entering termcap mode. 3681 * it must be called immediately after entering termcap mode.
3640 */ 3682 */
3641 void 3683 void
3642 may_req_ambiguous_char_width(void) 3684 may_req_ambiguous_char_width(void)
3643 { 3685 {
3644 if (u7_status == STATUS_GET 3686 if (u7_status.tr_progress == STATUS_GET
3645 && can_get_termresponse() 3687 && can_get_termresponse()
3646 && starting == 0 3688 && starting == 0
3647 && *T_U7 != NUL 3689 && *T_U7 != NUL
3648 && !option_was_set((char_u *)"ambiwidth")) 3690 && !option_was_set((char_u *)"ambiwidth"))
3649 { 3691 {
3650 char_u buf[16]; 3692 char_u buf[16];
3651 3693
3652 LOG_TR(("Sending U7 request")); 3694 LOG_TR(("Sending U7 request"));
3653 /* Do this in the second row. In the first row the returned sequence 3695 /* Do this in the second row. In the first row the returned sequence
3654 * may be CSI 1;2R, which is the same as <S-F3>. */ 3696 * may be CSI 1;2R, which is the same as <S-F3>. */
3655 term_windgoto(1, 0); 3697 term_windgoto(1, 0);
3656 buf[mb_char2bytes(0x25bd, buf)] = 0; 3698 buf[mb_char2bytes(0x25bd, buf)] = 0;
3657 out_str(buf); 3699 out_str(buf);
3658 out_str(T_U7); 3700 out_str(T_U7);
3659 u7_status = STATUS_SENT; 3701 termrequest_sent(&u7_status);
3660 out_flush(); 3702 out_flush();
3661 3703
3662 /* This overwrites a few characters on the screen, a redraw is needed 3704 /* This overwrites a few characters on the screen, a redraw is needed
3663 * after this. Clear them out for now. */ 3705 * after this. Clear them out for now. */
3664 term_windgoto(1, 0); 3706 term_windgoto(1, 0);
3665 out_str((char_u *)" "); 3707 out_str((char_u *)" ");
3666 term_windgoto(0, 0); 3708 term_windgoto(0, 0);
3667 3709
3668 /* Need to reset the known cursor position. */ 3710 /* Need to reset the known cursor position. */
3669 screen_start(); 3711 screen_start();
3670 3712
3671 /* check for the characters now, otherwise they might be eaten by 3713 /* check for the characters now, otherwise they might be eaten by
3672 * get_keystroke() */ 3714 * get_keystroke() */
3673 out_flush(); 3715 out_flush();
3674 (void)vpeekc_nomap(); 3716 (void)vpeekc_nomap();
3675 } 3717 }
3676 } 3718 }
3677 3719
3678 /* 3720 /*
3679 * Similar to requesting the version string: Request the terminal background 3721 * Similar to requesting the version string: Request the terminal background
3686 { 3728 {
3687 int didit = FALSE; 3729 int didit = FALSE;
3688 3730
3689 # ifdef FEAT_TERMINAL 3731 # ifdef FEAT_TERMINAL
3690 /* Only request foreground if t_RF is set. */ 3732 /* Only request foreground if t_RF is set. */
3691 if (rfg_status == STATUS_GET && *T_RFG != NUL) 3733 if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL)
3692 { 3734 {
3693 LOG_TR(("Sending FG request")); 3735 LOG_TR(("Sending FG request"));
3694 out_str(T_RFG); 3736 out_str(T_RFG);
3695 rfg_status = STATUS_SENT; 3737 termrequest_sent(&rfg_status);
3696 didit = TRUE; 3738 didit = TRUE;
3697 } 3739 }
3698 # endif 3740 # endif
3699 3741
3700 /* Only request background if t_RB is set. */ 3742 /* Only request background if t_RB is set. */
3701 if (rbg_status == STATUS_GET && *T_RBG != NUL) 3743 if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL)
3702 { 3744 {
3703 LOG_TR(("Sending BG request")); 3745 LOG_TR(("Sending BG request"));
3704 out_str(T_RBG); 3746 out_str(T_RBG);
3705 rbg_status = STATUS_SENT; 3747 termrequest_sent(&rbg_status);
3706 didit = TRUE; 3748 didit = TRUE;
3707 } 3749 }
3708 3750
3709 if (didit) 3751 if (didit)
3710 { 3752 {
3960 4002
3961 int 4003 int
3962 blink_state_is_inverted() 4004 blink_state_is_inverted()
3963 { 4005 {
3964 #ifdef FEAT_TERMRESPONSE 4006 #ifdef FEAT_TERMRESPONSE
3965 return rbm_status == STATUS_GOT && rcs_status == STATUS_GOT 4007 return rbm_status.tr_progress == STATUS_GOT && rcs_status.tr_progress == STATUS_GOT
3966 && initial_cursor_blink != initial_cursor_shape_blink; 4008 && initial_cursor_blink != initial_cursor_shape_blink;
3967 #else 4009 #else
3968 return FALSE; 4010 return FALSE;
3969 #endif 4011 #endif
3970 } 4012 }
4649 if (row_char == '2' && col >= 2) 4691 if (row_char == '2' && col >= 2)
4650 { 4692 {
4651 char *aw = NULL; 4693 char *aw = NULL;
4652 4694
4653 LOG_TR(("Received U7 status: %s", tp)); 4695 LOG_TR(("Received U7 status: %s", tp));
4654 u7_status = STATUS_GOT; 4696 u7_status.tr_progress = STATUS_GOT;
4655 did_cursorhold = TRUE; 4697 did_cursorhold = TRUE;
4656 if (col == 2) 4698 if (col == 2)
4657 aw = "single"; 4699 aw = "single";
4658 else if (col == 3) 4700 else if (col == 3)
4659 aw = "double"; 4701 aw = "double";
4687 && tp[i] == 'c') 4729 && tp[i] == 'c')
4688 { 4730 {
4689 int version = col; 4731 int version = col;
4690 4732
4691 LOG_TR(("Received CRV response: %s", tp)); 4733 LOG_TR(("Received CRV response: %s", tp));
4692 crv_status = STATUS_GOT; 4734 crv_status.tr_progress = STATUS_GOT;
4693 did_cursorhold = TRUE; 4735 did_cursorhold = TRUE;
4694 4736
4695 /* If this code starts with CSI, you can bet that the 4737 /* If this code starts with CSI, you can bet that the
4696 * terminal uses 8-bit codes. */ 4738 * terminal uses 8-bit codes. */
4697 if (tp[0] == CSI) 4739 if (tp[0] == CSI)
4802 /* Only request the cursor style if t_SH and t_RS are 4844 /* Only request the cursor style if t_SH and t_RS are
4803 * set. Only supported properly by xterm since version 4845 * set. Only supported properly by xterm since version
4804 * 279 (otherwise it returns 0x18). 4846 * 279 (otherwise it returns 0x18).
4805 * Not for Terminal.app, it can't handle t_RS, it 4847 * Not for Terminal.app, it can't handle t_RS, it
4806 * echoes the characters to the screen. */ 4848 * echoes the characters to the screen. */
4807 if (rcs_status == STATUS_GET 4849 if (rcs_status.tr_progress == STATUS_GET
4808 && version >= 279 4850 && version >= 279
4809 && !is_not_xterm 4851 && !is_not_xterm
4810 && *T_CSH != NUL 4852 && *T_CSH != NUL
4811 && *T_CRS != NUL) 4853 && *T_CRS != NUL)
4812 { 4854 {
4813 LOG_TR(("Sending cursor style request")); 4855 LOG_TR(("Sending cursor style request"));
4814 out_str(T_CRS); 4856 out_str(T_CRS);
4815 rcs_status = STATUS_SENT; 4857 termrequest_sent(&rcs_status);
4816 need_flush = TRUE; 4858 need_flush = TRUE;
4817 } 4859 }
4818 4860
4819 /* Only request the cursor blink mode if t_RC set. Not 4861 /* Only request the cursor blink mode if t_RC set. Not
4820 * for Gnome terminal, it can't handle t_RC, it 4862 * for Gnome terminal, it can't handle t_RC, it
4821 * echoes the characters to the screen. */ 4863 * echoes the characters to the screen. */
4822 if (rbm_status == STATUS_GET 4864 if (rbm_status.tr_progress == STATUS_GET
4823 && !is_not_xterm 4865 && !is_not_xterm
4824 && *T_CRC != NUL) 4866 && *T_CRC != NUL)
4825 { 4867 {
4826 LOG_TR(("Sending cursor blink mode request")); 4868 LOG_TR(("Sending cursor blink mode request"));
4827 out_str(T_CRC); 4869 out_str(T_CRC);
4828 rbm_status = STATUS_SENT; 4870 termrequest_sent(&rbm_status);
4829 need_flush = TRUE; 4871 need_flush = TRUE;
4830 } 4872 }
4831 4873
4832 if (need_flush) 4874 if (need_flush)
4833 out_flush(); 4875 out_flush();
4846 * {lead}?12;1$y set 4888 * {lead}?12;1$y set
4847 * {lead}?12;2$y not set 4889 * {lead}?12;2$y not set
4848 * 4890 *
4849 * {lead} can be <Esc>[ or CSI 4891 * {lead} can be <Esc>[ or CSI
4850 */ 4892 */
4851 else if (rbm_status == STATUS_SENT 4893 else if (rbm_status.tr_progress == STATUS_SENT
4852 && tp[(j = 1 + (tp[0] == ESC))] == '?' 4894 && tp[(j = 1 + (tp[0] == ESC))] == '?'
4853 && i == j + 6 4895 && i == j + 6
4854 && tp[j + 1] == '1' 4896 && tp[j + 1] == '1'
4855 && tp[j + 2] == '2' 4897 && tp[j + 2] == '2'
4856 && tp[j + 3] == ';' 4898 && tp[j + 3] == ';'
4857 && tp[i - 1] == '$' 4899 && tp[i - 1] == '$'
4858 && tp[i] == 'y') 4900 && tp[i] == 'y')
4859 { 4901 {
4860 initial_cursor_blink = (tp[j + 4] == '1'); 4902 initial_cursor_blink = (tp[j + 4] == '1');
4861 rbm_status = STATUS_GOT; 4903 rbm_status.tr_progress = STATUS_GOT;
4862 LOG_TR(("Received cursor blinking mode response: %s", tp)); 4904 LOG_TR(("Received cursor blinking mode response: %s", tp));
4863 key_name[0] = (int)KS_EXTRA; 4905 key_name[0] = (int)KS_EXTRA;
4864 key_name[1] = (int)KE_IGNORE; 4906 key_name[1] = (int)KE_IGNORE;
4865 slen = i + 1; 4907 slen = i + 1;
4866 # ifdef FEAT_EVAL 4908 # ifdef FEAT_EVAL
4894 key_name[0] = (int)KS_EXTRA; 4936 key_name[0] = (int)KS_EXTRA;
4895 key_name[1] = (int)KE_IGNORE; 4937 key_name[1] = (int)KE_IGNORE;
4896 slen = i + 1; 4938 slen = i + 1;
4897 4939
4898 if (--did_request_winpos <= 0) 4940 if (--did_request_winpos <= 0)
4899 winpos_status = STATUS_GOT; 4941 winpos_status.tr_progress = STATUS_GOT;
4900 } 4942 }
4901 } 4943 }
4902 if (i == len) 4944 if (i == len)
4903 { 4945 {
4904 LOG_TR(("not enough characters for winpos")); 4946 LOG_TR(("not enough characters for winpos"));
4946 { 4988 {
4947 char *newval = (3 * '6' < tp[j+7] + tp[j+12] 4989 char *newval = (3 * '6' < tp[j+7] + tp[j+12]
4948 + tp[j+17]) ? "light" : "dark"; 4990 + tp[j+17]) ? "light" : "dark";
4949 4991
4950 LOG_TR(("Received RBG response: %s", tp)); 4992 LOG_TR(("Received RBG response: %s", tp));
4951 rbg_status = STATUS_GOT; 4993 rbg_status.tr_progress = STATUS_GOT;
4952 # ifdef FEAT_TERMINAL 4994 # ifdef FEAT_TERMINAL
4953 bg_r = rval; 4995 bg_r = rval;
4954 bg_g = gval; 4996 bg_g = gval;
4955 bg_b = bval; 4997 bg_b = bval;
4956 # endif 4998 # endif
4966 } 5008 }
4967 # ifdef FEAT_TERMINAL 5009 # ifdef FEAT_TERMINAL
4968 else 5010 else
4969 { 5011 {
4970 LOG_TR(("Received RFG response: %s", tp)); 5012 LOG_TR(("Received RFG response: %s", tp));
4971 rfg_status = STATUS_GOT; 5013 rfg_status.tr_progress = STATUS_GOT;
4972 fg_r = rval; 5014 fg_r = rval;
4973 fg_g = gval; 5015 fg_g = gval;
4974 fg_b = bval; 5016 fg_b = bval;
4975 } 5017 }
4976 # endif 5018 # endif
5006 * {lead} can be <Esc>P or DCS 5048 * {lead} can be <Esc>P or DCS
5007 * {tail} can be Esc>\ or STERM 5049 * {tail} can be Esc>\ or STERM
5008 * 5050 *
5009 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". 5051 * Consume any code that starts with "{lead}.+r" or "{lead}.$r".
5010 */ 5052 */
5011 else if ((check_for_codes || rcs_status == STATUS_SENT) 5053 else if ((check_for_codes || rcs_status.tr_progress == STATUS_SENT)
5012 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') 5054 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P')
5013 || tp[0] == DCS)) 5055 || tp[0] == DCS))
5014 { 5056 {
5015 j = 1 + (tp[0] == ESC); 5057 j = 1 + (tp[0] == ESC);
5016 if (len < j + 3) 5058 if (len < j + 3)
5059 initial_cursor_shape = (number + 1) / 2; 5101 initial_cursor_shape = (number + 1) / 2;
5060 /* The blink flag is actually inverted, compared to 5102 /* The blink flag is actually inverted, compared to
5061 * the value set with T_SH. */ 5103 * the value set with T_SH. */
5062 initial_cursor_shape_blink = 5104 initial_cursor_shape_blink =
5063 (number & 1) ? FALSE : TRUE; 5105 (number & 1) ? FALSE : TRUE;
5064 rcs_status = STATUS_GOT; 5106 rcs_status.tr_progress = STATUS_GOT;
5065 LOG_TR(("Received cursor shape response: %s", tp)); 5107 LOG_TR(("Received cursor shape response: %s", tp));
5066 5108
5067 key_name[0] = (int)KS_EXTRA; 5109 key_name[0] = (int)KS_EXTRA;
5068 key_name[1] = (int)KE_IGNORE; 5110 key_name[1] = (int)KE_IGNORE;
5069 slen = i + 1; 5111 slen = i + 1;
6043 * Get the text foreground color, if known. 6085 * Get the text foreground color, if known.
6044 */ 6086 */
6045 void 6087 void
6046 term_get_fg_color(char_u *r, char_u *g, char_u *b) 6088 term_get_fg_color(char_u *r, char_u *g, char_u *b)
6047 { 6089 {
6048 if (rfg_status == STATUS_GOT) 6090 if (rfg_status.tr_progress == STATUS_GOT)
6049 { 6091 {
6050 *r = fg_r; 6092 *r = fg_r;
6051 *g = fg_g; 6093 *g = fg_g;
6052 *b = fg_b; 6094 *b = fg_b;
6053 } 6095 }
6057 * Get the text background color, if known. 6099 * Get the text background color, if known.
6058 */ 6100 */
6059 void 6101 void
6060 term_get_bg_color(char_u *r, char_u *g, char_u *b) 6102 term_get_bg_color(char_u *r, char_u *g, char_u *b)
6061 { 6103 {
6062 if (rbg_status == STATUS_GOT) 6104 if (rbg_status.tr_progress == STATUS_GOT)
6063 { 6105 {
6064 *r = bg_r; 6106 *r = bg_r;
6065 *g = bg_g; 6107 *g = bg_g;
6066 *b = bg_b; 6108 *b = bg_b;
6067 } 6109 }