the preset.go file
This commit is contained in:
parent
f29b1f13b1
commit
4e8ebbef04
39
preset.go
Normal file
39
preset.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// preset.go
|
||||||
|
package expr
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
// Preset variables
|
||||||
|
const (
|
||||||
|
preset_last_result = "_last"
|
||||||
|
preset_bool_shortcut = "_bool_shortcut"
|
||||||
|
)
|
||||||
|
|
||||||
|
func initDefaultVars(ctx exprContext) {
|
||||||
|
ctx.SetValue(preset_bool_shortcut, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func enable(ctx exprContext, name string) {
|
||||||
|
if strings.HasPrefix(name, "_") {
|
||||||
|
ctx.SetValue(name, true)
|
||||||
|
} else {
|
||||||
|
ctx.SetValue("_"+name, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func disable(ctx exprContext, name string) {
|
||||||
|
if strings.HasPrefix(name, "_") {
|
||||||
|
ctx.SetValue(name, false)
|
||||||
|
} else {
|
||||||
|
ctx.SetValue("_"+name, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isEnabled(ctx exprContext, name string) (status bool) {
|
||||||
|
if v, exists := ctx.GetValue(name); exists {
|
||||||
|
if b, ok := v.(bool); ok {
|
||||||
|
status = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user