forked from mbk-lab/rui_orig
Added Name and Args function to SizeFunc interface
This commit is contained in:
parent
ed03368f5d
commit
ed4d2b6ffa
14
sizeFunc.go
14
sizeFunc.go
|
@ -11,6 +11,10 @@ import (
|
||||||
// "min", "max", "clamp", "sum", "sub", "mul", and "div" functions are available.
|
// "min", "max", "clamp", "sum", "sub", "mul", and "div" functions are available.
|
||||||
type SizeFunc interface {
|
type SizeFunc interface {
|
||||||
fmt.Stringer
|
fmt.Stringer
|
||||||
|
// Name() returns the function name: "min", "max", "clamp", "sum", "sub", "mul", or "div"
|
||||||
|
Name() string
|
||||||
|
// Args() returns a list of function arguments
|
||||||
|
Args() []any
|
||||||
cssString(session Session) string
|
cssString(session Session) string
|
||||||
writeCSS(topFunc string, buffer *strings.Builder, session Session)
|
writeCSS(topFunc string, buffer *strings.Builder, session Session)
|
||||||
writeString(topFunc string, buffer *strings.Builder)
|
writeString(topFunc string, buffer *strings.Builder)
|
||||||
|
@ -159,6 +163,16 @@ func (data *sizeFuncData) String() string {
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (data *sizeFuncData) Name() string {
|
||||||
|
return data.tag
|
||||||
|
}
|
||||||
|
|
||||||
|
func (data *sizeFuncData) Args() []any {
|
||||||
|
args := make([]any, len(data.args))
|
||||||
|
copy(args, data.args)
|
||||||
|
return args
|
||||||
|
}
|
||||||
|
|
||||||
func (data *sizeFuncData) writeString(topFunc string, buffer *strings.Builder) {
|
func (data *sizeFuncData) writeString(topFunc string, buffer *strings.Builder) {
|
||||||
buffer.WriteString(data.tag)
|
buffer.WriteString(data.tag)
|
||||||
buffer.WriteRune('(')
|
buffer.WriteRune('(')
|
||||||
|
|
|
@ -582,7 +582,8 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s
|
||||||
} else {
|
} else {
|
||||||
for _, ch := range text {
|
for _, ch := range text {
|
||||||
if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
|
if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
|
||||||
ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' {
|
ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' ||
|
||||||
|
ch == '#' || ch == '%' || ch == 'π' || ch == '°' {
|
||||||
} else {
|
} else {
|
||||||
simple = false
|
simple = false
|
||||||
break
|
break
|
||||||
|
@ -667,7 +668,7 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s
|
||||||
value.writeString(buffer, indent+"\t")
|
value.writeString(buffer, indent+"\t")
|
||||||
|
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
buffer.WriteString(value.String())
|
writeString(value.String())
|
||||||
|
|
||||||
case []ViewShadow:
|
case []ViewShadow:
|
||||||
switch len(value) {
|
switch len(value) {
|
||||||
|
|
Loading…
Reference in New Issue