Mercurial > vim
annotate src/map.c @ 20520:70986f70880a v8.2.0814
patch 8.2.0814: clang warning for implicit conversion
Commit: https://github.com/vim/vim/commit/3718427ba3c28ccab30726880389e44070640d3b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 23 19:30:05 2020 +0200
patch 8.2.0814: clang warning for implicit conversion
Problem: Clang warning for implicit conversion.
Solution: Add type cast. (Dominique Pelle, closes https://github.com/vim/vim/issues/6124)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 23 May 2020 19:45:04 +0200 |
parents | d9e3fdf26cb9 |
children | 729853a754ea |
rev | line source |
---|---|
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * map.c: functions for maps and abbreviations |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 * List used for abbreviations. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 static mapblock_T *first_abbr = NULL; // first entry in abbrlist |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 * Each mapping is put in one of the 256 hash lists, to speed up finding it. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 static mapblock_T *(maphash[256]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 static int maphash_valid = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 * Make a hash value for a mapping. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 * "mode" is the lower 4 bits of the State for the mapping. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 * "c1" is the first character of the "lhs". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 * Returns a value between 0 and 255, index in maphash. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 * Put Normal/Visual mode mappings mostly separately from Insert/Cmdline mode. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 #define MAP_HASH(mode, c1) (((mode) & (NORMAL + VISUAL + SELECTMODE + OP_PENDING + TERMINAL)) ? (c1) : ((c1) ^ 0x80)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 * Get the start of the hashed map list for "state" and first character "c". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 mapblock_T * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 get_maphash_list(int state, int c) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 return maphash[MAP_HASH(state, c)]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 * Get the buffer-local hashed map list for "state" and first character "c". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 mapblock_T * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 get_buf_maphash_list(int state, int c) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 return curbuf->b_maphash[MAP_HASH(state, c)]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 is_maphash_valid(void) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 return maphash_valid; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 * Initialize maphash[] for first use. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 static void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 validate_maphash(void) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 if (!maphash_valid) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 { |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
68 CLEAR_FIELD(maphash); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 maphash_valid = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 * Delete one entry from the abbrlist or maphash[]. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 * "mpp" is a pointer to the m_next field of the PREVIOUS entry! |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 static void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 map_free(mapblock_T **mpp) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 mp = *mpp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 vim_free(mp->m_keys); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 vim_free(mp->m_str); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 vim_free(mp->m_orig_str); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 *mpp = mp->m_next; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 vim_free(mp); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 * Return characters to represent the map mode in an allocated string. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 * Returns NULL when out of memory. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 static char_u * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 map_mode_to_chars(int mode) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 garray_T mapmode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 ga_init2(&mapmode, 1, 7); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 if ((mode & (INSERT + CMDLINE)) == INSERT + CMDLINE) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 ga_append(&mapmode, '!'); // :map! |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 else if (mode & INSERT) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 ga_append(&mapmode, 'i'); // :imap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 else if (mode & LANGMAP) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 ga_append(&mapmode, 'l'); // :lmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 else if (mode & CMDLINE) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 ga_append(&mapmode, 'c'); // :cmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 else if ((mode & (NORMAL + VISUAL + SELECTMODE + OP_PENDING)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 == NORMAL + VISUAL + SELECTMODE + OP_PENDING) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 ga_append(&mapmode, ' '); // :map |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 if (mode & NORMAL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 ga_append(&mapmode, 'n'); // :nmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 if (mode & OP_PENDING) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 ga_append(&mapmode, 'o'); // :omap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 if (mode & TERMINAL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 ga_append(&mapmode, 't'); // :tmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 if ((mode & (VISUAL + SELECTMODE)) == VISUAL + SELECTMODE) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 ga_append(&mapmode, 'v'); // :vmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 if (mode & VISUAL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 ga_append(&mapmode, 'x'); // :xmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 if (mode & SELECTMODE) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 ga_append(&mapmode, 's'); // :smap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 ga_append(&mapmode, NUL); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 return (char_u *)mapmode.ga_data; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 static void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 showmap( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 mapblock_T *mp, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 int local) // TRUE for buffer-local map |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 int len = 1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 char_u *mapchars; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 if (message_filtered(mp->m_keys) && message_filtered(mp->m_str)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 return; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 if (msg_didout || msg_silent != 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 msg_putchar('\n'); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 if (got_int) // 'q' typed at MORE prompt |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 return; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 mapchars = map_mode_to_chars(mp->m_mode); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 if (mapchars != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 msg_puts((char *)mapchars); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 len = (int)STRLEN(mapchars); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 vim_free(mapchars); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 while (++len <= 3) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 msg_putchar(' '); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 // Display the LHS. Get length of what we write. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 len = msg_outtrans_special(mp->m_keys, TRUE, 0); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 do |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 msg_putchar(' '); // padd with blanks |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 ++len; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 } while (len < 12); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 if (mp->m_noremap == REMAP_NONE) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 msg_puts_attr("*", HL_ATTR(HLF_8)); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 else if (mp->m_noremap == REMAP_SCRIPT) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 msg_puts_attr("&", HL_ATTR(HLF_8)); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 msg_putchar(' '); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 if (local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 msg_putchar('@'); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 msg_putchar(' '); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 // Use FALSE below if we only want things like <Up> to show up as such on |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 // the rhs, and not M-x etc, TRUE gets both -- webb |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 if (*mp->m_str == NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 msg_puts_attr("<Nop>", HL_ATTR(HLF_8)); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 // Remove escaping of CSI, because "m_str" is in a format to be used |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 // as typeahead. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 char_u *s = vim_strsave(mp->m_str); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 if (s != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 vim_unescape_csi(s); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 msg_outtrans_special(s, FALSE, 0); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 vim_free(s); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 if (p_verbose > 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 last_set_msg(mp->m_script_ctx); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 out_flush(); // show one line at a time |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
207 static int |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
208 map_add( |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
209 mapblock_T **map_table, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
210 mapblock_T **abbr_table, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
211 char_u *keys, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
212 char_u *rhs, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
213 char_u *orig_rhs, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
214 int noremap, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
215 int nowait, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
216 int silent, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
217 int mode, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
218 int is_abbr, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
219 #ifdef FEAT_EVAL |
20510
3d9a2c8d4f95
patch 8.2.0809: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
220 int expr, |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
221 scid_T sid, // -1 to use current_sctx |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
222 linenr_T lnum, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
223 #endif |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
224 int simplified) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
225 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
226 mapblock_T *mp = ALLOC_ONE(mapblock_T); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
227 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
228 if (mp == NULL) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
229 return FAIL; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
230 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
231 // If CTRL-C has been mapped, don't always use it for Interrupting. |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
232 if (*keys == Ctrl_C) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
233 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
234 if (map_table == curbuf->b_maphash) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
235 curbuf->b_mapped_ctrl_c |= mode; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
236 else |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
237 mapped_ctrl_c |= mode; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
238 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
239 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
240 mp->m_keys = vim_strsave(keys); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
241 mp->m_str = vim_strsave(rhs); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
242 mp->m_orig_str = vim_strsave(orig_rhs); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
243 if (mp->m_keys == NULL || mp->m_str == NULL) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
244 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
245 vim_free(mp->m_keys); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
246 vim_free(mp->m_str); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
247 vim_free(mp->m_orig_str); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
248 vim_free(mp); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
249 return FAIL; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
250 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
251 mp->m_keylen = (int)STRLEN(mp->m_keys); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
252 mp->m_noremap = noremap; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
253 mp->m_nowait = nowait; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
254 mp->m_silent = silent; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
255 mp->m_mode = mode; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
256 mp->m_simplified = simplified; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
257 #ifdef FEAT_EVAL |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
258 mp->m_expr = expr; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
259 if (sid >= 0) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
260 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
261 mp->m_script_ctx.sc_sid = sid; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
262 mp->m_script_ctx.sc_lnum = lnum; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
263 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
264 else |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
265 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
266 mp->m_script_ctx = current_sctx; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
267 mp->m_script_ctx.sc_lnum += SOURCING_LNUM; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
268 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
269 #endif |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
270 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
271 // add the new entry in front of the abbrlist or maphash[] list |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
272 if (is_abbr) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
273 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
274 mp->m_next = *abbr_table; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
275 *abbr_table = mp; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
276 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
277 else |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
278 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
279 int n = MAP_HASH(mp->m_mode, mp->m_keys[0]); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
280 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
281 mp->m_next = map_table[n]; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
282 map_table[n] = mp; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
283 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
284 return OK; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
285 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
286 |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 * map[!] : show all key mappings |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 * map[!] {lhs} : show key mapping for {lhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 * map[!] {lhs} {rhs} : set key mapping for {lhs} to {rhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 * noremap[!] {lhs} {rhs} : same, but no remapping for {rhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 * unmap[!] {lhs} : remove key mapping for {lhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 * abbr : show all abbreviations |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 * abbr {lhs} : show abbreviations for {lhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 * abbr {lhs} {rhs} : set abbreviation for {lhs} to {rhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 * noreabbr {lhs} {rhs} : same, but no remapping for {rhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 * unabbr {lhs} : remove abbreviation for {lhs} |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 * maptype: 0 for :map, 1 for :unmap, 2 for noremap. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 * arg is pointer to any arguments. Note: arg cannot be a read-only string, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 * it will be modified. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 * for :map mode is NORMAL + VISUAL + SELECTMODE + OP_PENDING |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 * for :map! mode is INSERT + CMDLINE |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 * for :cmap mode is CMDLINE |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 * for :imap mode is INSERT |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 * for :lmap mode is LANGMAP |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 * for :nmap mode is NORMAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 * for :vmap mode is VISUAL + SELECTMODE |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 * for :xmap mode is VISUAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 * for :smap mode is SELECTMODE |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 * for :omap mode is OP_PENDING |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 * for :tmap mode is TERMINAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 * for :abbr mode is INSERT + CMDLINE |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 * for :iabbr mode is INSERT |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 * for :cabbr mode is CMDLINE |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 * Return 0 for success |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 * 1 for invalid arguments |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 * 2 for no match |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 * 4 for out of mem |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 * 5 for entry not unique |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 do_map( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 int maptype, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 char_u *arg, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 int mode, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 int abbrev) // not a mapping but an abbreviation |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 char_u *keys; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 mapblock_T *mp, **mpp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 char_u *rhs; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 int n; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 int len = 0; // init for GCC |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 int hasarg; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 int haskey; |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
341 int do_print; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
342 int keyround; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 char_u *keys_buf = NULL; |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
344 char_u *alt_keys_buf = NULL; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 char_u *arg_buf = NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 int retval = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 int do_backslash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 mapblock_T **abbr_table; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 mapblock_T **map_table; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 int unique = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 int nowait = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 int silent = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 int special = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 int expr = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 #endif |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
357 int did_simplify = FALSE; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 int noremap; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 char_u *orig_rhs; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 keys = arg; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 map_table = maphash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 abbr_table = &first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 // For ":noremap" don't remap, otherwise do remap. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 if (maptype == 2) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 noremap = REMAP_NONE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 noremap = REMAP_YES; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 // Accept <buffer>, <nowait>, <silent>, <expr> <script> and <unique> in |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 // any order. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 for (;;) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 // Check for "<buffer>": mapping local to buffer. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 if (STRNCMP(keys, "<buffer>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 keys = skipwhite(keys + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 map_table = curbuf->b_maphash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 abbr_table = &curbuf->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 // Check for "<nowait>": don't wait for more characters. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 if (STRNCMP(keys, "<nowait>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 keys = skipwhite(keys + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 nowait = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 // Check for "<silent>": don't echo commands. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 if (STRNCMP(keys, "<silent>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 keys = skipwhite(keys + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 silent = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 // Check for "<special>": accept special keys in <> |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 if (STRNCMP(keys, "<special>", 9) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 keys = skipwhite(keys + 9); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 special = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 // Check for "<script>": remap script-local mappings only |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 if (STRNCMP(keys, "<script>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 keys = skipwhite(keys + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 noremap = REMAP_SCRIPT; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 // Check for "<expr>": {rhs} is an expression. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 if (STRNCMP(keys, "<expr>", 6) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 keys = skipwhite(keys + 6); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 expr = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 // Check for "<unique>": don't overwrite an existing mapping. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 if (STRNCMP(keys, "<unique>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 keys = skipwhite(keys + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 unique = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 validate_maphash(); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 // Find end of keys and skip CTRL-Vs (and backslashes) in it. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 // Accept backslash like CTRL-V when 'cpoptions' does not contain 'B'. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 // with :unmap white space is included in the keys, no argument possible. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 p = keys; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 while (*p && (maptype == 1 || !VIM_ISWHITE(*p))) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 if ((p[0] == Ctrl_V || (do_backslash && p[0] == '\\')) && |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 p[1] != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 ++p; // skip CTRL-V or backslash |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 ++p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 if (*p != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 *p++ = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 p = skipwhite(p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 rhs = p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 hasarg = (*rhs != NUL); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 haskey = (*keys != NUL); |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
456 do_print = !haskey || (maptype != 1 && !hasarg); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 // check for :unmap without argument |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 if (maptype == 1 && !haskey) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 retval = 1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 goto theend; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 // If mapping has been given as ^V<C_UP> say, then replace the term codes |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 // with the appropriate two bytes. If it is a shifted special key, unshift |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 // it too, giving another two bytes. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 // replace_termcodes() may move the result to allocated memory, which |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 // needs to be freed later (*keys_buf and *arg_buf). |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 // replace_termcodes() also removes CTRL-Vs and sometimes backslashes. |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
471 // If something like <C-H> is simplified to 0x08 then mark it as simplified |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
472 // and also add a n entry with a modifier, which will work when |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
473 // modifyOtherKeys is working. |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 if (haskey) |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
475 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
476 char_u *new_keys; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
477 int flags = REPTERM_FROM_PART | REPTERM_DO_LT; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
478 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
479 if (special) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
480 flags |= REPTERM_SPECIAL; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
481 new_keys = replace_termcodes(keys, &keys_buf, flags, &did_simplify); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
482 if (did_simplify) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
483 (void)replace_termcodes(keys, &alt_keys_buf, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
484 flags | REPTERM_NO_SIMPLIFY, NULL); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
485 keys = new_keys; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
486 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 orig_rhs = rhs; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 if (hasarg) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 if (STRICMP(rhs, "<nop>") == 0) // "<Nop>" means nothing |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 rhs = (char_u *)""; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 else |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
493 rhs = replace_termcodes(rhs, &arg_buf, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
494 REPTERM_DO_LT | (special ? REPTERM_SPECIAL : 0), NULL); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
497 /* |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
498 * The following is done twice if we have two versions of keys: |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
499 * "alt_keys_buf" is not NULL. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
500 */ |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
501 for (keyround = 1; keyround <= 2; ++keyround) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
503 int did_it = FALSE; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
504 int did_local = FALSE; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
505 int round; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
506 int hash; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
507 int new_hash; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
508 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
509 if (keyround == 2) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
511 if (alt_keys_buf == NULL) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
512 break; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
513 keys = alt_keys_buf; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
515 else if (alt_keys_buf != NULL && do_print) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
516 // when printing always use the not-simplified map |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
517 keys = alt_keys_buf; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
519 // check arguments and translate function keys |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
520 if (haskey) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
522 len = (int)STRLEN(keys); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
523 if (len > MAXMAPLEN) // maximum length of MAXMAPLEN chars |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
525 retval = 1; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
526 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
527 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
529 if (abbrev && maptype != 1) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
530 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
531 // If an abbreviation ends in a keyword character, the |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
532 // rest must be all keyword-char or all non-keyword-char. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
533 // Otherwise we won't be able to find the start of it in a |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
534 // vi-compatible way. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
535 if (has_mbyte) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
537 int first, last; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
538 int same = -1; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
539 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
540 first = vim_iswordp(keys); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
541 last = first; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
542 p = keys + (*mb_ptr2len)(keys); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
543 n = 1; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
544 while (p < keys + len) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
545 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
546 ++n; // nr of (multi-byte) chars |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
547 last = vim_iswordp(p); // type of last char |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
548 if (same == -1 && last != first) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
549 same = n - 1; // count of same char type |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
550 p += (*mb_ptr2len)(p); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
551 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
552 if (last && n > 2 && same >= 0 && same < n - 1) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
553 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
554 retval = 1; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
555 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
556 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
558 else if (vim_iswordc(keys[len - 1])) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
559 // ends in keyword char |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 for (n = 0; n < len - 2; ++n) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2])) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 retval = 1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 goto theend; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
566 // An abbreviation cannot contain white space. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
567 for (n = 0; n < len; ++n) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
568 if (VIM_ISWHITE(keys[n])) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
569 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
570 retval = 1; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
571 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
572 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
573 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
576 if (haskey && hasarg && abbrev) // if we will add an abbreviation |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
577 no_abbr = FALSE; // reset flag that indicates there are |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 // no abbreviations |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
580 if (do_print) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
581 msg_start(); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
583 // Check if a new local mapping wasn't already defined globally. |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
584 if (unique && map_table == curbuf->b_maphash |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
585 && haskey && hasarg && maptype != 1) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
587 // need to loop over all global hash lists |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
588 for (hash = 0; hash < 256 && !got_int; ++hash) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
590 if (abbrev) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
591 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
592 if (hash != 0) // there is only one abbreviation list |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
593 break; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
594 mp = first_abbr; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
595 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
596 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
597 mp = maphash[hash]; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
598 for ( ; mp != NULL && !got_int; mp = mp->m_next) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
600 // check entries with the same mode |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
601 if ((mp->m_mode & mode) != 0 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
602 && mp->m_keylen == len |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
603 && STRNCMP(mp->m_keys, keys, (size_t)len) == 0) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
604 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
605 if (abbrev) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
606 semsg(_( |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
607 "E224: global abbreviation already exists for %s"), |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
608 mp->m_keys); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
609 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
610 semsg(_( |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
611 "E225: global mapping already exists for %s"), |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
612 mp->m_keys); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
613 retval = 5; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
614 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
615 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
620 // When listing global mappings, also list buffer-local ones here. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
621 if (map_table != curbuf->b_maphash && !hasarg && maptype != 1) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
623 // need to loop over all global hash lists |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
624 for (hash = 0; hash < 256 && !got_int; ++hash) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
626 if (abbrev) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
628 if (hash != 0) // there is only one abbreviation list |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
629 break; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
630 mp = curbuf->b_first_abbr; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
631 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
632 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
633 mp = curbuf->b_maphash[hash]; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
634 for ( ; mp != NULL && !got_int; mp = mp->m_next) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
635 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
636 // check entries with the same mode |
18329
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
637 if (!mp->m_simplified && (mp->m_mode & mode) != 0) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
639 if (!haskey) // show all entries |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 showmap(mp, TRUE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 did_local = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
644 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
645 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
646 n = mp->m_keylen; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
647 if (STRNCMP(mp->m_keys, keys, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
648 (size_t)(n < len ? n : len)) == 0) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
649 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
650 showmap(mp, TRUE); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
651 did_local = TRUE; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
652 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
653 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
659 // Find an entry in the maphash[] list that matches. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
660 // For :unmap we may loop two times: once to try to unmap an entry with |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
661 // a matching 'from' part, a second time, if the first fails, to unmap |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
662 // an entry with a matching 'to' part. This was done to allow ":ab foo |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
663 // bar" to be unmapped by typing ":unab foo", where "foo" will be |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
664 // replaced by "bar" because of the abbreviation. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
665 for (round = 0; (round == 0 || maptype == 1) && round <= 1 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
666 && !did_it && !got_int; ++round) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
668 // need to loop over all hash lists |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
669 for (hash = 0; hash < 256 && !got_int; ++hash) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
671 if (abbrev) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
672 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
673 if (hash > 0) // there is only one abbreviation list |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
674 break; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
675 mpp = abbr_table; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
676 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
677 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
678 mpp = &(map_table[hash]); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
679 for (mp = *mpp; mp != NULL && !got_int; mp = *mpp) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
681 |
18329
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
682 if ((mp->m_mode & mode) == 0) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 { |
18329
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
684 // skip entries with wrong mode |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
685 mpp = &(mp->m_next); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
686 continue; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
687 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
688 if (!haskey) // show all entries |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
689 { |
18329
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
690 if (!mp->m_simplified) |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
691 { |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
692 showmap(mp, map_table != maphash); |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
693 did_it = TRUE; |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
694 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
696 else // do we have a match? |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
698 if (round) // second round: Try unmap "rhs" string |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
699 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
700 n = (int)STRLEN(mp->m_str); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
701 p = mp->m_str; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
702 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
703 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
704 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
705 n = mp->m_keylen; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
706 p = mp->m_keys; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
707 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
708 if (STRNCMP(p, keys, (size_t)(n < len ? n : len)) == 0) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
710 if (maptype == 1) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
711 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
712 // Delete entry. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
713 // Only accept a full match. For abbreviations |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
714 // we ignore trailing space when matching with |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
715 // the "lhs", since an abbreviation can't have |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
716 // trailing space. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
717 if (n != len && (!abbrev || round || n > len |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 || *skipwhite(keys + n) != NUL)) |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
719 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
720 mpp = &(mp->m_next); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
721 continue; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
722 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
723 // We reset the indicated mode bits. If nothing |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
724 // is left the entry is deleted below. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
725 mp->m_mode &= ~mode; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
726 did_it = TRUE; // remember we did something |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
727 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
728 else if (!hasarg) // show matching entry |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
729 { |
18329
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
730 if (!mp->m_simplified) |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
731 { |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
732 showmap(mp, map_table != maphash); |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
733 did_it = TRUE; |
1784afa654c8
patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents:
18301
diff
changeset
|
734 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
735 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
736 else if (n != len) // new entry is ambiguous |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 mpp = &(mp->m_next); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
741 else if (unique) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
742 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
743 if (abbrev) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
744 semsg(_( |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
745 "E226: abbreviation already exists for %s"), |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
746 p); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
747 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
748 semsg(_( |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
749 "E227: mapping already exists for %s"), |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
750 p); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
751 retval = 5; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
752 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
753 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
756 // new rhs for existing entry |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
757 mp->m_mode &= ~mode; // remove mode bits |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
758 if (mp->m_mode == 0 && !did_it) // reuse entry |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
760 char_u *newstr = vim_strsave(rhs); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
761 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
762 if (newstr == NULL) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
763 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
764 retval = 4; // no mem |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
765 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
766 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
767 vim_free(mp->m_str); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
768 mp->m_str = newstr; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
769 vim_free(mp->m_orig_str); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
770 mp->m_orig_str = vim_strsave(orig_rhs); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
771 mp->m_noremap = noremap; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
772 mp->m_nowait = nowait; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
773 mp->m_silent = silent; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
774 mp->m_mode = mode; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
775 mp->m_simplified = |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
776 did_simplify && keyround == 1; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
777 #ifdef FEAT_EVAL |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
778 mp->m_expr = expr; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
779 mp->m_script_ctx = current_sctx; |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
780 mp->m_script_ctx.sc_lnum += SOURCING_LNUM; |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
781 #endif |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
782 did_it = TRUE; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
784 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
785 if (mp->m_mode == 0) // entry can be deleted |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
786 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
787 map_free(mpp); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
788 continue; // continue with *mpp |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
789 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
790 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
791 // May need to put this entry into another hash |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
792 // list. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
793 new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
794 if (!abbrev && new_hash != hash) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
795 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
796 *mpp = mp->m_next; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
797 mp->m_next = map_table[new_hash]; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
798 map_table[new_hash] = mp; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
799 |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
800 continue; // continue with *mpp |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 } |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
804 mpp = &(mp->m_next); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
809 if (maptype == 1) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
811 // delete entry |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
812 if (!did_it) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
813 retval = 2; // no match |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
814 else if (*keys == Ctrl_C) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
815 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
816 // If CTRL-C has been unmapped, reuse it for Interrupting. |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
817 if (map_table == curbuf->b_maphash) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
818 curbuf->b_mapped_ctrl_c &= ~mode; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
819 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
820 mapped_ctrl_c &= ~mode; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
821 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
822 continue; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
825 if (!haskey || !hasarg) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 { |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
827 // print entries |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
828 if (!did_it && !did_local) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
829 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
830 if (abbrev) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
831 msg(_("No abbreviation found")); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
832 else |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
833 msg(_("No mapping found")); |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
834 } |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
835 goto theend; // listing finished |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
838 if (did_it) |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
839 continue; // have added the new entry already |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
841 // Get here when adding a new entry to the maphash[] list or abbrlist. |
20510
3d9a2c8d4f95
patch 8.2.0809: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
842 if (map_add(map_table, abbr_table, keys, rhs, orig_rhs, |
3d9a2c8d4f95
patch 8.2.0809: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
843 noremap, nowait, silent, mode, abbrev, |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
844 #ifdef FEAT_EVAL |
20510
3d9a2c8d4f95
patch 8.2.0809: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
845 expr, /* sid */ -1, /* lnum */ 0, |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
846 #endif |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
847 did_simplify && keyround == 1) == FAIL) |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
848 { |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
849 retval = 4; // no mem |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
850 goto theend; |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
851 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 theend: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 vim_free(keys_buf); |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
856 vim_free(alt_keys_buf); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 vim_free(arg_buf); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 return retval; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 * Get the mapping mode from the command name. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 static int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 get_map_mode(char_u **cmdp, int forceit) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 int modec; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 int mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 p = *cmdp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 modec = *p++; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 if (modec == 'i') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 mode = INSERT; // :imap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 else if (modec == 'l') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 mode = LANGMAP; // :lmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 else if (modec == 'c') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 mode = CMDLINE; // :cmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 else if (modec == 'n' && *p != 'o') // avoid :noremap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 mode = NORMAL; // :nmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 else if (modec == 'v') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 mode = VISUAL + SELECTMODE; // :vmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 else if (modec == 'x') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 mode = VISUAL; // :xmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 else if (modec == 's') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 mode = SELECTMODE; // :smap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 else if (modec == 'o') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 mode = OP_PENDING; // :omap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 else if (modec == 't') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 mode = TERMINAL; // :tmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 --p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 if (forceit) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 mode = INSERT + CMDLINE; // :map ! |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 mode = VISUAL + SELECTMODE + NORMAL + OP_PENDING;// :map |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 *cmdp = p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 return mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 * Clear all mappings or abbreviations. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 * 'abbr' should be FALSE for mappings, TRUE for abbreviations. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 static void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 map_clear( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 char_u *cmdp, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 char_u *arg UNUSED, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 int forceit, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 int abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 int mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 int local; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 local = (STRCMP(arg, "<buffer>") == 0); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 if (!local && *arg != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 emsg(_(e_invarg)); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 return; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 mode = get_map_mode(&cmdp, forceit); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 map_clear_int(curbuf, mode, local, abbr); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 * Clear all mappings in "mode". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 map_clear_int( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 buf_T *buf, // buffer for local mappings |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 int mode, // mode in which to delete |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 int local, // TRUE for buffer-local mappings |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 int abbr) // TRUE for abbreviations |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 mapblock_T *mp, **mpp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 int hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 int new_hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 validate_maphash(); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 for (hash = 0; hash < 256; ++hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 if (abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 if (hash > 0) // there is only one abbrlist |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 if (local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 mpp = &buf->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 mpp = &first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 if (local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 mpp = &buf->b_maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 mpp = &maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 while (*mpp != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 mp = *mpp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 if (mp->m_mode & mode) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 mp->m_mode &= ~mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 if (mp->m_mode == 0) // entry can be deleted |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 map_free(mpp); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 // May need to put this entry into another hash list. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 new_hash = MAP_HASH(mp->m_mode, mp->m_keys[0]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 if (!abbr && new_hash != hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 *mpp = mp->m_next; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 if (local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 mp->m_next = buf->b_maphash[new_hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 buf->b_maphash[new_hash] = mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 mp->m_next = maphash[new_hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 maphash[new_hash] = mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 continue; // continue with *mpp |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 mpp = &(mp->m_next); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 #if defined(FEAT_EVAL) || defined(PROTO) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 int |
17946
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
999 mode_str2flags(char_u *modechars) |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 int mode = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 if (vim_strchr(modechars, 'n') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 mode |= NORMAL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 if (vim_strchr(modechars, 'v') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 mode |= VISUAL + SELECTMODE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 if (vim_strchr(modechars, 'x') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 mode |= VISUAL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 if (vim_strchr(modechars, 's') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 mode |= SELECTMODE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 if (vim_strchr(modechars, 'o') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 mode |= OP_PENDING; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 if (vim_strchr(modechars, 'i') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 mode |= INSERT; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 if (vim_strchr(modechars, 'l') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 mode |= LANGMAP; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 if (vim_strchr(modechars, 'c') != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 mode |= CMDLINE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 |
17946
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1020 return mode; |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1021 } |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1022 |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1023 /* |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1024 * Return TRUE if a map exists that has "str" in the rhs for mode "modechars". |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1025 * Recognize termcap codes in "str". |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1026 * Also checks mappings local to the current buffer. |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1027 */ |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1028 int |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1029 map_to_exists(char_u *str, char_u *modechars, int abbr) |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1030 { |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1031 char_u *rhs; |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1032 char_u *buf; |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1033 int retval; |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1034 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
1035 rhs = replace_termcodes(str, &buf, REPTERM_DO_LT, NULL); |
17946
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1036 |
ec4248c4b92c
patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents:
17940
diff
changeset
|
1037 retval = map_to_exists_mode(rhs, mode_str2flags(modechars), abbr); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 vim_free(buf); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 return retval; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 * Return TRUE if a map exists that has "str" in the rhs for mode "mode". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 * Also checks mappings local to the current buffer. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 map_to_exists_mode(char_u *rhs, int mode, int abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 int hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 int exp_buffer = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 validate_maphash(); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 // Do it twice: once for global maps and once for local maps. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 for (;;) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 for (hash = 0; hash < 256; ++hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 if (abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 if (hash > 0) // there is only one abbr list |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 if (exp_buffer) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 mp = curbuf->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 mp = first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 else if (exp_buffer) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 mp = curbuf->b_maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 mp = maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 for (; mp; mp = mp->m_next) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 if ((mp->m_mode & mode) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 && strstr((char *)mp->m_str, (char *)rhs) != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 return TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 if (exp_buffer) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 exp_buffer = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 return FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 * Used below when expanding mapping/abbreviation names. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 static int expand_mapmodes = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 static int expand_isabbrev = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 static int expand_buffer = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 /* |
19178
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1098 * Translate an internal mapping/abbreviation representation into the |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1099 * corresponding external one recognized by :map/:abbrev commands. |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1100 * Respects the current B/k/< settings of 'cpoption'. |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1101 * |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1102 * This function is called when expanding mappings/abbreviations on the |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1103 * command-line. |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1104 * |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1105 * It uses a growarray to build the translation string since the latter can be |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1106 * wider than the original description. The caller has to free the string |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1107 * afterwards. |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1108 * |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1109 * Returns NULL when there is a problem. |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1110 */ |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1111 static char_u * |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1112 translate_mapping(char_u *str) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1113 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1114 garray_T ga; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1115 int c; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1116 int modifiers; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1117 int cpo_bslash; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1118 int cpo_special; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1119 |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1120 ga_init(&ga); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1121 ga.ga_itemsize = 1; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1122 ga.ga_growsize = 40; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1123 |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1124 cpo_bslash = (vim_strchr(p_cpo, CPO_BSLASH) != NULL); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1125 cpo_special = (vim_strchr(p_cpo, CPO_SPECI) != NULL); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1126 |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1127 for (; *str; ++str) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1128 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1129 c = *str; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1130 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1131 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1132 modifiers = 0; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1133 if (str[1] == KS_MODIFIER) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1134 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1135 str++; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1136 modifiers = *++str; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1137 c = *++str; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1138 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1139 if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1140 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1141 if (cpo_special) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1142 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1143 ga_clear(&ga); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1144 return NULL; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1145 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1146 c = TO_SPECIAL(str[1], str[2]); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1147 if (c == K_ZERO) // display <Nul> as ^@ |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1148 c = NUL; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1149 str += 2; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1150 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1151 if (IS_SPECIAL(c) || modifiers) // special key |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1152 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1153 if (cpo_special) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1154 { |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1155 ga_clear(&ga); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1156 return NULL; |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1157 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1158 ga_concat(&ga, get_special_key_name(c, modifiers)); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1159 continue; // for (str) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1160 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1161 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1162 if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1163 || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1164 ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1165 if (c) |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1166 ga_append(&ga, c); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1167 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1168 ga_append(&ga, NUL); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1169 return (char_u *)(ga.ga_data); |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1170 } |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1171 |
f7081bd2680e
patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
1172 /* |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 * Work out what to complete when doing command line completion of mapping |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 * or abbreviation names. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 char_u * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 set_context_in_map_cmd( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 expand_T *xp, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 char_u *cmd, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 char_u *arg, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 int forceit, // TRUE if '!' given |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 int isabbrev, // TRUE if abbreviation |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 int isunmap, // TRUE if unmap/unabbrev command |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 cmdidx_T cmdidx) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 if (forceit && cmdidx != CMD_map && cmdidx != CMD_unmap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 xp->xp_context = EXPAND_NOTHING; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 if (isunmap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 expand_mapmodes = get_map_mode(&cmd, forceit || isabbrev); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 expand_mapmodes = INSERT + CMDLINE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 if (!isabbrev) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 expand_mapmodes += VISUAL + SELECTMODE + NORMAL + OP_PENDING; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 expand_isabbrev = isabbrev; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 xp->xp_context = EXPAND_MAPPINGS; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 expand_buffer = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 for (;;) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 if (STRNCMP(arg, "<buffer>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 expand_buffer = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 arg = skipwhite(arg + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 if (STRNCMP(arg, "<unique>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 arg = skipwhite(arg + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 if (STRNCMP(arg, "<nowait>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 arg = skipwhite(arg + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 if (STRNCMP(arg, "<silent>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 arg = skipwhite(arg + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 if (STRNCMP(arg, "<special>", 9) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 arg = skipwhite(arg + 9); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 if (STRNCMP(arg, "<script>", 8) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 arg = skipwhite(arg + 8); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 if (STRNCMP(arg, "<expr>", 6) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 arg = skipwhite(arg + 6); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 xp->xp_pattern = arg; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 return NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 * Find all mapping/abbreviation names that match regexp "regmatch"'. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 * For command line expansion of ":[un]map" and ":[un]abbrev" in all modes. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 * Return OK if matches found, FAIL otherwise. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 ExpandMappings( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 regmatch_T *regmatch, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 int *num_file, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 char_u ***file) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 int hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 int count; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 int round; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 int i; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 validate_maphash(); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 *num_file = 0; // return values in case of FAIL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 *file = NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 // round == 1: Count the matches. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 // round == 2: Build the array to keep the matches. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 for (round = 1; round <= 2; ++round) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 count = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 for (i = 0; i < 7; ++i) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 if (i == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 p = (char_u *)"<silent>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 else if (i == 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 p = (char_u *)"<unique>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 else if (i == 2) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 p = (char_u *)"<script>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 else if (i == 3) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 p = (char_u *)"<expr>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 else if (i == 4 && !expand_buffer) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 p = (char_u *)"<buffer>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 else if (i == 5) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 p = (char_u *)"<nowait>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 else if (i == 6) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 p = (char_u *)"<special>"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 if (vim_regexec(regmatch, p, (colnr_T)0)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 if (round == 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 ++count; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 (*file)[count++] = vim_strsave(p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 for (hash = 0; hash < 256; ++hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 if (expand_isabbrev) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 if (hash > 0) // only one abbrev list |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 break; // for (hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 mp = first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 else if (expand_buffer) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 mp = curbuf->b_maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 mp = maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 for (; mp; mp = mp->m_next) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 if (mp->m_mode & expand_mapmodes) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 p = translate_mapping(mp->m_keys); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 if (p != NULL && vim_regexec(regmatch, p, (colnr_T)0)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 if (round == 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 ++count; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 (*file)[count++] = p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 p = NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 vim_free(p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 } // for (mp) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 } // for (hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 if (count == 0) // no match found |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 break; // for (round) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 if (round == 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 *file = ALLOC_MULT(char_u *, count); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 if (*file == NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 } // for (round) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 if (count > 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 char_u **ptr1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 char_u **ptr2; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 char_u **ptr3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 // Sort the matches |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 sort_strings(*file, count); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 // Remove multiple entries |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 ptr1 = *file; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 ptr2 = ptr1 + 1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 ptr3 = ptr1 + count; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 while (ptr2 < ptr3) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 if (STRCMP(*ptr1, *ptr2)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 *++ptr1 = *ptr2++; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 vim_free(*ptr2++); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 count--; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 *num_file = count; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 return (count == 0 ? FAIL : OK); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 * Check for an abbreviation. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 * Cursor is at ptr[col]. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 * When inserting, mincol is where insert started. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 * For the command line, mincol is what is to be skipped over. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 * "c" is the character typed before check_abbr was called. It may have |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 * ABBR_OFF added to avoid prepending a CTRL-V to it. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 * Historic vi practice: The last character of an abbreviation must be an id |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 * character ([a-zA-Z0-9_]). The characters in front of it must be all id |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 * characters or all non-id characters. This allows for abbr. "#i" to |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 * "#include". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 * Vim addition: Allow for abbreviations that end in a non-keyword character. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 * Then there must be white space before the abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 * return TRUE if there is an abbreviation, FALSE if not |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 check_abbr( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 int c, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 char_u *ptr, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 int col, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 int mincol) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 int len; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 int scol; // starting column of the abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 int j; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 char_u *s; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 char_u tb[MB_MAXBYTES + 4]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 mapblock_T *mp2; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 int clen = 0; // length in characters |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 int is_id = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 int vim_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 if (typebuf.tb_no_abbr_cnt) // abbrev. are not recursive |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 return FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 // no remapping implies no abbreviation, except for CTRL-] |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 if (noremap_keys() && c != Ctrl_RSB) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 return FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 // Check for word before the cursor: If it ends in a keyword char all |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 // chars before it must be keyword chars or non-keyword chars, but not |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 // white space. If it ends in a non-keyword char we accept any characters |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 // before it except white space. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 if (col == 0) // cannot be an abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 return FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 if (has_mbyte) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 p = mb_prevptr(ptr, ptr + col); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 if (!vim_iswordp(p)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 vim_abbr = TRUE; // Vim added abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 vim_abbr = FALSE; // vi compatible abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 if (p > ptr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 is_id = vim_iswordp(mb_prevptr(ptr, p)); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 clen = 1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 while (p > ptr + mincol) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 p = mb_prevptr(ptr, p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 if (vim_isspace(*p) || (!vim_abbr && is_id != vim_iswordp(p))) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 p += (*mb_ptr2len)(p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 ++clen; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 scol = (int)(p - ptr); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 if (!vim_iswordc(ptr[col - 1])) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 vim_abbr = TRUE; // Vim added abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 vim_abbr = FALSE; // vi compatible abbr. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 if (col > 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 is_id = vim_iswordc(ptr[col - 2]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 for (scol = col - 1; scol > 0 && !vim_isspace(ptr[scol - 1]) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 && (vim_abbr || is_id == vim_iswordc(ptr[scol - 1])); --scol) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 ; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 if (scol < mincol) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 scol = mincol; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 if (scol < col) // there is a word in front of the cursor |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 ptr += scol; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 len = col - scol; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 mp = curbuf->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 mp2 = first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 if (mp == NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 mp = mp2; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 mp2 = NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 for ( ; mp; mp->m_next == NULL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 ? (mp = mp2, mp2 = NULL) : (mp = mp->m_next)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 int qlen = mp->m_keylen; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 char_u *q = mp->m_keys; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 int match; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 char_u *qe = vim_strsave(mp->m_keys); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 // might have CSI escaped mp->m_keys |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 if (qe != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 q = qe; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 vim_unescape_csi(q); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 qlen = (int)STRLEN(q); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 // find entries with right mode and keys |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 match = (mp->m_mode & State) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 && qlen == len |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 && !STRNCMP(q, ptr, (size_t)len); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 if (q != mp->m_keys) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 vim_free(q); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 if (match) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 if (mp != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 // Found a match: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 // Insert the rest of the abbreviation in typebuf.tb_buf[]. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 // This goes from end to start. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 // |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 // Characters 0x000 - 0x100: normal chars, may need CTRL-V, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 // except K_SPECIAL: Becomes K_SPECIAL KS_SPECIAL KE_FILLER |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 // Characters where IS_SPECIAL() == TRUE: key codes, need |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 // K_SPECIAL. Other characters (with ABBR_OFF): don't use CTRL-V. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 // |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 // Character CTRL-] is treated specially - it completes the |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 // abbreviation, but is not inserted into the input stream. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 j = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 if (c != Ctrl_RSB) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 // special key code, split up |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 if (IS_SPECIAL(c) || c == K_SPECIAL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 tb[j++] = K_SPECIAL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 tb[j++] = K_SECOND(c); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 tb[j++] = K_THIRD(c); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 if (c < ABBR_OFF && (c < ' ' || c > '~')) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 tb[j++] = Ctrl_V; // special char needs CTRL-V |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 if (has_mbyte) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 // if ABBR_OFF has been added, remove it here |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 if (c >= ABBR_OFF) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 c -= ABBR_OFF; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 j += (*mb_char2bytes)(c, tb + j); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 tb[j++] = c; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 tb[j] = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 // insert the last typed char |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 if (mp->m_expr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 s = eval_map_expr(mp->m_str, c); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 s = mp->m_str; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 if (s != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 // insert the to string |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 (void)ins_typebuf(s, mp->m_noremap, 0, TRUE, mp->m_silent); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 // no abbrev. for these chars |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 typebuf.tb_no_abbr_cnt += (int)STRLEN(s) + j + 1; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 if (mp->m_expr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 vim_free(s); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 tb[0] = Ctrl_H; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 tb[1] = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 if (has_mbyte) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 len = clen; // Delete characters instead of bytes |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 while (len-- > 0) // delete the from string |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 return TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1581 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 return FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 * Evaluate the RHS of a mapping or abbreviations and take care of escaping |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 * special characters. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 char_u * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1591 eval_map_expr( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 char_u *str, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 int c) // NUL or typed character for abbreviation |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 char_u *res; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1597 char_u *expr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 pos_T save_cursor; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 int save_msg_col; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 int save_msg_row; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1601 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1602 // Remove escaping of CSI, because "str" is in a format to be used as |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 // typeahead. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 expr = vim_strsave(str); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 if (expr == NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 return NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 vim_unescape_csi(expr); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1608 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 // Forbid changing text or using ":normal" to avoid most of the bad side |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 // effects. Also restore the cursor position. |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1611 ++textwinlock; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 ++ex_normal_lock; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 set_vim_var_char(c); // set v:char to the typed character |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 save_cursor = curwin->w_cursor; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 save_msg_col = msg_col; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 save_msg_row = msg_row; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 p = eval_to_string(expr, NULL, FALSE); |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1618 --textwinlock; |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 --ex_normal_lock; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 curwin->w_cursor = save_cursor; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 msg_col = save_msg_col; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 msg_row = save_msg_row; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 vim_free(expr); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 if (p == NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 return NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1628 // Escape CSI in the result to be able to use the string as typeahead. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 res = vim_strsave_escape_csi(p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 vim_free(p); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 return res; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 * Copy "p" to allocated memory, escaping K_SPECIAL and CSI so that the result |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 * can be put in the typeahead buffer. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 * Returns NULL when out of memory. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1640 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 char_u * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 vim_strsave_escape_csi( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 char_u *p) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 char_u *res; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1646 char_u *s, *d; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 // Need a buffer to hold up to three times as much. Four in case of an |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 // illegal utf-8 byte: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 // 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 res = alloc(STRLEN(p) * 4 + 1); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 if (res != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 d = res; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 for (s = p; *s != NUL; ) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 if (s[0] == K_SPECIAL && s[1] != NUL && s[2] != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 // Copy special key unmodified. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 *d++ = *s++; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 *d++ = *s++; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 *d++ = *s++; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 // Add character, possibly multi-byte to destination, escaping |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 // CSI and K_SPECIAL. Be careful, it can be an illegal byte! |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 d = add_char2buf(PTR2CHAR(s), d); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 s += MB_CPTR2LEN(s); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 *d = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1673 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1674 return res; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1675 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 * Remove escaping from CSI and K_SPECIAL characters. Reverse of |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 * vim_strsave_escape_csi(). Works in-place. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 vim_unescape_csi(char_u *p) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1684 char_u *s = p, *d = p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1685 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 while (*s != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1688 if (s[0] == K_SPECIAL && s[1] == KS_SPECIAL && s[2] == KE_FILLER) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1689 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 *d++ = K_SPECIAL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 s += 3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 else if ((s[0] == K_SPECIAL || s[0] == CSI) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 && s[1] == KS_EXTRA && s[2] == (int)KE_CSI) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1696 *d++ = CSI; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 s += 3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1699 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1700 *d++ = *s++; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1701 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1702 *d = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1703 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 * Write map commands for the current mappings to an .exrc file. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 * Return FAIL on error, OK otherwise. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 makemap( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1711 FILE *fd, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 buf_T *buf) // buffer for local mappings or NULL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 char_u c1, c2, c3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1716 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 char *cmd; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 int abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 int hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 int did_cpo = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 int i; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 validate_maphash(); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 // Do the loop twice: Once for mappings, once for abbreviations. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 // Then loop over all map hash lists. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1727 for (abbr = 0; abbr < 2; ++abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 for (hash = 0; hash < 256; ++hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1729 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 if (abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 if (hash > 0) // there is only one abbr list |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 if (buf != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 mp = buf->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 mp = first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 if (buf != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 mp = buf->b_maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 mp = maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 for ( ; mp; mp = mp->m_next) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 // skip script-local mappings |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 if (mp->m_noremap == REMAP_SCRIPT) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1751 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1752 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1753 // skip mappings that contain a <SNR> (script-local thing), |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1754 // they probably don't work when loaded again |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1755 for (p = mp->m_str; *p != NUL; ++p) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 if (p[0] == K_SPECIAL && p[1] == KS_EXTRA |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 && p[2] == (int)KE_SNR) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 if (*p != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 // It's possible to create a mapping and then ":unmap" certain |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 // modes. We recreate this here by mapping the individual |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 // modes, which requires up to three of them. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1765 c1 = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 c2 = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 c3 = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 if (abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 cmd = "abbr"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 cmd = "map"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 switch (mp->m_mode) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 case NORMAL + VISUAL + SELECTMODE + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 case NORMAL: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 case VISUAL: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 c1 = 'x'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 case SELECTMODE: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 c1 = 's'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 case OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 c1 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 case NORMAL + VISUAL: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 c2 = 'x'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 case NORMAL + SELECTMODE: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 c2 = 's'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 case NORMAL + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1798 c2 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 case VISUAL + SELECTMODE: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 c1 = 'v'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 case VISUAL + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 c1 = 'x'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 c2 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 case SELECTMODE + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 c1 = 's'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 c2 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 case NORMAL + VISUAL + SELECTMODE: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 c2 = 'v'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1814 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 case NORMAL + VISUAL + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 c2 = 'x'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 c3 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 case NORMAL + SELECTMODE + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 c1 = 'n'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 c2 = 's'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 c3 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 case VISUAL + SELECTMODE + OP_PENDING: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 c1 = 'v'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 c2 = 'o'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1828 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 case CMDLINE + INSERT: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 if (!abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 cmd = "map!"; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1832 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 case CMDLINE: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 c1 = 'c'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1835 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 case INSERT: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 c1 = 'i'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 case LANGMAP: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 c1 = 'l'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 case TERMINAL: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 c1 = 't'; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 default: |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 iemsg(_("E228: makemap: Illegal mode")); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1847 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 do // do this twice if c2 is set, 3 times with c3 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1850 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 // When outputting <> form, need to make sure that 'cpo' |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 // is set to the Vim default. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1853 if (!did_cpo) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1854 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1855 if (*mp->m_str == NUL) // will use <Nop> |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 did_cpo = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 for (i = 0; i < 2; ++i) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 for (p = (i ? mp->m_str : mp->m_keys); *p; ++p) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 if (*p == K_SPECIAL || *p == NL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 did_cpo = TRUE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 if (did_cpo) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 if (fprintf(fd, "let s:cpo_save=&cpo") < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 || put_eol(fd) < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 || fprintf(fd, "set cpo&vim") < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 || put_eol(fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 if (c1 && putc(c1, fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1873 if (mp->m_noremap != REMAP_YES && fprintf(fd, "nore") < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 if (fputs(cmd, fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 if (buf != NULL && fputs(" <buffer>", fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 if (mp->m_nowait && fputs(" <nowait>", fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 if (mp->m_silent && fputs(" <silent>", fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 #ifdef FEAT_EVAL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 if (mp->m_noremap == REMAP_SCRIPT |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 && fputs("<script>", fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1886 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1887 if (mp->m_expr && fputs(" <expr>", fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1888 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1891 if ( putc(' ', fd) < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 || put_escstr(fd, mp->m_keys, 0) == FAIL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1893 || putc(' ', fd) < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1894 || put_escstr(fd, mp->m_str, 1) == FAIL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 || put_eol(fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1897 c1 = c2; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 c2 = c3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1899 c3 = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 } while (c1 != NUL); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1904 if (did_cpo) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 if (fprintf(fd, "let &cpo=s:cpo_save") < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 || put_eol(fd) < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1907 || fprintf(fd, "unlet s:cpo_save") < 0 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 || put_eol(fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1909 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1910 return OK; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1911 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1912 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1913 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1914 * write escape string to file |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1915 * "what": 0 for :map lhs, 1 for :map rhs, 2 for :set |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 * return FAIL for failure, OK otherwise |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 int |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 put_escstr(FILE *fd, char_u *strstart, int what) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 char_u *str = strstart; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 int c; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 int modifiers; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 // :map xx <Nop> |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 if (*str == NUL && what == 1) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 if (fprintf(fd, "<Nop>") < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 return OK; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1933 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1934 for ( ; *str != NUL; ++str) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1935 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1936 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1937 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 // Check for a multi-byte character, which may contain escaped |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 // K_SPECIAL and CSI bytes |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 p = mb_unescape(&str); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 if (p != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 while (*p != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 if (fputc(*p++, fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1946 --str; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1948 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1949 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1950 c = *str; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1951 // Special key codes have to be translated to be able to make sense |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1952 // when they are read back. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1953 if (c == K_SPECIAL && what != 2) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1954 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1955 modifiers = 0x0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1956 if (str[1] == KS_MODIFIER) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1957 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1958 modifiers = str[2]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1959 str += 3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 c = *str; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1962 if (c == K_SPECIAL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 c = TO_SPECIAL(str[1], str[2]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 str += 2; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 if (IS_SPECIAL(c) || modifiers) // special key |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 if (fputs((char *)get_special_key_name(c, modifiers), fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1975 // A '\n' in a map command should be written as <NL>. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 // A '\n' in a set command should be written as \^V^J. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1977 if (c == NL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1978 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1979 if (what == 2) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1980 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 if (fprintf(fd, IF_EB("\\\026\n", "\\" CTRL_V_STR "\n")) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 if (fprintf(fd, "<NL>") < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1987 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1988 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1989 continue; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1990 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1991 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1992 // Some characters have to be escaped with CTRL-V to |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1993 // prevent them from misinterpreted in DoOneCmd(). |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1994 // A space, Tab and '"' has to be escaped with a backslash to |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1995 // prevent it to be misinterpreted in do_set(). |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1996 // A space has to be escaped with a CTRL-V when it's at the start of a |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1997 // ":map" rhs. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1998 // A '<' has to be escaped with a CTRL-V to prevent it being |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1999 // interpreted as the start of a special key name. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2000 // A space in the lhs of a :map needs a CTRL-V. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2001 if (what == 2 && (VIM_ISWHITE(c) || c == '"' || c == '\\')) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2002 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2003 if (putc('\\', fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2004 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2005 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2006 else if (c < ' ' || c > '~' || c == '|' |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2007 || (what == 0 && c == ' ') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2008 || (what == 1 && str == strstart && c == ' ') |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2009 || (what != 2 && c == '<')) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2010 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2011 if (putc(Ctrl_V, fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2012 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2013 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2014 if (putc(c, fd) < 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2015 return FAIL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2016 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2017 return OK; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2018 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2019 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2021 * Check all mappings for the presence of special key codes. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2022 * Used after ":set term=xxx". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2023 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2024 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 check_map_keycodes(void) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2027 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2028 char_u *p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2029 int i; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 char_u buf[3]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 int abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 int hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2033 buf_T *bp; |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
2034 ESTACK_CHECK_DECLARATION |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2035 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2036 validate_maphash(); |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2037 // avoids giving error messages |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2038 estack_push(ETYPE_INTERNAL, (char_u *)"mappings", 0); |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
2039 ESTACK_CHECK_SETUP |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2040 |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18329
diff
changeset
|
2041 // Do this once for each buffer, and then once for global |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 // mappings/abbreviations with bp == NULL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2043 for (bp = firstbuf; ; bp = bp->b_next) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2044 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2045 // Do the loop twice: Once for mappings, once for abbreviations. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2046 // Then loop over all map hash lists. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 for (abbr = 0; abbr <= 1; ++abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2048 for (hash = 0; hash < 256; ++hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2049 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2050 if (abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2051 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 if (hash) // there is only one abbr list |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2053 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2054 if (bp != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2055 mp = bp->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2056 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2057 mp = first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2058 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2059 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2060 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2061 if (bp != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2062 mp = bp->b_maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2063 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2064 mp = maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2065 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2066 for ( ; mp != NULL; mp = mp->m_next) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2067 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2068 for (i = 0; i <= 1; ++i) // do this twice |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2069 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2070 if (i == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2071 p = mp->m_keys; // once for the "from" part |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2072 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2073 p = mp->m_str; // and once for the "to" part |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2074 while (*p) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2075 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2076 if (*p == K_SPECIAL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2077 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2078 ++p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2079 if (*p < 128) // for "normal" tcap entries |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2080 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2081 buf[0] = p[0]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2082 buf[1] = p[1]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2083 buf[2] = NUL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2084 (void)add_termcap_entry(buf, FALSE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2085 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2086 ++p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2087 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2088 ++p; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2089 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2090 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2091 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2092 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2093 if (bp == NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2094 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2095 } |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
2096 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2097 estack_pop(); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2100 #if defined(FEAT_EVAL) || defined(PROTO) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2101 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2102 * Check the string "keys" against the lhs of all mappings. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2103 * Return pointer to rhs of mapping (mapblock->m_str). |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2104 * NULL when no mapping found. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2105 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2106 char_u * |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2107 check_map( |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2108 char_u *keys, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2109 int mode, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 int exact, // require exact match |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2111 int ign_mod, // ignore preceding modifier |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2112 int abbr, // do abbreviations |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 mapblock_T **mp_ptr, // return: pointer to mapblock or NULL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2114 int *local_ptr) // return: buffer-local mapping or NULL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2115 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2116 int hash; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 int len, minlen; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2119 char_u *s; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2120 int local; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2121 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2122 validate_maphash(); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2123 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2124 len = (int)STRLEN(keys); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2125 for (local = 1; local >= 0; --local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2126 // loop over all hash lists |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2127 for (hash = 0; hash < 256; ++hash) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2128 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2129 if (abbr) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2130 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2131 if (hash > 0) // there is only one list. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2132 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2133 if (local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2134 mp = curbuf->b_first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2135 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2136 mp = first_abbr; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2137 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 else if (local) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2139 mp = curbuf->b_maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2140 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2141 mp = maphash[hash]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2142 for ( ; mp != NULL; mp = mp->m_next) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2143 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2144 // skip entries with wrong mode, wrong length and not matching |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2145 // ones |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2146 if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2147 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2148 if (len > mp->m_keylen) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2149 minlen = mp->m_keylen; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 minlen = len; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 s = mp->m_keys; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 if (ign_mod && s[0] == K_SPECIAL && s[1] == KS_MODIFIER |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 && s[2] != NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2155 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2156 s += 3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 if (len > mp->m_keylen - 3) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2158 minlen = mp->m_keylen - 3; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2159 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2160 if (STRNCMP(s, keys, minlen) == 0) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2162 if (mp_ptr != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2163 *mp_ptr = mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 if (local_ptr != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2165 *local_ptr = local; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 return mp->m_str; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2167 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2169 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 return NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2176 get_maparg(typval_T *argvars, typval_T *rettv, int exact) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2178 char_u *keys; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2179 char_u *which; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 char_u buf[NUMBUFLEN]; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2181 char_u *keys_buf = NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2182 char_u *rhs; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 int mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2184 int abbr = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2185 int get_dict = FALSE; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 mapblock_T *mp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2187 int buffer_local; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 // return empty string for failure |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 rettv->v_type = VAR_STRING; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 rettv->vval.v_string = NULL; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2193 keys = tv_get_string(&argvars[0]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2194 if (*keys == NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2195 return; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2196 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2197 if (argvars[1].v_type != VAR_UNKNOWN) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2199 which = tv_get_string_buf_chk(&argvars[1], buf); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2200 if (argvars[2].v_type != VAR_UNKNOWN) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2201 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2202 abbr = (int)tv_get_number(&argvars[2]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2203 if (argvars[3].v_type != VAR_UNKNOWN) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2204 get_dict = (int)tv_get_number(&argvars[3]); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2205 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2206 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2207 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2208 which = (char_u *)""; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2209 if (which == NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2210 return; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2211 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2212 mode = get_map_mode(&which, 0); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2213 |
18301
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
2214 keys = replace_termcodes(keys, &keys_buf, |
506bf60a30a0
patch 8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Bram Moolenaar <Bram@vim.org>
parents:
17946
diff
changeset
|
2215 REPTERM_FROM_PART | REPTERM_DO_LT, NULL); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2216 rhs = check_map(keys, mode, exact, FALSE, abbr, &mp, &buffer_local); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2217 vim_free(keys_buf); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2218 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2219 if (!get_dict) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2220 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 // Return a string. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2222 if (rhs != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 if (*rhs == NUL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 rettv->vval.v_string = vim_strsave((char_u *)"<Nop>"); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 rettv->vval.v_string = str2special_save(rhs, FALSE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2229 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2230 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 // Return a dictionary. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 char_u *lhs = str2special_save(mp->m_keys, TRUE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 char_u *mapmode = map_mode_to_chars(mp->m_mode); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2236 dict_T *dict = rettv->vval.v_dict; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2238 dict_add_string(dict, "lhs", lhs); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2239 dict_add_string(dict, "rhs", mp->m_orig_str); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2240 dict_add_number(dict, "noremap", mp->m_noremap ? 1L : 0L); |
19870
658248b68f7c
patch 8.2.0491: cannot recognize a <script> mapping using maparg()
Bram Moolenaar <Bram@vim.org>
parents:
19178
diff
changeset
|
2241 dict_add_number(dict, "script", mp->m_noremap == REMAP_SCRIPT |
658248b68f7c
patch 8.2.0491: cannot recognize a <script> mapping using maparg()
Bram Moolenaar <Bram@vim.org>
parents:
19178
diff
changeset
|
2242 ? 1L : 0L); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2243 dict_add_number(dict, "expr", mp->m_expr ? 1L : 0L); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2244 dict_add_number(dict, "silent", mp->m_silent ? 1L : 0L); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 dict_add_number(dict, "sid", (long)mp->m_script_ctx.sc_sid); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2246 dict_add_number(dict, "lnum", (long)mp->m_script_ctx.sc_lnum); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 dict_add_number(dict, "buffer", (long)buffer_local); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2248 dict_add_number(dict, "nowait", mp->m_nowait ? 1L : 0L); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 dict_add_string(dict, "mode", mapmode); |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2250 dict_add_number(dict, "simplified", mp->m_simplified); |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2251 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2252 vim_free(lhs); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2253 vim_free(mapmode); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2254 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2255 } |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2256 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2257 /* |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2258 * "mapset()" function |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2259 */ |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2260 void |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2261 f_mapset(typval_T *argvars, typval_T *rettv UNUSED) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2262 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2263 char_u *keys; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2264 char_u *keys_buf = NULL; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2265 char_u *which; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2266 int mode; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2267 char_u buf[NUMBUFLEN]; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2268 int is_abbr; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2269 dict_T *d; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2270 char_u *lhs; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2271 char_u *rhs; |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2272 char_u *orig_rhs; |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2273 char_u *arg_buf = NULL; |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2274 int noremap; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2275 int expr; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2276 int silent; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2277 scid_T sid; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2278 linenr_T lnum; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2279 mapblock_T **map_table = maphash; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2280 mapblock_T **abbr_table = &first_abbr; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2281 int nowait; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2282 int simplified; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2283 char_u *arg; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2284 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2285 which = tv_get_string_buf_chk(&argvars[0], buf); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2286 mode = get_map_mode(&which, 0); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2287 is_abbr = (int)tv_get_number(&argvars[1]); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2288 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2289 if (argvars[2].v_type != VAR_DICT) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2290 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2291 emsg(_(e_dictkey)); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2292 return; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2293 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2294 d = argvars[2].vval.v_dict; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2295 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2296 // Get the values in the same order as above in get_maparg(). |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2297 lhs = dict_get_string(d, (char_u *)"lhs", FALSE); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2298 if (lhs == NULL) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2299 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2300 emsg(_("E99: lhs entry missing in mapset() dict argument")); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2301 return; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2302 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2303 rhs = dict_get_string(d, (char_u *)"rhs", FALSE); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2304 if (rhs == NULL) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2305 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2306 emsg(_("E99: rhs entry missing in mapset() dict argument")); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2307 return; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2308 } |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2309 orig_rhs = rhs; |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2310 rhs = replace_termcodes(rhs, &arg_buf, |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2311 REPTERM_DO_LT | REPTERM_SPECIAL, NULL); |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2312 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2313 noremap = dict_get_number(d, (char_u *)"noremap") ? REMAP_NONE: 0; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2314 if (dict_get_number(d, (char_u *)"script") != 0) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2315 noremap = REMAP_SCRIPT; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2316 expr = dict_get_number(d, (char_u *)"expr") != 0; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2317 silent = dict_get_number(d, (char_u *)"silent") != 0; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2318 sid = dict_get_number(d, (char_u *)"sid"); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2319 lnum = dict_get_number(d, (char_u *)"lnum"); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2320 if (dict_get_number(d, (char_u *)"buffer")) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2321 { |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2322 map_table = curbuf->b_maphash; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2323 abbr_table = &curbuf->b_first_abbr; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2324 } |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2325 nowait = dict_get_number(d, (char_u *)"nowait") != 0; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2326 // mode from the dict is not used |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2327 simplified = dict_get_number(d, (char_u *)"simplified") != 0; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2328 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2329 // Delete any existing mapping for this lhs and mode. |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2330 arg = vim_strsave(lhs); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2331 if (arg == NULL) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2332 return; |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2333 do_map(1, arg, mode, is_abbr); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2334 vim_free(arg); |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2335 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2336 keys = replace_termcodes(lhs, &keys_buf, |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2337 REPTERM_FROM_PART | REPTERM_DO_LT, NULL); |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2338 (void)map_add(map_table, abbr_table, keys, rhs, orig_rhs, noremap, |
20510
3d9a2c8d4f95
patch 8.2.0809: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
2339 nowait, silent, mode, is_abbr, expr, sid, lnum, simplified); |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2340 vim_free(keys_buf); |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20510
diff
changeset
|
2341 vim_free(arg_buf); |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2342 } |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2343 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2344 |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
2345 |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2346 #if defined(MSWIN) || defined(MACOS_X) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2347 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2348 # define VIS_SEL (VISUAL+SELECTMODE) // abbreviation |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2349 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2350 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 * Default mappings for some often used keys. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2352 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2353 struct initmap |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2355 char_u *arg; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 int mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2357 }; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2359 # ifdef FEAT_GUI_MSWIN |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2360 // Use the Windows (CUA) keybindings. (GUI) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2361 static struct initmap initmappings[] = |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2362 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2363 // paste, copy and cut |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2364 {(char_u *)"<S-Insert> \"*P", NORMAL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2365 {(char_u *)"<S-Insert> \"-d\"*P", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2366 {(char_u *)"<S-Insert> <C-R><C-O>*", INSERT+CMDLINE}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2367 {(char_u *)"<C-Insert> \"*y", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2368 {(char_u *)"<S-Del> \"*d", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2369 {(char_u *)"<C-Del> \"*d", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2370 {(char_u *)"<C-X> \"*d", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2371 // Missing: CTRL-C (cancel) and CTRL-V (block selection) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 }; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2373 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2374 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2375 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2376 // Use the Windows (CUA) keybindings. (Console) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2377 static struct initmap cinitmappings[] = |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2378 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2379 {(char_u *)"\316w <C-Home>", NORMAL+VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2380 {(char_u *)"\316w <C-Home>", INSERT+CMDLINE}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2381 {(char_u *)"\316u <C-End>", NORMAL+VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2382 {(char_u *)"\316u <C-End>", INSERT+CMDLINE}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2384 // paste, copy and cut |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2385 # ifdef FEAT_CLIPBOARD |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2386 {(char_u *)"\316\324 \"*P", NORMAL}, // SHIFT-Insert is "*P |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2387 {(char_u *)"\316\324 \"-d\"*P", VIS_SEL}, // SHIFT-Insert is "-d"*P |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 {(char_u *)"\316\324 \022\017*", INSERT}, // SHIFT-Insert is ^R^O* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2389 {(char_u *)"\316\325 \"*y", VIS_SEL}, // CTRL-Insert is "*y |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 {(char_u *)"\316\327 \"*d", VIS_SEL}, // SHIFT-Del is "*d |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2391 {(char_u *)"\316\330 \"*d", VIS_SEL}, // CTRL-Del is "*d |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2392 {(char_u *)"\030 \"*d", VIS_SEL}, // CTRL-X is "*d |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2393 # else |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2394 {(char_u *)"\316\324 P", NORMAL}, // SHIFT-Insert is P |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2395 {(char_u *)"\316\324 \"-dP", VIS_SEL}, // SHIFT-Insert is "-dP |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2396 {(char_u *)"\316\324 \022\017\"", INSERT}, // SHIFT-Insert is ^R^O" |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 {(char_u *)"\316\325 y", VIS_SEL}, // CTRL-Insert is y |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2398 {(char_u *)"\316\327 d", VIS_SEL}, // SHIFT-Del is d |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2399 {(char_u *)"\316\330 d", VIS_SEL}, // CTRL-Del is d |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2400 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2401 }; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2402 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2403 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2404 # if defined(MACOS_X) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2405 static struct initmap initmappings[] = |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 // Use the Standard MacOS binding. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2408 // paste, copy and cut |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2409 {(char_u *)"<D-v> \"*P", NORMAL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 {(char_u *)"<D-v> \"-d\"*P", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2411 {(char_u *)"<D-v> <C-R>*", INSERT+CMDLINE}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2412 {(char_u *)"<D-c> \"*y", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2413 {(char_u *)"<D-x> \"*d", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2414 {(char_u *)"<Backspace> \"-d", VIS_SEL}, |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2415 }; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2417 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2418 # undef VIS_SEL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2419 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2420 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2421 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2422 * Set up default mappings. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2423 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2424 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 init_mappings(void) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2426 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2427 #if defined(MSWIN) || defined(MACOS_X) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2428 int i; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2429 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2430 # if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2431 # ifdef VIMDLL |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2432 if (!gui.starting) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2433 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2434 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2435 for (i = 0; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2436 i < (int)(sizeof(cinitmappings) / sizeof(struct initmap)); ++i) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2437 add_map(cinitmappings[i].arg, cinitmappings[i].mode); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2438 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2439 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2440 # if defined(FEAT_GUI_MSWIN) || defined(MACOS_X) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2441 for (i = 0; i < (int)(sizeof(initmappings) / sizeof(struct initmap)); ++i) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2442 add_map(initmappings[i].arg, initmappings[i].mode); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2443 # endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2444 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2445 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2446 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2447 #if defined(MSWIN) || defined(FEAT_CMDWIN) || defined(MACOS_X) \ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2448 || defined(PROTO) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2449 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2450 * Add a mapping "map" for mode "mode". |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2451 * Need to put string in allocated memory, because do_map() will modify it. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2452 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2453 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2454 add_map(char_u *map, int mode) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2455 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2456 char_u *s; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2457 char_u *cpo_save = p_cpo; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2458 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2459 p_cpo = (char_u *)""; // Allow <> notation |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2460 s = vim_strsave(map); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2461 if (s != NULL) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2462 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2463 (void)do_map(0, s, mode, FALSE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2464 vim_free(s); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2465 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2466 p_cpo = cpo_save; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2467 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2468 #endif |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2469 |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2470 #if defined(FEAT_LANGMAP) || defined(PROTO) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2471 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2472 * Any character has an equivalent 'langmap' character. This is used for |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2473 * keyboards that have a special language mode that sends characters above |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2474 * 128 (although other characters can be translated too). The "to" field is a |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2475 * Vim command character. This avoids having to switch the keyboard back to |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2476 * ASCII mode when leaving Insert mode. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2477 * |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2478 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2479 * commands. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2480 * langmap_mapga.ga_data is a sorted table of langmap_entry_T. This does the |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2481 * same as langmap_mapchar[] for characters >= 256. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2482 * |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2483 * Use growarray for 'langmap' chars >= 256 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2484 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2485 typedef struct |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2486 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2487 int from; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2488 int to; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2489 } langmap_entry_T; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2490 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2491 static garray_T langmap_mapga; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2492 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2493 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2494 * Search for an entry in "langmap_mapga" for "from". If found set the "to" |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2495 * field. If not found insert a new entry at the appropriate location. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2496 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2497 static void |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2498 langmap_set_entry(int from, int to) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2499 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2500 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2501 int a = 0; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2502 int b = langmap_mapga.ga_len; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2503 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2504 // Do a binary search for an existing entry. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2505 while (a != b) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2506 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2507 int i = (a + b) / 2; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2508 int d = entries[i].from - from; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2509 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2510 if (d == 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2511 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2512 entries[i].to = to; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2513 return; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2514 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2515 if (d < 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2516 a = i + 1; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2517 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2518 b = i; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2519 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2520 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2521 if (ga_grow(&langmap_mapga, 1) != OK) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2522 return; // out of memory |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2523 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2524 // insert new entry at position "a" |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2525 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2526 mch_memmove(entries + 1, entries, |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2527 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2528 ++langmap_mapga.ga_len; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2529 entries[0].from = from; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2530 entries[0].to = to; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2531 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2532 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2533 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2534 * Apply 'langmap' to multi-byte character "c" and return the result. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2535 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2536 int |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2537 langmap_adjust_mb(int c) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2538 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2539 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2540 int a = 0; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2541 int b = langmap_mapga.ga_len; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2542 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2543 while (a != b) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2544 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2545 int i = (a + b) / 2; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2546 int d = entries[i].from - c; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2547 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2548 if (d == 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2549 return entries[i].to; // found matching entry |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2550 if (d < 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2551 a = i + 1; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2552 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2553 b = i; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2554 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2555 return c; // no entry found, return "c" unmodified |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2556 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2557 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2558 void |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2559 langmap_init(void) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2560 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2561 int i; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2562 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2563 for (i = 0; i < 256; i++) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2564 langmap_mapchar[i] = i; // we init with a one-to-one map |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2565 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2566 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2567 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2568 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2569 * Called when langmap option is set; the language map can be |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2570 * changed at any time! |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2571 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2572 void |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2573 langmap_set(void) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2574 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2575 char_u *p; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2576 char_u *p2; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2577 int from, to; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2578 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2579 ga_clear(&langmap_mapga); // clear the previous map first |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2580 langmap_init(); // back to one-to-one map |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2581 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2582 for (p = p_langmap; p[0] != NUL; ) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2583 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2584 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2585 MB_PTR_ADV(p2)) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2586 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2587 if (p2[0] == '\\' && p2[1] != NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2588 ++p2; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2589 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2590 if (p2[0] == ';') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2591 ++p2; // abcd;ABCD form, p2 points to A |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2592 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2593 p2 = NULL; // aAbBcCdD form, p2 is NULL |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2594 while (p[0]) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2595 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2596 if (p[0] == ',') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2597 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2598 ++p; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2599 break; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2600 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2601 if (p[0] == '\\' && p[1] != NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2602 ++p; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2603 from = (*mb_ptr2char)(p); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2604 to = NUL; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2605 if (p2 == NULL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2606 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2607 MB_PTR_ADV(p); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2608 if (p[0] != ',') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2609 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2610 if (p[0] == '\\') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2611 ++p; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2612 to = (*mb_ptr2char)(p); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2613 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2614 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2615 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2616 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2617 if (p2[0] != ',') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2618 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2619 if (p2[0] == '\\') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2620 ++p2; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2621 to = (*mb_ptr2char)(p2); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2622 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2623 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2624 if (to == NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2625 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2626 semsg(_("E357: 'langmap': Matching character missing for %s"), |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2627 transchar(from)); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2628 return; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2629 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2630 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2631 if (from >= 256) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2632 langmap_set_entry(from, to); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2633 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2634 langmap_mapchar[from & 255] = to; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2635 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2636 // Advance to next pair |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2637 MB_PTR_ADV(p); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2638 if (p2 != NULL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2639 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2640 MB_PTR_ADV(p2); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2641 if (*p == ';') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2642 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2643 p = p2; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2644 if (p[0] != NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2645 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2646 if (p[0] != ',') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2647 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2648 semsg(_("E358: 'langmap': Extra characters after semicolon: %s"), p); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2649 return; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2650 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2651 ++p; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2652 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2653 break; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2654 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2655 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2656 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2657 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2658 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2659 #endif |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
2660 |
17576
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2661 static void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2662 do_exmap(exarg_T *eap, int isabbrev) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2663 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2664 int mode; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2665 char_u *cmdp; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2666 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2667 cmdp = eap->cmd; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2668 mode = get_map_mode(&cmdp, eap->forceit || isabbrev); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2669 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2670 switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'), |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2671 eap->arg, mode, isabbrev)) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2672 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2673 case 1: emsg(_(e_invarg)); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2674 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2675 case 2: emsg((isabbrev ? _(e_noabbr) : _(e_nomap))); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2676 break; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2677 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2678 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2679 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2680 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2681 * ":abbreviate" and friends. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2682 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2683 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 ex_abbreviate(exarg_T *eap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2685 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2686 do_exmap(eap, TRUE); // almost the same as mapping |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2687 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2688 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2689 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2690 * ":map" and friends. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2691 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2692 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2693 ex_map(exarg_T *eap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2694 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2695 // If we are sourcing .exrc or .vimrc in current directory we |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2696 // print the mappings for security reasons. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2697 if (secure) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2698 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2699 secure = 2; |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2700 msg_outtrans(eap->cmd); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2701 msg_putchar('\n'); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2702 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2703 do_exmap(eap, FALSE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2704 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2705 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2706 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2707 * ":unmap" and friends. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2708 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2709 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2710 ex_unmap(exarg_T *eap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2711 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2712 do_exmap(eap, FALSE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2713 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2714 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2715 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2716 * ":mapclear" and friends. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2717 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2718 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2719 ex_mapclear(exarg_T *eap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2720 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2721 map_clear(eap->cmd, eap->arg, eap->forceit, FALSE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2722 } |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2723 |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2724 /* |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2725 * ":abclear" and friends. |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2726 */ |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2727 void |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2728 ex_abclear(exarg_T *eap) |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2729 { |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 map_clear(eap->cmd, eap->arg, TRUE, TRUE); |
97a750e8707f
patch 8.1.1785: map functionality mixed with character input
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2731 } |