1package theme23import "strings"45// HighContrast is the theme name for the high-contrast schemes: the dark6// one on a dark terminal, the light one on a light terminal, switching7// when the terminal does. HighContrastDark and HighContrastLight name8// one of them.9const (10 HighContrast = "high-contrast"11 HighContrastDark = "High Contrast Dark"12 HighContrastLight = "High Contrast Light"13)1415// The high-contrast schemes: white on black and black on white, with16// ANSI colors picked so the roles defined on them (black text on the17// pointer's cyan, the found cells' yellow, the traced cells' green) meet18// WCAG AAA before correction, and a selection in saturated blue with19// white text. FromPalette then holds every role to AAA (aaa below).20const highContrastDark = `# High Contrast Dark: WCAG AAA (7:1) text.21background = #00000022foreground = #ffffff23selection-background = #0033cc24palette = 0=#00000025palette = 1=#ff808026palette = 2=#40e04027palette = 3=#ffe04028palette = 4=#80a8ff29palette = 5=#ff80ff30palette = 6=#40e0ff31palette = 7=#e0e0e032palette = 8=#3a3a3a33palette = 9=#ffa0a034palette = 10=#80ff8035palette = 11=#ffff8036palette = 12=#a0c0ff37palette = 13=#ffa0ff38palette = 14=#a0f0ff39palette = 15=#ffffff40`4142const highContrastLight = `# High Contrast Light: WCAG AAA (7:1) text.43background = #ffffff44foreground = #00000045selection-background = #0033cc46palette = 0=#00000047palette = 1=#a0000048palette = 2=#b0f0b049palette = 3=#ffe07050palette = 4=#0033cc51palette = 5=#80008052palette = 6=#a0e8ff53palette = 7=#d0d0d054palette = 8=#6a6a6a55palette = 9=#a0000056palette = 10=#005a0057palette = 11=#6a4a0058palette = 12=#0033cc59palette = 13=#80008060palette = 14=#005a6a61palette = 15=#ffffff62`6364// highContrastPalettes are the two schemes, dark first.65func highContrastPalettes() []Palette {66 var out []Palette67 for _, s := range []struct{ name, text string }{{HighContrastDark, highContrastDark}, {HighContrastLight, highContrastLight}} {68 p, _, err := parseText(s.text)69 if err != nil {70 panic("theme: " + s.name + ": " + err.Error())71 }72 p.Name, p.HighContrast = s.name, true73 out = append(out, p)74 }75 return out76}7778// isHighContrast reports whether name is HighContrast, loosely matched79// as Lookup matches names.80func isHighContrast(name string) bool {81 return squash(strings.TrimSpace(name)) == squash(HighContrast)82}8384// highContrastFor is the high-contrast scheme for a dark or light85// terminal.86func highContrastFor(dark bool) Palette {87 ps := highContrastPalettes()88 if dark {89 return ps[0]90 }91 return ps[1]92}