comparison src/main.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 dfb8254aa735
children aa3f6d093f4b
comparison
equal deleted inserted replaced
12476:2516383741e6 12477:68d7bc045dbe
45 static void parse_command_name(mparm_T *parmp); 45 static void parse_command_name(mparm_T *parmp);
46 static void command_line_scan(mparm_T *parmp); 46 static void command_line_scan(mparm_T *parmp);
47 static void check_tty(mparm_T *parmp); 47 static void check_tty(mparm_T *parmp);
48 static void read_stdin(void); 48 static void read_stdin(void);
49 static void create_windows(mparm_T *parmp); 49 static void create_windows(mparm_T *parmp);
50 # ifdef FEAT_WINDOWS
51 static void edit_buffers(mparm_T *parmp, char_u *cwd); 50 static void edit_buffers(mparm_T *parmp, char_u *cwd);
52 # endif
53 static void exe_pre_commands(mparm_T *parmp); 51 static void exe_pre_commands(mparm_T *parmp);
54 static void exe_commands(mparm_T *parmp); 52 static void exe_commands(mparm_T *parmp);
55 static void source_startup_scripts(mparm_T *parmp); 53 static void source_startup_scripts(mparm_T *parmp);
56 static void main_start_gui(void); 54 static void main_start_gui(void);
57 # if defined(HAS_SWAP_EXISTS_ACTION) 55 # if defined(HAS_SWAP_EXISTS_ACTION)
139 params.argv = argv; 137 params.argv = argv;
140 params.want_full_screen = TRUE; 138 params.want_full_screen = TRUE;
141 #ifdef FEAT_EVAL 139 #ifdef FEAT_EVAL
142 params.use_debug_break_level = -1; 140 params.use_debug_break_level = -1;
143 #endif 141 #endif
144 #ifdef FEAT_WINDOWS
145 params.window_count = -1; 142 params.window_count = -1;
146 #endif
147 143
148 #ifdef FEAT_RUBY 144 #ifdef FEAT_RUBY
149 { 145 {
150 int ruby_stack_start; 146 int ruby_stack_start;
151 vim_ruby_init((void *)&ruby_stack_start); 147 vim_ruby_init((void *)&ruby_stack_start);
752 qf_jump(NULL, 0, 0, FALSE); 748 qf_jump(NULL, 0, 0, FALSE);
753 TIME_MSG("jump to first error"); 749 TIME_MSG("jump to first error");
754 } 750 }
755 #endif 751 #endif
756 752
757 #ifdef FEAT_WINDOWS
758 /* 753 /*
759 * If opened more than one window, start editing files in the other 754 * If opened more than one window, start editing files in the other
760 * windows. 755 * windows.
761 */ 756 */
762 edit_buffers(&params, start_dir); 757 edit_buffers(&params, start_dir);
763 #endif
764 vim_free(start_dir); 758 vim_free(start_dir);
765 759
766 #ifdef FEAT_DIFF 760 #ifdef FEAT_DIFF
767 if (params.diff_mode) 761 if (params.diff_mode)
768 { 762 {
865 859
866 #if defined(WIN3264) && !defined(FEAT_GUI_W32) 860 #if defined(WIN3264) && !defined(FEAT_GUI_W32)
867 mch_set_winsize_now(); /* Allow winsize changes from now on */ 861 mch_set_winsize_now(); /* Allow winsize changes from now on */
868 #endif 862 #endif
869 863
870 #if defined(FEAT_GUI) && defined(FEAT_WINDOWS) 864 #if defined(FEAT_GUI)
871 /* When tab pages were created, may need to update the tab pages line and 865 /* When tab pages were created, may need to update the tab pages line and
872 * scrollbars. This is skipped while creating them. */ 866 * scrollbars. This is skipped while creating them. */
873 if (first_tabpage->tp_next != NULL) 867 if (first_tabpage->tp_next != NULL)
874 { 868 {
875 out_flush(); 869 out_flush();
1255 update_curbuf(INVERTED);/* update inverted part */ 1249 update_curbuf(INVERTED);/* update inverted part */
1256 else if (must_redraw) 1250 else if (must_redraw)
1257 update_screen(0); 1251 update_screen(0);
1258 else if (redraw_cmdline || clear_cmdline) 1252 else if (redraw_cmdline || clear_cmdline)
1259 showmode(); 1253 showmode();
1260 #ifdef FEAT_WINDOWS
1261 redraw_statuslines(); 1254 redraw_statuslines();
1262 #endif
1263 #ifdef FEAT_TITLE 1255 #ifdef FEAT_TITLE
1264 if (need_maketitle) 1256 if (need_maketitle)
1265 maketitle(); 1257 maketitle();
1266 #endif 1258 #endif
1267 #ifdef FEAT_VIMINFO 1259 #ifdef FEAT_VIMINFO
1433 1425
1434 #ifdef FEAT_AUTOCMD 1426 #ifdef FEAT_AUTOCMD
1435 if (get_vim_var_nr(VV_DYING) <= 1) 1427 if (get_vim_var_nr(VV_DYING) <= 1)
1436 { 1428 {
1437 /* Trigger BufWinLeave for all windows, but only once per buffer. */ 1429 /* Trigger BufWinLeave for all windows, but only once per buffer. */
1438 # if defined FEAT_WINDOWS
1439 for (tp = first_tabpage; tp != NULL; tp = next_tp) 1430 for (tp = first_tabpage; tp != NULL; tp = next_tp)
1440 { 1431 {
1441 next_tp = tp->tp_next; 1432 next_tp = tp->tp_next;
1442 FOR_ALL_WINDOWS_IN_TAB(tp, wp) 1433 FOR_ALL_WINDOWS_IN_TAB(tp, wp)
1443 { 1434 {
1454 next_tp = first_tabpage; 1445 next_tp = first_tabpage;
1455 break; 1446 break;
1456 } 1447 }
1457 } 1448 }
1458 } 1449 }
1459 # else
1460 apply_autocmds(EVENT_BUFWINLEAVE, curbuf, curbuf->b_fname,
1461 FALSE, curbuf);
1462 # endif
1463 1450
1464 /* Trigger BufUnload for buffers that are loaded */ 1451 /* Trigger BufUnload for buffers that are loaded */
1465 FOR_ALL_BUFFERS(buf) 1452 FOR_ALL_BUFFERS(buf)
1466 if (buf->b_ml.ml_mfp != NULL) 1453 if (buf->b_ml.ml_mfp != NULL)
1467 { 1454 {
2100 argv_idx = -1; /* bypass full -psn */ 2087 argv_idx = -1; /* bypass full -psn */
2101 main_start_gui(); 2088 main_start_gui();
2102 break; 2089 break;
2103 } 2090 }
2104 #endif 2091 #endif
2105 #ifdef FEAT_WINDOWS
2106 /* default is 0: open window for each file */ 2092 /* default is 0: open window for each file */
2107 parmp->window_count = get_number_arg((char_u *)argv[0], 2093 parmp->window_count = get_number_arg((char_u *)argv[0],
2108 &argv_idx, 0); 2094 &argv_idx, 0);
2109 parmp->window_layout = WIN_TABS; 2095 parmp->window_layout = WIN_TABS;
2110 #endif
2111 break; 2096 break;
2112 2097
2113 case 'o': /* "-o[N]" open N horizontal split windows */ 2098 case 'o': /* "-o[N]" open N horizontal split windows */
2114 #ifdef FEAT_WINDOWS
2115 /* default is 0: open window for each file */ 2099 /* default is 0: open window for each file */
2116 parmp->window_count = get_number_arg((char_u *)argv[0], 2100 parmp->window_count = get_number_arg((char_u *)argv[0],
2117 &argv_idx, 0); 2101 &argv_idx, 0);
2118 parmp->window_layout = WIN_HOR; 2102 parmp->window_layout = WIN_HOR;
2119 #endif
2120 break; 2103 break;
2121 2104
2122 case 'O': /* "-O[N]" open N vertical split windows */ 2105 case 'O': /* "-O[N]" open N vertical split windows */
2123 #ifdef FEAT_WINDOWS
2124 /* default is 0: open window for each file */ 2106 /* default is 0: open window for each file */
2125 parmp->window_count = get_number_arg((char_u *)argv[0], 2107 parmp->window_count = get_number_arg((char_u *)argv[0],
2126 &argv_idx, 0); 2108 &argv_idx, 0);
2127 parmp->window_layout = WIN_VER; 2109 parmp->window_layout = WIN_VER;
2128 #endif
2129 break; 2110 break;
2130 2111
2131 #ifdef FEAT_QUICKFIX 2112 #ifdef FEAT_QUICKFIX
2132 case 'q': /* "-q" QuickFix mode */ 2113 case 'q': /* "-q" QuickFix mode */
2133 if (parmp->edit_type != EDIT_NONE) 2114 if (parmp->edit_type != EDIT_NONE)
2638 * Also does recovery if "recoverymode" set. 2619 * Also does recovery if "recoverymode" set.
2639 */ 2620 */
2640 static void 2621 static void
2641 create_windows(mparm_T *parmp UNUSED) 2622 create_windows(mparm_T *parmp UNUSED)
2642 { 2623 {
2643 #ifdef FEAT_WINDOWS
2644 int dorewind; 2624 int dorewind;
2645 int done = 0; 2625 int done = 0;
2646 2626
2647 /* 2627 /*
2648 * Create the number of windows that was requested. 2628 * Create the number of windows that was requested.
2671 else 2651 else
2672 parmp->window_count = win_count(); 2652 parmp->window_count = win_count();
2673 } 2653 }
2674 else 2654 else
2675 parmp->window_count = 1; 2655 parmp->window_count = 1;
2676 #endif
2677 2656
2678 if (recoverymode) /* do recover */ 2657 if (recoverymode) /* do recover */
2679 { 2658 {
2680 msg_scroll = TRUE; /* scroll message up */ 2659 msg_scroll = TRUE; /* scroll message up */
2681 ml_recover(); 2660 ml_recover();
2695 * Don't execute Win/Buf Enter/Leave autocommands here 2674 * Don't execute Win/Buf Enter/Leave autocommands here
2696 */ 2675 */
2697 ++autocmd_no_enter; 2676 ++autocmd_no_enter;
2698 ++autocmd_no_leave; 2677 ++autocmd_no_leave;
2699 #endif 2678 #endif
2700 #ifdef FEAT_WINDOWS
2701 dorewind = TRUE; 2679 dorewind = TRUE;
2702 while (done++ < 1000) 2680 while (done++ < 1000)
2703 { 2681 {
2704 if (dorewind) 2682 if (dorewind)
2705 { 2683 {
2719 if (curwin->w_next == NULL) 2697 if (curwin->w_next == NULL)
2720 break; 2698 break;
2721 curwin = curwin->w_next; 2699 curwin = curwin->w_next;
2722 } 2700 }
2723 dorewind = FALSE; 2701 dorewind = FALSE;
2724 #endif
2725 curbuf = curwin->w_buffer; 2702 curbuf = curwin->w_buffer;
2726 if (curbuf->b_ml.ml_mfp == NULL) 2703 if (curbuf->b_ml.ml_mfp == NULL)
2727 { 2704 {
2728 #ifdef FEAT_FOLDING 2705 #ifdef FEAT_FOLDING
2729 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */ 2706 /* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */
2760 #endif 2737 #endif
2761 #ifdef FEAT_AUTOCMD 2738 #ifdef FEAT_AUTOCMD
2762 dorewind = TRUE; /* start again */ 2739 dorewind = TRUE; /* start again */
2763 #endif 2740 #endif
2764 } 2741 }
2765 #ifdef FEAT_WINDOWS
2766 ui_breakcheck(); 2742 ui_breakcheck();
2767 if (got_int) 2743 if (got_int)
2768 { 2744 {
2769 (void)vgetc(); /* only break the file loading, not the rest */ 2745 (void)vgetc(); /* only break the file loading, not the rest */
2770 break; 2746 break;
2771 } 2747 }
2772 } 2748 }
2773 #endif
2774 #ifdef FEAT_WINDOWS
2775 if (parmp->window_layout == WIN_TABS) 2749 if (parmp->window_layout == WIN_TABS)
2776 goto_tabpage(1); 2750 goto_tabpage(1);
2777 else 2751 else
2778 curwin = firstwin; 2752 curwin = firstwin;
2779 curbuf = curwin->w_buffer; 2753 curbuf = curwin->w_buffer;
2780 #endif
2781 #ifdef FEAT_AUTOCMD 2754 #ifdef FEAT_AUTOCMD
2782 --autocmd_no_enter; 2755 --autocmd_no_enter;
2783 --autocmd_no_leave; 2756 --autocmd_no_leave;
2784 #endif 2757 #endif
2785 } 2758 }
2786 } 2759 }
2787 2760
2788 #ifdef FEAT_WINDOWS
2789 /* 2761 /*
2790 * If opened more than one window, start editing files in the other 2762 * If opened more than one window, start editing files in the other
2791 * windows. make_windows() has already opened the windows. 2763 * windows. make_windows() has already opened the windows.
2792 */ 2764 */
2793 static void 2765 static void
2891 --autocmd_no_enter; 2863 --autocmd_no_enter;
2892 # endif 2864 # endif
2893 2865
2894 /* make the first window the current window */ 2866 /* make the first window the current window */
2895 win = firstwin; 2867 win = firstwin;
2896 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 2868 #if defined(FEAT_QUICKFIX)
2897 /* Avoid making a preview window the current window. */ 2869 /* Avoid making a preview window the current window. */
2898 while (win->w_p_pvw) 2870 while (win->w_p_pvw)
2899 { 2871 {
2900 win = win->w_next; 2872 win = win->w_next;
2901 if (win == NULL) 2873 if (win == NULL)
2905 } 2877 }
2906 } 2878 }
2907 #endif 2879 #endif
2908 win_enter(win, FALSE); 2880 win_enter(win, FALSE);
2909 2881
2910 # ifdef FEAT_AUTOCMD 2882 #ifdef FEAT_AUTOCMD
2911 --autocmd_no_leave; 2883 --autocmd_no_leave;
2912 # endif 2884 #endif
2913 TIME_MSG("editing files in windows"); 2885 TIME_MSG("editing files in windows");
2914 if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS) 2886 if (parmp->window_count > 1 && parmp->window_layout != WIN_TABS)
2915 win_equal(curwin, FALSE, 'b'); /* adjust heights */ 2887 win_equal(curwin, FALSE, 'b'); /* adjust heights */
2916 } 2888 }
2917 #endif /* FEAT_WINDOWS */
2918 2889
2919 /* 2890 /*
2920 * Execute the commands from --cmd arguments "cmds[cnt]". 2891 * Execute the commands from --cmd arguments "cmds[cnt]".
2921 */ 2892 */
2922 static void 2893 static void
3365 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc")); 3336 main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc"));
3366 #ifdef FEAT_GUI 3337 #ifdef FEAT_GUI
3367 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc")); 3338 main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc"));
3368 #endif 3339 #endif
3369 main_msg(_("--noplugin\t\tDon't load plugin scripts")); 3340 main_msg(_("--noplugin\t\tDon't load plugin scripts"));
3370 #ifdef FEAT_WINDOWS
3371 main_msg(_("-p[N]\t\tOpen N tab pages (default: one for each file)")); 3341 main_msg(_("-p[N]\t\tOpen N tab pages (default: one for each file)"));
3372 main_msg(_("-o[N]\t\tOpen N windows (default: one for each file)")); 3342 main_msg(_("-o[N]\t\tOpen N windows (default: one for each file)"));
3373 main_msg(_("-O[N]\t\tLike -o but split vertically")); 3343 main_msg(_("-O[N]\t\tLike -o but split vertically"));
3374 #endif
3375 main_msg(_("+\t\t\tStart at end of file")); 3344 main_msg(_("+\t\t\tStart at end of file"));
3376 main_msg(_("+<lnum>\t\tStart at line <lnum>")); 3345 main_msg(_("+<lnum>\t\tStart at line <lnum>"));
3377 main_msg(_("--cmd <command>\tExecute <command> before loading any vimrc file")); 3346 main_msg(_("--cmd <command>\tExecute <command> before loading any vimrc file"));
3378 main_msg(_("-c <command>\t\tExecute <command> after loading the first file")); 3347 main_msg(_("-c <command>\t\tExecute <command> after loading the first file"));
3379 main_msg(_("-S <session>\t\tSource file <session> after loading the first file")); 3348 main_msg(_("-S <session>\t\tSource file <session> after loading the first file"));
3392 #ifdef FEAT_CLIENTSERVER 3361 #ifdef FEAT_CLIENTSERVER
3393 main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible")); 3362 main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible"));
3394 main_msg(_("--remote-silent <files> Same, don't complain if there is no server")); 3363 main_msg(_("--remote-silent <files> Same, don't complain if there is no server"));
3395 main_msg(_("--remote-wait <files> As --remote but wait for files to have been edited")); 3364 main_msg(_("--remote-wait <files> As --remote but wait for files to have been edited"));
3396 main_msg(_("--remote-wait-silent <files> Same, don't complain if there is no server")); 3365 main_msg(_("--remote-wait-silent <files> Same, don't complain if there is no server"));
3397 # ifdef FEAT_WINDOWS
3398 main_msg(_("--remote-tab[-wait][-silent] <files> As --remote but use tab page per file")); 3366 main_msg(_("--remote-tab[-wait][-silent] <files> As --remote but use tab page per file"));
3399 # endif
3400 main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit")); 3367 main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit"));
3401 main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result")); 3368 main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result"));
3402 main_msg(_("--serverlist\t\tList available Vim server names and exit")); 3369 main_msg(_("--serverlist\t\tList available Vim server names and exit"));
3403 main_msg(_("--servername <name>\tSend to/become the Vim server <name>")); 3370 main_msg(_("--servername <name>\tSend to/become the Vim server <name>"));
3404 #endif 3371 #endif