1
Fork 0
mirror of https://github.com/RGBCube/color.v synced 2025-07-31 09:57:47 +00:00

Make it work (except the builder error)

This commit is contained in:
RGBCube 2022-11-18 20:01:39 +03:00
parent b5cf7edd09
commit 30893f1c78
2 changed files with 23 additions and 5 deletions

12
color/color.v Normal file
View file

@ -0,0 +1,12 @@
module color
type Color = BasicColor | TrueColor
// I have no idea why this is needed
fn (c Color) apply(msg string) string {
return c.apply(msg)
}
fn (c Color) apply_bg(msg string) string {
return c.apply_bg(msg)
}

View file

@ -2,8 +2,6 @@ module color
import term
type Color = BasicColor | TrueColor
const can_show_color = term.can_show_color_on_stdout()
pub struct PaintBrush {
@ -21,11 +19,19 @@ pub fn (p &PaintBrush) apply(msg string) string {
mut result := msg
// IS NOT IMPLEMENTED YET !!!
if fg := p.fg {
// if fg := p.fg {
// result = fg.apply(result)
// }
// if bg := p.bg {
// result = bg.apply(result)
// }
fg := p.fg or { unsafe { nil } }
if !isnil(fg) {
result = fg.apply(result)
}
if bg := p.bg {
result = bg.apply(result)
bg := p.bg or { unsafe { nil } }
if !isnil(fg) {
result = bg.apply_bg(result)
}
for style in p.styles {