diff --git a/color/color.v b/color/color.v index 29e5ad3..a40d6c1 100644 --- a/color/color.v +++ b/color/color.v @@ -1,19 +1,19 @@ module color -pub interface Renderable { +pub interface Style { render(string) string } -pub fn (r Renderable) cprint(msg string) { - print(r.render(msg)) +pub fn (s Style) cprint(msg string) { + print(s.render(msg)) } -pub fn (r Renderable) cprintln(msg string) { - println(r.render(msg)) +pub fn (s Style) cprintln(msg string) { + println(s.render(msg)) } pub interface Color { - Renderable + Style render_bg(string) string } diff --git a/color/constants.v b/color/constants.v index ca6d31d..bd2032c 100644 --- a/color/constants.v +++ b/color/constants.v @@ -21,16 +21,16 @@ pub const ( bright_cyan = Color(BasicColor.bright_cyan) bright_white = Color(BasicColor.bright_white) // Styles - reset = Renderable(Style.reset) - bold = Renderable(Style.bold) - dim = Renderable(Style.dim) - italic = Renderable(Style.italic) - underline = Renderable(Style.underline) - slow_blink = Renderable(Style.slow_blink) - rapid_blink = Renderable(Style.rapid_blink) - inverse = Renderable(Style.inverse) - hidden = Renderable(Style.hidden) - strikethrough = Renderable(Style.strikethrough) + reset = Style(BasicStyle.reset) + bold = Style(BasicStyle.bold) + dim = Style(BasicStyle.dim) + italic = Style(BasicStyle.italic) + underline = Style(BasicStyle.underline) + slow_blink = Style(BasicStyle.slow_blink) + rapid_blink = Style(BasicStyle.rapid_blink) + inverse = Style(BasicStyle.inverse) + hidden = Style(BasicStyle.hidden) + strikethrough = Style(BasicStyle.strikethrough) ) const no_color = !term.can_show_color_on_stdout() diff --git a/color/style.v b/color/style.v index fd91403..fd7821d 100644 --- a/color/style.v +++ b/color/style.v @@ -2,7 +2,7 @@ module color import term -enum Style { +enum BasicStyle { reset bold dim @@ -15,7 +15,7 @@ enum Style { strikethrough } -pub fn (s Style) render(msg string) string { +pub fn (s BasicStyle) render(msg string) string { return if no_color { msg } else {