comparison src/term.c @ 12232:1553d1a4bf7c v8.0.0996

patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app commit https://github.com/vim/vim/commit/833e0e3c8ccd6047dd596c4ffd68cb0ab13b4e41 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 26 15:16:03 2017 +0200 patch 8.0.0996: Mac: t_RS is echoed on the screne in Terminal.app Problem: Mac: t_RS is echoed on the screne in Terminal.app. Even though $TERM is set to "xterm-256colors" it cannot handle this xterm escape sequence. Solution: Recognize Terminal.app from the termresponse and skip sending t_RS if it looks like Terminal.app.
author Christian Brabandt <cb@256bit.org>
date Sat, 26 Aug 2017 15:30:04 +0200
parents 2b965b3dd20c
children 2b333727279d
comparison
equal deleted inserted replaced
12231:ccfa880d4773 12232:1553d1a4bf7c
1358 1358
1359 static int need_gather = FALSE; /* need to fill termleader[] */ 1359 static int need_gather = FALSE; /* need to fill termleader[] */
1360 static char_u termleader[256 + 1]; /* for check_termcode() */ 1360 static char_u termleader[256 + 1]; /* for check_termcode() */
1361 #ifdef FEAT_TERMRESPONSE 1361 #ifdef FEAT_TERMRESPONSE
1362 static int check_for_codes = FALSE; /* check for key code response */ 1362 static int check_for_codes = FALSE; /* check for key code response */
1363 # ifdef MACOS
1364 static int is_terminal_app = FALSE; /* recognized Terminal.app */
1365 # endif
1363 #endif 1366 #endif
1364 1367
1365 static struct builtin_term * 1368 static struct builtin_term *
1366 find_builtin_term(char_u *term) 1369 find_builtin_term(char_u *term)
1367 { 1370 {
3495 * Also request the cursor shape, if possible. 3498 * Also request the cursor shape, if possible.
3496 */ 3499 */
3497 void 3500 void
3498 may_req_bg_color(void) 3501 may_req_bg_color(void)
3499 { 3502 {
3500 int done = FALSE;
3501
3502 if (can_get_termresponse() && starting == 0) 3503 if (can_get_termresponse() && starting == 0)
3503 { 3504 {
3504 /* Only request background if t_RB is set and 'background' wasn't 3505 /* Only request background if t_RB is set and 'background' wasn't
3505 * changed. */ 3506 * changed. */
3506 if (rbg_status == STATUS_GET 3507 if (rbg_status == STATUS_GET
3508 && !option_was_set((char_u *)"bg")) 3509 && !option_was_set((char_u *)"bg"))
3509 { 3510 {
3510 LOG_TR("Sending BG request"); 3511 LOG_TR("Sending BG request");
3511 out_str(T_RBG); 3512 out_str(T_RBG);
3512 rbg_status = STATUS_SENT; 3513 rbg_status = STATUS_SENT;
3513 done = TRUE; 3514
3514 } 3515 /* check for the characters now, otherwise they might be eaten by
3515 3516 * get_keystroke() */
3516 /* Only request the cursor shape if t_SH and t_RS are set. */ 3517 out_flush();
3517 if (rcm_status == STATUS_GET 3518 (void)vpeekc_nomap();
3518 && *T_CSH != NUL 3519 }
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 {
3529 /* check for the characters now, otherwise they might be eaten by
3530 * get_keystroke() */
3531 out_flush();
3532 (void)vpeekc_nomap();
3533 } 3520 }
3534 } 3521 }
3535 3522
3536 # ifdef DEBUG_TERMRESPONSE 3523 # ifdef DEBUG_TERMRESPONSE
3537 static void 3524 static void
4528 /* If run from Vim $COLORS is set to the number of 4515 /* If run from Vim $COLORS is set to the number of
4529 * colors the terminal supports. Otherwise assume 4516 * colors the terminal supports. Otherwise assume
4530 * 256, libvterm supports even more. */ 4517 * 256, libvterm supports even more. */
4531 if (mch_getenv((char_u *)"COLORS") == NULL) 4518 if (mch_getenv((char_u *)"COLORS") == NULL)
4532 may_adjust_color_count(256); 4519 may_adjust_color_count(256);
4520 }
4521
4522 # ifdef MACOS
4523 /* Mac Terminal.app sends 1;95;0 */
4524 if (col == 95
4525 && STRNCMP(tp + extra - 2, ">1;95;0c", 9) == 0)
4526 {
4527 /* Terminal.app sets $TERM to "xterm-256colors",
4528 * but it's not fully xterm compatible. */
4529 is_terminal_app = TRUE;
4530 }
4531 # endif
4532
4533 /* Only request the cursor style if t_SH and t_RS are
4534 * set. Not for Terminal.app, it can't handle t_RS, it
4535 * echoes the characters to the screen. */
4536 if (rcm_status == STATUS_GET
4537 # ifdef MACOS
4538 && !is_terminal_app
4539 # endif
4540 && *T_CSH != NUL
4541 && *T_CRS != NUL)
4542 {
4543 LOG_TR("Sending cursor style request");
4544 out_str(T_CRS);
4545 rcm_status = STATUS_SENT;
4546 out_flush();
4533 } 4547 }
4534 } 4548 }
4535 # ifdef FEAT_EVAL 4549 # ifdef FEAT_EVAL
4536 set_vim_var_string(VV_TERMRESPONSE, tp, i + 1); 4550 set_vim_var_string(VV_TERMRESPONSE, tp, i + 1);
4537 # endif 4551 # endif