1
Fork 0
mirror of https://github.com/RGBCube/color.v synced 2025-07-31 09:57:47 +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
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
}

View file

@ -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()

View file

@ -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 {