mirror of
https://github.com/RGBCube/color.v
synced 2025-07-31 09:57:47 +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
|
// Interface
|
||||||
|
|
||||||
|
// Color is a Style extension that also supports rendering in the background.
|
||||||
pub interface Color {
|
pub interface Color {
|
||||||
Style
|
Style
|
||||||
render_bg(string) string
|
render_bg(string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print_bg prints the given string with the color in the background.
|
||||||
pub fn (c Color) print_bg(msg string) {
|
pub fn (c Color) print_bg(msg string) {
|
||||||
print(c.render_bg(msg))
|
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) {
|
pub fn (c Color) println_bg(msg string) {
|
||||||
println(c.render_bg(msg))
|
println(c.render_bg(msg))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ module color
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
|
// Brush is the complex Style type that can hold multiple colors and styles.
|
||||||
pub interface Brush {
|
pub interface Brush {
|
||||||
Style
|
Style
|
||||||
mut:
|
mut:
|
||||||
|
@ -12,16 +13,19 @@ mut:
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
pub struct BrushParams {
|
pub struct BrushParams {
|
||||||
fg ?Color
|
fg ?Color
|
||||||
bg ?Color
|
bg ?Color
|
||||||
styles []Style
|
styles []Style
|
||||||
|
disabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// new_brush creates a new Brush with the given parameters.
|
||||||
pub fn new_brush(p BrushParams) !Brush {
|
pub fn new_brush(p BrushParams) !Brush {
|
||||||
return BrushImpl{
|
return BrushImpl{
|
||||||
fg: p.fg
|
fg: p.fg
|
||||||
bg: p.bg
|
bg: p.bg
|
||||||
styles: p.styles
|
styles: p.styles
|
||||||
|
disabled: disabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,17 @@ import term
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
|
// Style is an interface for a style.
|
||||||
pub interface Style {
|
pub interface Style {
|
||||||
render(string) string
|
render(string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print prints the given string with the given style.
|
||||||
pub fn (s Style) print(msg string) {
|
pub fn (s Style) print(msg string) {
|
||||||
print(s.render(msg))
|
print(s.render(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// println prints the given string with the given style with an added newline.
|
||||||
pub fn (s Style) println(msg string) {
|
pub fn (s Style) println(msg string) {
|
||||||
println(s.render(msg))
|
println(s.render(msg))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue