diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-09-16 20:54:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-09-16 20:54:51 +0200 |
commit | 4033c55eca575777718c0701e26635a0cc47d907 (patch) | |
tree | 8dc460ad495106198a9119b52f6505033f7a75b3 /src/ex_docmd.c | |
parent | e738a1a033cd31cd2568ba99a9e2dca1e65b45ea (diff) | |
download | vim-git-4033c55eca575777718c0701e26635a0cc47d907.tar.gz |
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefsv8.0.1118
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.
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 196 |
1 files changed, 43 insertions, 153 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index e804e2a5d..dbdd4034a 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -108,7 +108,7 @@ static void ex_blast(exarg_T *eap); # define buflist_list ex_ni # define ex_checktime ex_ni #endif -#if !defined(FEAT_LISTCMDS) || !defined(FEAT_WINDOWS) +#if !defined(FEAT_LISTCMDS) # define ex_buffer_all ex_ni #endif static char_u *getargcmd(char_u **); @@ -126,7 +126,7 @@ static int getargopt(exarg_T *eap); # define ex_helpgrep ex_ni # define ex_vimgrep ex_ni #endif -#if !defined(FEAT_QUICKFIX) || !defined(FEAT_WINDOWS) +#if !defined(FEAT_QUICKFIX) # define ex_cclose ex_ni # define ex_copen ex_ni # define ex_cwindow ex_ni @@ -159,7 +159,6 @@ static void ex_colorscheme(exarg_T *eap); static void ex_quit(exarg_T *eap); static void ex_cquit(exarg_T *eap); static void ex_quit_all(exarg_T *eap); -#ifdef FEAT_WINDOWS static void ex_close(exarg_T *eap); static void ex_win_close(int forceit, win_T *win, tabpage_T *tp); static void ex_only(exarg_T *eap); @@ -170,20 +169,7 @@ static void ex_tabonly(exarg_T *eap); static void ex_tabnext(exarg_T *eap); static void ex_tabmove(exarg_T *eap); static void ex_tabs(exarg_T *eap); -#else -# define ex_close ex_ni -# define ex_only ex_ni -# define ex_all ex_ni -# define ex_resize ex_ni -# define ex_splitview ex_ni -# define ex_stag ex_ni -# define ex_tabnext ex_ni -# define ex_tabmove ex_ni -# define ex_tabs ex_ni -# define ex_tabclose ex_ni -# define ex_tabonly ex_ni -#endif -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) static void ex_pclose(exarg_T *eap); static void ex_ptag(exarg_T *eap); static void ex_pedit(exarg_T *eap); @@ -314,11 +300,7 @@ static void ex_equal(exarg_T *eap); static void ex_sleep(exarg_T *eap); static void do_exmap(exarg_T *eap, int isabbrev); static void ex_winsize(exarg_T *eap); -#ifdef FEAT_WINDOWS static void ex_wincmd(exarg_T *eap); -#else -# define ex_wincmd ex_ni -#endif #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) static void ex_winpos(exarg_T *eap); #else @@ -356,7 +338,7 @@ static void ex_findpat(exarg_T *eap); # define ex_findpat ex_ni # define ex_checkpath ex_ni #endif -#if defined(FEAT_FIND_ID) && defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX) static void ex_psearch(exarg_T *eap); #else # define ex_psearch ex_ni @@ -1675,7 +1657,6 @@ compute_buffer_local_count(int addr_type, int lnum, int offset) return buf->b_fnum; } -#ifdef FEAT_WINDOWS static int current_win_nr(win_T *win); static int current_tab_nr(tabpage_T *tab); @@ -1713,13 +1694,6 @@ current_tab_nr(tabpage_T *tab) # define LAST_WIN_NR current_win_nr(NULL) # define CURRENT_TAB_NR current_tab_nr(curtab) # define LAST_TAB_NR current_tab_nr(NULL) -#else -# define CURRENT_WIN_NR 1 -# define LAST_WIN_NR 1 -# define CURRENT_TAB_NR 1 -# define LAST_TAB_NR 1 -#endif - /* * Execute one Ex command. @@ -1843,16 +1817,12 @@ do_one_cmd( /* When adding an entry, also modify cmd_exists(). */ case 'a': if (!checkforcmd(&ea.cmd, "aboveleft", 3)) break; -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_ABOVE; -#endif continue; case 'b': if (checkforcmd(&ea.cmd, "belowright", 3)) { -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_BELOW; -#endif continue; } if (checkforcmd(&ea.cmd, "browse", 3)) @@ -1864,9 +1834,7 @@ do_one_cmd( } if (!checkforcmd(&ea.cmd, "botright", 2)) break; -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_BOT; -#endif continue; case 'c': if (!checkforcmd(&ea.cmd, "confirm", 4)) @@ -1937,9 +1905,7 @@ do_one_cmd( if (!checkforcmd(&ea.cmd, "leftabove", 5)) break; -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_ABOVE; -#endif continue; case 'n': if (checkforcmd(&ea.cmd, "noautocmd", 3)) @@ -1963,9 +1929,7 @@ do_one_cmd( case 'r': if (!checkforcmd(&ea.cmd, "rightbelow", 6)) break; -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_BELOW; -#endif continue; case 's': if (checkforcmd(&ea.cmd, "sandbox", 3)) @@ -1993,7 +1957,6 @@ do_one_cmd( case 't': if (checkforcmd(&p, "tab", 3)) { -#ifdef FEAT_WINDOWS long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS, ea.skip, FALSE, 1); if (tabnr == MAXLNUM) @@ -2008,14 +1971,11 @@ do_one_cmd( cmdmod.tab = tabnr + 1; } ea.cmd = p; -#endif continue; } if (!checkforcmd(&ea.cmd, "topleft", 2)) break; -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_TOP; -#endif continue; case 'u': if (!checkforcmd(&ea.cmd, "unsilent", 3)) @@ -2027,9 +1987,7 @@ do_one_cmd( case 'v': if (checkforcmd(&ea.cmd, "vertical", 4)) { -#ifdef FEAT_WINDOWS cmdmod.split |= WSP_VERT; -#endif continue; } if (!checkforcmd(&p, "verbose", 4)) @@ -2112,11 +2070,9 @@ do_one_cmd( else ea.addr_type = ADDR_LINES; -#ifdef FEAT_WINDOWS /* :wincmd range depends on the argument. */ if (ea.cmdidx == CMD_wincmd && p != NULL) get_wincmd_addr_type(skipwhite(p), &ea); -#endif } /* repeat for all ',' or ';' separated addresses */ @@ -6795,7 +6751,6 @@ uc_check_code( *buf = '\0'; } -#ifdef FEAT_WINDOWS /* :aboveleft and :leftabove */ if (cmdmod.split & WSP_ABOVE) result += add_cmd_modifier(buf, "aboveleft", &multi_mods); @@ -6805,7 +6760,6 @@ uc_check_code( /* :botright */ if (cmdmod.split & WSP_BOT) result += add_cmd_modifier(buf, "botright", &multi_mods); -#endif /* the modifiers that are simple flags */ for (i = 0; mod_entries[i].varp != NULL; ++i) @@ -6821,23 +6775,19 @@ uc_check_code( if (msg_silent > 0) result += add_cmd_modifier(buf, emsg_silent > 0 ? "silent!" : "silent", &multi_mods); -#ifdef FEAT_WINDOWS /* :tab */ if (cmdmod.tab > 0) result += add_cmd_modifier(buf, "tab", &multi_mods); /* :topleft */ if (cmdmod.split & WSP_TOP) result += add_cmd_modifier(buf, "topleft", &multi_mods); -#endif /* TODO: How to support :unsilent?*/ /* :verbose */ if (p_verbose > 0) result += add_cmd_modifier(buf, "verbose", &multi_mods); -#ifdef FEAT_WINDOWS /* :vertical */ if (cmdmod.split & WSP_VERT) result += add_cmd_modifier(buf, "vertical", &multi_mods); -#endif if (quote && buf != NULL) { buf += result - 2; @@ -7270,9 +7220,7 @@ not_exiting(void) static void ex_quit(exarg_T *eap) { -#if defined(FEAT_WINDOWS) || defined(FEAT_AUTOCMD) win_T *wp; -#endif #ifdef FEAT_CMDWIN if (cmdwin_type != 0) @@ -7287,7 +7235,6 @@ ex_quit(exarg_T *eap) text_locked_msg(); return; } -#ifdef FEAT_WINDOWS if (eap->addr_count > 0) { int wnr = eap->line2; @@ -7297,19 +7244,13 @@ ex_quit(exarg_T *eap) break; } else -#endif -#if defined(FEAT_WINDOWS) || defined(FEAT_AUTOCMD) wp = curwin; -#endif #ifdef FEAT_AUTOCMD apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); /* Refuse to quit when locked or when the buffer in the last window is * being closed (can only happen in autocommands). */ - if (curbuf_locked() -# ifdef FEAT_WINDOWS - || !win_valid(wp) -# endif + if (curbuf_locked() || !win_valid(wp) || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) return; #endif @@ -7334,7 +7275,6 @@ ex_quit(exarg_T *eap) } else { -#ifdef FEAT_WINDOWS /* quit last window * Note: only_one_window() returns true, even so a help window is * still open. In that case only quit, if no address has been @@ -7343,15 +7283,12 @@ ex_quit(exarg_T *eap) * :h|wincmd w|q - quit */ if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) -#endif getout(0); -#ifdef FEAT_WINDOWS -# ifdef FEAT_GUI +#ifdef FEAT_GUI need_mouse_correct = TRUE; -# endif +#endif /* close window; may free buffer */ win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); -#endif } } @@ -7402,7 +7339,6 @@ ex_quit_all(exarg_T *eap) not_exiting(); } -#if defined(FEAT_WINDOWS) || defined(PROTO) /* * ":close": close current window, unless it is the last one */ @@ -7411,11 +7347,11 @@ ex_close(exarg_T *eap) { win_T *win; int winnr = 0; -# ifdef FEAT_CMDWIN +#ifdef FEAT_CMDWIN if (cmdwin_type != 0) cmdwin_result = Ctrl_C; else -# endif +#endif if (!text_locked() #ifdef FEAT_AUTOCMD && !curbuf_locked() @@ -7438,7 +7374,7 @@ ex_close(exarg_T *eap) } } -# ifdef FEAT_QUICKFIX +#ifdef FEAT_QUICKFIX /* * ":pclose": Close any preview window. */ @@ -7454,7 +7390,7 @@ ex_pclose(exarg_T *eap) break; } } -# endif +#endif /* * Close window "win" and take care of handling closing the last window for a @@ -7472,7 +7408,7 @@ ex_win_close( need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1); if (need_hide && !buf_hide(buf) && !forceit) { -# if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) +#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && p_write) { bufref_T bufref; @@ -7484,16 +7420,16 @@ ex_win_close( need_hide = FALSE; } else -# endif +#endif { no_write_message(); return; } } -# ifdef FEAT_GUI +#ifdef FEAT_GUI need_mouse_correct = TRUE; -# endif +#endif /* free buffer when not hiding it or when it's a scratch buffer */ if (tp == NULL) @@ -7779,18 +7715,16 @@ ex_all(exarg_T *eap) eap->line2 = 9999; do_arg_all((int)eap->line2, eap->forceit, eap->cmdidx == CMD_drop); } -#endif /* FEAT_WINDOWS */ static void ex_hide(exarg_T *eap UNUSED) { /* ":hide" or ":hide | cmd": hide current window */ -#ifdef FEAT_WINDOWS if (!eap->skip) { -# ifdef FEAT_GUI +#ifdef FEAT_GUI need_mouse_correct = TRUE; -# endif +#endif if (eap->addr_count == 0) win_close(curwin, FALSE); /* don't free buffer */ else @@ -7809,7 +7743,6 @@ ex_hide(exarg_T *eap UNUSED) win_close(win, FALSE); } } -#endif } /* @@ -7887,17 +7820,13 @@ ex_exit(exarg_T *eap) } else { -#ifdef FEAT_WINDOWS if (only_one_window()) /* quit last window, exit Vim */ -#endif getout(0); -#ifdef FEAT_WINDOWS # ifdef FEAT_GUI need_mouse_correct = TRUE; # endif /* Quit current window, may free the buffer. */ win_close(curwin, !buf_hide(curwin->w_buffer)); -#endif } } @@ -7947,7 +7876,7 @@ ex_shell(exarg_T *eap UNUSED) do_shell(NULL, 0); } -#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) \ +#if defined(HAVE_DROP_FILE) \ || (defined(FEAT_GUI_GTK) && defined(FEAT_DND)) \ || defined(FEAT_GUI_MSWIN) \ || defined(FEAT_GUI_MAC) \ @@ -8000,7 +7929,6 @@ handle_drop( } if (split) { -# ifdef FEAT_WINDOWS if (win_split(0, 0) == FAIL) return; RESET_BINDING(curwin); @@ -8009,9 +7937,6 @@ handle_drop( * existing one is overwritten. */ alist_unlink(curwin->w_alist); alist_new(); -# else - return; /* can't split, always fail */ -# endif } /* @@ -8058,8 +7983,6 @@ alist_init(alist_T *al) ga_init2(&al->al_ga, (int)sizeof(aentry_T), 5); } -#if defined(FEAT_WINDOWS) || defined(PROTO) - /* * Remove a reference from an argument list. * Ignored when the argument list is the global one. @@ -8075,7 +7998,7 @@ alist_unlink(alist_T *al) } } -# if defined(FEAT_LISTCMDS) || defined(HAVE_DROP_FILE) || defined(PROTO) +#if defined(FEAT_LISTCMDS) || defined(HAVE_DROP_FILE) || defined(PROTO) /* * Create a new argument list and use it for the current window. */ @@ -8095,7 +8018,6 @@ alist_new(void) alist_init(curwin->w_alist); } } -# endif #endif #if !defined(UNIX) || defined(PROTO) @@ -8179,9 +8101,7 @@ alist_set( } else FreeWild(count, files); -#ifdef FEAT_WINDOWS if (al == &global_alist) -#endif arg_had_last = FALSE; } @@ -8215,21 +8135,17 @@ alist_add( alist_slash_adjust(void) { int i; -# ifdef FEAT_WINDOWS win_T *wp; tabpage_T *tp; -# endif for (i = 0; i < GARGCOUNT; ++i) if (GARGLIST[i].ae_fname != NULL) slash_adjust(GARGLIST[i].ae_fname); -# ifdef FEAT_WINDOWS FOR_ALL_TAB_WINDOWS(tp, wp) if (wp->w_alist != &global_alist) for (i = 0; i < WARGCOUNT(wp); ++i) if (WARGLIST(wp)[i].ae_fname != NULL) slash_adjust(WARGLIST(wp)[i].ae_fname); -# endif } #endif @@ -8271,7 +8187,6 @@ ex_wrongmodifier(exarg_T *eap) eap->errmsg = e_invcmd; } -#ifdef FEAT_WINDOWS /* * :sview [+command] file split window with new file, read-only * :split [[+command] file] split window with current or new file @@ -8289,18 +8204,18 @@ ex_wrongmodifier(exarg_T *eap) ex_splitview(exarg_T *eap) { win_T *old_curwin = curwin; -# if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) +#if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) char_u *fname = NULL; -# endif -# ifdef FEAT_BROWSE +#endif +#ifdef FEAT_BROWSE int browse_flag = cmdmod.browse; -# endif +#endif -# ifdef FEAT_GUI +#ifdef FEAT_GUI need_mouse_correct = TRUE; -# endif +#endif -# ifdef FEAT_QUICKFIX +#ifdef FEAT_QUICKFIX /* A ":split" in the quickfix window works like ":new". Don't want two * quickfix windows. But it's OK when doing ":tab split". */ if (bt_quickfix(curbuf) && cmdmod.tab == 0) @@ -8310,9 +8225,9 @@ ex_splitview(exarg_T *eap) if (eap->cmdidx == CMD_vsplit) eap->cmdidx = CMD_vnew; } -# endif +#endif -# ifdef FEAT_SEARCHPATH +#ifdef FEAT_SEARCHPATH if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) { fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), @@ -8321,11 +8236,11 @@ ex_splitview(exarg_T *eap) goto theend; eap->arg = fname; } -# ifdef FEAT_BROWSE +# ifdef FEAT_BROWSE else -# endif # endif -# ifdef FEAT_BROWSE +#endif +#ifdef FEAT_BROWSE if (cmdmod.browse && eap->cmdidx != CMD_vnew && eap->cmdidx != CMD_new) @@ -8353,7 +8268,7 @@ ex_splitview(exarg_T *eap) } } cmdmod.browse = FALSE; /* Don't browse again in do_ecmd(). */ -# endif +#endif /* * Either open new tab page or split the window. @@ -8534,8 +8449,6 @@ ex_tabs(exarg_T *eap UNUSED) } } -#endif /* FEAT_WINDOWS */ - /* * ":mode": Set screen mode. * If no argument given, just get the screen size and redraw. @@ -8549,7 +8462,6 @@ ex_mode(exarg_T *eap) mch_screenmode(eap->arg); } -#ifdef FEAT_WINDOWS /* * ":resize". * set, increment or decrement current window height @@ -8588,7 +8500,6 @@ ex_resize(exarg_T *eap) win_setheight_win((int)n, wp); } } -#endif /* * ":find [+command] <file>" command. @@ -8681,9 +8592,7 @@ do_exedit( win_T *old_curwin) /* curwin before doing a split or NULL */ { int n; -#ifdef FEAT_WINDOWS int need_hide; -#endif int exmode_was = exmode_active; /* @@ -8738,10 +8647,7 @@ do_exedit( if ((eap->cmdidx == CMD_new || eap->cmdidx == CMD_tabnew || eap->cmdidx == CMD_tabedit -#ifdef FEAT_WINDOWS - || eap->cmdidx == CMD_vnew -#endif - ) && *eap->arg == NUL) + || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) { /* ":new" or ":tabnew" without argument: edit an new empty buffer */ setpcmark(); @@ -8749,11 +8655,7 @@ do_exedit( ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), old_curwin == NULL ? curwin : NULL); } - else if ((eap->cmdidx != CMD_split -#ifdef FEAT_WINDOWS - && eap->cmdidx != CMD_vsplit -#endif - ) + else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) || *eap->arg != NUL #ifdef FEAT_BROWSE || cmdmod.browse @@ -8789,33 +8691,31 @@ do_exedit( , old_curwin == NULL ? curwin : NULL) == FAIL) { /* Editing the file failed. If the window was split, close it. */ -#ifdef FEAT_WINDOWS if (old_curwin != NULL) { need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1); if (!need_hide || buf_hide(curbuf)) { -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) cleanup_T cs; /* Reset the error/interrupt/exception state here so that * aborting() returns FALSE when closing a window. */ enter_cleanup(&cs); -# endif -# ifdef FEAT_GUI +#endif +#ifdef FEAT_GUI need_mouse_correct = TRUE; -# endif +#endif win_close(curwin, !need_hide && !buf_hide(curbuf)); -# if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) +#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) /* Restore the error/interrupt/exception state if not * discarded by a new aborting error, interrupt, or * uncaught exception. */ leave_cleanup(&cs); -# endif +#endif } } -#endif } else if (readonlymode && curbuf->b_nwindows == 1) { @@ -8841,7 +8741,6 @@ do_exedit( #endif } -#ifdef FEAT_WINDOWS /* * if ":split file" worked, set alternate file name in old window to new * file @@ -8853,7 +8752,6 @@ do_exedit( && old_curwin->w_buffer != curbuf && !cmdmod.keepalt) old_curwin->w_alt_fnum = curbuf->b_fnum; -#endif ex_no_reprint = TRUE; } @@ -8952,9 +8850,7 @@ ex_syncbind(exarg_T *eap UNUSED) curwin->w_scbind_pos = topline; redraw_later(VALID); cursor_correct(); -#ifdef FEAT_WINDOWS curwin->w_redr_status = TRUE; -#endif } } curwin = save_curwin; @@ -9309,7 +9205,6 @@ ex_winsize(exarg_T *eap) EMSG(_("E465: :winsize requires two number arguments")); } -#ifdef FEAT_WINDOWS static void ex_wincmd(exarg_T *eap) { @@ -9344,7 +9239,6 @@ ex_wincmd(exarg_T *eap) postponed_split_tab = 0; } } -#endif #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) /* @@ -9865,7 +9759,6 @@ ex_redraw(exarg_T *eap) static void ex_redrawstatus(exarg_T *eap UNUSED) { -#if defined(FEAT_WINDOWS) int r = RedrawingDisabled; int p = p_lz; @@ -9879,7 +9772,6 @@ ex_redrawstatus(exarg_T *eap UNUSED) RedrawingDisabled = r; p_lz = p; out_flush(); -#endif } static void @@ -10457,7 +10349,7 @@ ex_checkpath(exarg_T *eap) (linenr_T)1, (linenr_T)MAXLNUM); } -#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) +#if defined(FEAT_QUICKFIX) /* * ":psearch" */ @@ -10528,9 +10420,8 @@ ex_findpat(exarg_T *eap) } #endif -#ifdef FEAT_WINDOWS -# ifdef FEAT_QUICKFIX +#ifdef FEAT_QUICKFIX /* * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. */ @@ -10563,7 +10454,7 @@ ex_pedit(exarg_T *eap) } g_do_tagpreview = 0; } -# endif +#endif /* * ":stag", ":stselect" and ":stjump". @@ -10578,7 +10469,6 @@ ex_stag(exarg_T *eap) postponed_split_flags = 0; postponed_split_tab = 0; } -#endif /* * ":tag", ":tselect", ":tjump", ":tnext", etc. |