Mercurial > vim
comparison src/term.c @ 12170:1345621ecdfb v8.0.0965
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
commit https://github.com/vim/vim/commit/3eee06e7d4c3a8e2dbb2577a1eef0e0f108e0288
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 19 19:40:50 2017 +0200
patch 8.0.0965: not restoring cursor shape after it was set in a terminal
Problem: The cursor shape is not reset after it was changed in a terminal.
Solution: Request the original cursor shape and restore it. Add t_RS.
Do not add t_SH for now, it does not work properly.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 19 Aug 2017 19:45:04 +0200 |
parents | d21b8f31b296 |
children | 444793fce117 |
comparison
equal
deleted
inserted
replaced
12169:28f606bb906c | 12170:1345621ecdfb |
---|---|
112 static void log_tr(char *msg); | 112 static void log_tr(char *msg); |
113 # define LOG_TR(msg) log_tr(msg) | 113 # define LOG_TR(msg) log_tr(msg) |
114 # else | 114 # else |
115 # define LOG_TR(msg) | 115 # define LOG_TR(msg) |
116 # endif | 116 # endif |
117 | |
118 # define STATUS_GET 1 /* send request when switching to RAW mode */ | |
119 # define STATUS_SENT 2 /* did send request, waiting for response */ | |
120 # define STATUS_GOT 3 /* received response */ | |
121 | |
117 /* Request Terminal Version status: */ | 122 /* Request Terminal Version status: */ |
118 # define CRV_GET 1 /* send T_CRV when switched to RAW mode */ | 123 static int crv_status = STATUS_GET; |
119 # define CRV_SENT 2 /* did send T_CRV, waiting for answer */ | 124 |
120 # define CRV_GOT 3 /* received T_CRV response */ | |
121 static int crv_status = CRV_GET; | |
122 /* Request Cursor position report: */ | 125 /* Request Cursor position report: */ |
123 # define U7_GET 1 /* send T_U7 when switched to RAW mode */ | 126 static int u7_status = STATUS_GET; |
124 # define U7_SENT 2 /* did send T_U7, waiting for answer */ | 127 |
125 # define U7_GOT 3 /* received T_U7 response */ | |
126 static int u7_status = U7_GET; | |
127 /* Request background color report: */ | 128 /* Request background color report: */ |
128 # define RBG_GET 1 /* send T_RBG when switched to RAW mode */ | 129 static int rbg_status = STATUS_GET; |
129 # define RBG_SENT 2 /* did send T_RBG, waiting for answer */ | 130 |
130 # define RBG_GOT 3 /* received T_RBG response */ | 131 /* Request cursor mode report: */ |
131 static int rbg_status = RBG_GET; | 132 static int rcm_status = STATUS_GET; |
132 # endif | 133 # endif |
133 | 134 |
134 /* | 135 /* |
135 * Don't declare these variables if termcap.h contains them. | 136 * Don't declare these variables if termcap.h contains them. |
136 * Autoconf checks if these variables should be declared extern (not all | 137 * Autoconf checks if these variables should be declared extern (not all |
157 # define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) | 158 # define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) |
158 static char_u *vim_tgetstr(char *s, char_u **pp); | 159 static char_u *vim_tgetstr(char *s, char_u **pp); |
159 #endif /* HAVE_TGETENT */ | 160 #endif /* HAVE_TGETENT */ |
160 | 161 |
161 static int detected_8bit = FALSE; /* detected 8-bit terminal */ | 162 static int detected_8bit = FALSE; /* detected 8-bit terminal */ |
163 | |
164 /* When the cursor shape was detected these values are used: | |
165 * 1: block, 2: underline, 3: vertical bar | |
166 * initial_cursor_blink is only valid when initial_cursor_shape is not zero. */ | |
167 static int initial_cursor_shape = 0; | |
168 static int initial_cursor_blink = FALSE; | |
162 | 169 |
163 static struct builtin_term builtin_termcaps[] = | 170 static struct builtin_term builtin_termcaps[] = |
164 { | 171 { |
165 | 172 |
166 #if defined(FEAT_GUI) | 173 #if defined(FEAT_GUI) |
818 {(int)KS_UT, "y"}, | 825 {(int)KS_UT, "y"}, |
819 {(int)KS_LE, "\b"}, | 826 {(int)KS_LE, "\b"}, |
820 {(int)KS_VI, IF_EB("\033[?25l", ESC_STR "[?25l")}, | 827 {(int)KS_VI, IF_EB("\033[?25l", ESC_STR "[?25l")}, |
821 {(int)KS_VE, IF_EB("\033[?25h", ESC_STR "[?25h")}, | 828 {(int)KS_VE, IF_EB("\033[?25h", ESC_STR "[?25h")}, |
822 {(int)KS_VS, IF_EB("\033[?12h", ESC_STR "[?12h")}, | 829 {(int)KS_VS, IF_EB("\033[?12h", ESC_STR "[?12h")}, |
830 #if 0 | |
831 /* This is currently disabled, because we cannot reliably restore the | |
832 * cursor because of what appears to be an xterm bug. */ | |
823 # ifdef TERMINFO | 833 # ifdef TERMINFO |
824 {(int)KS_CSH, IF_EB("\033[%p1%d q", ESC_STR "[%p1%d q")}, | 834 {(int)KS_CSH, IF_EB("\033[%p1%d q", ESC_STR "[%p1%d q")}, |
825 # else | 835 # else |
826 {(int)KS_CSH, IF_EB("\033[%d q", ESC_STR "[%d q")}, | 836 {(int)KS_CSH, IF_EB("\033[%d q", ESC_STR "[%d q")}, |
827 # endif | 837 # endif |
838 #endif | |
839 {(int)KS_CRS, IF_EB("\033P$q q\033\\", ESC_STR "P$q q" ESC_STR "\\")}, | |
828 # ifdef TERMINFO | 840 # ifdef TERMINFO |
829 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", | 841 {(int)KS_CM, IF_EB("\033[%i%p1%d;%p2%dH", |
830 ESC_STR "[%i%p1%d;%p2%dH")}, | 842 ESC_STR "[%i%p1%d;%p2%dH")}, |
831 # else | 843 # else |
832 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, | 844 {(int)KS_CM, IF_EB("\033[%i%d;%dH", ESC_STR "[%i%d;%dH")}, |
1801 * Any "stty" settings override the default for t_kb from the termcap. | 1813 * Any "stty" settings override the default for t_kb from the termcap. |
1802 * This is in os_unix.c, because it depends a lot on the version of unix that | 1814 * This is in os_unix.c, because it depends a lot on the version of unix that |
1803 * is being used. | 1815 * is being used. |
1804 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. | 1816 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. |
1805 */ | 1817 */ |
1806 #ifdef FEAT_GUI | 1818 # ifdef FEAT_GUI |
1807 if (!gui.in_use) | 1819 if (!gui.in_use) |
1808 #endif | 1820 # endif |
1809 get_stty(); | 1821 get_stty(); |
1810 #endif | 1822 #endif |
1811 | 1823 |
1812 /* | 1824 /* |
1813 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also | 1825 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also |
1904 ttest(TRUE); /* make sure we have a valid set of terminal codes */ | 1916 ttest(TRUE); /* make sure we have a valid set of terminal codes */ |
1905 | 1917 |
1906 full_screen = TRUE; /* we can use termcap codes from now on */ | 1918 full_screen = TRUE; /* we can use termcap codes from now on */ |
1907 set_term_defaults(); /* use current values as defaults */ | 1919 set_term_defaults(); /* use current values as defaults */ |
1908 #ifdef FEAT_TERMRESPONSE | 1920 #ifdef FEAT_TERMRESPONSE |
1909 LOG_TR("setting crv_status to CRV_GET"); | 1921 LOG_TR("setting crv_status to STATUS_GET"); |
1910 crv_status = CRV_GET; /* Get terminal version later */ | 1922 crv_status = STATUS_GET; /* Get terminal version later */ |
1911 #endif | 1923 #endif |
1912 | 1924 |
1913 /* | 1925 /* |
1914 * Initialize the terminal with the appropriate termcap codes. | 1926 * Initialize the terminal with the appropriate termcap codes. |
1915 * Set the mouse and window title if possible. | 1927 * Set the mouse and window title if possible. |
3296 # endif | 3308 # endif |
3297 { | 3309 { |
3298 /* May need to check for T_CRV response and termcodes, it | 3310 /* May need to check for T_CRV response and termcodes, it |
3299 * doesn't work in Cooked mode, an external program may get | 3311 * doesn't work in Cooked mode, an external program may get |
3300 * them. */ | 3312 * them. */ |
3301 if (tmode != TMODE_RAW && (crv_status == CRV_SENT | 3313 if (tmode != TMODE_RAW && (crv_status == STATUS_SENT |
3302 || u7_status == U7_SENT | 3314 || u7_status == STATUS_SENT |
3303 || rbg_status == RBG_SENT)) | 3315 || rbg_status == STATUS_SENT |
3316 || rcm_status == STATUS_SENT)) | |
3304 (void)vpeekc_nomap(); | 3317 (void)vpeekc_nomap(); |
3305 check_for_codes_from_term(); | 3318 check_for_codes_from_term(); |
3306 } | 3319 } |
3307 #endif | 3320 #endif |
3308 #ifdef FEAT_MOUSE_TTY | 3321 #ifdef FEAT_MOUSE_TTY |
3345 # endif | 3358 # endif |
3346 { | 3359 { |
3347 may_req_termresponse(); | 3360 may_req_termresponse(); |
3348 /* Immediately check for a response. If t_Co changes, we don't | 3361 /* Immediately check for a response. If t_Co changes, we don't |
3349 * want to redraw with wrong colors first. */ | 3362 * want to redraw with wrong colors first. */ |
3350 if (crv_status == CRV_SENT) | 3363 if (crv_status == STATUS_SENT) |
3351 check_for_codes_from_term(); | 3364 check_for_codes_from_term(); |
3352 } | 3365 } |
3353 #endif | 3366 #endif |
3354 } | 3367 } |
3355 } | 3368 } |
3365 # ifdef FEAT_GUI | 3378 # ifdef FEAT_GUI |
3366 if (!gui.in_use && !gui.starting) | 3379 if (!gui.in_use && !gui.starting) |
3367 # endif | 3380 # endif |
3368 { | 3381 { |
3369 /* May need to discard T_CRV, T_U7 or T_RBG response. */ | 3382 /* May need to discard T_CRV, T_U7 or T_RBG response. */ |
3370 if (crv_status == CRV_SENT || u7_status == U7_SENT | 3383 if (crv_status == STATUS_SENT |
3371 || rbg_status == RBG_SENT) | 3384 || u7_status == STATUS_SENT |
3385 || rbg_status == STATUS_SENT | |
3386 || rcm_status == STATUS_SENT) | |
3372 { | 3387 { |
3373 # ifdef UNIX | 3388 # ifdef UNIX |
3374 /* Give the terminal a chance to respond. */ | 3389 /* Give the terminal a chance to respond. */ |
3375 mch_delay(100L, FALSE); | 3390 mch_delay(100L, FALSE); |
3376 # endif | 3391 # endif |
3412 * The result is caught in check_termcode(). | 3427 * The result is caught in check_termcode(). |
3413 */ | 3428 */ |
3414 void | 3429 void |
3415 may_req_termresponse(void) | 3430 may_req_termresponse(void) |
3416 { | 3431 { |
3417 if (crv_status == CRV_GET | 3432 if (crv_status == STATUS_GET |
3418 && can_get_termresponse() | 3433 && can_get_termresponse() |
3419 && starting == 0 | 3434 && starting == 0 |
3420 && *T_CRV != NUL) | 3435 && *T_CRV != NUL) |
3421 { | 3436 { |
3422 LOG_TR("Sending CRV"); | 3437 LOG_TR("Sending CRV request"); |
3423 out_str(T_CRV); | 3438 out_str(T_CRV); |
3424 crv_status = CRV_SENT; | 3439 crv_status = STATUS_SENT; |
3425 /* check for the characters now, otherwise they might be eaten by | 3440 /* check for the characters now, otherwise they might be eaten by |
3426 * get_keystroke() */ | 3441 * get_keystroke() */ |
3427 out_flush(); | 3442 out_flush(); |
3428 (void)vpeekc_nomap(); | 3443 (void)vpeekc_nomap(); |
3429 } | 3444 } |
3440 * it must be called immediately after entering termcap mode. | 3455 * it must be called immediately after entering termcap mode. |
3441 */ | 3456 */ |
3442 void | 3457 void |
3443 may_req_ambiguous_char_width(void) | 3458 may_req_ambiguous_char_width(void) |
3444 { | 3459 { |
3445 if (u7_status == U7_GET | 3460 if (u7_status == STATUS_GET |
3446 && can_get_termresponse() | 3461 && can_get_termresponse() |
3447 && starting == 0 | 3462 && starting == 0 |
3448 && *T_U7 != NUL | 3463 && *T_U7 != NUL |
3449 && !option_was_set((char_u *)"ambiwidth")) | 3464 && !option_was_set((char_u *)"ambiwidth")) |
3450 { | 3465 { |
3455 * may be CSI 1;2R, which is the same as <S-F3>. */ | 3470 * may be CSI 1;2R, which is the same as <S-F3>. */ |
3456 term_windgoto(1, 0); | 3471 term_windgoto(1, 0); |
3457 buf[mb_char2bytes(0x25bd, buf)] = 0; | 3472 buf[mb_char2bytes(0x25bd, buf)] = 0; |
3458 out_str(buf); | 3473 out_str(buf); |
3459 out_str(T_U7); | 3474 out_str(T_U7); |
3460 u7_status = U7_SENT; | 3475 u7_status = STATUS_SENT; |
3461 out_flush(); | 3476 out_flush(); |
3462 | 3477 |
3463 /* This overwrites a few characters on the screen, a redraw is needed | 3478 /* This overwrites a few characters on the screen, a redraw is needed |
3464 * after this. Clear them out for now. */ | 3479 * after this. Clear them out for now. */ |
3465 term_windgoto(1, 0); | 3480 term_windgoto(1, 0); |
3475 # endif | 3490 # endif |
3476 | 3491 |
3477 /* | 3492 /* |
3478 * Similar to requesting the version string: Request the terminal background | 3493 * Similar to requesting the version string: Request the terminal background |
3479 * color when it is the right moment. | 3494 * color when it is the right moment. |
3495 * Also request the cursor shape, if possible. | |
3480 */ | 3496 */ |
3481 void | 3497 void |
3482 may_req_bg_color(void) | 3498 may_req_bg_color(void) |
3483 { | 3499 { |
3484 if (rbg_status == RBG_GET | 3500 int done = FALSE; |
3485 && can_get_termresponse() | 3501 |
3486 && starting == 0 | 3502 if (can_get_termresponse() && starting == 0) |
3487 && *T_RBG != NUL | 3503 { |
3488 && !option_was_set((char_u *)"bg")) | 3504 /* Only request background if t_RB is set and 'background' wasn't |
3489 { | 3505 * changed. */ |
3490 LOG_TR("Sending BG request"); | 3506 if (rbg_status == STATUS_GET |
3491 out_str(T_RBG); | 3507 && *T_RBG != NUL |
3492 rbg_status = RBG_SENT; | 3508 && !option_was_set((char_u *)"bg")) |
3509 { | |
3510 LOG_TR("Sending BG request"); | |
3511 out_str(T_RBG); | |
3512 rbg_status = STATUS_SENT; | |
3513 done = TRUE; | |
3514 } | |
3515 | |
3516 /* Only request the cursor shape if t_SH and t_RS are set. */ | |
3517 if (rcm_status == STATUS_GET | |
3518 && *T_CSH != NUL | |
3519 && *T_CRS != NUL) | |
3520 { | |
3521 LOG_TR("Sending cursor shape request"); | |
3522 out_str(T_CRS); | |
3523 rcm_status = STATUS_SENT; | |
3524 done = TRUE; | |
3525 } | |
3526 } | |
3527 if (done) | |
3528 { | |
3493 /* check for the characters now, otherwise they might be eaten by | 3529 /* check for the characters now, otherwise they might be eaten by |
3494 * get_keystroke() */ | 3530 * get_keystroke() */ |
3495 out_flush(); | 3531 out_flush(); |
3496 (void)vpeekc_nomap(); | 3532 (void)vpeekc_nomap(); |
3497 } | 3533 } |
3674 char_u *p; | 3710 char_u *p; |
3675 | 3711 |
3676 /* Only do something when redrawing the screen and we can restore the | 3712 /* Only do something when redrawing the screen and we can restore the |
3677 * mode. */ | 3713 * mode. */ |
3678 if (!full_screen || *T_CEI == NUL) | 3714 if (!full_screen || *T_CEI == NUL) |
3715 { | |
3716 if (forced && initial_cursor_shape > 0) | |
3717 /* Restore to initial values. */ | |
3718 term_cursor_shape(initial_cursor_shape, initial_cursor_blink); | |
3679 return; | 3719 return; |
3720 } | |
3680 | 3721 |
3681 if ((State & REPLACE) == REPLACE) | 3722 if ((State & REPLACE) == REPLACE) |
3682 { | 3723 { |
3683 if (forced || showing_mode != REPLACE) | 3724 if (forced || showing_mode != REPLACE) |
3684 { | 3725 { |
4288 continue; /* no match */ | 4329 continue; /* no match */ |
4289 else | 4330 else |
4290 { | 4331 { |
4291 /* Skip over the digits, the final char must | 4332 /* Skip over the digits, the final char must |
4292 * follow. */ | 4333 * follow. */ |
4293 for (j = slen - 2; j < len && (isdigit(tp[j]) || tp[j] == ';'); ++j) | 4334 for (j = slen - 2; j < len && (isdigit(tp[j]) |
4335 || tp[j] == ';'); ++j) | |
4294 ; | 4336 ; |
4295 ++j; | 4337 ++j; |
4296 if (len < j) /* got a partial sequence */ | 4338 if (len < j) /* got a partial sequence */ |
4297 return -1; /* need to get more chars */ | 4339 return -1; /* need to get more chars */ |
4298 if (tp[j - 1] != termcodes[idx].code[slen - 1]) | 4340 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
4392 if (row_char == '2' && col >= 2) | 4434 if (row_char == '2' && col >= 2) |
4393 { | 4435 { |
4394 char *aw = NULL; | 4436 char *aw = NULL; |
4395 | 4437 |
4396 LOG_TR("Received U7 status"); | 4438 LOG_TR("Received U7 status"); |
4397 u7_status = U7_GOT; | 4439 u7_status = STATUS_GOT; |
4398 # ifdef FEAT_AUTOCMD | 4440 # ifdef FEAT_AUTOCMD |
4399 did_cursorhold = TRUE; | 4441 did_cursorhold = TRUE; |
4400 # endif | 4442 # endif |
4401 if (col == 2) | 4443 if (col == 2) |
4402 aw = "single"; | 4444 aw = "single"; |
4431 else | 4473 else |
4432 #endif | 4474 #endif |
4433 /* eat it when at least one digit and ending in 'c' */ | 4475 /* eat it when at least one digit and ending in 'c' */ |
4434 if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') | 4476 if (*T_CRV != NUL && i > 2 + (tp[0] != CSI) && tp[i] == 'c') |
4435 { | 4477 { |
4436 LOG_TR("Received CRV"); | 4478 LOG_TR("Received CRV response"); |
4437 crv_status = CRV_GOT; | 4479 crv_status = STATUS_GOT; |
4438 # ifdef FEAT_AUTOCMD | 4480 # ifdef FEAT_AUTOCMD |
4439 did_cursorhold = TRUE; | 4481 did_cursorhold = TRUE; |
4440 # endif | 4482 # endif |
4441 | 4483 |
4442 /* If this code starts with CSI, you can bet that the | 4484 /* If this code starts with CSI, you can bet that the |
4564 && !option_was_set((char_u *)"bg")) | 4606 && !option_was_set((char_u *)"bg")) |
4565 { | 4607 { |
4566 char *newval = (3 * '6' < tp[j+7] + tp[j+12] | 4608 char *newval = (3 * '6' < tp[j+7] + tp[j+12] |
4567 + tp[j+17]) ? "light" : "dark"; | 4609 + tp[j+17]) ? "light" : "dark"; |
4568 | 4610 |
4569 LOG_TR("Received RBG"); | 4611 LOG_TR("Received RBG response"); |
4570 rbg_status = RBG_GOT; | 4612 rbg_status = STATUS_GOT; |
4571 if (STRCMP(p_bg, newval) != 0) | 4613 if (STRCMP(p_bg, newval) != 0) |
4572 { | 4614 { |
4573 /* value differs, apply it */ | 4615 /* value differs, apply it */ |
4574 set_option_value((char_u *)"bg", 0L, | 4616 set_option_value((char_u *)"bg", 0L, |
4575 (char_u *)newval, 0); | 4617 (char_u *)newval, 0); |
4590 return -1; | 4632 return -1; |
4591 } | 4633 } |
4592 } | 4634 } |
4593 | 4635 |
4594 /* Check for key code response from xterm: | 4636 /* Check for key code response from xterm: |
4595 * | |
4596 * {lead}{flag}+r<hex bytes><{tail} | 4637 * {lead}{flag}+r<hex bytes><{tail} |
4597 * | 4638 * |
4598 * {lead} can be <Esc>P or DCS | 4639 * {lead} can be <Esc>P or DCS |
4599 * {flag} can be '0' or '1' | 4640 * {flag} can be '0' or '1' |
4600 * {tail} can be Esc>\ or STERM | 4641 * {tail} can be Esc>\ or STERM |
4601 * | 4642 * |
4602 * Consume any code that starts with "{lead}.+r". | 4643 * Check for cursor shape response from xterm: |
4644 * {lead}1$r<number> q{tail} | |
4645 * | |
4646 * {lead} can be <Esc>P or DCS | |
4647 * {tail} can be Esc>\ or STERM | |
4648 * | |
4649 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". | |
4603 */ | 4650 */ |
4604 else if (check_for_codes | 4651 else if ((check_for_codes || rcm_status == STATUS_SENT) |
4605 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') | 4652 && ((tp[0] == ESC && len >= 2 && tp[1] == 'P') |
4606 || tp[0] == DCS)) | 4653 || tp[0] == DCS)) |
4607 { | 4654 { |
4608 j = 1 + (tp[0] == ESC); | 4655 j = 1 + (tp[0] == ESC); |
4609 if (len >= j + 3 && (argp[1] != '+' || argp[2] != 'r')) | 4656 if (len < j + 3) |
4657 i = len; /* need more chars */ | |
4658 else if ((argp[1] != '+' && argp[1] != '$') || argp[2] != 'r') | |
4610 i = 0; /* no match */ | 4659 i = 0; /* no match */ |
4611 else | 4660 else if (argp[1] == '+') |
4661 /* key code response */ | |
4612 for (i = j; i < len; ++i) | 4662 for (i = j; i < len; ++i) |
4663 { | |
4613 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') | 4664 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
4614 || tp[i] == STERM) | 4665 || tp[i] == STERM) |
4615 { | 4666 { |
4616 if (i - j >= 3) | 4667 if (i - j >= 3) |
4617 got_code_from_term(tp + j, i); | 4668 got_code_from_term(tp + j, i); |
4618 key_name[0] = (int)KS_EXTRA; | 4669 key_name[0] = (int)KS_EXTRA; |
4619 key_name[1] = (int)KE_IGNORE; | 4670 key_name[1] = (int)KE_IGNORE; |
4620 slen = i + 1 + (tp[i] == ESC); | 4671 slen = i + 1 + (tp[i] == ESC); |
4621 break; | 4672 break; |
4622 } | 4673 } |
4674 } | |
4675 else if ((len >= j + 6 && isdigit(argp[3])) | |
4676 && argp[4] == ' ' | |
4677 && argp[5] == 'q') | |
4678 { | |
4679 /* cursor shape response */ | |
4680 i = j + 6; | |
4681 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') | |
4682 || tp[i] == STERM) | |
4683 { | |
4684 int number = argp[3] - '0'; | |
4685 | |
4686 /* 0, 1 = block blink, 2 = block | |
4687 * 3 = underline blink, 4 = underline | |
4688 * 5 = vertical bar blink, 6 = vertical bar */ | |
4689 number = number == 0 ? 1 : number; | |
4690 initial_cursor_shape = (number + 1) / 2; | |
4691 initial_cursor_blink = (number & 1) ? TRUE : FALSE; | |
4692 rcm_status = STATUS_GOT; | |
4693 LOG_TR("Received cursor shape response"); | |
4694 | |
4695 key_name[0] = (int)KS_EXTRA; | |
4696 key_name[1] = (int)KE_IGNORE; | |
4697 slen = i + 1 + (tp[i] == ESC); | |
4698 } | |
4699 } | |
4623 | 4700 |
4624 if (i == len) | 4701 if (i == len) |
4625 { | 4702 { |
4626 /* These codes arrive many together, each code can be | 4703 /* These codes arrive many together, each code can be |
4627 * truncated at any point. */ | 4704 * truncated at any point. */ |
5835 #ifdef FEAT_GUI | 5912 #ifdef FEAT_GUI |
5836 if (gui.in_use) | 5913 if (gui.in_use) |
5837 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ | 5914 termleader[len++] = CSI; /* the GUI codes are not in termcodes[] */ |
5838 #endif | 5915 #endif |
5839 #ifdef FEAT_TERMRESPONSE | 5916 #ifdef FEAT_TERMRESPONSE |
5840 if (check_for_codes) | 5917 if (check_for_codes || *T_CRS != NUL) |
5841 termleader[len++] = DCS; /* the termcode response starts with DCS | 5918 termleader[len++] = DCS; /* the termcode response starts with DCS |
5842 in 8-bit mode */ | 5919 in 8-bit mode */ |
5843 #endif | 5920 #endif |
5844 termleader[len] = NUL; | 5921 termleader[len] = NUL; |
5845 | 5922 |