Skip to content

Commit e97da9f

Browse files
committed
testing
1 parent aedcdd2 commit e97da9f

File tree

4 files changed

+126
-130
lines changed

4 files changed

+126
-130
lines changed

color.odin

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@ Color :: struct {
1919
type: union {No_Color, ANSI_Color, ANSI256_Color, RGB_Color},
2020
}
2121

22-
// create a new colorful hex color
23-
// TODO: Add colorful.Color to API above?
24-
// May be confusing becase RGB_Color is a hex string internally
25-
// while a colorful.Color is abtually defined (r,g,b)
26-
// Define an RGB color with (r,g,b) too?
27-
new_hex_color :: proc(s: string) -> (color: colorful.Color) {
28-
color, _ = colorful.hex(s)
29-
return
30-
}
31-
32-
// No_Color is a nop for terminals that don't support colors.
22+
// No_Color for terminals that don't support colors.
3323
No_Color :: struct {
3424
using clr: ^Color,
3525
}
@@ -41,10 +31,6 @@ new_no_color :: proc() -> ^Color {
4131
return color
4232
}
4333

44-
no_color_string :: proc(c: No_Color) -> string {
45-
return ""
46-
}
47-
4834
// ANSI is a color (0-15) as defined by the ANSI Standard.
4935
ANSI_Color :: struct {
5036
using clr: ^Color,
@@ -58,10 +44,6 @@ new_ansi_color :: proc(c: int) -> ^Color {
5844
return color
5945
}
6046

61-
ansi_string :: proc(c: ANSI_Color) -> (str: string) {
62-
return c.color
63-
}
64-
6547
// ANSI256_Color is a color (16-255) as defined by the ANSI Standard.
6648
ANSI256_Color :: struct {
6749
using clr: ^Color,
@@ -75,10 +57,6 @@ new_ansi256_color :: proc(c: int) -> ^Color {
7557
return color
7658
}
7759

78-
ansi256_string :: proc(c: ANSI256_Color) -> (str: string) {
79-
return c.color
80-
}
81-
8260
// RGB is a hex-encoded color, e.g. "#abcdef".
8361
RGB_Color :: struct {
8462
using clr: ^Color,
@@ -92,8 +70,8 @@ new_rgb_color :: proc(c: string) -> ^Color {
9270
return color
9371
}
9472

95-
// ConvertToRGB converts a Color to a colorful.Color.
96-
convert_to_hex :: proc(c: ^Color) -> colorful.Color {
73+
// Converts a Color to an rgb colorful.Color.
74+
convert_to_rgb :: proc(c: ^Color) -> colorful.Color {
9775
hex: string
9876
switch v in c.type {
9977
case RGB_Color:
@@ -110,7 +88,7 @@ convert_to_hex :: proc(c: ^Color) -> colorful.Color {
11088
return ch
11189
}
11290

113-
// returns a hex string from a color
91+
// returns a hex string from an rgb color
11492
hex :: proc(c: colorful.Color) -> string {
11593
return colorful.color_hex(c)
11694
}
@@ -234,9 +212,9 @@ ansi256_to_ansi :: proc(c: ANSI256_Color) -> ^Color {
234212
r: int
235213
md := math.F64_MAX
236214

237-
h, _ := colorful.hex(ansi_hex[c.c])
215+
h, _ := colorful.hex(c.color)
238216
for i := 0; i <= 15; i += 1 {
239-
hb, _ := colorful.hex(ansi_hex[c.c])
217+
hb, _ := colorful.hex(ansi_hex[i])
240218
d := colorful.distance_hsluv(h, hb)
241219

242220
if d < md {

output.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ output_bg_color :: proc(o: ^Output) -> ^Color {
9898

9999
// HasDarkBackground returns whether terminal uses a dark-ish background.
100100
output_has_dark_bg :: proc(o: ^Output) -> bool {
101-
c := convert_to_hex(output_bg_color(o))
101+
c := convert_to_rgb(output_bg_color(o))
102102
_, _, l := colorful.hsl(c)
103103
return l < 0.5
104104
}

profile.odin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ profile_convert :: proc(p: Profile, c: ^Color) -> ^Color {
3636
if p == ANSI do return ansi256_to_ansi(v)
3737
return v
3838
case RGB_Color:
39-
h, err := colorful.hex(v.c)
39+
h, err := colorful.hex(v.color)
4040
if err != 0 do return nil
4141
if p != True_Color {
4242
ac := hex_to_ansi256(h)

0 commit comments

Comments
 (0)