1
Fork 0
mirror of https://github.com/RGBCube/color.v synced 2025-08-01 10:27:45 +00:00

Make not printing color actually work

This commit is contained in:
RGBCube 2022-11-18 21:39:14 +03:00
parent 712324f893
commit e147a4de42
3 changed files with 12 additions and 8 deletions

View file

@ -22,10 +22,6 @@ enum BasicColor {
} }
pub fn (c BasicColor) render(msg string) string { pub fn (c BasicColor) render(msg string) string {
if no_color {
return msg
}
func := match c { func := match c {
.black { term.black } .black { term.black }
.red { term.red } .red { term.red }
@ -49,10 +45,6 @@ pub fn (c BasicColor) render(msg string) string {
} }
pub fn (c BasicColor) render_bg(msg string) string { pub fn (c BasicColor) render_bg(msg string) string {
if no_color {
return msg
}
func := match c { func := match c {
.black { term.bg_black } .black { term.bg_black }
.red { term.bg_red } .red { term.bg_red }

View file

@ -3,10 +3,18 @@ module color
pub type Color = BasicColor | TrueColor pub type Color = BasicColor | TrueColor
pub fn (c Color) render(msg string) string { pub fn (c Color) render(msg string) string {
if no_color {
return msg
}
return c.render(msg) return c.render(msg)
} }
pub fn (c Color) render_bg(msg string) string { pub fn (c Color) render_bg(msg string) string {
if no_color {
return msg
}
return c.render_bg(msg) return c.render_bg(msg)
} }

View file

@ -16,6 +16,10 @@ enum Style {
} }
pub fn (s Style) render(msg string) string { pub fn (s Style) render(msg string) string {
if no_color {
return msg
}
func := match s { func := match s {
.reset { term.reset } .reset { term.reset }
.bold { term.bold } .bold { term.bold }