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)
diff --git a/src/term.c b/src/term.c
index 5bae1f2..af7d27c 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4094,7 +4094,12 @@
#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 @@
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 @@
}
#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 @@
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 @@
((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 @@
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 @@
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