mirror of
https://github.com/RGBCube/color.v
synced 2025-08-01 10:27:45 +00:00
Make it work (except the builder error)
This commit is contained in:
parent
b5cf7edd09
commit
30893f1c78
2 changed files with 23 additions and 5 deletions
12
color/color.v
Normal file
12
color/color.v
Normal 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)
|
||||||
|
}
|
|
@ -2,8 +2,6 @@ module color
|
||||||
|
|
||||||
import term
|
import term
|
||||||
|
|
||||||
type Color = BasicColor | TrueColor
|
|
||||||
|
|
||||||
const can_show_color = term.can_show_color_on_stdout()
|
const can_show_color = term.can_show_color_on_stdout()
|
||||||
|
|
||||||
pub struct PaintBrush {
|
pub struct PaintBrush {
|
||||||
|
@ -21,11 +19,19 @@ pub fn (p &PaintBrush) apply(msg string) string {
|
||||||
mut result := msg
|
mut result := msg
|
||||||
|
|
||||||
// IS NOT IMPLEMENTED YET !!!
|
// 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)
|
result = fg.apply(result)
|
||||||
}
|
}
|
||||||
if bg := p.bg {
|
bg := p.bg or { unsafe { nil } }
|
||||||
result = bg.apply(result)
|
if !isnil(fg) {
|
||||||
|
result = bg.apply_bg(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
for style in p.styles {
|
for style in p.styles {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue