package main
import (
"encoding/base64"
"encoding/hex"
"fmt"
"image/color"
"strconv"
)
func printXfce(colors []color.Color) string {
output := ""
output += "ColorPalette="
for _, c := range colors {
bytes := []byte{byte(c.(color.NRGBA).R), byte(c.(color.NRGBA).R), byte(c.(color.NRGBA).G), byte(c.(color.NRGBA).G), byte(c.(color.NRGBA).B), byte(c.(color.NRGBA).B)}
output += "#"
output += hex.EncodeToString(bytes)
output += ";"
}
output += "\n"
return output
}
func printLilyTerm(colors []color.Color) string {
output := ""
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "Color"
output += strconv.Itoa(i)
output += " = "
output += "#"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}
func printTermite(colors []color.Color) string {
output := ""
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "color"
output += strconv.Itoa(i)
output += " = "
output += "#"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}
func printTerminator(colors []color.Color) string {
output := "palette = \""
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
if i < len(colors)-1 {
output += "#"
output += hex.EncodeToString(bytes)
output += ":"
} else if i == len(colors)-1 {
output += "#"
output += hex.EncodeToString(bytes)
output += "\"\n"
}
}
return output
}
func printXterm(colors []color.Color) string {
output := ""
output += "! Terminal colors"
output += "\n"
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "*color"
output += strconv.Itoa(i)
output += ": #"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}
func printKonsole(colors []color.Color) string {
output := ""
for i, c := range colors {
cc := c.(color.NRGBA)
output += "[Color"
if i > 7 {
output += strconv.Itoa(i - 8)
output += "Intense"
} else {
output += strconv.Itoa(i)
}
output += "]\n"
output += "Color="
output += strconv.Itoa(int(cc.R)) + ","
output += strconv.Itoa(int(cc.G)) + ","
output += strconv.Itoa(int(cc.B)) + "\n"
output += "Transparency=false\n\n"
}
return output
}
func printRoxTerm(colors []color.Color) string {
output := "[roxterm colour scheme]\n"
output += "pallete_size=16\n"
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "color"
output += strconv.Itoa(i)
output += " = "
output += "#"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}
func printITerm2(colors []color.Color) string {
output := "\n"
output += "\n"
output += "\n"
output += "\n"
for i, c := range colors {
cc := c.(color.NRGBA)
output += "\tAnsi "
output += strconv.Itoa(i)
output += " Color\n"
output += "\t\n"
output += "\t\tBlue Component\n"
output += "\t\t"
output += strconv.FormatFloat(float64(cc.B)/255, 'f', 17, 64)
output += "\n"
output += "\t\tGreen Component\n"
output += "\t\t"
output += strconv.FormatFloat(float64(cc.G)/255, 'f', 17, 64)
output += "\n"
output += "\t\tRed Component\n"
output += "\t\t"
output += strconv.FormatFloat(float64(cc.R)/255, 'f', 17, 64)
output += "\n"
output += "\t\n"
}
output += "\n"
output += "\n"
return output
}
func printURxvt(colors []color.Color) string {
output := ""
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "URxvt*color"
output += strconv.Itoa(i)
output += ": "
output += "#"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}
func printColors(colors []color.Color) string {
output := ""
for _, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "#"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}
func printChrome(colors []color.Color) string {
output := "{"
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += " \""
output += strconv.Itoa(i)
output += "\""
output += ": "
output += " \""
output += "#"
output += hex.EncodeToString(bytes)
output += "\" "
if i != len(colors)-1 {
output += ", "
}
}
output += "}\n"
return output
}
func printOSXTerminal(colors []color.Color) string {
// The plist that is used by OS X's Terminal to store colours. Normally,
// Terminal stores the colours in a base64 encoded binary plist but it'll
// happily read base64 encoded xml plists which makes things easier.
const OSXSerializedNSColorTemplate = `$archiverNSKeyedArchiver$objects$null$classCF$UID2NSColorSpace1NSRGB%s$classesNSColorNSObject$classnameNSColor$toprootCF$UID1$version100000`
OSXColorNames := map[int]string{
0: "Black",
1: "Red",
2: "Green",
3: "Yellow",
4: "Blue",
5: "Magenta",
6: "Cyan",
7: "White",
}
output := "\n"
output += "\n"
output += "\n"
output += "\n"
for i, c := range colors {
cc := c.(color.NRGBA)
output += "\tANSI"
if i > 7 {
output += "Bright" + OSXColorNames[i-8]
} else {
output += OSXColorNames[i]
}
output += "Color\n"
output += "\t\n"
rgbColorString := fmt.Sprintf("%.10f %.10f %.10f", float64(cc.R)/255, float64(cc.G)/255, float64(cc.B)/255)
serializedColor := fmt.Sprintf(OSXSerializedNSColorTemplate, base64.StdEncoding.EncodeToString([]byte(rgbColorString)))
output += "\t" + base64.StdEncoding.EncodeToString([]byte(serializedColor))
output += "\n\t\n"
}
output += "\ttype\n" // Need this key or Terminal says the file is corrupt
output += "\tWindow Settings\n"
output += "\n"
output += "\n"
return output
}
func printGnomeDConf(colors []color.Color) string {
output := "#!/usr/bin/env bash\npalette=\"["
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "'"
output += "#"
output += hex.EncodeToString(bytes)
output += "'"
if i < len(colors)-1 {
output += ","
}
}
output += "]\""
output += "\n"
output += "default=$(dconf read /org/gnome/terminal/legacy/profiles:/default | sed -e \"s/'//g\")"
output += "\n"
output += "dconf write /org/gnome/terminal/legacy/profiles:/:$default/palette \"$palette\""
output += "\n"
return output
}
func printKittyTerm(colors []color.Color) string {
output := ""
for i, c := range colors {
cc := c.(color.NRGBA)
bytes := []byte{byte(cc.R), byte(cc.G), byte(cc.B)}
output += "color"
output += strconv.Itoa(i)
output += "\t#"
output += hex.EncodeToString(bytes)
output += "\n"
}
return output
}