1
0
forked from aniani/vim

patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe

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)
This commit is contained in:
Bram Moolenaar
2019-04-28 19:46:49 +02:00
parent ab4cece605
commit afde13b62b
42 changed files with 1202 additions and 468 deletions

View File

@@ -2563,8 +2563,12 @@ t_puts(
msg_use_printf(void)
{
return (!msg_check_screen()
#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
# ifdef VIMDLL
|| (!gui.in_use && !termcap_active)
# else
|| !termcap_active
# endif
#endif
|| (swapping_screen() && !termcap_active)
);
@@ -2940,15 +2944,10 @@ do_more_prompt(int typed_char)
# undef mch_msg
#endif
/*
* Give an error message. To be used when the screen hasn't been initialized
* yet. When stderr can't be used, collect error messages until the GUI has
* started and they can be displayed in a message box.
*/
void
mch_errmsg(char *str)
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
static void
mch_errmsg_c(char *str)
{
#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
int len = (int)STRLEN(str);
DWORD nwrite = 0;
DWORD mode = 0;
@@ -2966,34 +2965,57 @@ mch_errmsg(char *str)
{
fprintf(stderr, "%s", str);
}
#else
int len;
}
#endif
# if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
/*
* Give an error message. To be used when the screen hasn't been initialized
* yet. When stderr can't be used, collect error messages until the GUI has
* started and they can be displayed in a message box.
*/
void
mch_errmsg(char *str)
{
#if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
int len;
#endif
#if (defined(UNIX) || defined(FEAT_GUI)) && (!defined(ALWAYS_USE_GUI) || !defined(VIMDLL))
/* On Unix use stderr if it's a tty.
* When not going to start the GUI also use stderr.
* On Mac, when started from Finder, stderr is the console. */
if (
# ifdef UNIX
# ifdef MACOS_X
# ifdef UNIX
# ifdef MACOS_X
(isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
# else
# else
isatty(2)
# endif
# ifdef FEAT_GUI
||
# endif
# endif
# ifdef FEAT_GUI
!(gui.in_use || gui.starting)
||
# endif
# endif
# ifdef FEAT_GUI
!(gui.in_use || gui.starting)
# endif
)
{
fprintf(stderr, "%s", str);
return;
}
# endif
#endif
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
# ifdef VIMDLL
if (!(gui.in_use || gui.starting))
# endif
{
mch_errmsg_c(str);
return;
}
#endif
#if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
/* avoid a delay for a message that isn't there */
emsg_on_display = FALSE;
@@ -3028,15 +3050,10 @@ mch_errmsg(char *str)
#endif
}
/*
* Give a message. To be used when the screen hasn't been initialized yet.
* When there is no tty, collect messages until the GUI has started and they
* can be displayed in a message box.
*/
void
mch_msg(char *str)
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
static void
mch_msg_c(char *str)
{
#if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
int len = (int)STRLEN(str);
DWORD nwrite = 0;
DWORD mode;
@@ -3055,32 +3072,53 @@ mch_msg(char *str)
{
printf("%s", str);
}
#else
# if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
}
#endif
/*
* Give a message. To be used when the screen hasn't been initialized yet.
* When there is no tty, collect messages until the GUI has started and they
* can be displayed in a message box.
*/
void
mch_msg(char *str)
{
#if (defined(UNIX) || defined(FEAT_GUI)) && (!defined(ALWAYS_USE_GUI) || !defined(VIMDLL))
/* On Unix use stdout if we have a tty. This allows "vim -h | more" and
* uses mch_errmsg() when started from the desktop.
* When not going to start the GUI also use stdout.
* On Mac, when started from Finder, stderr is the console. */
if (
# ifdef UNIX
# ifdef MACOS_X
# ifdef UNIX
# ifdef MACOS_X
(isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
# else
# else
isatty(2)
# endif
# ifdef FEAT_GUI
||
# endif
# endif
# ifdef FEAT_GUI
!(gui.in_use || gui.starting)
||
# endif
# endif
# ifdef FEAT_GUI
!(gui.in_use || gui.starting)
# endif
)
{
printf("%s", str);
return;
}
#endif
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
# ifdef VIMDLL
if (!(gui.in_use || gui.starting))
# endif
{
mch_msg_c(str);
return;
}
#endif
#if !defined(MSWIN) || defined(FEAT_GUI_MSWIN)
mch_errmsg(str);
#endif
}