comparison src/ex_docmd.c @ 17576:97a750e8707f v8.1.1785

patch 8.1.1785: map functionality mixed with character input commit https://github.com/vim/vim/commit/b66bab381c8ba71fd6e92327d1d34c6f8a65f2a7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 1 14:28:24 2019 +0200 patch 8.1.1785: map functionality mixed with character input Problem: Map functionality mixed with character input. Solution: Move the map functionality to a separate file. (Yegappan Lakshmanan, closes #4740) Graduate the +localmap feature.
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Aug 2019 14:30:07 +0200
parents 554240b9574b
children ccbf8c2a47ee
comparison
equal deleted inserted replaced
17575:b2a246caeb25 17576:97a750e8707f
27 #endif 27 #endif
28 static void free_cmdmod(void); 28 static void free_cmdmod(void);
29 static void append_command(char_u *cmd); 29 static void append_command(char_u *cmd);
30 static char_u *find_command(exarg_T *eap, int *full); 30 static char_u *find_command(exarg_T *eap, int *full);
31 31
32 static void ex_abbreviate(exarg_T *eap);
33 static void ex_map(exarg_T *eap);
34 static void ex_unmap(exarg_T *eap);
35 static void ex_mapclear(exarg_T *eap);
36 static void ex_abclear(exarg_T *eap);
37 #ifndef FEAT_MENU 32 #ifndef FEAT_MENU
38 # define ex_emenu ex_ni 33 # define ex_emenu ex_ni
39 # define ex_menu ex_ni 34 # define ex_menu ex_ni
40 # define ex_menutranslate ex_ni 35 # define ex_menutranslate ex_ni
41 #endif 36 #endif
229 static void ex_syncbind(exarg_T *eap); 224 static void ex_syncbind(exarg_T *eap);
230 static void ex_read(exarg_T *eap); 225 static void ex_read(exarg_T *eap);
231 static void ex_pwd(exarg_T *eap); 226 static void ex_pwd(exarg_T *eap);
232 static void ex_equal(exarg_T *eap); 227 static void ex_equal(exarg_T *eap);
233 static void ex_sleep(exarg_T *eap); 228 static void ex_sleep(exarg_T *eap);
234 static void do_exmap(exarg_T *eap, int isabbrev);
235 static void ex_winsize(exarg_T *eap); 229 static void ex_winsize(exarg_T *eap);
236 static void ex_wincmd(exarg_T *eap); 230 static void ex_wincmd(exarg_T *eap);
237 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) 231 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
238 static void ex_winpos(exarg_T *eap); 232 static void ex_winpos(exarg_T *eap);
239 #else 233 #else
5345 } 5339 }
5346 5340
5347 return OK; 5341 return OK;
5348 } 5342 }
5349 5343
5350 /*
5351 * ":abbreviate" and friends.
5352 */
5353 static void
5354 ex_abbreviate(exarg_T *eap)
5355 {
5356 do_exmap(eap, TRUE); /* almost the same as mapping */
5357 }
5358
5359 /*
5360 * ":map" and friends.
5361 */
5362 static void
5363 ex_map(exarg_T *eap)
5364 {
5365 /*
5366 * If we are sourcing .exrc or .vimrc in current directory we
5367 * print the mappings for security reasons.
5368 */
5369 if (secure)
5370 {
5371 secure = 2;
5372 msg_outtrans(eap->cmd);
5373 msg_putchar('\n');
5374 }
5375 do_exmap(eap, FALSE);
5376 }
5377
5378 /*
5379 * ":unmap" and friends.
5380 */
5381 static void
5382 ex_unmap(exarg_T *eap)
5383 {
5384 do_exmap(eap, FALSE);
5385 }
5386
5387 /*
5388 * ":mapclear" and friends.
5389 */
5390 static void
5391 ex_mapclear(exarg_T *eap)
5392 {
5393 map_clear(eap->cmd, eap->arg, eap->forceit, FALSE);
5394 }
5395
5396 /*
5397 * ":abclear" and friends.
5398 */
5399 static void
5400 ex_abclear(exarg_T *eap)
5401 {
5402 map_clear(eap->cmd, eap->arg, TRUE, TRUE);
5403 }
5404
5405 static void 5344 static void
5406 ex_autocmd(exarg_T *eap) 5345 ex_autocmd(exarg_T *eap)
5407 { 5346 {
5408 /* 5347 /*
5409 * Disallow autocommands from .exrc and .vimrc in current 5348 * Disallow autocommands from .exrc and .vimrc in current
7780 // input buffer, otherwise a following call to input() fails. 7719 // input buffer, otherwise a following call to input() fails.
7781 if (got_int) 7720 if (got_int)
7782 (void)vpeekc(); 7721 (void)vpeekc();
7783 } 7722 }
7784 7723
7785 static void
7786 do_exmap(exarg_T *eap, int isabbrev)
7787 {
7788 int mode;
7789 char_u *cmdp;
7790
7791 cmdp = eap->cmd;
7792 mode = get_map_mode(&cmdp, eap->forceit || isabbrev);
7793
7794 switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'),
7795 eap->arg, mode, isabbrev))
7796 {
7797 case 1: emsg(_(e_invarg));
7798 break;
7799 case 2: emsg((isabbrev ? _(e_noabbr) : _(e_nomap)));
7800 break;
7801 }
7802 }
7803
7804 /* 7724 /*
7805 * ":winsize" command (obsolete). 7725 * ":winsize" command (obsolete).
7806 */ 7726 */
7807 static void 7727 static void
7808 ex_winsize(exarg_T *eap) 7728 ex_winsize(exarg_T *eap)