1
Fork 0
mirror of https://github.com/RGBCube/color.v synced 2025-07-30 17:37:45 +00:00

Dont use unsupported feature

This commit is contained in:
RGBCube 2022-11-20 21:16:12 +03:00
parent dd59120f1c
commit af04d8f929
2 changed files with 8 additions and 8 deletions

View file

@ -9,23 +9,23 @@ mut:
}
[params]
pub interface BrushParams {
fg ?Color
bg ?Color
pub struct BrushParams {
fg ?Color
bg ?Color
styles []Style
}
pub fn new_brush(p BrushParams) !Brush {
mut style_counter := map[Style]int{}
mut style_counter := map[int]int{}
for style in p.styles {
if style is Color {
return error('A Color was given instead of a Style')
}
// Style is definitely not a Color
style_counter[style]++
style_counter[typeof(style).idx]++
if style_counter[style] > 1 {
if style_counter[typeof(style).idx] > 1 {
return error('Multiple of the same style was provided')
}
}

4
test.v
View file

@ -4,13 +4,13 @@ import color
fn main() {
color.red.cprintln('Hello World')
color.cyan.cprintln_bg('Hello World')
color.black.cprintln_bg('Hello World')
color.bold.cprintln('Hello World')
brush := color.new_brush(
fg: color.rgb(0, 0, 0)
bg: color.hex(0xffffff)
style: [color.bold, color.underline, color.italic]
styles: [color.bold, color.dim, color.italic]
)!
brush.cprintln('Hello World')