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

69 lines
987 B
Go
Raw Normal View History

2021-07-31 04:54:28 +02:00
package style
import "github.com/gookit/color"
type Decoration struct {
2023-05-21 02:45:45 +02:00
bold bool
underline bool
reverse bool
strikethrough bool
2021-07-31 04:54:28 +02:00
}
2021-07-31 20:48:40 +02:00
func (d *Decoration) SetBold() {
2021-07-31 04:54:28 +02:00
d.bold = true
}
2021-07-31 20:48:40 +02:00
func (d *Decoration) SetUnderline() {
2021-07-31 04:54:28 +02:00
d.underline = true
}
2021-07-31 20:48:40 +02:00
func (d *Decoration) SetReverse() {
2021-07-31 04:54:28 +02:00
d.reverse = true
}
2023-05-21 02:45:45 +02:00
func (d *Decoration) SetStrikethrough() {
d.strikethrough = true
}
2021-07-31 04:54:28 +02:00
func (d Decoration) ToOpts() color.Opts {
opts := make([]color.Color, 0, 3)
if d.bold {
opts = append(opts, color.OpBold)
}
if d.underline {
opts = append(opts, color.OpUnderscore)
}
if d.reverse {
opts = append(opts, color.OpReverse)
}
2023-05-21 02:45:45 +02:00
if d.strikethrough {
opts = append(opts, color.OpStrikethrough)
}
2021-07-31 04:54:28 +02:00
return opts
}
func (d Decoration) Merge(other Decoration) Decoration {
if other.bold {
d.bold = true
}
2021-07-31 07:34:45 +02:00
2021-07-31 04:54:28 +02:00
if other.underline {
d.underline = true
}
2021-07-31 07:34:45 +02:00
2021-07-31 04:54:28 +02:00
if other.reverse {
d.reverse = true
}
2023-05-21 02:45:45 +02:00
if other.strikethrough {
d.strikethrough = true
}
2021-07-31 04:54:28 +02:00
return d
}