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

@@ -4094,7 +4094,12 @@ add_termcode(char_u *name, char_u *string, int flags)
#if defined(MSWIN) && !defined(FEAT_GUI)
s = vim_strnsave(string, (int)STRLEN(string) + 1);
#else
s = vim_strsave(string);
# ifdef VIMDLL
if (!gui.in_use)
s = vim_strnsave(string, (int)STRLEN(string) + 1);
else
# endif
s = vim_strsave(string);
#endif
if (s == NULL)
return;
@@ -4106,11 +4111,16 @@ add_termcode(char_u *name, char_u *string, int flags)
s[0] = term_7to8bit(string);
}
#if defined(MSWIN) && !defined(FEAT_GUI)
if (s[0] == K_NUL)
#if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))
# ifdef VIMDLL
if (!gui.in_use)
# endif
{
STRMOVE(s + 1, s);
s[1] = 3;
if (s[0] == K_NUL)
{
STRMOVE(s + 1, s);
s[1] = 3;
}
}
#endif
@@ -6712,7 +6722,7 @@ translate_mapping(
}
#endif
#if (defined(MSWIN) && !defined(FEAT_GUI)) || defined(PROTO)
#if (defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))) || defined(PROTO)
static char ksme_str[20];
static char ksmr_str[20];
static char ksmd_str[20];
@@ -6902,6 +6912,19 @@ hex_digit(int c)
return 0x1ffffff;
}
# ifdef VIMDLL
static guicolor_T
gui_adjust_rgb(guicolor_T c)
{
if (gui.in_use)
return c;
else
return ((c & 0xff) << 16) | (c & 0x00ff00) | ((c >> 16) & 0xff);
}
# else
# define gui_adjust_rgb(c) (c)
# endif
guicolor_T
gui_get_color_cmn(char_u *name)
{
@@ -6973,13 +6996,13 @@ gui_get_color_cmn(char_u *name)
((hex_digit(name[5]) << 4) + hex_digit(name[6])));
if (color > 0xffffff)
return INVALCOLOR;
return color;
return gui_adjust_rgb(color);
}
/* Check if the name is one of the colors we know */
for (i = 0; i < (int)(sizeof(rgb_table) / sizeof(rgb_table[0])); i++)
if (STRICMP(name, rgb_table[i].color_name) == 0)
return rgb_table[i].color;
return gui_adjust_rgb(rgb_table[i].color);
/*
* Last attempt. Look in the file "$VIMRUNTIME/rgb.txt".
@@ -7060,7 +7083,7 @@ gui_get_color_cmn(char_u *name)
for (i = 0; i < size; i++)
if (STRICMP(name, colornames_table[i].color_name) == 0)
return colornames_table[i].color;
return gui_adjust_rgb(colornames_table[i].color);
return INVALCOLOR;
}
@@ -7072,11 +7095,11 @@ gui_get_rgb_color_cmn(int r, int g, int b)
if (color > 0xffffff)
return INVALCOLOR;
return color;
return gui_adjust_rgb(color);
}
#endif
#if (defined(MSWIN) && !defined(FEAT_GUI_MSWIN)) || defined(FEAT_TERMINAL) \
#if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL) \
|| defined(PROTO)
static int cube_value[] = {
0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF