...
This commit is contained in:
parent
da38cb3254
commit
e2fda5d1c4
@ -472,7 +472,7 @@ def go_type_data(parser_func: ParserFuncType, ctype: str, is_multiple: bool = Fa
|
|||||||
if p == 'unit_float':
|
if p == 'unit_float':
|
||||||
return 'float64', 'config.UnitFloat(val, 10, 64)'
|
return 'float64', 'config.UnitFloat(val, 10, 64)'
|
||||||
if p == 'python_string':
|
if p == 'python_string':
|
||||||
return 'string', 'config.StringLiteral(val, 10, 64)'
|
return 'string', 'config.StringLiteral(val)'
|
||||||
th = get_type_hints(parser_func)
|
th = get_type_hints(parser_func)
|
||||||
rettype = th['return']
|
rettype = th['return']
|
||||||
return {int: 'int64', str: 'string', float: 'float64'}[rettype], f'{p}(val)'
|
return {int: 'int64', str: 'string', float: 'float64'}[rettype], f'{p}(val)'
|
||||||
|
|||||||
@ -157,6 +157,20 @@ func ParseColor(color string) (RGBA, error) {
|
|||||||
return RGBA{}, fmt.Errorf("Not a valid color name: %#v", color)
|
return RGBA{}, fmt.Errorf("Not a valid color name: %#v", color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NullableColor struct {
|
||||||
|
Color RGBA
|
||||||
|
IsNull bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseColorOrNone(color string) (NullableColor, error) {
|
||||||
|
raw := strings.TrimSpace(strings.ToLower(color))
|
||||||
|
if raw == "none" {
|
||||||
|
return NullableColor{IsNull: true}, nil
|
||||||
|
}
|
||||||
|
c, err := ParseColor(raw)
|
||||||
|
return NullableColor{Color: c}, err
|
||||||
|
}
|
||||||
|
|
||||||
var named_colors = map[string]uint8{
|
var named_colors = map[string]uint8{
|
||||||
"black": 0, "red": 1, "green": 2, "yellow": 3, "blue": 4, "magenta": 5, "cyan": 6, "gray": 7, "white": 7,
|
"black": 0, "red": 1, "green": 2, "yellow": 3, "blue": 4, "magenta": 5, "cyan": 6, "gray": 7, "white": 7,
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user