diff src/gui_x11.c @ 11745:5a5709918a98 v8.0.0755

patch 8.0.0755: terminal window does not have colors in the GUI commit https://github.com/vim/vim/commit/26af85d97ba1ed0ade6cdd41890ca04ed879b9c7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 23 16:45:10 2017 +0200 patch 8.0.0755: terminal window does not have colors in the GUI Problem: Terminal window does not have colors in the GUI. Solution: Lookup the GUI color.
author Christian Brabandt <cb@256bit.org>
date Sun, 23 Jul 2017 17:00:04 +0200
parents d8a550329a97
children 0aa1910a3dfa
line wrap: on
line diff
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -2272,8 +2272,6 @@ gui_mch_get_color(char_u *name)
     guicolor_T  requested;
     XColor      available;
     Colormap	colormap;
-#define COLORSPECBUFSIZE 8 /* space enough to hold "#RRGGBB" */
-    char        spec[COLORSPECBUFSIZE];
 
     /* can't do this when GUI not running */
     if (!gui.in_use || name == NULL || *name == NUL)
@@ -2283,11 +2281,22 @@ gui_mch_get_color(char_u *name)
     if (requested == INVALCOLOR)
 	return INVALCOLOR;
 
-    vim_snprintf(spec, COLORSPECBUFSIZE, "#%.2x%.2x%.2x",
+    return gui_mch_get_rgb_color(
 	    (requested & 0xff0000) >> 16,
 	    (requested & 0xff00) >> 8,
 	    requested & 0xff);
-#undef COLORSPECBUFSIZE
+}
+
+/*
+ * Return the Pixel value (color) for the given RGB values.
+ * Return INVALCOLOR for error.
+ */
+    guicolor_T
+gui_mch_get_rgb_color(int r, int g, int b)
+{
+    char        spec[8]; /* space enough to hold "#RRGGBB" */
+
+    vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b);
     colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy));
     if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0
 	    && XAllocColor(gui.dpy, colormap, &available) != 0)