From d4b9c8e406c75dfbbeed8b256d99ca41b29967bc Mon Sep 17 00:00:00 2001 From: RGBCube Date: Thu, 1 Dec 2022 12:36:28 +0300 Subject: [PATCH] Add docs --- color/color.v | 3 +++ color/paintbrush.v | 10 +++++++--- color/style.v | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/color/color.v b/color/color.v index 1746a90..9aa4daf 100644 --- a/color/color.v +++ b/color/color.v @@ -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)) } diff --git a/color/paintbrush.v b/color/paintbrush.v index f762aea..16e5900 100644 --- a/color/paintbrush.v +++ b/color/paintbrush.v @@ -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 } } diff --git a/color/style.v b/color/style.v index 4c20498..021231a 100644 --- a/color/style.v +++ b/color/style.v @@ -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)) }