From 26af85d97ba1ed0ade6cdd41890ca04ed879b9c7 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 23 Jul 2017 16:45:10 +0200 Subject: 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. --- src/gui_x11.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/gui_x11.c') diff --git a/src/gui_x11.c b/src/gui_x11.c index 2226e89547..e0b91e65cd 100644 --- 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) -- cgit v1.2.3