allow configuration of the whole palette
This commit is contained in:
		
							parent
							
								
									a1d588981d
								
							
						
					
					
						commit
						f89df13e5a
					
				
							
								
								
									
										52
									
								
								termite.c
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								termite.c
									
									
									
									
									
								
							| @ -400,32 +400,44 @@ static void load_config(GtkWindow *window, VteTerminal *vte, | |||||||
|             vte_terminal_set_opacity(vte, (guint16)(0xffff * (1 - cfgdouble))); |             vte_terminal_set_opacity(vte, (guint16)(0xffff * (1 - cfgdouble))); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         static const long palette_size = 24; |         static const long palette_size = 255; | ||||||
|         GdkColor color, palette[palette_size]; |         GdkColor color, palette[palette_size]; | ||||||
| 
 | 
 | ||||||
|         static const char * const colors[8] = {"black", "red", "green", "yellow", |         char color_key[] = "color000"; | ||||||
|                                                "blue", "magenta", "cyan", "white"}; |  | ||||||
| 
 | 
 | ||||||
|         bool success = true; |         bool success = true; | ||||||
|         for (unsigned i = 0; success && i < 8; i++) { |         for (unsigned i = 0; success && i < palette_size; i++) { | ||||||
|             GError *error = NULL; |             snprintf(color_key, sizeof color_key, "color%u", i); | ||||||
|             gsize length; |             if (get_config_string(config, "colors", color_key, &cfgstr)) { | ||||||
|             char **triplet = g_key_file_get_string_list(config, "colors", colors[i], &length, &error); |                 if (!gdk_color_parse(cfgstr, &palette[i])) { | ||||||
|  |                     g_printerr("invalid color string: %s\n", cfgstr); | ||||||
|                     success = false; |                     success = false; | ||||||
|             if (error) { |  | ||||||
|                 g_error_free(error); |  | ||||||
|             } else if (length != 3) { |  | ||||||
|                 g_printerr("%s is not set to a triplet of color strings\n", colors[i]); |  | ||||||
|             } else if (!gdk_color_parse(triplet[0], &palette[i])) { |  | ||||||
|                 g_printerr("invalid color string: %s\n", triplet[0]); |  | ||||||
|             } else if (!gdk_color_parse(triplet[1], &palette[i+8])) { |  | ||||||
|                 g_printerr("invalid color string: %s\n", triplet[1]); |  | ||||||
|             } else if (!gdk_color_parse(triplet[2], &palette[i+16])) { |  | ||||||
|                 g_printerr("invalid color string: %s\n", triplet[2]); |  | ||||||
|             } else { |  | ||||||
|                 success = true; |  | ||||||
|                 } |                 } | ||||||
|             g_strfreev(triplet); |             } else { | ||||||
|  |                 if (i < 16) { | ||||||
|  |                     palette[i].blue = (i & 4) ? 0xc000 : 0; | ||||||
|  |                     palette[i].green = (i & 2) ? 0xc000 : 0; | ||||||
|  |                     palette[i].red = (i & 1) ? 0xc000 : 0; | ||||||
|  |                     if (i > 7) { | ||||||
|  |                         palette[i].blue += 0x3fff; | ||||||
|  |                         palette[i].green += 0x3fff; | ||||||
|  |                         palette[i].red += 0x3fff; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 else if (i < 232) { | ||||||
|  |                     unsigned j = i - 16; | ||||||
|  |                     unsigned r = j / 36, g = (j / 6) % 6, b = j % 6; | ||||||
|  |                     unsigned red =   (r == 0) ? 0 : r * 40 + 55; | ||||||
|  |                     unsigned green = (g == 0) ? 0 : g * 40 + 55; | ||||||
|  |                     unsigned blue =  (b == 0) ? 0 : b * 40 + 55; | ||||||
|  |                     palette[i].red   = red | red << 8  ; | ||||||
|  |                     palette[i].green = green | green << 8; | ||||||
|  |                     palette[i].blue  = blue | blue << 8; | ||||||
|  |                 } else if (i < 256) { | ||||||
|  |                     unsigned shade = 8 + (i - 232) * 10; | ||||||
|  |                     palette[i].red = palette[i].green = palette[i].blue = shade | shade << 8; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (success) { |         if (success) { | ||||||
|  | |||||||
							
								
								
									
										26
									
								
								termite.cfg
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								termite.cfg
									
									
									
									
									
								
							| @ -36,12 +36,20 @@ foreground_bold = #ffffff | |||||||
| background = #3f3f3f | background = #3f3f3f | ||||||
| #cursor = #dcdccc | #cursor = #dcdccc | ||||||
| 
 | 
 | ||||||
| # color = normal;bold;dim | # colors from color0 to color254 can be set | ||||||
| black = #3f3f3f;#709080;#3f3f3f | color0 = #3f3f3f | ||||||
| red = #705050;#dca3a3;#705050 | color1 = #705050 | ||||||
| green = #60b48a;#c3bf9f;#60b48a | color2 = #60b48a | ||||||
| yellow = #dfaf8f;#f0dfaf;#dfaf8f | color3 = #dfaf8f | ||||||
| blue = #506070;#94bff3;#506070 | color4 = #506070 | ||||||
| magenta = #dc8cc3;#ec93d3;#dc8cc3 | color5 = #dc8cc3 | ||||||
| cyan = #8cd0d3;#93e0e3;#8cd0d3 | color6 = #8cd0d3 | ||||||
| white = #dcdccc;#ffffff;#dcdccc | color7 = #dcdccc | ||||||
|  | color8 = #709080 | ||||||
|  | color9 = #dca3a3 | ||||||
|  | color10 = #c3bf9f | ||||||
|  | color11 = #f0dfaf | ||||||
|  | color12 = #94bff3 | ||||||
|  | color13 = #ec93d3 | ||||||
|  | color14 = #93e0e3 | ||||||
|  | color15 = #ffffff | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Micay
						Daniel Micay