Documentation ¶
Overview ¶
Package gui provides tool for a HTML based modificator for Go values.
Package gui contains code to render an arbitrary Go value as a HTML form and update the value from the submitted form data. The generated HTML can include documentation in the form of tooltips.
Global State ¶
To render and update a Go value to/from a HTML form package gui needs information about the types like documentation of types and fields, which type satisfies which interface and which struct fields should not be rendered. This information is kept in package scoped variables which is ugly but easy:
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CSS = `` /* 1910-byte string literal not displayed */
CSS contains some minimal CSS definitions needed to render the HTML properly.
var Favicon = []byte{}/* 318 elements not displayed */
Favicon is a blue/red "ht" in 16x16 ico format.
Implements is the global lookup of what types implement a given interface
var Typedata = make(map[reflect.Type]Typeinfo)
Typedata is the global registry to look up infos for types.
Functions ¶
func RegisterImplementation ¶
func RegisterImplementation(iface interface{}, typ interface{})
RegisterImplementation records that iface is implemented by typ. To register that AbcWriter implements the Writer interface use:
RegisterImplementation((*Writer)(nil), AbcWriter{})
func RegisterType ¶
func RegisterType(typ interface{}, info Typeinfo)
RegisterType registers the given info for typ in Typedata.
Types ¶
type Fieldinfo ¶
type Fieldinfo struct { Doc string // Doc is the field documentation Multiline bool // Multiline allows multiline strings Const bool // Const values are unchangeable (display only) Only []string // Only contains the set of allowed values (pick one) Any []string // Any contains the set of allowed values (pick any) Validate *regexp.Regexp // Validate this field Omit bool // Omit this field }
Fieldinfo contains metadata to fields of structs.
type Typeinfo ¶
type Typeinfo struct { // Doc is the documentation for the type as a whole. Doc string // Fields contains field metadata indexed by field name. Field map[string]Fieldinfo }
Typeinfo contains metadata for types.
type Value ¶
type Value struct { // Current is the current value. Current interface{} // Last contains the last values Last []interface{} // Path is the path prefix applied to this value. Path string // Messages contains messages to be rendered for paths. E.g.: // Test.Request.Timeout => Message{typ:error, txt=wrong} Messages map[string][]Message // contains filtered or unexported fields }
Value contains a value to be displayed and updated through a HTML GUI.
func (*Value) BinaryData ¶
BinaryData returns the string or byte slice addressed by path.
func (*Value) PushCurrent ¶
func (v *Value) PushCurrent()
PushCurrent stores the Current value in v to the list of Last values. This allows to checkpoint the state of v for subsequent undoes to one of the Pushed states.
type ValueError ¶
ValueError is an error from invalid form input, e.g. "foo" to an time.Duration field.
func (ValueError) Error ¶
func (ve ValueError) Error() string