To: vim_dev@googlegroups.com Subject: Patch 9.0.0971 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0971 Problem: Escape sequences not recognized without the termresponse feature. Solution: Recognize escape sequences to avoid display mess up. Files: src/term.c *** ../vim-9.0.0970/src/term.c 2022-11-28 18:51:38.967571631 +0000 --- src/term.c 2022-11-29 13:56:45.382095352 +0000 *************** *** 4720,4726 **** return new_slen; } - #ifdef FEAT_TERMRESPONSE /* * Handle a cursor position report. */ --- 4720,4725 ---- *************** *** 4744,4761 **** // that right away if possible, keeping any // messages. set_option_value_give_err((char_u *)"ambw", 0L, (char_u *)aw, 0); ! # ifdef DEBUG_TERMRESPONSE { int r = redraw_asap(UPD_CLEAR); log_tr("set 'ambiwidth', redraw_asap(): %d", r); } ! # else redraw_asap(UPD_CLEAR); ! # endif ! # ifdef FEAT_EVAL set_vim_var_string(VV_TERMU7RESP, tp, csi_len); ! # endif } } else if (arg[0] == 3) --- 4743,4760 ---- // that right away if possible, keeping any // messages. set_option_value_give_err((char_u *)"ambw", 0L, (char_u *)aw, 0); ! #ifdef DEBUG_TERMRESPONSE { int r = redraw_asap(UPD_CLEAR); log_tr("set 'ambiwidth', redraw_asap(): %d", r); } ! #else redraw_asap(UPD_CLEAR); ! #endif ! #ifdef FEAT_EVAL set_vim_var_string(VV_TERMU7RESP, tp, csi_len); ! #endif } } else if (arg[0] == 3) *************** *** 5237,5245 **** handle_version_response(first, arg, argc, tp); *slen = csi_len; ! # ifdef FEAT_EVAL set_vim_var_string(VV_TERMRESPONSE, tp, *slen); ! # endif apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); key_name[0] = (int)KS_EXTRA; --- 5236,5244 ---- handle_version_response(first, arg, argc, tp); *slen = csi_len; ! #ifdef FEAT_EVAL set_vim_var_string(VV_TERMRESPONSE, tp, *slen); ! #endif apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); key_name[0] = (int)KS_EXTRA; *************** *** 5264,5272 **** key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = csi_len; ! # ifdef FEAT_EVAL set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); ! # endif } // Kitty keyboard protocol status response: CSI ? flags u --- 5263,5271 ---- key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = csi_len; ! #ifdef FEAT_EVAL set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); ! #endif } // Kitty keyboard protocol status response: CSI ? flags u *************** *** 5373,5385 **** char_u *tp_r = tp + j + 7; char_u *tp_g = tp + j + (is_4digit ? 12 : 10); char_u *tp_b = tp + j + (is_4digit ? 17 : 13); ! # ifdef FEAT_TERMINAL int rval, gval, bval; rval = hexhex2nr(tp_r); gval = hexhex2nr(tp_b); bval = hexhex2nr(tp_g); ! # endif if (is_bg) { char *new_bg_val = (3 * '6' < *tp_r + *tp_g + --- 5372,5384 ---- char_u *tp_r = tp + j + 7; char_u *tp_g = tp + j + (is_4digit ? 12 : 10); char_u *tp_b = tp + j + (is_4digit ? 17 : 13); ! #ifdef FEAT_TERMINAL int rval, gval, bval; rval = hexhex2nr(tp_r); gval = hexhex2nr(tp_b); bval = hexhex2nr(tp_g); ! #endif if (is_bg) { char *new_bg_val = (3 * '6' < *tp_r + *tp_g + *************** *** 5387,5397 **** LOG_TR(("Received RBG response: %s", tp)); rbg_status.tr_progress = STATUS_GOT; ! # ifdef FEAT_TERMINAL bg_r = rval; bg_g = gval; bg_b = bval; ! # endif if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, new_bg_val) != 0) { --- 5386,5396 ---- LOG_TR(("Received RBG response: %s", tp)); rbg_status.tr_progress = STATUS_GOT; ! #ifdef FEAT_TERMINAL bg_r = rval; bg_g = gval; bg_b = bval; ! #endif if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, new_bg_val) != 0) { *************** *** 5402,5408 **** redraw_asap(UPD_CLEAR); } } ! # ifdef FEAT_TERMINAL else { LOG_TR(("Received RFG response: %s", tp)); --- 5401,5407 ---- redraw_asap(UPD_CLEAR); } } ! #ifdef FEAT_TERMINAL else { LOG_TR(("Received RFG response: %s", tp)); *************** *** 5411,5427 **** fg_g = gval; fg_b = bval; } ! # endif } // got finished code: consume it key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = i + 1 + (tp[i] == ESC); ! # ifdef FEAT_EVAL set_vim_var_string(is_bg ? VV_TERMRBGRESP : VV_TERMRFGRESP, tp, *slen); ! # endif break; } if (i == len) --- 5410,5426 ---- fg_g = gval; fg_b = bval; } ! #endif } // got finished code: consume it key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = i + 1 + (tp[i] == ESC); ! #ifdef FEAT_EVAL set_vim_var_string(is_bg ? VV_TERMRBGRESP : VV_TERMRFGRESP, tp, *slen); ! #endif break; } if (i == len) *************** *** 5513,5521 **** key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = i + 1; ! # ifdef FEAT_EVAL set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); ! # endif break; } } --- 5512,5520 ---- key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = i + 1; ! #ifdef FEAT_EVAL set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); ! #endif break; } } *************** *** 5530,5536 **** } return OK; } - #endif // FEAT_TERMRESPONSE /* * Check if typebuf.tb_buf[] contains a terminal key code. --- 5529,5534 ---- *************** *** 5831,5847 **** } } - #ifdef FEAT_TERMRESPONSE if (key_name[0] == NUL // Mouse codes of DEC and pterm start with [. When // detecting the start of these mouse codes they might as well be // another key code or terminal response. ! # ifdef FEAT_MOUSE_DEC || key_name[0] == KS_DEC_MOUSE ! # endif ! # ifdef FEAT_MOUSE_PTERM || key_name[0] == KS_PTERM_MOUSE ! # endif ) { char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; --- 5829,5844 ---- } } if (key_name[0] == NUL // Mouse codes of DEC and pterm start with [. When // detecting the start of these mouse codes they might as well be // another key code or terminal response. ! #ifdef FEAT_MOUSE_DEC || key_name[0] == KS_DEC_MOUSE ! #endif ! #ifdef FEAT_MOUSE_PTERM || key_name[0] == KS_PTERM_MOUSE ! #endif ) { char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; *************** *** 5874,5883 **** bufsize, buflen, key_name, &slen); if (resp != 0) { ! # ifdef DEBUG_TERMRESPONSE if (resp == -1) LOG_TR(("Not enough characters for CSI sequence")); ! # endif return resp; } } --- 5871,5880 ---- bufsize, buflen, key_name, &slen); if (resp != 0) { ! #ifdef DEBUG_TERMRESPONSE if (resp == -1) LOG_TR(("Not enough characters for CSI sequence")); ! #endif return resp; } } *************** *** 5903,5909 **** return -1; } } - #endif if (key_name[0] == NUL) continue; // No match at this position, try next one --- 5900,5905 ---- *** ../vim-9.0.0970/src/version.c 2022-11-29 13:46:43.122213356 +0000 --- src/version.c 2022-11-29 13:58:23.366061354 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 971, /**/ -- I'm so disorganized my keyboard isn't even in alphabetical order! /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///