diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-28 19:46:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-28 19:46:49 +0200 |
commit | afde13b62b8fa25dac4635d5caee8d088b937ee0 (patch) | |
tree | 6a8b58aa58e180e55b2948e5d0bfdbc3d4692a49 /src/main.c | |
parent | ab4cece6053b0bfd604e15065227b94af873608b (diff) | |
download | vim-git-afde13b62b8fa25dac4635d5caee8d088b937ee0.tar.gz |
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exev8.1.1230
Problem: A lot of code is shared between vim.exe and gvim.exe.
Solution: Optionally put the shared code in vim.dll. (Ken Takata,
closes #4287)
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c index 0f26e984a..40a682d4c 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ # include <limits.h> #endif -#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) +#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) # include "iscygpty.h" #endif @@ -95,6 +95,9 @@ static char_u *start_dir = NULL; /* current working dir on startup */ static int has_dash_c_arg = FALSE; +# ifdef VIMDLL +__declspec(dllexport) +# endif int # ifdef MSWIN # ifdef __BORLANDC__ @@ -174,6 +177,11 @@ main #endif common_init(¶ms); +#ifdef VIMDLL + // Check if the current executable file is for the GUI subsystem. + gui.starting = mch_is_gui_executable(); +#endif + #ifdef FEAT_CLIENTSERVER /* * Do the client-server stuff, unless "--servername ''" was used. @@ -292,7 +300,8 @@ main * For GTK we can't be sure, but when started from the desktop it doesn't * make sense to try using a terminal. */ -#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) +#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ + || defined(VIMDLL) if (gui.starting # ifdef FEAT_GUI_GTK && !isatty(2) @@ -542,7 +551,7 @@ vim_main2(void) putchar('\n'); #endif - gui_start(); /* will set full_screen to TRUE */ + gui_start(NULL); /* will set full_screen to TRUE */ TIME_MSG("starting GUI"); /* When running "evim" or "gvim -y" we need the menus, exit if we @@ -851,8 +860,11 @@ vim_main2(void) } #endif -#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) - mch_set_winsize_now(); /* Allow winsize changes from now on */ +#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) +# ifdef VIMDLL + if (!gui.in_use) +# endif + mch_set_winsize_now(); /* Allow winsize changes from now on */ #endif #if defined(FEAT_GUI) @@ -1761,7 +1773,15 @@ parse_command_name(mparm_T *parmp) #ifdef FEAT_GUI ++initstr; #endif +#ifdef GUI_MAY_SPAWN + gui.dospawn = FALSE; // No need to spawn a new process. +#endif } +#ifdef GUI_MAY_SPAWN + else + gui.dospawn = TRUE; // Not "gvim". Need to spawn gvim.exe. +#endif + if (STRNICMP(initstr, "view", 4) == 0) { @@ -2181,7 +2201,7 @@ command_line_scan(mparm_T *parmp) case 'v': /* "-v" Vi-mode (as if called "vi") */ exmode_active = 0; -#ifdef FEAT_GUI +#if defined(FEAT_GUI) && !defined(VIMDLL) gui.starting = FALSE; /* don't start GUI */ #endif break; @@ -2558,8 +2578,12 @@ check_tty(mparm_T *parmp) exit(1); } #endif -#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN) - if (is_cygpty_used()) +#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) + if ( +# ifdef VIMDLL + !gui.starting && +# endif + is_cygpty_used()) { # if defined(HAVE_BIND_TEXTDOMAIN_CODESET) \ && defined(FEAT_GETTEXT) @@ -3440,8 +3464,13 @@ usage(void) main_msg(_("--echo-wid\t\tMake gvim echo the Window ID on stdout")); #endif #ifdef FEAT_GUI_MSWIN - main_msg(_("-P <parent title>\tOpen Vim inside parent application")); - main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); +# ifdef VIMDLL + if (gui.starting) +# endif + { + main_msg(_("-P <parent title>\tOpen Vim inside parent application")); + main_msg(_("--windowid <HWND>\tOpen Vim inside another win32 widget")); + } #endif #ifdef FEAT_GUI_GNOME |