comparison src/ex_cmds.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 98586656fcae
children 972ea22c946f
comparison
equal deleted inserted replaced
12476:2516383741e6 12477:68d7bc045dbe
3223 if (eap->cmdidx == CMD_saveas) 3223 if (eap->cmdidx == CMD_saveas)
3224 { 3224 {
3225 if (retval == OK) 3225 if (retval == OK)
3226 { 3226 {
3227 curbuf->b_p_ro = FALSE; 3227 curbuf->b_p_ro = FALSE;
3228 #ifdef FEAT_WINDOWS
3229 redraw_tabline = TRUE; 3228 redraw_tabline = TRUE;
3230 #endif
3231 } 3229 }
3232 } 3230 }
3233 3231
3234 /* Change directories when the 'acd' option is set and the file name 3232 /* Change directories when the 'acd' option is set and the file name
3235 * got changed or set. */ 3233 * got changed or set. */
4151 curwin_init(); 4149 curwin_init();
4152 4150
4153 #ifdef FEAT_FOLDING 4151 #ifdef FEAT_FOLDING
4154 /* It's possible that all lines in the buffer changed. Need to update 4152 /* It's possible that all lines in the buffer changed. Need to update
4155 * automatic folding for all windows where it's used. */ 4153 * automatic folding for all windows where it's used. */
4156 # ifdef FEAT_WINDOWS
4157 { 4154 {
4158 win_T *win; 4155 win_T *win;
4159 tabpage_T *tp; 4156 tabpage_T *tp;
4160 4157
4161 FOR_ALL_TAB_WINDOWS(tp, win) 4158 FOR_ALL_TAB_WINDOWS(tp, win)
4162 if (win->w_buffer == curbuf) 4159 if (win->w_buffer == curbuf)
4163 foldUpdateAll(win); 4160 foldUpdateAll(win);
4164 } 4161 }
4165 # else
4166 foldUpdateAll(curwin);
4167 # endif
4168 #endif 4162 #endif
4169 4163
4170 /* Change directories when the 'acd' option is set. */ 4164 /* Change directories when the 'acd' option is set. */
4171 DO_AUTOCHDIR 4165 DO_AUTOCHDIR
4172 4166
4282 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; 4276 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
4283 beginline(BL_WHITE | BL_FIX); 4277 beginline(BL_WHITE | BL_FIX);
4284 } 4278 }
4285 } 4279 }
4286 4280
4287 #ifdef FEAT_WINDOWS
4288 /* Check if cursors in other windows on the same buffer are still valid */ 4281 /* Check if cursors in other windows on the same buffer are still valid */
4289 check_lnums(FALSE); 4282 check_lnums(FALSE);
4290 #endif
4291 4283
4292 /* 4284 /*
4293 * Did not read the file, need to show some info about the file. 4285 * Did not read the file, need to show some info about the file.
4294 * Do this after setting the cursor. 4286 * Do this after setting the cursor.
4295 */ 4287 */
4581 4573
4582 /* Vi compatible: ":z!" uses display height, without a count uses 4574 /* Vi compatible: ":z!" uses display height, without a count uses
4583 * 'scroll' */ 4575 * 'scroll' */
4584 if (eap->forceit) 4576 if (eap->forceit)
4585 bigness = curwin->w_height; 4577 bigness = curwin->w_height;
4586 #ifdef FEAT_WINDOWS
4587 else if (!ONE_WINDOW) 4578 else if (!ONE_WINDOW)
4588 bigness = curwin->w_height - 3; 4579 bigness = curwin->w_height - 3;
4589 #endif
4590 else 4580 else
4591 bigness = curwin->w_p_scr * 2; 4581 bigness = curwin->w_p_scr * 2;
4592 if (bigness < 1) 4582 if (bigness < 1)
4593 bigness = 1; 4583 bigness = 1;
4594 4584
6150 { 6140 {
6151 vim_free(old_sub); 6141 vim_free(old_sub);
6152 } 6142 }
6153 #endif 6143 #endif
6154 6144
6155 #if (defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)) || defined(PROTO) 6145 #if defined(FEAT_QUICKFIX) || defined(PROTO)
6156 /* 6146 /*
6157 * Set up for a tagpreview. 6147 * Set up for a tagpreview.
6158 * Return TRUE when it was created. 6148 * Return TRUE when it was created.
6159 */ 6149 */
6160 int 6150 int
6213 char_u *arg; 6203 char_u *arg;
6214 char_u *tag; 6204 char_u *tag;
6215 FILE *helpfd; /* file descriptor of help file */ 6205 FILE *helpfd; /* file descriptor of help file */
6216 int n; 6206 int n;
6217 int i; 6207 int i;
6218 #ifdef FEAT_WINDOWS
6219 win_T *wp; 6208 win_T *wp;
6220 #endif
6221 int num_matches; 6209 int num_matches;
6222 char_u **matches; 6210 char_u **matches;
6223 char_u *p; 6211 char_u *p;
6224 int empty_fnum = 0; 6212 int empty_fnum = 0;
6225 int alt_fnum = 0; 6213 int alt_fnum = 0;
6317 6305
6318 /* 6306 /*
6319 * Re-use an existing help window or open a new one. 6307 * Re-use an existing help window or open a new one.
6320 * Always open a new one for ":tab help". 6308 * Always open a new one for ":tab help".
6321 */ 6309 */
6322 if (!bt_help(curwin->w_buffer) 6310 if (!bt_help(curwin->w_buffer) || cmdmod.tab != 0)
6323 #ifdef FEAT_WINDOWS 6311 {
6324 || cmdmod.tab != 0
6325 #endif
6326 )
6327 {
6328 #ifdef FEAT_WINDOWS
6329 if (cmdmod.tab != 0) 6312 if (cmdmod.tab != 0)
6330 wp = NULL; 6313 wp = NULL;
6331 else 6314 else
6332 FOR_ALL_WINDOWS(wp) 6315 FOR_ALL_WINDOWS(wp)
6333 if (bt_help(wp->w_buffer)) 6316 if (bt_help(wp->w_buffer))
6334 break; 6317 break;
6335 if (wp != NULL && wp->w_buffer->b_nwindows > 0) 6318 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
6336 win_enter(wp, TRUE); 6319 win_enter(wp, TRUE);
6337 else 6320 else
6338 #endif
6339 { 6321 {
6340 /* 6322 /*
6341 * There is no help window yet. 6323 * There is no help window yet.
6342 * Try to open the file specified by the "helpfile" option. 6324 * Try to open the file specified by the "helpfile" option.
6343 */ 6325 */
6346 smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf); 6328 smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
6347 goto erret; 6329 goto erret;
6348 } 6330 }
6349 fclose(helpfd); 6331 fclose(helpfd);
6350 6332
6351 #ifdef FEAT_WINDOWS
6352 /* Split off help window; put it at far top if no position 6333 /* Split off help window; put it at far top if no position
6353 * specified, the current window is vertically split and 6334 * specified, the current window is vertically split and
6354 * narrow. */ 6335 * narrow. */
6355 n = WSP_HELP; 6336 n = WSP_HELP;
6356 if (cmdmod.split == 0 && curwin->w_width != Columns 6337 if (cmdmod.split == 0 && curwin->w_width != Columns
6357 && curwin->w_width < 80) 6338 && curwin->w_width < 80)
6358 n |= WSP_TOP; 6339 n |= WSP_TOP;
6359 if (win_split(0, n) == FAIL) 6340 if (win_split(0, n) == FAIL)
6360 goto erret; 6341 goto erret;
6361 #else 6342
6362 /* use current window */
6363 if (!can_abandon(curbuf, FALSE))
6364 goto erret;
6365 #endif
6366
6367 #ifdef FEAT_WINDOWS
6368 if (curwin->w_height < p_hh) 6343 if (curwin->w_height < p_hh)
6369 win_setheight((int)p_hh); 6344 win_setheight((int)p_hh);
6370 #endif
6371 6345
6372 /* 6346 /*
6373 * Open help file (do_ecmd() will set b_help flag, readfile() will 6347 * Open help file (do_ecmd() will set b_help flag, readfile() will
6374 * set b_p_ro flag). 6348 * set b_p_ro flag).
6375 * Set the alternate file to the previously edited file. 6349 * Set the alternate file to the previously edited file.
6376 */ 6350 */
6377 alt_fnum = curbuf->b_fnum; 6351 alt_fnum = curbuf->b_fnum;
6378 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL, 6352 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
6379 ECMD_HIDE + ECMD_SET_HELP, 6353 ECMD_HIDE + ECMD_SET_HELP,
6380 #ifdef FEAT_WINDOWS 6354 NULL); /* buffer is still open, don't store info */
6381 NULL /* buffer is still open, don't store info */
6382 #else
6383 curwin
6384 #endif
6385 );
6386 if (!cmdmod.keepalt) 6355 if (!cmdmod.keepalt)
6387 curwin->w_alt_fnum = alt_fnum; 6356 curwin->w_alt_fnum = alt_fnum;
6388 empty_fnum = curbuf->b_fnum; 6357 empty_fnum = curbuf->b_fnum;
6389 } 6358 }
6390 } 6359 }
6423 * ":helpclose": Close one help window 6392 * ":helpclose": Close one help window
6424 */ 6393 */
6425 void 6394 void
6426 ex_helpclose(exarg_T *eap UNUSED) 6395 ex_helpclose(exarg_T *eap UNUSED)
6427 { 6396 {
6428 #if defined(FEAT_WINDOWS)
6429 win_T *win; 6397 win_T *win;
6430 6398
6431 FOR_ALL_WINDOWS(win) 6399 FOR_ALL_WINDOWS(win)
6432 { 6400 {
6433 if (bt_help(win->w_buffer)) 6401 if (bt_help(win->w_buffer))
6434 { 6402 {
6435 win_close(win, FALSE); 6403 win_close(win, FALSE);
6436 return; 6404 return;
6437 } 6405 }
6438 } 6406 }
6439 #endif
6440 } 6407 }
6441 6408
6442 #if defined(FEAT_MULTI_LANG) || defined(PROTO) 6409 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
6443 /* 6410 /*
6444 * In an argument search for a language specifiers in the form "@xx". 6411 * In an argument search for a language specifiers in the form "@xx".
8348 ex_drop(exarg_T *eap) 8315 ex_drop(exarg_T *eap)
8349 { 8316 {
8350 int split = FALSE; 8317 int split = FALSE;
8351 win_T *wp; 8318 win_T *wp;
8352 buf_T *buf; 8319 buf_T *buf;
8353 # ifdef FEAT_WINDOWS
8354 tabpage_T *tp; 8320 tabpage_T *tp;
8355 # endif
8356 8321
8357 /* 8322 /*
8358 * Check if the first argument is already being edited in a window. If 8323 * Check if the first argument is already being edited in a window. If
8359 * so, jump to that window. 8324 * so, jump to that window.
8360 * We would actually need to check all arguments, but that's complicated 8325 * We would actually need to check all arguments, but that's complicated
8370 * already did an error message for this. 8335 * already did an error message for this.
8371 */ 8336 */
8372 if (ARGCOUNT == 0) 8337 if (ARGCOUNT == 0)
8373 return; 8338 return;
8374 8339
8375 # ifdef FEAT_WINDOWS
8376 if (cmdmod.tab) 8340 if (cmdmod.tab)
8377 { 8341 {
8378 /* ":tab drop file ...": open a tab for each argument that isn't 8342 /* ":tab drop file ...": open a tab for each argument that isn't
8379 * edited in a window yet. It's like ":tab all" but without closing 8343 * edited in a window yet. It's like ":tab all" but without closing
8380 * windows or tabs. */ 8344 * windows or tabs. */
8381 ex_all(eap); 8345 ex_all(eap);
8382 } 8346 }
8383 else 8347 else
8384 # endif
8385 { 8348 {
8386 /* ":drop file ...": Edit the first argument. Jump to an existing 8349 /* ":drop file ...": Edit the first argument. Jump to an existing
8387 * window if possible, edit in current window if the current buffer 8350 * window if possible, edit in current window if the current buffer
8388 * can be abandoned, otherwise open a new window. */ 8351 * can be abandoned, otherwise open a new window. */
8389 buf = buflist_findnr(ARGLIST[0].ae_fnum); 8352 buf = buflist_findnr(ARGLIST[0].ae_fnum);
8390 8353
8391 FOR_ALL_TAB_WINDOWS(tp, wp) 8354 FOR_ALL_TAB_WINDOWS(tp, wp)
8392 { 8355 {
8393 if (wp->w_buffer == buf) 8356 if (wp->w_buffer == buf)
8394 { 8357 {
8395 # ifdef FEAT_WINDOWS
8396 goto_tabpage_win(tp, wp); 8358 goto_tabpage_win(tp, wp);
8397 # endif
8398 curwin->w_arg_idx = 0; 8359 curwin->w_arg_idx = 0;
8399 return; 8360 return;
8400 } 8361 }
8401 } 8362 }
8402 8363
8406 * Skip the check if the 'hidden' option is set, as in this case the 8367 * Skip the check if the 'hidden' option is set, as in this case the
8407 * buffer won't be lost. 8368 * buffer won't be lost.
8408 */ 8369 */
8409 if (!buf_hide(curbuf)) 8370 if (!buf_hide(curbuf))
8410 { 8371 {
8411 # ifdef FEAT_WINDOWS
8412 ++emsg_off; 8372 ++emsg_off;
8413 # endif
8414 split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD); 8373 split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
8415 # ifdef FEAT_WINDOWS
8416 --emsg_off; 8374 --emsg_off;
8417 # else
8418 if (split)
8419 return;
8420 # endif
8421 } 8375 }
8422 8376
8423 /* Fake a ":sfirst" or ":first" command edit the first argument. */ 8377 /* Fake a ":sfirst" or ":first" command edit the first argument. */
8424 if (split) 8378 if (split)
8425 { 8379 {