1
Fork 0
mirror of https://github.com/RGBCube/color.v synced 2025-08-01 10:27: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] [params]
pub interface BrushParams { pub struct BrushParams {
fg ?Color fg ?Color
bg ?Color bg ?Color
styles []Style styles []Style
} }
pub fn new_brush(p BrushParams) !Brush { pub fn new_brush(p BrushParams) !Brush {
mut style_counter := map[Style]int{} mut style_counter := map[int]int{}
for style in p.styles { for style in p.styles {
if style is Color { if style is Color {
return error('A Color was given instead of a Style') return error('A Color was given instead of a Style')
} }
// Style is definitely not a Color // 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') return error('Multiple of the same style was provided')
} }
} }

4
test.v
View file

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