Mercurial > vim
diff src/gui_gtk_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 | 621e41f6dcc2 |
children | 24abce52ad20 |
line wrap: on
line diff
--- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -5606,16 +5606,34 @@ gui_mch_get_color(char_u *name) return name != NULL ? gui_get_color_cmn(name) : INVALCOLOR; #else guicolor_T color; - GdkColor gcolor; - int ret; color = (name != NULL) ? gui_get_color_cmn(name) : INVALCOLOR; if (color == INVALCOLOR) return INVALCOLOR; - gcolor.red = (guint16)(((color & 0xff0000) >> 16) / 255.0 * 65535 + 0.5); - gcolor.green = (guint16)(((color & 0xff00) >> 8) / 255.0 * 65535 + 0.5); - gcolor.blue = (guint16)((color & 0xff) / 255.0 * 65535 + 0.5); + return gui_mch_get_rgb_color( + (color & 0xff0000) >> 16, + (color & 0xff00) >> 8, + color & 0xff); +#endif +} + +/* + * 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) +{ +#if GTK_CHECK_VERSION(3,0,0) + return gui_get_rgb_color_cmn(r, g, b); +#else + GdkColor gcolor; + int ret; + + gcolor.red = (guint16)(r / 255.0 * 65535 + 0.5); + gcolor.green = (guint16)(g / 255.0 * 65535 + 0.5); + gcolor.blue = (guint16)(b / 255.0 * 65535 + 0.5); ret = gdk_colormap_alloc_color(gtk_widget_get_colormap(gui.drawarea), &gcolor, FALSE, TRUE);