comparison src/fileio.c @ 12477:68d7bc045dbe v8.0.1118

patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs commit https://github.com/vim/vim/commit/4033c55eca575777718c0701e26635a0cc47d907 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 16 20:54:51 2017 +0200 patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs Problem: FEAT_WINDOWS adds a lot of #ifdefs while it is nearly always enabled and only adds 7% to the binary size of the tiny build. Solution: Graduate FEAT_WINDOWS.
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Sep 2017 21:00:06 +0200
parents e971ef6c0dee
children 0a9dacb8826a
comparison
equal deleted inserted replaced
12476:2516383741e6 12477:68d7bc045dbe
4172 { 4172 {
4173 buf->b_p_ro = FALSE; 4173 buf->b_p_ro = FALSE;
4174 #ifdef FEAT_TITLE 4174 #ifdef FEAT_TITLE
4175 need_maketitle = TRUE; /* set window title later */ 4175 need_maketitle = TRUE; /* set window title later */
4176 #endif 4176 #endif
4177 #ifdef FEAT_WINDOWS
4178 status_redraw_all(); /* redraw status lines later */ 4177 status_redraw_all(); /* redraw status lines later */
4179 #endif
4180 } 4178 }
4181 4179
4182 if (end > buf->b_ml.ml_line_count) 4180 if (end > buf->b_ml.ml_line_count)
4183 end = buf->b_ml.ml_line_count; 4181 end = buf->b_ml.ml_line_count;
4184 if (buf->b_ml.ml_flags & ML_EMPTY) 4182 if (buf->b_ml.ml_flags & ML_EMPTY)
6195 6193
6196 /* Always make the swap file name a full path, a "nofile" buffer may 6194 /* Always make the swap file name a full path, a "nofile" buffer may
6197 * also have a swap file. */ 6195 * also have a swap file. */
6198 mf_fullname(buf->b_ml.ml_mfp); 6196 mf_fullname(buf->b_ml.ml_mfp);
6199 } 6197 }
6200 #ifdef FEAT_WINDOWS
6201 status_redraw_all(); 6198 status_redraw_all();
6202 redraw_tabline = TRUE; 6199 redraw_tabline = TRUE;
6203 #endif
6204 } 6200 }
6205 6201
6206 #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \ 6202 #if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
6207 || defined(FEAT_GUI_MSWIN) \ 6203 || defined(FEAT_GUI_MSWIN) \
6208 || defined(FEAT_GUI_MAC) \ 6204 || defined(FEAT_GUI_MAC) \
8961 aucmd_prepbuf( 8957 aucmd_prepbuf(
8962 aco_save_T *aco, /* structure to save values in */ 8958 aco_save_T *aco, /* structure to save values in */
8963 buf_T *buf) /* new curbuf */ 8959 buf_T *buf) /* new curbuf */
8964 { 8960 {
8965 win_T *win; 8961 win_T *win;
8966 #ifdef FEAT_WINDOWS
8967 int save_ea; 8962 int save_ea;
8968 #endif
8969 #ifdef FEAT_AUTOCHDIR 8963 #ifdef FEAT_AUTOCHDIR
8970 int save_acd; 8964 int save_acd;
8971 #endif 8965 #endif
8972 8966
8973 /* Find a window that is for the new buffer */ 8967 /* Find a window that is for the new buffer */
8974 if (buf == curbuf) /* be quick when buf is curbuf */ 8968 if (buf == curbuf) /* be quick when buf is curbuf */
8975 win = curwin; 8969 win = curwin;
8976 else 8970 else
8977 #ifdef FEAT_WINDOWS
8978 FOR_ALL_WINDOWS(win) 8971 FOR_ALL_WINDOWS(win)
8979 if (win->w_buffer == buf) 8972 if (win->w_buffer == buf)
8980 break; 8973 break;
8981 #else
8982 win = NULL;
8983 #endif
8984 8974
8985 /* Allocate "aucmd_win" when needed. If this fails (out of memory) fall 8975 /* Allocate "aucmd_win" when needed. If this fails (out of memory) fall
8986 * back to using the current window. */ 8976 * back to using the current window. */
8987 if (win == NULL && aucmd_win == NULL) 8977 if (win == NULL && aucmd_win == NULL)
8988 { 8978 {
9024 aucmd_win->w_localdir = NULL; 9014 aucmd_win->w_localdir = NULL;
9025 aco->globaldir = globaldir; 9015 aco->globaldir = globaldir;
9026 globaldir = NULL; 9016 globaldir = NULL;
9027 9017
9028 9018
9029 #ifdef FEAT_WINDOWS
9030 /* Split the current window, put the aucmd_win in the upper half. 9019 /* Split the current window, put the aucmd_win in the upper half.
9031 * We don't want the BufEnter or WinEnter autocommands. */ 9020 * We don't want the BufEnter or WinEnter autocommands. */
9032 block_autocmds(); 9021 block_autocmds();
9033 make_snapshot(SNAP_AUCMD_IDX); 9022 make_snapshot(SNAP_AUCMD_IDX);
9034 save_ea = p_ea; 9023 save_ea = p_ea;
9035 p_ea = FALSE; 9024 p_ea = FALSE;
9036 9025
9037 # ifdef FEAT_AUTOCHDIR 9026 #ifdef FEAT_AUTOCHDIR
9038 /* Prevent chdir() call in win_enter_ext(), through do_autochdir(). */ 9027 /* Prevent chdir() call in win_enter_ext(), through do_autochdir(). */
9039 save_acd = p_acd; 9028 save_acd = p_acd;
9040 p_acd = FALSE; 9029 p_acd = FALSE;
9041 # endif 9030 #endif
9042 9031
9043 (void)win_split_ins(0, WSP_TOP, aucmd_win, 0); 9032 (void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
9044 (void)win_comp_pos(); /* recompute window positions */ 9033 (void)win_comp_pos(); /* recompute window positions */
9045 p_ea = save_ea; 9034 p_ea = save_ea;
9046 # ifdef FEAT_AUTOCHDIR 9035 #ifdef FEAT_AUTOCHDIR
9047 p_acd = save_acd; 9036 p_acd = save_acd;
9048 # endif 9037 #endif
9049 unblock_autocmds(); 9038 unblock_autocmds();
9050 #endif
9051 curwin = aucmd_win; 9039 curwin = aucmd_win;
9052 } 9040 }
9053 curbuf = buf; 9041 curbuf = buf;
9054 aco->new_curwin = curwin; 9042 aco->new_curwin = curwin;
9055 set_bufref(&aco->new_curbuf, curbuf); 9043 set_bufref(&aco->new_curbuf, curbuf);
9062 */ 9050 */
9063 void 9051 void
9064 aucmd_restbuf( 9052 aucmd_restbuf(
9065 aco_save_T *aco) /* structure holding saved values */ 9053 aco_save_T *aco) /* structure holding saved values */
9066 { 9054 {
9067 #ifdef FEAT_WINDOWS
9068 int dummy; 9055 int dummy;
9069 #endif
9070 9056
9071 if (aco->use_aucmd_win) 9057 if (aco->use_aucmd_win)
9072 { 9058 {
9073 --curbuf->b_nwindows; 9059 --curbuf->b_nwindows;
9074 #ifdef FEAT_WINDOWS
9075 /* Find "aucmd_win", it can't be closed, but it may be in another tab 9060 /* Find "aucmd_win", it can't be closed, but it may be in another tab
9076 * page. Do not trigger autocommands here. */ 9061 * page. Do not trigger autocommands here. */
9077 block_autocmds(); 9062 block_autocmds();
9078 if (curwin != aucmd_win) 9063 if (curwin != aucmd_win)
9079 { 9064 {
9110 if (win_valid(aco->save_curwin)) 9095 if (win_valid(aco->save_curwin))
9111 curwin = aco->save_curwin; 9096 curwin = aco->save_curwin;
9112 else 9097 else
9113 /* Hmm, original window disappeared. Just use the first one. */ 9098 /* Hmm, original window disappeared. Just use the first one. */
9114 curwin = firstwin; 9099 curwin = firstwin;
9115 # ifdef FEAT_EVAL 9100 #ifdef FEAT_EVAL
9116 vars_clear(&aucmd_win->w_vars->dv_hashtab); /* free all w: variables */ 9101 vars_clear(&aucmd_win->w_vars->dv_hashtab); /* free all w: variables */
9117 hash_init(&aucmd_win->w_vars->dv_hashtab); /* re-use the hashtab */ 9102 hash_init(&aucmd_win->w_vars->dv_hashtab); /* re-use the hashtab */
9118 # endif
9119 #else
9120 curwin = aco->save_curwin;
9121 #endif 9103 #endif
9122 curbuf = curwin->w_buffer; 9104 curbuf = curwin->w_buffer;
9123 9105
9124 vim_free(globaldir); 9106 vim_free(globaldir);
9125 globaldir = aco->globaldir; 9107 globaldir = aco->globaldir;
9141 #endif 9123 #endif
9142 } 9124 }
9143 else 9125 else
9144 { 9126 {
9145 /* restore curwin */ 9127 /* restore curwin */
9146 #ifdef FEAT_WINDOWS
9147 if (win_valid(aco->save_curwin)) 9128 if (win_valid(aco->save_curwin))
9148 #endif
9149 { 9129 {
9150 /* Restore the buffer which was previously edited by curwin, if 9130 /* Restore the buffer which was previously edited by curwin, if
9151 * it was changed, we are still the same window and the buffer is 9131 * it was changed, we are still the same window and the buffer is
9152 * valid. */ 9132 * valid. */
9153 if (curwin == aco->new_curwin 9133 if (curwin == aco->new_curwin