summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-28 19:46:49 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-28 19:46:49 +0200
commitafde13b62b8fa25dac4635d5caee8d088b937ee0 (patch)
tree6a8b58aa58e180e55b2948e5d0bfdbc3d4692a49 /src/term.c
parentab4cece6053b0bfd604e15065227b94af873608b (diff)
downloadvim-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/term.c')
-rw-r--r--src/term.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/term.c b/src/term.c
index 5bae1f2dd..af7d27c69 100644
--- a/src/term.c
+++ b/src/term.c
@@ -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