comparison src/term.c @ 31211:d6355c3af211 v9.0.0939

patch 9.0.0939: still using simplified mappings when using kitty protocol Commit: https://github.com/vim/vim/commit/47f1fdc28c6839ec8f5aede631d3a870624767b6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 24 13:27:36 2022 +0000 patch 9.0.0939: still using simplified mappings when using kitty protocol Problem: Still using simplified mappings when using the kitty keyboard protocol. Solution: Use the kitty_protocol_state value to decide whether to use simplified mappings. Improve how seenModifyOtherKeys is set and reset.
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Nov 2022 14:30:03 +0100
parents b4491e73d6d1
children 5b71c3884a2a
comparison
equal deleted inserted replaced
31210:50ad80360e99 31211:d6355c3af211
3673 void 3673 void
3674 out_str_t_TE(void) 3674 out_str_t_TE(void)
3675 { 3675 {
3676 out_str(T_CTE); 3676 out_str(T_CTE);
3677 3677
3678 // The seenModifyOtherKeys flag is not reset here. We do expect t_TE to
3679 // disable modifyOtherKeys, but there is no way to detect it's enabled
3680 // again after the following t_TI. We assume that when seenModifyOtherKeys
3681 // was set before it will still be valid.
3682
3678 // When the kitty keyboard protocol is enabled we expect t_TE to disable 3683 // When the kitty keyboard protocol is enabled we expect t_TE to disable
3679 // it. Remembering that it was detected to be enabled is useful in some 3684 // it. Remembering that it was detected to be enabled is useful in some
3680 // situations. 3685 // situations.
3686 // The following t_TI is expected to request the state and then
3687 // kitty_protocol_state will be set again.
3681 if (kitty_protocol_state == KKPS_ENABLED 3688 if (kitty_protocol_state == KKPS_ENABLED
3682 || kitty_protocol_state == KKPS_DISABLED) 3689 || kitty_protocol_state == KKPS_DISABLED)
3683 kitty_protocol_state = KKPS_DISABLED; 3690 kitty_protocol_state = KKPS_DISABLED;
3684 else 3691 else
3685 kitty_protocol_state = KKPS_AFTER_T_KE; 3692 kitty_protocol_state = KKPS_AFTER_T_KE;
5048 { 5055 {
5049 int key; 5056 int key;
5050 int modifiers; 5057 int modifiers;
5051 char_u string[MAX_KEY_CODE_LEN + 1]; 5058 char_u string[MAX_KEY_CODE_LEN + 1];
5052 5059
5060 // Only set seenModifyOtherKeys for the "{lead}27;" code to avoid setting
5061 // it for terminals using the kitty keyboard protocol. Xterm sends
5062 // the form ending in "u" when the formatOtherKeys resource is set. We do
5063 // not support this.
5064 //
5065 // Do not set seenModifyOtherKeys if there was a positive response at any
5066 // time from requesting the kitty keyboard protocol state, these are not
5067 // expected to support modifyOtherKeys level 2.
5068 //
5053 // Do not set seenModifyOtherKeys for kitty, it does send some sequences 5069 // Do not set seenModifyOtherKeys for kitty, it does send some sequences
5054 // like this but does not have the modifyOtherKeys feature. 5070 // like this but does not have the modifyOtherKeys feature.
5055 if (term_props[TPR_KITTY].tpr_status != TPR_YES) 5071 if (trail != 'u'
5072 && (kitty_protocol_state == KKPS_INITIAL
5073 || kitty_protocol_state == KKPS_OFF
5074 || kitty_protocol_state == KKPS_AFTER_T_KE)
5075 && term_props[TPR_KITTY].tpr_status != TPR_YES)
5056 seenModifyOtherKeys = TRUE; 5076 seenModifyOtherKeys = TRUE;
5057 5077
5058 if (trail == 'u') 5078 if (trail == 'u')
5059 key = arg[0]; 5079 key = arg[0];
5060 else 5080 else
5235 // Kitty keyboard protocol status response: CSI ? flags u 5255 // Kitty keyboard protocol status response: CSI ? flags u
5236 else if (first == '?' && argc == 1 && trail == 'u') 5256 else if (first == '?' && argc == 1 && trail == 'u')
5237 { 5257 {
5238 // The protocol has various "progressive enhancement flags" values, but 5258 // The protocol has various "progressive enhancement flags" values, but
5239 // we only check for zero and non-zero here. 5259 // we only check for zero and non-zero here.
5240 kitty_protocol_state = arg[0] == '0' ? KKPS_OFF : KKPS_ENABLED; 5260 if (arg[0] == '0')
5261 {
5262 kitty_protocol_state = KKPS_OFF;
5263 }
5264 else
5265 {
5266 kitty_protocol_state = KKPS_ENABLED;
5267
5268 // Reset seenModifyOtherKeys just in case some key combination has
5269 // been seen that set it before we get the status response.
5270 seenModifyOtherKeys = FALSE;
5271 }
5241 5272
5242 key_name[0] = (int)KS_EXTRA; 5273 key_name[0] = (int)KS_EXTRA;
5243 key_name[1] = (int)KE_IGNORE; 5274 key_name[1] = (int)KE_IGNORE;
5244 *slen = csi_len; 5275 *slen = csi_len;
5245 } 5276 }