Mercurial > vim
comparison src/map.c @ 29318:fcf524e1e97e v9.0.0002
patch 9.0.0002: map functionality outside of map.c
Commit: https://github.com/vim/vim/commit/c207fd2535717030d78f9b92839e5f2ac004cc78
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed Jun 29 10:37:40 2022 +0100
patch 9.0.0002: map functionality outside of map.c
Problem: Map functionality outside of map.c.
Solution: Move f_hasmapto() to map.c. Rename a function. (closes https://github.com/vim/vim/issues/10611)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 29 Jun 2022 11:45:04 +0200 |
parents | 35a30cb18005 |
children | 827d9f2b7a71 |
comparison
equal
deleted
inserted
replaced
29317:01ef523fec06 | 29318:fcf524e1e97e |
---|---|
906 *cmdp = p; | 906 *cmdp = p; |
907 return mode; | 907 return mode; |
908 } | 908 } |
909 | 909 |
910 /* | 910 /* |
911 * Clear all mappings or abbreviations. | 911 * Clear all mappings (":mapclear") or abbreviations (":abclear"). |
912 * 'abbr' should be FALSE for mappings, TRUE for abbreviations. | 912 * "abbr" should be FALSE for mappings, TRUE for abbreviations. |
913 */ | 913 */ |
914 static void | 914 static void |
915 map_clear( | 915 map_clear( |
916 char_u *cmdp, | 916 char_u *cmdp, |
917 char_u *arg UNUSED, | 917 char_u *arg, |
918 int forceit, | 918 int forceit, |
919 int abbr) | 919 int abbr) |
920 { | 920 { |
921 int mode; | 921 int mode; |
922 int local; | 922 int local; |
927 emsg(_(e_invalid_argument)); | 927 emsg(_(e_invalid_argument)); |
928 return; | 928 return; |
929 } | 929 } |
930 | 930 |
931 mode = get_map_mode(&cmdp, forceit); | 931 mode = get_map_mode(&cmdp, forceit); |
932 map_clear_int(curbuf, mode, local, abbr); | 932 map_clear_mode(curbuf, mode, local, abbr); |
933 } | 933 } |
934 | 934 |
935 /* | 935 /* |
936 * Clear all mappings in "mode". | 936 * Clear all mappings in "mode". |
937 */ | 937 */ |
938 void | 938 void |
939 map_clear_int( | 939 map_clear_mode( |
940 buf_T *buf, // buffer for local mappings | 940 buf_T *buf, // buffer for local mappings |
941 int mode, // mode in which to delete | 941 int mode, // mode in which to delete |
942 int local, // TRUE for buffer-local mappings | 942 int local, // TRUE for buffer-local mappings |
943 int abbr) // TRUE for abbreviations | 943 int abbr) // TRUE for abbreviations |
944 { | 944 { |
2271 | 2271 |
2272 return NULL; | 2272 return NULL; |
2273 } | 2273 } |
2274 | 2274 |
2275 /* | 2275 /* |
2276 * "hasmapto()" function | |
2277 */ | |
2278 void | |
2279 f_hasmapto(typval_T *argvars, typval_T *rettv) | |
2280 { | |
2281 char_u *name; | |
2282 char_u *mode; | |
2283 char_u buf[NUMBUFLEN]; | |
2284 int abbr = FALSE; | |
2285 | |
2286 if (in_vim9script() | |
2287 && (check_for_string_arg(argvars, 0) == FAIL | |
2288 || check_for_opt_string_arg(argvars, 1) == FAIL | |
2289 || (argvars[1].v_type != VAR_UNKNOWN | |
2290 && check_for_opt_bool_arg(argvars, 2) == FAIL))) | |
2291 return; | |
2292 | |
2293 name = tv_get_string(&argvars[0]); | |
2294 if (argvars[1].v_type == VAR_UNKNOWN) | |
2295 mode = (char_u *)"nvo"; | |
2296 else | |
2297 { | |
2298 mode = tv_get_string_buf(&argvars[1], buf); | |
2299 if (argvars[2].v_type != VAR_UNKNOWN) | |
2300 abbr = (int)tv_get_bool(&argvars[2]); | |
2301 } | |
2302 | |
2303 if (map_to_exists(name, mode, abbr)) | |
2304 rettv->vval.v_number = TRUE; | |
2305 else | |
2306 rettv->vval.v_number = FALSE; | |
2307 } | |
2308 | |
2309 /* | |
2276 * Fill in the empty dictionary with items as defined by maparg builtin. | 2310 * Fill in the empty dictionary with items as defined by maparg builtin. |
2277 */ | 2311 */ |
2278 static void | 2312 static void |
2279 mapblock2dict( | 2313 mapblock2dict( |
2280 mapblock_T *mp, | 2314 mapblock_T *mp, |