ui

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeywordWindow = "window"
	KeywordAction = "action"
	KeywordLink   = "link"
)

Basic keywords:

View Source
const (
	NameChoose  = "choose"
	NameConfirm = "confirm"
	NameSubmit  = "submit"
	NameCancel  = "cancel"
	NameDismiss = "dismiss"
)

Typical names of actions:

View Source
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:

View Source
const WinMain = "main"

Variables

View Source
var ColorRegex = regexp.MustCompile(`^#(?:[0-9a-f]{6}|[0-9a-f]{8})$`)
View Source
var LinkRegex = regexp.MustCompile(`^[\pL\pN_]+(?:[.][\pL\pN_]+)*$`)
View Source
var NameRegex = regexp.MustCompile(`^[\pL\pN_]+$`)

Functions

func AnysToStrings

func AnysToStrings(a any) []string

func DeleteAllValues

func DeleteAllValues()

func DeleteValueGroup

func DeleteValueGroup(group string)

func ExitApp

func ExitApp(code int)

func FullNameFor

func FullNameFor(parent, name string) string

func FullNameForID

func FullNameForID(id string) (string, bool)

FullNameForID returns the full display name for an ID. It returns `false` if nothing was found.

func GetValueByFullName

func GetValueByFullName(fullName, group string) (any, bool)

func GetValueByID

func GetValueByID(id, group string) (any, bool)

func GetValueGroup

func GetValueGroup(group string) (map[string]any, bool)

func IDForFullName

func IDForFullName(fullName string) (string, bool)

IDForFullName returns the registered ID for a full name path. It returns `false` if nothing was found.

func NewApp

func NewApp(appid string)

func NewWindow

func NewWindow(title string) fyne.Window

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

func RegisterID(id string, fullName string) error

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 RunApp

func RunApp()

func SplitName

func SplitName(fullName string) []string

func StoreExitCode

func StoreExitCode(code int32)

StoreExitCode stores the given code as exit code for ending the app.

func StoreValue

func StoreValue(value any, outputKey, id, fullName, group string)

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 AttributeValidator func(v any, strict bool, parent string) (any, bool)

type AttributeValueType

type AttributeValueType struct {
	Required bool
	Validate AttributeValidator
}

type AttributesDescr

type AttributesDescr map[string]any

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.

type ValidKeywordType

type ValidKeywordType struct {
	Keyword string
	Type    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL