ZyX_I avatar ZyX_I committed 8ee8eef

Made it work with Normal group. Also modified a bunch of conditions

Comments (0)

Files changed (3)

 EXTERN int	cterm_normal_fg_color INIT(= 0);
 EXTERN int	cterm_normal_fg_bold INIT(= 0);
 EXTERN int	cterm_normal_bg_color INIT(= 0);
+#ifdef FEAT_XTERM_RGB
+EXTERN long_u	cterm_normal_fg_gui_color INIT(= INVALCOLOR);
+EXTERN long_u	cterm_normal_bg_gui_color INIT(= INVALCOLOR);
+#endif
 
 #ifdef FEAT_AUTOCMD
 EXTERN int	autocmd_busy INIT(= FALSE);	/* Is apply_autocmds() busy? */
 	{
 	    if (attr > HL_ALL)				/* special HL attr. */
 	    {
-		if (t_colors > 1)
+		if (t_colors > 1
+#ifdef FEAT_XTERM_RGB
+			|| p_guicolors
+#endif
+			)
 		    aep = syn_cterm_attr2entry(attr);
 		else
 		    aep = syn_term_attr2entry(attr);
 	    {
 		attrentry_T *aep;
 
-		if (t_colors > 1)
+		if (t_colors > 1
+#ifdef FEAT_XTERM_RGB
+			|| p_guicolors
+#endif
+			)
 		{
 		    /*
 		     * Assume that t_me restores the original colors!
 	    if (do_ME || (screen_attr & (HL_BOLD | HL_INVERSE)))
 		out_str(T_ME);
 
-	    if (t_colors > 1)
-	    {
-		/* set Normal cterm colors */
-		if (cterm_normal_fg_color != 0)
-		    term_fg_color(cterm_normal_fg_color - 1);
-		if (cterm_normal_bg_color != 0)
-		    term_bg_color(cterm_normal_bg_color - 1);
-		if (cterm_normal_fg_bold)
-		    out_str(T_MD);
+#ifdef FEAT_XTERM_RGB
+	    if (p_guicolors)
+	    {
+		if (cterm_normal_fg_gui_color != INVALCOLOR)
+		    term_fg_rgb_color(cterm_normal_fg_gui_color);
+		if (cterm_normal_bg_gui_color != INVALCOLOR)
+		    term_bg_rgb_color(cterm_normal_bg_gui_color);
+	    }
+	    else
+#endif
+	    {
+		if (t_colors > 1)
+		{
+		    /* set Normal cterm colors */
+		    if (cterm_normal_fg_color != 0)
+			term_fg_color(cterm_normal_fg_color - 1);
+		    if (cterm_normal_bg_color != 0)
+			term_bg_color(cterm_normal_bg_color - 1);
+		    if (cterm_normal_fg_bold)
+			out_str(T_MD);
+		}
 	    }
 	}
     }
     void
 reset_cterm_colors()
 {
-    if (t_colors > 1)
+    if (t_colors > 1
+#ifdef FEAT_XTERM_RGB
+	    || p_guicolors
+#endif
+	)
     {
 	/* set Normal cterm colors */
+#ifdef FEAT_XTERM_RGB
+	if (p_guicolors ?
+		(cterm_normal_fg_gui_color != INVALCOLOR
+		 || cterm_normal_bg_gui_color != INVALCOLOR):
+		(cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
+#else
 	if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
+#endif
 	{
 	    out_str(T_OP);
 	    screen_attr = -1;
 #ifdef FEAT_GUI
 	    !gui.in_use &&
 #endif
+#ifdef FEAT_XTERM_RGB
+	    !p_guicolors &&
+#endif
 			    t_colors <= 1);
     for (row = start_row; row < end_row; ++row)
     {
 #ifdef FEAT_GUI
 		|| gui.in_use
 #endif
+#ifdef FEAT_XTERM_RGB
+		|| (p_guicolors && cterm_normal_bg_gui_color != INVALCOLOR)
+#endif
 		|| cterm_normal_bg_color == 0 || *T_UT != NUL));
 }
 
 #ifdef FEAT_GUI
 					    && !gui.in_use
 #endif
+#ifdef FEAT_XTERM_RGB
+					    && !p_guicolors
+#endif
 					    );
 
     redraw_tabline = FALSE;
     cterm_normal_fg_color = 0;
     cterm_normal_fg_bold = 0;
     cterm_normal_bg_color = 0;
+# ifdef FEAT_XTERM_RGB
+    cterm_normal_fg_gui_color = INVALCOLOR;
+    cterm_normal_bg_gui_color = INVALCOLOR;
+# endif
 #endif
 }
 
 #endif
 }
 
-#if defined(FEAT_GUI) || defined(PROTO)
+#if defined(FEAT_GUI) || defined(FEAT_XTERM_RGB) || defined(PROTO)
 /*
  * Set the normal foreground and background colors according to the "Normal"
  * highlighting group.  For X11 also set "Menu", "Scrollbar", and
     void
 set_normal_colors()
 {
-    if (set_group_colors((char_u *)"Normal",
-			     &gui.norm_pixel, &gui.back_pixel,
-			     FALSE, TRUE, FALSE))
-    {
-	gui_mch_new_colors();
-	must_redraw = CLEAR;
-    }
-#ifdef FEAT_GUI_X11
-    if (set_group_colors((char_u *)"Menu",
-			 &gui.menu_fg_pixel, &gui.menu_bg_pixel,
-			 TRUE, FALSE, FALSE))
-    {
-# ifdef FEAT_MENU
-	gui_mch_new_menu_colors();
+#ifdef FEAT_GUI
+# ifdef FEAT_XTERM_RGB
+    if (gui.in_use)
 # endif
-	must_redraw = CLEAR;
-    }
-# ifdef FEAT_BEVAL
-    if (set_group_colors((char_u *)"Tooltip",
-			 &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel,
-			 FALSE, FALSE, TRUE))
-    {
-# ifdef FEAT_TOOLBAR
-	gui_mch_new_tooltip_colors();
+    {
+	if (set_group_colors((char_u *)"Normal",
+				 &gui.norm_pixel, &gui.back_pixel,
+				 FALSE, TRUE, FALSE))
+	{
+	    gui_mch_new_colors();
+	    must_redraw = CLEAR;
+	}
+# ifdef FEAT_GUI_X11
+	if (set_group_colors((char_u *)"Menu",
+			     &gui.menu_fg_pixel, &gui.menu_bg_pixel,
+			     TRUE, FALSE, FALSE))
+	{
+#  ifdef FEAT_MENU
+	    gui_mch_new_menu_colors();
+#  endif
+	    must_redraw = CLEAR;
+	}
+#  ifdef FEAT_BEVAL
+	if (set_group_colors((char_u *)"Tooltip",
+			     &gui.tooltip_fg_pixel, &gui.tooltip_bg_pixel,
+			     FALSE, FALSE, TRUE))
+	{
+#   ifdef FEAT_TOOLBAR
+	    gui_mch_new_tooltip_colors();
+#   endif
+	    must_redraw = CLEAR;
+	}
+#  endif
+	if (set_group_colors((char_u *)"Scrollbar",
+			&gui.scroll_fg_pixel, &gui.scroll_bg_pixel,
+			FALSE, FALSE, FALSE))
+	{
+	    gui_new_scrollbar_colors();
+	    must_redraw = CLEAR;
+	}
 # endif
-	must_redraw = CLEAR;
-    }
-#endif
-    if (set_group_colors((char_u *)"Scrollbar",
-		    &gui.scroll_fg_pixel, &gui.scroll_bg_pixel,
-		    FALSE, FALSE, FALSE))
-    {
-	gui_new_scrollbar_colors();
-	must_redraw = CLEAR;
-    }
-#endif
-}
-
+    }
+#endif
+#ifdef FEAT_XTERM_RGB
+# ifdef FEAT_GUI
+    else
+# endif
+    {
+	int		idx;
+
+	idx = syn_name2id((char_u *)"Normal") - 1;
+	if (idx >= 0)
+	{
+	    gui_do_one_color(idx, FALSE, FALSE);
+
+	    if (HL_TABLE()[idx].sg_gui_fg != INVALCOLOR)
+	    {
+		cterm_normal_fg_gui_color = HL_TABLE()[idx].sg_gui_fg;
+		must_redraw = CLEAR;
+	    }
+	    if (HL_TABLE()[idx].sg_gui_bg != INVALCOLOR)
+	    {
+		cterm_normal_bg_gui_color = HL_TABLE()[idx].sg_gui_bg;
+		must_redraw = CLEAR;
+	    }
+	}
+    }
+#endif
+}
+#endif
+
+#if defined(FEAT_GUI) || defined(PROTO)
 /*
  * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar".
  */
 	else
 #endif
 #ifdef FEAT_XTERM_RGB
-	    return 0xffffff;
+	    return cterm_normal_fg_gui_color;
 #endif
     if (STRICMP(name, "bg") == 0 || STRICMP(name, "background") == 0)
 #if defined(FEAT_XTERM_RGB) && defined(FEAT_GUI)
 	else
 #endif
 #ifdef FEAT_XTERM_RGB
-	    return 0x000000;
+	    return cterm_normal_bg_gui_color;
 #endif
 
     return gui_get_color(name);
     }
 #endif
 
