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

Rename Renderable to Style

This commit is contained in:
RGBCube 2022-11-20 20:19:26 +03:00
parent 3345868729
commit 4d734f91c0
3 changed files with 18 additions and 18 deletions

View file

@ -1,19 +1,19 @@
module color module color
pub interface Renderable { pub interface Style {
render(string) string render(string) string
} }
pub fn (r Renderable) cprint(msg string) { pub fn (s Style) cprint(msg string) {
print(r.render(msg)) print(s.render(msg))
} }
pub fn (r Renderable) cprintln(msg string) { pub fn (s Style) cprintln(msg string) {
println(r.render(msg)) println(s.render(msg))
} }
pub interface Color { pub interface Color {
Renderable Style
render_bg(string) string render_bg(string) string
} }

View file

@ -21,16 +21,16 @@ pub const (
bright_cyan = Color(BasicColor.bright_cyan) bright_cyan = Color(BasicColor.bright_cyan)
bright_white = Color(BasicColor.bright_white) bright_white = Color(BasicColor.bright_white)
// Styles // Styles
reset = Renderable(Style.reset) reset = Style(BasicStyle.reset)
bold = Renderable(Style.bold) bold = Style(BasicStyle.bold)
dim = Renderable(Style.dim) dim = Style(BasicStyle.dim)
italic = Renderable(Style.italic) italic = Style(BasicStyle.italic)
underline = Renderable(Style.underline) underline = Style(BasicStyle.underline)
slow_blink = Renderable(Style.slow_blink) slow_blink = Style(BasicStyle.slow_blink)
rapid_blink = Renderable(Style.rapid_blink) rapid_blink = Style(BasicStyle.rapid_blink)
inverse = Renderable(Style.inverse) inverse = Style(BasicStyle.inverse)
hidden = Renderable(Style.hidden) hidden = Style(BasicStyle.hidden)
strikethrough = Renderable(Style.strikethrough) strikethrough = Style(BasicStyle.strikethrough)
) )
const no_color = !term.can_show_color_on_stdout() const no_color = !term.can_show_color_on_stdout()

View file

@ -2,7 +2,7 @@ module color
import term import term
enum Style { enum BasicStyle {
reset reset
bold bold
dim dim
@ -15,7 +15,7 @@ enum Style {
strikethrough strikethrough
} }
pub fn (s Style) render(msg string) string { pub fn (s BasicStyle) render(msg string) string {
return if no_color { return if no_color {
msg msg
} else { } else {