Documentation ¶
Index ¶
- Constants
- Variables
- func AnysToStrings(a any) []string
- func DeleteAllValues()
- func DeleteValueGroup(group string)
- func ExitApp(code int)
- func FullNameFor(parent, name string) string
- func FullNameForID(id string) (string, bool)
- func GetValueByFullName(fullName, group string) (any, bool)
- func GetValueByID(id, group string) (any, bool)
- func GetValueGroup(group string) (map[string]any, bool)
- func IDForFullName(fullName string) (string, bool)
- func NewApp(appid string)
- func NewWindow(title string) fyne.Window
- func PreprocessAttributesDescription(descr AttributesDescr, fullName string) bool
- func RegisterAction(name string, runFunc RunFunction) error
- func RegisterID(id string, fullName string) error
- func RegisterRunKeyword(longKW, shortKW string, runFunc RunFunction) error
- func RegisterValidKeyword(keyword, typ string, validKWMap ValidAttributesType) error
- func RunApp()
- func SplitName(fullName string) []string
- func StoreExitCode(code int32)
- func StoreValue(value any, outputKey, id, fullName, group string)
- type AttributeValidator
- type AttributeValueType
- type AttributesDescr
- type CommandsDescr
- type RunFunction
- type ValidAttributesType
- type ValidKeywordType
Constants ¶
const ( KeywordWindow = "window" KeywordAction = "action" KeywordLink = "link" )
Basic keywords:
const ( NameChoose = "choose" NameConfirm = "confirm" NameSubmit = "submit" NameCancel = "cancel" NameDismiss = "dismiss" )
Typical names of actions:
const ( AttrKeyword = ":keyword" AttrName = ":name" AttrChildren = ":children" AttrType = "type" // type is used like an ordinary attribute, but it has special semantics AttrGroup = "group" // group is allowed everywhere and used for writing JSON objects AttrID = "id" // id is allowed everywhere and used for linking and output AttrOutputKey = "outputKey" // should be enabled for all input keywords and is e.g. in JSON: "outputKey": jsonValue )
Reserved attribute names:
const WinMain = "main"
Variables ¶
var ColorRegex = regexp.MustCompile(`^#(?:[0-9a-f]{6}|[0-9a-f]{8})$`)
var LinkRegex = regexp.MustCompile(`^[\pL\pN_]+(?:[.][\pL\pN_]+)*$`)
var NameRegex = regexp.MustCompile(`^[\pL\pN_]+$`)
Functions ¶
func AnysToStrings ¶
func DeleteAllValues ¶
func DeleteAllValues()
func DeleteValueGroup ¶
func DeleteValueGroup(group string)
func FullNameFor ¶
func FullNameForID ¶
FullNameForID returns the full display name for an ID. It returns `false` if nothing was found.
func GetValueByFullName ¶
func GetValueByID ¶
func IDForFullName ¶
IDForFullName returns the registered ID for a full name path. It returns `false` if nothing was found.
func PreprocessAttributesDescription ¶
func PreprocessAttributesDescription(descr AttributesDescr, fullName string) bool
PreprocessAttributesDescription prepares an attributes description for validation and running. Specifically it:
- converts known short keywords to their long counterparts and
- registers all IDs.
`false` is returned if an error occurs.
func RegisterAction ¶
func RegisterAction(name string, runFunc RunFunction) error
RegisterAction registers an action with a name and a run function.
func RegisterID ¶
RegisterID registers an ID as a shortcut for the fullName.
func RegisterRunKeyword ¶
func RegisterRunKeyword(longKW, shortKW string, runFunc RunFunction) error
RegisterRunKeyword registers a keyword with long and (potentially) short name and run function.
func RegisterValidKeyword ¶
func RegisterValidKeyword(keyword, typ string, validKWMap ValidAttributesType) error
func StoreExitCode ¶
func StoreExitCode(code int32)
StoreExitCode stores the given code as exit code for ending the app.
func StoreValue ¶
StoreValue stores a value in the value map. The group can be used to group multiple values together (e.g. for a form). An empty group is allowed but not encouraged. The key can be either the full path name of the component storing the value or an outputKey as it should appear in the output (e.g. in JSON).
Types ¶
type AttributeValidator ¶
type AttributeValueType ¶
type AttributeValueType struct { Required bool Validate AttributeValidator }
type AttributesDescr ¶
type CommandsDescr ¶
type CommandsDescr = *omap.OrderedMap[string, AttributesDescr]
type RunFunction ¶
type RunFunction func( detailDescr AttributesDescr, fullName string, win fyne.Window, completeDescr CommandsDescr, )
func ActionRunFunc ¶
func ActionRunFunc(name string) (runFunc RunFunction, ok bool)
ActionRunFunc returns the run function for a registered action. It returns `false` if nothing was found.
func RunFuncForKeyword ¶
func RunFuncForKeyword(keyword string) (runFunc RunFunction, ok bool)
RunFuncForKeyword returns the run function for a registered keyword. It returns `false` if nothing was found.
type ValidAttributesType ¶
type ValidAttributesType struct { Attributes map[string]AttributeValueType Validate func(attrs AttributesDescr, parent string) bool }
func KeywordValidData ¶
func KeywordValidData(keyword, typ string) (ValidAttributesType, bool)
KeywordValidData returns the validation data for a registered keyword, type combination. The keyword might be the shortened variant. It returns `false` if nothing was found.