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
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{})
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 NewValue ¶
NewValue creates a new Value from val.
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.
func (*Value) Render ¶
Render v's Current value. The returned byte slice must neither be modified nor kept longer then up to the next call of Render.
Source Files
¶
- doc.go
- render.go
- state.go
- value.go
- walk.go