named_colors.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* named_colors.c - Named color values. */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2008 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <grub/types.h>
  20. #include <grub/gui.h>
  21. #include <grub/gui_string_util.h>
  22. #include <grub/misc.h>
  23. struct named_color
  24. {
  25. const char *name;
  26. grub_gui_color_t color;
  27. };
  28. /*
  29. Named color list generated from the list of SVG color keywords from
  30. <http://www.w3.org/TR/css3-color/#svg-color>,
  31. processed through the following Perl command:
  32. perl -ne 'chomp;split;print "{ \"$_[0]\", RGB_COLOR($_[2]) },\n"'
  33. */
  34. #define RGB_COLOR(r,g,b) {.red = r, .green = g, .blue = b, .alpha = 255}
  35. static struct named_color named_colors[] =
  36. {
  37. { "aliceblue", RGB_COLOR(240,248,255) },
  38. { "antiquewhite", RGB_COLOR(250,235,215) },
  39. { "aqua", RGB_COLOR(0,255,255) },
  40. { "aquamarine", RGB_COLOR(127,255,212) },
  41. { "azure", RGB_COLOR(240,255,255) },
  42. { "beige", RGB_COLOR(245,245,220) },
  43. { "bisque", RGB_COLOR(255,228,196) },
  44. { "black", RGB_COLOR(0,0,0) },
  45. { "blanchedalmond", RGB_COLOR(255,235,205) },
  46. { "blue", RGB_COLOR(0,0,255) },
  47. { "blueviolet", RGB_COLOR(138,43,226) },
  48. { "brown", RGB_COLOR(165,42,42) },
  49. { "burlywood", RGB_COLOR(222,184,135) },
  50. { "cadetblue", RGB_COLOR(95,158,160) },
  51. { "chartreuse", RGB_COLOR(127,255,0) },
  52. { "chocolate", RGB_COLOR(210,105,30) },
  53. { "coral", RGB_COLOR(255,127,80) },
  54. { "cornflowerblue", RGB_COLOR(100,149,237) },
  55. { "cornsilk", RGB_COLOR(255,248,220) },
  56. { "crimson", RGB_COLOR(220,20,60) },
  57. { "cyan", RGB_COLOR(0,255,255) },
  58. { "darkblue", RGB_COLOR(0,0,139) },
  59. { "darkcyan", RGB_COLOR(0,139,139) },
  60. { "darkgoldenrod", RGB_COLOR(184,134,11) },
  61. { "darkgray", RGB_COLOR(169,169,169) },
  62. { "darkgreen", RGB_COLOR(0,100,0) },
  63. { "darkgrey", RGB_COLOR(169,169,169) },
  64. { "darkkhaki", RGB_COLOR(189,183,107) },
  65. { "darkmagenta", RGB_COLOR(139,0,139) },
  66. { "darkolivegreen", RGB_COLOR(85,107,47) },
  67. { "darkorange", RGB_COLOR(255,140,0) },
  68. { "darkorchid", RGB_COLOR(153,50,204) },
  69. { "darkred", RGB_COLOR(139,0,0) },
  70. { "darksalmon", RGB_COLOR(233,150,122) },
  71. { "darkseagreen", RGB_COLOR(143,188,143) },
  72. { "darkslateblue", RGB_COLOR(72,61,139) },
  73. { "darkslategray", RGB_COLOR(47,79,79) },
  74. { "darkslategrey", RGB_COLOR(47,79,79) },
  75. { "darkturquoise", RGB_COLOR(0,206,209) },
  76. { "darkviolet", RGB_COLOR(148,0,211) },
  77. { "deeppink", RGB_COLOR(255,20,147) },
  78. { "deepskyblue", RGB_COLOR(0,191,255) },
  79. { "dimgray", RGB_COLOR(105,105,105) },
  80. { "dimgrey", RGB_COLOR(105,105,105) },
  81. { "dodgerblue", RGB_COLOR(30,144,255) },
  82. { "firebrick", RGB_COLOR(178,34,34) },
  83. { "floralwhite", RGB_COLOR(255,250,240) },
  84. { "forestgreen", RGB_COLOR(34,139,34) },
  85. { "fuchsia", RGB_COLOR(255,0,255) },
  86. { "gainsboro", RGB_COLOR(220,220,220) },
  87. { "ghostwhite", RGB_COLOR(248,248,255) },
  88. { "gold", RGB_COLOR(255,215,0) },
  89. { "goldenrod", RGB_COLOR(218,165,32) },
  90. { "gray", RGB_COLOR(128,128,128) },
  91. { "green", RGB_COLOR(0,128,0) },
  92. { "greenyellow", RGB_COLOR(173,255,47) },
  93. { "grey", RGB_COLOR(128,128,128) },
  94. { "honeydew", RGB_COLOR(240,255,240) },
  95. { "hotpink", RGB_COLOR(255,105,180) },
  96. { "indianred", RGB_COLOR(205,92,92) },
  97. { "indigo", RGB_COLOR(75,0,130) },
  98. { "ivory", RGB_COLOR(255,255,240) },
  99. { "khaki", RGB_COLOR(240,230,140) },
  100. { "lavender", RGB_COLOR(230,230,250) },
  101. { "lavenderblush", RGB_COLOR(255,240,245) },
  102. { "lawngreen", RGB_COLOR(124,252,0) },
  103. { "lemonchiffon", RGB_COLOR(255,250,205) },
  104. { "lightblue", RGB_COLOR(173,216,230) },
  105. { "lightcoral", RGB_COLOR(240,128,128) },
  106. { "lightcyan", RGB_COLOR(224,255,255) },
  107. { "lightgoldenrodyellow", RGB_COLOR(250,250,210) },
  108. { "lightgray", RGB_COLOR(211,211,211) },
  109. { "lightgreen", RGB_COLOR(144,238,144) },
  110. { "lightgrey", RGB_COLOR(211,211,211) },
  111. { "lightpink", RGB_COLOR(255,182,193) },
  112. { "lightsalmon", RGB_COLOR(255,160,122) },
  113. { "lightseagreen", RGB_COLOR(32,178,170) },
  114. { "lightskyblue", RGB_COLOR(135,206,250) },
  115. { "lightslategray", RGB_COLOR(119,136,153) },
  116. { "lightslategrey", RGB_COLOR(119,136,153) },
  117. { "lightsteelblue", RGB_COLOR(176,196,222) },
  118. { "lightyellow", RGB_COLOR(255,255,224) },
  119. { "lime", RGB_COLOR(0,255,0) },
  120. { "limegreen", RGB_COLOR(50,205,50) },
  121. { "linen", RGB_COLOR(250,240,230) },
  122. { "magenta", RGB_COLOR(255,0,255) },
  123. { "maroon", RGB_COLOR(128,0,0) },
  124. { "mediumaquamarine", RGB_COLOR(102,205,170) },
  125. { "mediumblue", RGB_COLOR(0,0,205) },
  126. { "mediumorchid", RGB_COLOR(186,85,211) },
  127. { "mediumpurple", RGB_COLOR(147,112,219) },
  128. { "mediumseagreen", RGB_COLOR(60,179,113) },
  129. { "mediumslateblue", RGB_COLOR(123,104,238) },
  130. { "mediumspringgreen", RGB_COLOR(0,250,154) },
  131. { "mediumturquoise", RGB_COLOR(72,209,204) },
  132. { "mediumvioletred", RGB_COLOR(199,21,133) },
  133. { "midnightblue", RGB_COLOR(25,25,112) },
  134. { "mintcream", RGB_COLOR(245,255,250) },
  135. { "mistyrose", RGB_COLOR(255,228,225) },
  136. { "moccasin", RGB_COLOR(255,228,181) },
  137. { "navajowhite", RGB_COLOR(255,222,173) },
  138. { "navy", RGB_COLOR(0,0,128) },
  139. { "oldlace", RGB_COLOR(253,245,230) },
  140. { "olive", RGB_COLOR(128,128,0) },
  141. { "olivedrab", RGB_COLOR(107,142,35) },
  142. { "orange", RGB_COLOR(255,165,0) },
  143. { "orangered", RGB_COLOR(255,69,0) },
  144. { "orchid", RGB_COLOR(218,112,214) },
  145. { "palegoldenrod", RGB_COLOR(238,232,170) },
  146. { "palegreen", RGB_COLOR(152,251,152) },
  147. { "paleturquoise", RGB_COLOR(175,238,238) },
  148. { "palevioletred", RGB_COLOR(219,112,147) },
  149. { "papayawhip", RGB_COLOR(255,239,213) },
  150. { "peachpuff", RGB_COLOR(255,218,185) },
  151. { "peru", RGB_COLOR(205,133,63) },
  152. { "pink", RGB_COLOR(255,192,203) },
  153. { "plum", RGB_COLOR(221,160,221) },
  154. { "powderblue", RGB_COLOR(176,224,230) },
  155. { "purple", RGB_COLOR(128,0,128) },
  156. { "red", RGB_COLOR(255,0,0) },
  157. { "rosybrown", RGB_COLOR(188,143,143) },
  158. { "royalblue", RGB_COLOR(65,105,225) },
  159. { "saddlebrown", RGB_COLOR(139,69,19) },
  160. { "salmon", RGB_COLOR(250,128,114) },
  161. { "sandybrown", RGB_COLOR(244,164,96) },
  162. { "seagreen", RGB_COLOR(46,139,87) },
  163. { "seashell", RGB_COLOR(255,245,238) },
  164. { "sienna", RGB_COLOR(160,82,45) },
  165. { "silver", RGB_COLOR(192,192,192) },
  166. { "skyblue", RGB_COLOR(135,206,235) },
  167. { "slateblue", RGB_COLOR(106,90,205) },
  168. { "slategray", RGB_COLOR(112,128,144) },
  169. { "slategrey", RGB_COLOR(112,128,144) },
  170. { "snow", RGB_COLOR(255,250,250) },
  171. { "springgreen", RGB_COLOR(0,255,127) },
  172. { "steelblue", RGB_COLOR(70,130,180) },
  173. { "tan", RGB_COLOR(210,180,140) },
  174. { "teal", RGB_COLOR(0,128,128) },
  175. { "thistle", RGB_COLOR(216,191,216) },
  176. { "tomato", RGB_COLOR(255,99,71) },
  177. { "turquoise", RGB_COLOR(64,224,208) },
  178. { "violet", RGB_COLOR(238,130,238) },
  179. { "wheat", RGB_COLOR(245,222,179) },
  180. { "white", RGB_COLOR(255,255,255) },
  181. { "whitesmoke", RGB_COLOR(245,245,245) },
  182. { "yellow", RGB_COLOR(255,255,0) },
  183. { "yellowgreen", RGB_COLOR(154,205,50) },
  184. { 0, { 0, 0, 0, 0 } } /* Terminator. */
  185. };
  186. /* Get the color named NAME. If the color was found, returns 1 and
  187. stores the color into *COLOR. If the color was not found, returns 0 and
  188. does not modify *COLOR. */
  189. int
  190. grub_gui_get_named_color (const char *name,
  191. grub_gui_color_t *color)
  192. {
  193. int i;
  194. for (i = 0; named_colors[i].name; i++)
  195. {
  196. if (grub_strcmp (named_colors[i].name, name) == 0)
  197. {
  198. *color = named_colors[i].color;
  199. return 1;
  200. }
  201. }
  202. return 0;
  203. }