From e147a4de4293c892f85e529097cc3c6e8194f7da Mon Sep 17 00:00:00 2001 From: RGBCube Date: Fri, 18 Nov 2022 21:39:14 +0300 Subject: [PATCH] Make not printing color actually work --- color/basic_color.v | 8 -------- color/color.v | 8 ++++++++ color/style.v | 4 ++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/color/basic_color.v b/color/basic_color.v index f0ffe03..db4eb9d 100644 --- a/color/basic_color.v +++ b/color/basic_color.v @@ -22,10 +22,6 @@ enum BasicColor { } pub fn (c BasicColor) render(msg string) string { - if no_color { - return msg - } - func := match c { .black { term.black } .red { term.red } @@ -49,10 +45,6 @@ pub fn (c BasicColor) render(msg string) string { } pub fn (c BasicColor) render_bg(msg string) string { - if no_color { - return msg - } - func := match c { .black { term.bg_black } .red { term.bg_red } diff --git a/color/color.v b/color/color.v index a4806b5..1d5643e 100644 --- a/color/color.v +++ b/color/color.v @@ -3,10 +3,18 @@ module color pub type Color = BasicColor | TrueColor pub fn (c Color) render(msg string) string { + if no_color { + return msg + } + return c.render(msg) } pub fn (c Color) render_bg(msg string) string { + if no_color { + return msg + } + return c.render_bg(msg) } diff --git a/color/style.v b/color/style.v index e759e6e..bd31820 100644 --- a/color/style.v +++ b/color/style.v @@ -16,6 +16,10 @@ enum Style { } pub fn (s Style) render(msg string) string { + if no_color { + return msg + } + func := match s { .reset { term.reset } .bold { term.bold }