diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-07-23 16:45:10 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-07-23 16:45:10 +0200 |
commit | 26af85d97ba1ed0ade6cdd41890ca04ed879b9c7 (patch) | |
tree | c34204de31a63785f2801279402fee3fc84ee9b2 /src/gui_x11.c | |
parent | eeac67788677a9ea81bcab69f81b4fc22c2adc00 (diff) | |
download | vim-git-26af85d97ba1ed0ade6cdd41890ca04ed879b9c7.tar.gz |
patch 8.0.0755: terminal window does not have colors in the GUIv8.0.0755
Problem: Terminal window does not have colors in the GUI.
Solution: Lookup the GUI color.
Diffstat (limited to 'src/gui_x11.c')
-rw-r--r-- | src/gui_x11.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/gui_x11.c b/src/gui_x11.c index 2226e8954..e0b91e65c 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) |