To: vim_dev@googlegroups.com Subject: Patch 9.0.1276 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1276 Problem: Some mappings with Meta and Shift do not work. Solution: Apply the Shift modifier to the key. (issue #11913) Files: runtime/doc/map.txt, src/term.c *** ../vim-9.0.1275/runtime/doc/map.txt 2022-12-01 12:03:42.259227523 +0000 --- runtime/doc/map.txt 2023-02-03 12:23:29.175281269 +0000 *************** *** 20,28 **** 1.8 Examples |map-examples| 1.9 Using mappings |map-typing| 1.10 Mapping alt-keys |:map-alt-keys| ! 1.11 Mapping in modifyOtherKeys mode |modifyOtherKeys| ! 1.12 Mapping with Kitty keyboard protocol |kitty-keyboard-protocol| ! 1.13 Mapping an operator |:map-operator| 2. Abbreviations |abbreviations| 3. Local mappings and functions |script-local| 4. User-defined commands |user-commands| --- 20,29 ---- 1.8 Examples |map-examples| 1.9 Using mappings |map-typing| 1.10 Mapping alt-keys |:map-alt-keys| ! 1.11 Mapping meta-keys |:map-meta-keys| ! 1.12 Mapping in modifyOtherKeys mode |modifyOtherKeys| ! 1.13 Mapping with Kitty keyboard protocol |kitty-keyboard-protocol| ! 1.14 Mapping an operator |:map-operator| 2. Abbreviations |abbreviations| 3. Local mappings and functions |script-local| 4. User-defined commands |user-commands| *************** *** 786,793 **** suggestions: - Function keys , , etc.. Also the shifted function keys , , etc. Note that is already used for the help command. ! - Meta-keys (with the ALT key pressed). Depending on your keyboard accented ! characters may be used as well. |:map-alt-keys| - Use the '_' or ',' character and then any other character. The "_" and "," commands do exist in Vim (see |_| and |,|), but you probably never use them. - Use a key that is a synonym for another command. For example: CTRL-P and --- 795,802 ---- suggestions: - Function keys , , etc.. Also the shifted function keys , , etc. Note that is already used for the help command. ! - Any key with the Alt or Meta key pressed. Depending on your keyboard ! accented characters may be used as well. |:map-alt-keys| - Use the '_' or ',' character and then any other character. The "_" and "," commands do exist in Vim (see |_| and |,|), but you probably never use them. - Use a key that is a synonym for another command. For example: CTRL-P and *************** *** 920,925 **** --- 929,936 ---- If the terminal supports the modifyOtherKeys mode and it has been enabled, then Vim can recognize more key combinations, see |modifyOtherKeys| below. + The Kitty keyboard protocol works in a similar way, see + |kitty-keyboard-protocol|. By default Vim assumes that pressing the ALT key sets the 8th bit of a typed character. Most decent terminals can work that way, such as xterm, aterm and *************** *** 958,964 **** using other applications but not when inside Vim. ! 1.11 MAPPING IN modifyOtherKeys mode *modifyOtherKeys* Xterm and a few other terminals can be put in a mode where keys with modifiers are sent with a special escape code. Vim recognizes these codes and can then --- 969,989 ---- using other applications but not when inside Vim. ! 1.11 MAPPING META-KEYS *:map-meta-keys* ! ! Mapping keys with the Meta modifier works very similar to using the Alt key. ! What key on your keyboard produces the Meta modifier depends on your keyboard ! and configuration. ! ! Note that mapping actually is for using the Alt key. That can be ! confusing! It cannot be changed, it would not be backwards compatible. ! ! For the Meta modifier the "T" character is used. For example, to map Meta-b ! in Insert mode: > ! :imap terrible ! ! ! 1.12 MAPPING IN modifyOtherKeys mode *modifyOtherKeys* Xterm and a few other terminals can be put in a mode where keys with modifiers are sent with a special escape code. Vim recognizes these codes and can then *************** *** 1020,1026 **** Insert mode to avoid every key with a modifier causing Insert mode to end. ! 1.12 MAPPING WITH KITTY KEYBOARD PROTOCOL *kitty-keyboard-protocol* If the value of 'term' contains "kitty" then Vim will send out an escape sequence to enable the Kitty keyboard protocol. This can be changed with the --- 1045,1051 ---- Insert mode to avoid every key with a modifier causing Insert mode to end. ! 1.13 MAPPING WITH KITTY KEYBOARD PROTOCOL *kitty-keyboard-protocol* If the value of 'term' contains "kitty" then Vim will send out an escape sequence to enable the Kitty keyboard protocol. This can be changed with the *************** *** 1047,1053 **** previous state is unknown ! 1.13 MAPPING AN OPERATOR *:map-operator* An operator is used before a {motion} command. To define your own operator you must create a mapping that first sets the 'operatorfunc' option and then --- 1072,1078 ---- previous state is unknown ! 1.14 MAPPING AN OPERATOR *:map-operator* An operator is used before a {motion} command. To define your own operator you must create a mapping that first sets the 'operatorfunc' option and then *** ../vim-9.0.1275/src/term.c 2023-01-25 21:05:35.127042805 +0000 --- src/term.c 2023-02-03 12:10:50.232098370 +0000 *************** *** 5343,5348 **** --- 5343,5354 ---- int key = trail == 'u' ? arg[0] : arg[2]; int modifiers = decode_modifiers(arg[1]); + + // Some terminals do not apply the Shift modifier to the key. To make + // mappings consistent we do it here. TODO: support more keys. + if ((modifiers & MOD_MASK_SHIFT) && key >= 'a' && key <= 'z') + key += 'A' - 'a'; + return put_key_modifiers_in_typebuf(key, modifiers, csi_len, offset, buf, bufsize, buflen); } *** ../vim-9.0.1275/src/version.c 2023-02-02 16:34:07.745513238 +0000 --- src/version.c 2023-02-03 12:11:59.104030733 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1276, /**/ -- Warning label on a superhero Halloween costume: "Caution: Cape does not enable user to fly." /// 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 ///