53d46aa3 |
1 | package main |
03519b4f |
2 | |
73f250ed |
3 | import( |
4 | "fmt" |
5 | "net/http" |
6 | "os" |
7 | |
8 | "github.com/wsxiaoys/terminal/color" |
9 | ) |
10 | |
11 | /* holds our palette, or 16 ANSI colors (8 normal colors + bright complements) |
12 | and two foreground/background colors. colors are 3 byte arrays (RGB) */ |
13 | type ktPalette struct { |
14 | |
15 | black [3]byte |
16 | bblack [3]byte |
17 | |
18 | red [3]byte |
19 | bred [3]byte |
20 | |
21 | green [3]byte |
22 | bgreen [3]byte |
23 | |
24 | yellow [3]byte |
25 | byellow [3]byte |
26 | |
27 | blue [3]byte |
28 | bblue [3]byte |
29 | |
30 | purple [3]byte |
31 | bpurple [3]byte |
32 | |
33 | cyan [3]byte |
34 | bcyan [3]byte |
35 | |
36 | white [3]byte |
37 | bwhite [3]byte |
38 | |
39 | fg [3]byte |
40 | bg [3]byte |
41 | } |
42 | |
43 | /* the default "control" ANSI color set (boring) */ |
44 | var ansiColors = ktPalette { |
45 | |
46 | black : [3]byte {0,0,0}, |
47 | bblack : [3]byte {128,128,128}, |
48 | |
49 | red : [3]byte {128,0,0}, |
50 | bred : [3]byte {255,0,0}, |
51 | |
52 | green : [3]byte {0,128,0}, |
53 | bgreen : [3]byte {0,255,0}, |
54 | |
55 | yellow : [3]byte {128,128,0}, |
56 | byellow : [3]byte {255,255,0}, |
57 | |
58 | blue : [3]byte {0,0,128}, |
59 | bblue : [3]byte {0,0,255}, |
60 | |
61 | purple : [3]byte {128,0,128}, |
62 | bpurple : [3]byte {255,0,255}, |
63 | |
64 | cyan : [3]byte {0,128,128}, |
65 | bcyan : [3]byte {0,255,255}, |
66 | |
67 | white : [3]byte {128,128,128}, |
68 | bwhite : [3]byte {255,255,255}, |
69 | |
70 | fg : [3]byte {0,0,0}, |
71 | bg : [3]byte {255,255,255}, |
72 | } |
73 | |
74 | /* parses a colorfile, returns palette struct. given a nil file pointer, |
75 | returns standard ANSI color set (our "control") */ |
76 | func parseColors(colorfile *os.File) (pal ktPalette, err error) { |
77 | |
78 | return ansiColors, nil |
79 | } |
80 | |
81 | func ktInit(dirPrepend string, port int, colorfilePath string) error { |
82 | |
83 | color.Print("@yparsing colorfile :: @{|}") |
84 | file, err := os.Open(colorfilePath) |
85 | if err != nil { |
86 | color.Printf("@r[%s]@{|} - bad colorfile path\n", xM) |
87 | return fmt.Errorf("%s\n", "bad colorfile path") |
88 | } |
89 | |
90 | pal, err := parseColors(file) |
91 | fmt.Print(pal) |
92 | |
93 | if err != nil { |
94 | color.Printf("@r[%s]@{|} - malformed colorfile\n", xM) |
95 | return fmt.Errorf("%s\n", "malformed colorfile") |
96 | } |
97 | |
98 | color.Printf("@g[%s]@{|}\n", checkM) |
99 | |
100 | color.Printf("@ystarting httpd on port @b%d@{|} :: ", port) |
101 | |
102 | return nil |
103 | } |
03519b4f |
104 | |
105 | func main() { |
106 | |
73f250ed |
107 | err := ktInit("kolors", 999, "/home/kremlin/go/src/k_transpose/kremlin_colors"); |
108 | |
53d46aa3 |
109 | /* make sure to close() anything you need to (you need to) */ |
53d46aa3 |
110 | resp, err := http.Get("http://kremlin.cc") |
111 | |
112 | if err != nil {} |
113 | fmt.Println(resp) |
03519b4f |
114 | } |
73f250ed |
115 | |
116 | var checkM = "✓" |
117 | var xM = "✗" |
118 | |