-    if (t_colors > 1)
+    if (t_colors > 1
+#ifdef FEAT_XTERM_RGB
+	    || p_guicolors
+#endif
+	    )
     {
 	if (char_attr > HL_ALL)
 	    char_aep = syn_cterm_attr2entry(char_attr);
 	aep = syn_gui_attr2entry(attr);
     else
 #endif
-	if (t_colors > 1)
-	aep = syn_cterm_attr2entry(attr);
-    else
-	aep = syn_term_attr2entry(attr);
+	if (t_colors > 1
+#ifdef FEAT_XTERM_RGB
+		|| p_guicolors
+#endif
+		)
+	    aep = syn_cterm_attr2entry(attr);
+	else
+	    aep = syn_term_attr2entry(attr);
 
     if (aep == NULL)	    /* highlighting not set */
 	return 0;
 	attr = sgp->sg_gui_attr;
     else
 #endif
-	if (t_colors > 1)
+	if (t_colors > 1
+#ifdef FEAT_XTERM_RGB
+		|| p_guicolors
+#endif
+		)
 	    attr = sgp->sg_cterm_attr;
 	else
 	    attr = sgp->sg_term_attr;
     int	    idx;
 
     /* First get the colors from the "Normal" and "Menu" group, if set */
-# ifdef FEAT_GUI
+# if defined(FEAT_GUI) || defined(FEAT_XTERM_RGB)
 #  ifdef FEAT_XTERM_RGB
-    if (gui.in_use)
+    if (
+#   ifdef FEAT_GUI
+	    gui.in_use ||
+#   endif
+	    p_guicolors)
 #  endif
 	set_normal_colors();
 # endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.