Mercurial > vim
comparison src/misc2.c @ 20627:8bce783af0cb v8.2.0867
patch 8.2.0867: using {xxx} for encoding a modifier is not nice
Commit: https://github.com/vim/vim/commit/fccd93f0917234b962ce07d1df3adf9d7105936f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 31 22:06:51 2020 +0200
patch 8.2.0867: using \{xxx} for encoding a modifier is not nice
Problem: Using \{xxx} for encoding a modifier is not nice.
Solution: Use \<*xxx> instead, since it's the same as \<xxx> but producing a
different code.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 31 May 2020 22:15:03 +0200 |
parents | c2570baa2e4c |
children | d9a2e5dcfd9f |
comparison
equal
deleted
inserted
replaced
20626:38f728a93c07 | 20627:8bce783af0cb |
---|---|
2770 char_u *bp; | 2770 char_u *bp; |
2771 int in_string = flags & FSK_IN_STRING; | 2771 int in_string = flags & FSK_IN_STRING; |
2772 int modifiers; | 2772 int modifiers; |
2773 int bit; | 2773 int bit; |
2774 int key; | 2774 int key; |
2775 int endchar = (flags & FSK_CURLY) ? '}' : '>'; | |
2776 uvarnumber_T n; | 2775 uvarnumber_T n; |
2777 int l; | 2776 int l; |
2778 | 2777 |
2779 src = *srcp; | 2778 src = *srcp; |
2780 if (src[0] != ((flags & FSK_CURLY) ? '{' : '<')) | 2779 if (src[0] != '<') |
2781 return 0; | 2780 return 0; |
2781 if (src[1] == '*') // <*xxx>: do not simplify | |
2782 ++src; | |
2782 | 2783 |
2783 // Find end of modifier list | 2784 // Find end of modifier list |
2784 last_dash = src; | 2785 last_dash = src; |
2785 for (bp = src + 1; *bp == '-' || vim_isIDc(*bp); bp++) | 2786 for (bp = src + 1; *bp == '-' || vim_isIDc(*bp); bp++) |
2786 { | 2787 { |
2794 else | 2795 else |
2795 l = 1; | 2796 l = 1; |
2796 // Anything accepted, like <C-?>. | 2797 // Anything accepted, like <C-?>. |
2797 // <C-"> or <M-"> are not special in strings as " is | 2798 // <C-"> or <M-"> are not special in strings as " is |
2798 // the string delimiter. With a backslash it works: <M-\"> | 2799 // the string delimiter. With a backslash it works: <M-\"> |
2799 if (!(in_string && bp[1] == '"') && bp[l + 1] == endchar) | 2800 if (!(in_string && bp[1] == '"') && bp[l + 1] == '>') |
2800 bp += l; | 2801 bp += l; |
2801 else if (in_string && bp[1] == '\\' && bp[2] == '"' | 2802 else if (in_string && bp[1] == '\\' && bp[2] == '"' |
2802 && bp[3] == endchar) | 2803 && bp[3] == '>') |
2803 bp += 2; | 2804 bp += 2; |
2804 } | 2805 } |
2805 } | 2806 } |
2806 if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) | 2807 if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) |
2807 bp += 3; // skip t_xx, xx may be '-' or '>'/'}' | 2808 bp += 3; // skip t_xx, xx may be '-' or '>' |
2808 else if (STRNICMP(bp, "char-", 5) == 0) | 2809 else if (STRNICMP(bp, "char-", 5) == 0) |
2809 { | 2810 { |
2810 vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE); | 2811 vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, TRUE); |
2811 if (l == 0) | 2812 if (l == 0) |
2812 { | 2813 { |
2816 bp += l + 5; | 2817 bp += l + 5; |
2817 break; | 2818 break; |
2818 } | 2819 } |
2819 } | 2820 } |
2820 | 2821 |
2821 if (*bp == endchar) // found matching '>' or '}' | 2822 if (*bp == '>') // found matching '>' |
2822 { | 2823 { |
2823 end_of_name = bp + 1; | 2824 end_of_name = bp + 1; |
2824 | 2825 |
2825 // Which modifiers are given? | 2826 // Which modifiers are given? |
2826 modifiers = 0x0; | 2827 modifiers = 0x0; |
2862 off = 2; | 2863 off = 2; |
2863 if (has_mbyte) | 2864 if (has_mbyte) |
2864 l = mb_ptr2len(last_dash + off); | 2865 l = mb_ptr2len(last_dash + off); |
2865 else | 2866 else |
2866 l = 1; | 2867 l = 1; |
2867 if (modifiers != 0 && last_dash[l + off] == endchar) | 2868 if (modifiers != 0 && last_dash[l + off] == '>') |
2868 key = PTR2CHAR(last_dash + off); | 2869 key = PTR2CHAR(last_dash + off); |
2869 else | 2870 else |
2870 { | 2871 { |
2871 key = get_special_key_code(last_dash + off); | 2872 key = get_special_key_code(last_dash + off); |
2872 if (!(flags & FSK_KEEP_X_KEY)) | 2873 if (!(flags & FSK_KEEP_X_KEY)) |