diff --git a/README.md b/README.md index 7993c83..42cb4e8 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ An easier way to print colored text to the terminal ```v import color -println(color.red.apply('Hello World')) -println(color.bold.apply('Hello World')) +println(color.red.color('Hello World')) +println(color.bold.color('Hello World')) ``` ## Advanced @@ -24,5 +24,5 @@ p := color.PaintBrush{ styles: [color.bold, color.underline, color.italic] } -print(p.apply('Hello World')) +print(p.color('Hello World')) ``` diff --git a/builder_error1.v b/builder_error1.v index 614e33a..cc39d8b 100644 --- a/builder_error1.v +++ b/builder_error1.v @@ -3,6 +3,6 @@ module main import color fn main() { - println(color.red.apply('Hello World')) - println(color.bold.apply('Hello World')) + println(color.red.color('Hello World')) + println(color.bold.color('Hello World')) } diff --git a/builder_error2.v b/builder_error2.v index 63b4fa1..96697e3 100644 --- a/builder_error2.v +++ b/builder_error2.v @@ -9,5 +9,5 @@ fn main() { styles: [color.bold, color.underline, color.italic] } - print(p.apply('Hello World')) + print(p.color('Hello World')) } diff --git a/color/basic_color.v b/color/basic_color.v index 43ccef8..250ea7b 100644 --- a/color/basic_color.v +++ b/color/basic_color.v @@ -40,7 +40,7 @@ enum BasicColor { bright_white } -pub fn (c BasicColor) apply(msg string) string { +pub fn (c BasicColor) color(msg string) string { func := match c { .black { term.black } .red { term.red } @@ -62,7 +62,7 @@ pub fn (c BasicColor) apply(msg string) string { return func(msg) } -pub fn (c BasicColor) apply_bg(msg string) string { +pub fn (c BasicColor) color_bg(msg string) string { func := match c { .black { term.bg_black } .red { term.bg_red } diff --git a/color/color.v b/color/color.v index de6f9ed..b5fc76c 100644 --- a/color/color.v +++ b/color/color.v @@ -3,10 +3,10 @@ module color type Color = BasicColor | TrueColor // I have no idea why this is needed -fn (c Color) apply(msg string) string { - return c.apply(msg) +fn (c Color) color(msg string) string { + return c.color(msg) } -fn (c Color) apply_bg(msg string) string { - return c.apply_bg(msg) +fn (c Color) color_bg(msg string) string { + return c.color_bg(msg) } diff --git a/color/paintbrush.v b/color/paintbrush.v index 01b7dfe..9ef29e5 100644 --- a/color/paintbrush.v +++ b/color/paintbrush.v @@ -11,7 +11,7 @@ pub: styles []Style } -pub fn (p &PaintBrush) apply(msg string) string { +pub fn (p &PaintBrush) color(msg string) string { if !color.can_show_color { return msg } @@ -19,14 +19,14 @@ pub fn (p &PaintBrush) apply(msg string) string { mut result := msg if fg := p.fg { - result = fg.apply(result) + result = fg.color(result) } if bg := p.bg { - result = bg.apply(result) + result = bg.color(result) } for style in p.styles { - result = style.apply(result) + result = style.color(result) } return result diff --git a/color/style.v b/color/style.v index 13dcdab..432d281 100644 --- a/color/style.v +++ b/color/style.v @@ -28,7 +28,7 @@ enum Style { strikethrough } -pub fn (s Style) apply(msg string) string { +pub fn (s Style) color(msg string) string { func := match s { .reset { term.reset } .bold { term.bold } diff --git a/color/true_color.v b/color/true_color.v index e0e1d19..f0749b9 100644 --- a/color/true_color.v +++ b/color/true_color.v @@ -25,10 +25,10 @@ pub: b int } -pub fn (c TrueColor) apply(msg string) string { +pub fn (c TrueColor) color(msg string) string { return term.rgb(c.r, c.g, c.b, msg) } -pub fn (c TrueColor) apply_bg(msg string) string { +pub fn (c TrueColor) color_bg(msg string) string { return term.bg_rgb(c.r, c.g, c.b, msg) }