mirror of
https://github.com/RGBCube/color.v
synced 2025-07-30 17:37:45 +00:00
Add docs
This commit is contained in:
parent
e821cb4f5c
commit
d4b9c8e406
3 changed files with 13 additions and 3 deletions
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue