1
Fork 0
mirror of https://github.com/RGBCube/color.v synced 2025-07-30 17:37:45 +00:00
This commit is contained in:
RGBCube 2022-12-01 12:36:28 +03:00
parent e821cb4f5c
commit d4b9c8e406
3 changed files with 13 additions and 3 deletions

View file

@ -4,15 +4,18 @@ import term
// Interface
// Color is a Style extension that also supports rendering in the background.
pub interface Color {
Style
render_bg(string) string
}
// print_bg prints the given string with the color in the background.
pub fn (c Color) print_bg(msg string) {
print(c.render_bg(msg))
}
// println_bg prints the given string with the color in the background with an added newline.
pub fn (c Color) println_bg(msg string) {
println(c.render_bg(msg))
}

View file

@ -2,6 +2,7 @@ module color
// Interface
// Brush is the complex Style type that can hold multiple colors and styles.
pub interface Brush {
Style
mut:
@ -12,16 +13,19 @@ mut:
[params]
pub struct BrushParams {
fg ?Color
bg ?Color
styles []Style
fg ?Color
bg ?Color
styles []Style
disabled bool
}
// new_brush creates a new Brush with the given parameters.
pub fn new_brush(p BrushParams) !Brush {
return BrushImpl{
fg: p.fg
bg: p.bg
styles: p.styles
disabled: disabled
}
}

View file

@ -4,14 +4,17 @@ import term
// Interface
// Style is an interface for a style.
pub interface Style {
render(string) string
}
// print prints the given string with the given style.
pub fn (s Style) print(msg string) {
print(s.render(msg))
}
// println prints the given string with the given style with an added newline.
pub fn (s Style) println(msg string) {
println(s.render(msg))
}