comparison src/gui.c @ 13380:69517d67421f v8.0.1564

patch 8.0.1564: too many #ifdefs commit https://github.com/vim/vim/commit/f2bd8ef2b4507d02c6043affff8f7e85e3414d5f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 4 18:08:14 2018 +0100 patch 8.0.1564: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate the +autocmd feature. Takes away 450 #ifdefs and increases code size of tiny Vim by only 40 Kbyte.
author Christian Brabandt <cb@256bit.org>
date Sun, 04 Mar 2018 18:15:08 +0100
parents 3efdd2ae3717
children 6740c499de13
comparison
equal deleted inserted replaced
13379:0f9dd1b43244 13380:69517d67421f
130 #endif 130 #endif
131 } 131 }
132 132
133 vim_free(old_term); 133 vim_free(old_term);
134 134
135 #ifdef FEAT_AUTOCMD
136 /* If the GUI started successfully, trigger the GUIEnter event, otherwise 135 /* If the GUI started successfully, trigger the GUIEnter event, otherwise
137 * the GUIFailed event. */ 136 * the GUIFailed event. */
138 gui_mch_update(); 137 gui_mch_update();
139 apply_autocmds(gui.in_use ? EVENT_GUIENTER : EVENT_GUIFAILED, 138 apply_autocmds(gui.in_use ? EVENT_GUIENTER : EVENT_GUIFAILED,
140 NULL, NULL, FALSE, curbuf); 139 NULL, NULL, FALSE, curbuf);
141 #endif
142 --recursive; 140 --recursive;
143 } 141 }
144 142
145 /* 143 /*
146 * Set_termname() will call gui_init() to start the GUI. 144 * Set_termname() will call gui_init() to start the GUI.
2952 */ 2950 */
2953 int 2951 int
2954 gui_wait_for_chars(long wtime, int tb_change_cnt) 2952 gui_wait_for_chars(long wtime, int tb_change_cnt)
2955 { 2953 {
2956 int retval; 2954 int retval;
2957 #if defined(ELAPSED_FUNC) && defined(FEAT_AUTOCMD) 2955 #if defined(ELAPSED_FUNC)
2958 ELAPSED_TYPE start_tv; 2956 ELAPSED_TYPE start_tv;
2959 #endif 2957 #endif
2960 2958
2961 #ifdef FEAT_MENU 2959 #ifdef FEAT_MENU
2962 /* 2960 /*
2984 retval = gui_wait_for_chars_or_timer(wtime); 2982 retval = gui_wait_for_chars_or_timer(wtime);
2985 gui_mch_stop_blink(TRUE); 2983 gui_mch_stop_blink(TRUE);
2986 return retval; 2984 return retval;
2987 } 2985 }
2988 2986
2989 #if defined(ELAPSED_FUNC) && defined(FEAT_AUTOCMD) 2987 #if defined(ELAPSED_FUNC)
2990 ELAPSED_INIT(start_tv); 2988 ELAPSED_INIT(start_tv);
2991 #endif 2989 #endif
2992 2990
2993 /* 2991 /*
2994 * While we are waiting indefinitely for a character, blink the cursor. 2992 * While we are waiting indefinitely for a character, blink the cursor.
3001 * 'updatetime' and if nothing is typed within that time, and feedkeys() 2999 * 'updatetime' and if nothing is typed within that time, and feedkeys()
3002 * wasn't used, put the K_CURSORHOLD key in the input buffer. 3000 * wasn't used, put the K_CURSORHOLD key in the input buffer.
3003 */ 3001 */
3004 if (gui_wait_for_chars_or_timer(p_ut) == OK) 3002 if (gui_wait_for_chars_or_timer(p_ut) == OK)
3005 retval = OK; 3003 retval = OK;
3006 #ifdef FEAT_AUTOCMD
3007 else if (trigger_cursorhold() 3004 else if (trigger_cursorhold()
3008 # ifdef ELAPSED_FUNC 3005 #ifdef ELAPSED_FUNC
3009 && ELAPSED_FUNC(start_tv) >= p_ut 3006 && ELAPSED_FUNC(start_tv) >= p_ut
3010 # endif 3007 #endif
3011 && typebuf.tb_change_cnt == tb_change_cnt) 3008 && typebuf.tb_change_cnt == tb_change_cnt)
3012 { 3009 {
3013 char_u buf[3]; 3010 char_u buf[3];
3014 3011
3015 /* Put K_CURSORHOLD in the input buffer. */ 3012 /* Put K_CURSORHOLD in the input buffer. */
3018 buf[2] = (int)KE_CURSORHOLD; 3015 buf[2] = (int)KE_CURSORHOLD;
3019 add_to_input_buf(buf, 3); 3016 add_to_input_buf(buf, 3);
3020 3017
3021 retval = OK; 3018 retval = OK;
3022 } 3019 }
3023 #endif
3024 3020
3025 if (retval == FAIL && typebuf.tb_change_cnt == tb_change_cnt) 3021 if (retval == FAIL && typebuf.tb_change_cnt == tb_change_cnt)
3026 { 3022 {
3027 /* Blocking wait. */ 3023 /* Blocking wait. */
3028 before_blocking(); 3024 before_blocking();
5129 * Update the current window and the screen. 5125 * Update the current window and the screen.
5130 */ 5126 */
5131 void 5127 void
5132 gui_update_screen(void) 5128 gui_update_screen(void)
5133 { 5129 {
5134 #ifdef FEAT_CONCEAL 5130 # ifdef FEAT_CONCEAL
5135 linenr_T conceal_old_cursor_line = 0; 5131 linenr_T conceal_old_cursor_line = 0;
5136 linenr_T conceal_new_cursor_line = 0; 5132 linenr_T conceal_new_cursor_line = 0;
5137 int conceal_update_lines = FALSE; 5133 int conceal_update_lines = FALSE;
5138 #endif 5134 # endif
5139 5135
5140 update_topline(); 5136 update_topline();
5141 validate_cursor(); 5137 validate_cursor();
5142 5138
5143 #if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL)
5144 /* Trigger CursorMoved if the cursor moved. */ 5139 /* Trigger CursorMoved if the cursor moved. */
5145 if (!finish_op && ( 5140 if (!finish_op && (has_cursormoved()
5146 # ifdef FEAT_AUTOCMD
5147 has_cursormoved()
5148 # endif
5149 # if defined(FEAT_AUTOCMD) && defined(FEAT_CONCEAL)
5150 ||
5151 # endif
5152 # ifdef FEAT_CONCEAL 5141 # ifdef FEAT_CONCEAL
5153 curwin->w_p_cole > 0 5142 || curwin->w_p_cole > 0
5154 # endif 5143 # endif
5155 ) 5144 ) && !EQUAL_POS(last_cursormoved, curwin->w_cursor))
5156 && !EQUAL_POS(last_cursormoved, curwin->w_cursor)) 5145 {
5157 {
5158 # ifdef FEAT_AUTOCMD
5159 if (has_cursormoved()) 5146 if (has_cursormoved())
5160 apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf); 5147 apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf);
5161 # endif
5162 # ifdef FEAT_CONCEAL 5148 # ifdef FEAT_CONCEAL
5163 if (curwin->w_p_cole > 0) 5149 if (curwin->w_p_cole > 0)
5164 { 5150 {
5165 conceal_old_cursor_line = last_cursormoved.lnum; 5151 conceal_old_cursor_line = last_cursormoved.lnum;
5166 conceal_new_cursor_line = curwin->w_cursor.lnum; 5152 conceal_new_cursor_line = curwin->w_cursor.lnum;
5167 conceal_update_lines = TRUE; 5153 conceal_update_lines = TRUE;
5168 } 5154 }
5169 # endif 5155 # endif
5170 last_cursormoved = curwin->w_cursor; 5156 last_cursormoved = curwin->w_cursor;
5171 } 5157 }
5172 #endif
5173 5158
5174 update_screen(0); /* may need to update the screen */ 5159 update_screen(0); /* may need to update the screen */
5175 setcursor(); 5160 setcursor();
5176 # if defined(FEAT_CONCEAL) 5161 # ifdef FEAT_CONCEAL
5177 if (conceal_update_lines 5162 if (conceal_update_lines
5178 && (conceal_old_cursor_line != conceal_new_cursor_line 5163 && (conceal_old_cursor_line != conceal_new_cursor_line
5179 || conceal_cursor_line(curwin) 5164 || conceal_cursor_line(curwin)
5180 || need_cursor_line_redraw)) 5165 || need_cursor_line_redraw))
5181 { 5166 {