summaryrefslogtreecommitdiff
path: root/src/gui_gtk_x11.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-23 16:45:10 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-23 16:45:10 +0200
commit26af85d97ba1ed0ade6cdd41890ca04ed879b9c7 (patch)
treec34204de31a63785f2801279402fee3fc84ee9b2 /src/gui_gtk_x11.c
parenteeac67788677a9ea81bcab69f81b4fc22c2adc00 (diff)
downloadvim-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_gtk_x11.c')
-rw-r--r--src/gui_gtk_x11.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 5837c0b17..480b8d3b8 100644
--- 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);