1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/style/color.go

40 lines
630 B
Go
Raw Normal View History

2021-07-31 04:54:28 +02:00
package style
import "github.com/gookit/color"
type Color struct {
rgb *color.RGBColor
basic *color.Color
}
func NewRGBColor(cl color.RGBColor) Color {
c := Color{}
c.rgb = &cl
return c
}
func NewBasicColor(cl color.Color) Color {
c := Color{}
c.basic = &cl
return c
}
2021-07-31 07:34:45 +02:00
func (c Color) IsRGB() bool {
2021-07-31 04:54:28 +02:00
return c.rgb != nil
}
2021-07-31 20:48:40 +02:00
func (c Color) ToRGB(isBg bool) Color {
2021-07-31 04:54:28 +02:00
if c.IsRGB() {
2021-07-31 07:34:45 +02:00
return c
2021-07-31 04:54:28 +02:00
}
2021-07-31 20:48:40 +02:00
if isBg {
// We need to convert bg color to fg color
// This is a gookit/color bug,
// https://github.com/gookit/color/issues/39
return NewRGBColor((*c.basic - 10).RGB())
}
2021-07-31 07:34:45 +02:00
return NewRGBColor(c.basic.RGB())
2021-07-31 04:54:28 +02:00
}