From ed70f4a236a4b21de234ab94f111212e104e8777 Mon Sep 17 00:00:00 2001 From: RGBCube Date: Fri, 18 Nov 2022 20:44:16 +0300 Subject: [PATCH] Remove redundant methods and adjust spacing --- color/color.v | 26 -------------------------- color/paintbrush.v | 1 - color/style.v | 1 + color/true_color.v | 2 +- 4 files changed, 2 insertions(+), 28 deletions(-) diff --git a/color/color.v b/color/color.v index f3a77a8..c54c8b0 100644 --- a/color/color.v +++ b/color/color.v @@ -1,29 +1,3 @@ module color pub type Color = BasicColor | TrueColor - -// I have no idea why these are needed - -fn (c Color) render(msg string) string { - return c.render(msg) -} - -fn (c Color) render_bg(msg string) string { - return c.render_bg(msg) -} - -fn (c Color) cprint(msg string) string { - return c.cprint(msg) -} - -fn (c Color) cprintln(msg string) string { - return c.cprintln(msg) -} - -fn (c Color) cprintln_bg(msg string) string { - return c.cprintln_bg(msg) -} - -fn (c Color) cprint_bg(msg string) string { - return c.cprint_bg(msg) -} diff --git a/color/paintbrush.v b/color/paintbrush.v index 3b1e65a..101e758 100644 --- a/color/paintbrush.v +++ b/color/paintbrush.v @@ -20,7 +20,6 @@ pub fn (p &PaintBrush) render(msg string) string { if bg := p.bg { result = bg.render(result) } - for style in p.styles { result = style.render(result) } diff --git a/color/style.v b/color/style.v index b2b1e02..e759e6e 100644 --- a/color/style.v +++ b/color/style.v @@ -28,6 +28,7 @@ pub fn (s Style) render(msg string) string { .hidden { term.hidden } .strikethrough { term.strikethrough } } + return func(msg) } diff --git a/color/true_color.v b/color/true_color.v index cec6af8..207697a 100644 --- a/color/true_color.v +++ b/color/true_color.v @@ -13,6 +13,7 @@ pub fn rgb(r int, g int, b int) !Color { if r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 { return error('Red, green and blue must each be between 0 and 255') } + return TrueColor{ r: r g: g @@ -24,7 +25,6 @@ pub fn hex(hex int) !Color { return rgb(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF)! } - pub fn (c TrueColor) render(msg string) string { return term.rgb(c.r, c.g, c.b, msg) }