Mercurial > vim
comparison src/ex_getln.c @ 12656:0a9dacb8826a v8.0.1206
patch 8.0.1206: no autocmd for entering or leaving the command line
commit https://github.com/vim/vim/commit/fafcf0dd59fd9c4ef743bb333ae40d1d322b6079
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 19 18:35:51 2017 +0200
patch 8.0.1206: no autocmd for entering or leaving the command line
Problem: No autocmd for entering or leaving the command line.
Solution: Add CmdlineEnter and CmdlineLeave.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 19 Oct 2017 18:45:05 +0200 |
parents | 158917d728b4 |
children | 42cd1f315e8b |
comparison
equal
deleted
inserted
replaced
12655:6963f5ca8813 | 12656:0a9dacb8826a |
---|---|
143 #endif | 143 #endif |
144 #ifdef FEAT_SEARCH_EXTRA | 144 #ifdef FEAT_SEARCH_EXTRA |
145 static void set_search_match(pos_T *t); | 145 static void set_search_match(pos_T *t); |
146 #endif | 146 #endif |
147 | 147 |
148 | |
149 #ifdef FEAT_AUTOCMD | |
150 static void | |
151 trigger_cmd_autocmd(int typechar, int evt) | |
152 { | |
153 char_u typestr[2]; | |
154 | |
155 typestr[0] = typechar; | |
156 typestr[1] = NUL; | |
157 apply_autocmds(evt, typestr, typestr, FALSE, curbuf); | |
158 } | |
159 #endif | |
160 | |
148 /* | 161 /* |
149 * getcmdline() - accept a command line starting with firstc. | 162 * getcmdline() - accept a command line starting with firstc. |
150 * | 163 * |
151 * firstc == ':' get ":" command line. | 164 * firstc == ':' get ":" command line. |
152 * firstc == '/' or '?' get search pattern | 165 * firstc == '/' or '?' get search pattern |
220 /* Everything that may work recursively should save and restore the | 233 /* Everything that may work recursively should save and restore the |
221 * current command line in save_ccline. That includes update_screen(), a | 234 * current command line in save_ccline. That includes update_screen(), a |
222 * custom status line may invoke ":normal". */ | 235 * custom status line may invoke ":normal". */ |
223 struct cmdline_info save_ccline; | 236 struct cmdline_info save_ccline; |
224 #endif | 237 #endif |
238 #ifdef FEAT_AUTOCMD | |
239 int cmdline_type; | |
240 #endif | |
225 | 241 |
226 #ifdef FEAT_EVAL | 242 #ifdef FEAT_EVAL |
227 if (firstc == -1) | 243 if (firstc == -1) |
228 { | 244 { |
229 firstc = NUL; | 245 firstc = NUL; |
346 #endif | 362 #endif |
347 | 363 |
348 /* When inside an autocommand for writing "exiting" may be set and | 364 /* When inside an autocommand for writing "exiting" may be set and |
349 * terminal mode set to cooked. Need to set raw mode here then. */ | 365 * terminal mode set to cooked. Need to set raw mode here then. */ |
350 settmode(TMODE_RAW); | 366 settmode(TMODE_RAW); |
367 | |
368 #ifdef FEAT_AUTOCMD | |
369 /* Trigger CmdlineEnter autocommands. */ | |
370 cmdline_type = firstc == NUL ? '-' : firstc; | |
371 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINEENTER); | |
372 #endif | |
351 | 373 |
352 #ifdef FEAT_CMDHIST | 374 #ifdef FEAT_CMDHIST |
353 init_history(); | 375 init_history(); |
354 hiscnt = hislen; /* set hiscnt to impossible history value */ | 376 hiscnt = hislen; /* set hiscnt to impossible history value */ |
355 histype = hist_char2type(firstc); | 377 histype = hist_char2type(firstc); |
2083 | 2105 |
2084 /* When the command line was typed, no need for a wait-return prompt. */ | 2106 /* When the command line was typed, no need for a wait-return prompt. */ |
2085 if (some_key_typed) | 2107 if (some_key_typed) |
2086 need_wait_return = FALSE; | 2108 need_wait_return = FALSE; |
2087 | 2109 |
2110 #ifdef FEAT_AUTOCMD | |
2111 /* Trigger CmdlineLeave autocommands. */ | |
2112 trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE); | |
2113 #endif | |
2114 | |
2088 State = save_State; | 2115 State = save_State; |
2089 #ifdef USE_IM_CONTROL | 2116 #ifdef USE_IM_CONTROL |
2090 if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP) | 2117 if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP) |
2091 im_save_status(b_im_ptr); | 2118 im_save_status(b_im_ptr); |
2092 im_set_active(FALSE); | 2119 im_set_active(FALSE); |
6832 win_T *wp; | 6859 win_T *wp; |
6833 int i; | 6860 int i; |
6834 linenr_T lnum; | 6861 linenr_T lnum; |
6835 int histtype; | 6862 int histtype; |
6836 garray_T winsizes; | 6863 garray_T winsizes; |
6837 #ifdef FEAT_AUTOCMD | |
6838 char_u typestr[2]; | |
6839 #endif | |
6840 int save_restart_edit = restart_edit; | 6864 int save_restart_edit = restart_edit; |
6841 int save_State = State; | 6865 int save_State = State; |
6842 int save_exmode = exmode_active; | 6866 int save_exmode = exmode_active; |
6843 #ifdef FEAT_RIGHTLEFT | 6867 #ifdef FEAT_RIGHTLEFT |
6844 int save_cmdmsg_rl = cmdmsg_rl; | 6868 int save_cmdmsg_rl = cmdmsg_rl; |
6963 setmouse(); | 6987 setmouse(); |
6964 # endif | 6988 # endif |
6965 | 6989 |
6966 # ifdef FEAT_AUTOCMD | 6990 # ifdef FEAT_AUTOCMD |
6967 /* Trigger CmdwinEnter autocommands. */ | 6991 /* Trigger CmdwinEnter autocommands. */ |
6968 typestr[0] = cmdwin_type; | 6992 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINENTER); |
6969 typestr[1] = NUL; | |
6970 apply_autocmds(EVENT_CMDWINENTER, typestr, typestr, FALSE, curbuf); | |
6971 if (restart_edit != 0) /* autocmd with ":startinsert" */ | 6993 if (restart_edit != 0) /* autocmd with ":startinsert" */ |
6972 stuffcharReadbuff(K_NOP); | 6994 stuffcharReadbuff(K_NOP); |
6973 # endif | 6995 # endif |
6974 | 6996 |
6975 i = RedrawingDisabled; | 6997 i = RedrawingDisabled; |
6988 # ifdef FEAT_FOLDING | 7010 # ifdef FEAT_FOLDING |
6989 save_KeyTyped = KeyTyped; | 7011 save_KeyTyped = KeyTyped; |
6990 # endif | 7012 # endif |
6991 | 7013 |
6992 /* Trigger CmdwinLeave autocommands. */ | 7014 /* Trigger CmdwinLeave autocommands. */ |
6993 apply_autocmds(EVENT_CMDWINLEAVE, typestr, typestr, FALSE, curbuf); | 7015 trigger_cmd_autocmd(cmdwin_type, EVENT_CMDWINLEAVE); |
6994 | 7016 |
6995 # ifdef FEAT_FOLDING | 7017 # ifdef FEAT_FOLDING |
6996 /* Restore KeyTyped in case it is modified by autocommands */ | 7018 /* Restore KeyTyped in case it is modified by autocommands */ |
6997 KeyTyped = save_KeyTyped; | 7019 KeyTyped = save_KeyTyped; |
6998 # endif | 7020 # endif |