Hardcode name colors so individual colors can be removed

This commit is contained in:
Tulir Asokan 2020-02-19 23:42:26 +02:00
parent 56b9f22781
commit 78f7a7aadc

View File

@ -19,23 +19,156 @@ package widget
import ( import (
"fmt" "fmt"
"hash/fnv" "hash/fnv"
"sort"
"maunium.net/go/tcell" "maunium.net/go/tcell"
) )
var colorNames []string var colorNames = []string{
"maroon",
// init initializes the colorNames array. "green",
func init() { "olive",
colorNames = make([]string, len(tcell.ColorNames)) "navy",
i := 0 "purple",
for name := range tcell.ColorNames { "teal",
colorNames[i] = name "silver",
i++ "gray",
} "red",
// In order to have consistent coloring between restarts, we need to sort the array. "lime",
sort.Sort(sort.StringSlice(colorNames)) "yellow",
"blue",
"fuchsia",
"aqua",
"white",
"aliceblue",
"antiquewhite",
"aquamarine",
"azure",
"beige",
"bisque",
"blanchedalmond",
"blueviolet",
"brown",
"burlywood",
"cadetblue",
"chartreuse",
"chocolate",
"coral",
"cornflowerblue",
"cornsilk",
"crimson",
"darkblue",
"darkcyan",
"darkgoldenrod",
"darkgray",
"darkgreen",
"darkkhaki",
"darkmagenta",
"darkolivegreen",
"darkorange",
"darkorchid",
"darkred",
"darksalmon",
"darkseagreen",
"darkslateblue",
"darkslategray",
"darkturquoise",
"darkviolet",
"deeppink",
"deepskyblue",
"dimgray",
"dodgerblue",
"firebrick",
"floralwhite",
"forestgreen",
"gainsboro",
"ghostwhite",
"gold",
"goldenrod",
"greenyellow",
"honeydew",
"hotpink",
"indianred",
"indigo",
"ivory",
"khaki",
"lavender",
"lavenderblush",
"lawngreen",
"lemonchiffon",
"lightblue",
"lightcoral",
"lightcyan",
"lightgoldenrodyellow",
"lightgray",
"lightgreen",
"lightpink",
"lightsalmon",
"lightseagreen",
"lightskyblue",
"lightslategray",
"lightsteelblue",
"lightyellow",
"limegreen",
"linen",
"mediumaquamarine",
"mediumblue",
"mediumorchid",
"mediumpurple",
"mediumseagreen",
"mediumslateblue",
"mediumspringgreen",
"mediumturquoise",
"mediumvioletred",
"midnightblue",
"mintcream",
"mistyrose",
"moccasin",
"navajowhite",
"oldlace",
"olivedrab",
"orange",
"orangered",
"orchid",
"palegoldenrod",
"palegreen",
"paleturquoise",
"palevioletred",
"papayawhip",
"peachpuff",
"peru",
"pink",
"plum",
"powderblue",
"rebeccapurple",
"rosybrown",
"royalblue",
"saddlebrown",
"salmon",
"sandybrown",
"seagreen",
"seashell",
"sienna",
"skyblue",
"slateblue",
"slategray",
"snow",
"springgreen",
"steelblue",
"tan",
"thistle",
"tomato",
"turquoise",
"violet",
"wheat",
"whitesmoke",
"yellowgreen",
"grey",
"dimgrey",
"darkgrey",
"darkslategrey",
"lightgrey",
"lightslategrey",
"slategrey",
} }
// GetHashColorName gets a color name for the given string based on its FNV-1 hash. // GetHashColorName gets a color name for the given string based on its FNV-1 hash.