golib

package module
v0.0.55 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: BSD-3-Clause Imports: 14 Imported by: 2

README

Copyright 2024 ProntoGUI, LLC. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

pgui-go

Go language module for Pronto!GUI

Generating the protobuf code

In the project folder:

make

Setting up the gRPC tools

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

Add to ~/.zshrc or ~/.zprofile

export PATH="$PATH:$(go env GOPATH)/bin"

Refer to gRPC website for latest instructions: https://grpc.io/docs/languages/go/quickstart/

Documentation

Overview

Copyright 2024 ProntoGUI, LLC. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonizeEmbodiment added in v0.0.54

func CanonizeEmbodiment(embodiment string) string

Types

type Any1DField added in v0.0.38

type Any1DField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*Any1DField) EgestValue added in v0.0.38

func (f *Any1DField) EgestValue() any

func (*Any1DField) Get added in v0.0.38

func (f *Any1DField) Get() []Primitive

func (*Any1DField) IngestValue added in v0.0.38

func (f *Any1DField) IngestValue(value any) error

func (*Any1DField) Length added in v0.0.46

func (f *Any1DField) Length() int

Convenience function that returns the length of the array.

func (*Any1DField) PrepareForUpdates added in v0.0.38

func (f *Any1DField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*Any1DField) Set added in v0.0.38

func (f *Any1DField) Set(ary []Primitive)

type Any2DField added in v0.0.38

type Any2DField struct {
	FieldBase
	// contains filtered or unexported fields
}

TODO: swap any type with primitive.Interface and update the test accordingly.

func (*Any2DField) EgestValue added in v0.0.38

func (f *Any2DField) EgestValue() any

func (*Any2DField) Get added in v0.0.38

func (f *Any2DField) Get() [][]Primitive

func (*Any2DField) IngestValue added in v0.0.38

func (f *Any2DField) IngestValue(value any) error

func (*Any2DField) Length added in v0.0.46

func (f *Any2DField) Length() int

Convenience function that returns the length of the array in rows.

func (*Any2DField) PrepareForUpdates added in v0.0.38

func (f *Any2DField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*Any2DField) Set added in v0.0.38

func (f *Any2DField) Set(ary [][]Primitive)

type AnyField added in v0.0.38

type AnyField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*AnyField) EgestValue added in v0.0.38

func (f *AnyField) EgestValue() any

func (*AnyField) Get added in v0.0.38

func (f *AnyField) Get() Primitive

func (*AnyField) IngestValue added in v0.0.38

func (f *AnyField) IngestValue(value any) error

func (*AnyField) PrepareForUpdates added in v0.0.38

func (f *AnyField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*AnyField) Set added in v0.0.38

func (f *AnyField) Set(p Primitive)

type BlobField added in v0.0.38

type BlobField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*BlobField) EgestValue added in v0.0.38

func (f *BlobField) EgestValue() any

func (*BlobField) Get added in v0.0.38

func (f *BlobField) Get() []byte

func (*BlobField) IngestValue added in v0.0.38

func (f *BlobField) IngestValue(value any) error

func (*BlobField) PrepareForUpdates added in v0.0.38

func (f *BlobField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*BlobField) Set added in v0.0.38

func (f *BlobField) Set(blob []byte)

type BooleanField added in v0.0.38

type BooleanField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*BooleanField) EgestValue added in v0.0.38

func (f *BooleanField) EgestValue() any

func (*BooleanField) Get added in v0.0.38

func (f *BooleanField) Get() bool

func (*BooleanField) IngestValue added in v0.0.38

func (f *BooleanField) IngestValue(value any) error

func (*BooleanField) PrepareForUpdates added in v0.0.38

func (f *BooleanField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*BooleanField) Set added in v0.0.38

func (f *BooleanField) Set(b bool)

type Check added in v0.0.16

type Check struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A check provides a yes/no, on/off, 1/0, kind of choice to the user. It is often represented with a check box like you would see on a form.

func NewCheck added in v0.0.40

func NewCheck(label string) *Check

Creates a new Check and assigns a label.

func (*Check) Checked added in v0.0.16

func (check *Check) Checked() bool

Returns true if the check state is Yes, On, 1, etc., and false if the check state is No, Off, 0, etc.

func (*Check) Embodiment added in v0.0.27

func (check *Check) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Check) Label added in v0.0.16

func (check *Check) Label() string

Returns the label to display in the check.

func (*Check) PrepareForUpdates added in v0.0.16

func (check *Check) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Check) SetChecked added in v0.0.16

func (check *Check) SetChecked(b bool) *Check

Sets the check state.

func (*Check) SetEmbodiment added in v0.0.27

func (check *Check) SetEmbodiment(s string) *Check

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Check) SetLabel added in v0.0.16

func (check *Check) SetLabel(s string) *Check

Sets the label to display in the check.

func (*Check) SetTag added in v0.0.41

func (check *Check) SetTag(s string) *Check

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Checks as Table cells.

func (*Check) String added in v0.0.40

func (check *Check) String() string

Returns a string representation of this primitive: the label. Implements of fmt:Stringer interface.

func (*Check) Tag added in v0.0.41

func (check *Check) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Checks as Table cells.

type CheckWith added in v0.0.17

type CheckWith struct {
	Checked    bool
	Embodiment string
	Label      string
	Tag        string
}

A check provides a yes/no, on/off, 1/0, kind of choice to the user. It is often represented with a check box like you would see on a form.

func (CheckWith) Make added in v0.0.17

func (w CheckWith) Make() *Check

Makes a new Check with specified field values.

type Choice added in v0.0.16

type Choice struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A choice is a user selection from a set of choices. It is often represented using a pull-down list.

func NewChoice added in v0.0.40

func NewChoice(choices ...string) *Choice

Creates a new Choice and assigns the initiali Choice and Choices fields.

func (*Choice) Choice added in v0.0.16

func (choice *Choice) Choice() string

Returns the selected choice or empty if none chosen.

func (*Choice) ChoiceIndex added in v0.0.49

func (choice *Choice) ChoiceIndex() int

Returns the index (0, 1, ..) of selected choice or -1 if choice is empty. This is a covenvenience function as an alternative to Choice(). The canonical storage of choice remains a string.

func (*Choice) Choices added in v0.0.16

func (choice *Choice) Choices() []string

Returns the set of valid choices to choose from.

func (*Choice) Embodiment added in v0.0.27

func (choice *Choice) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Choice) PrepareForUpdates added in v0.0.16

func (choice *Choice) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Choice) SetChoice added in v0.0.16

func (choice *Choice) SetChoice(s string) *Choice

Sets the selected choice or empty if none chosen.

func (*Choice) SetChoiceIndex added in v0.0.49

func (choice *Choice) SetChoiceIndex(index int) *Choice

Sets the selected choice or empty if none chosen or if index is out of range. This is a covenvenience function as an alternative to SetChoice(). The canonical storage of choice remains a string.

func (*Choice) SetChoices added in v0.0.16

func (choice *Choice) SetChoices(sa []string) *Choice

Sets the set of valid choices to choose from.

func (*Choice) SetChoicesVA added in v0.0.16

func (choice *Choice) SetChoicesVA(sa ...string) *Choice

Set the Choices field using variadic string arguments.

func (*Choice) SetEmbodiment added in v0.0.27

func (choice *Choice) SetEmbodiment(s string) *Choice

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Choice) SetTag added in v0.0.41

func (choice *Choice) SetTag(s string) *Choice

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Choices as Table cells.

func (*Choice) String added in v0.0.40

func (choice *Choice) String() string

Returns a string representation of this primitive: the current choice. Implements of fmt:Stringer interface.

func (*Choice) Tag added in v0.0.41

func (choice *Choice) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Choices as Table cells.

type ChoiceWith added in v0.0.17

type ChoiceWith struct {
	Choice     string
	Choices    []string
	Embodiment string
	Tag        string
}

A choice is a user selection from a set of choices. It is often represented using a pull-down list.

func (ChoiceWith) Make added in v0.0.17

func (w ChoiceWith) Make() *Choice

Makes a new Choice with specified field values.

type Command added in v0.0.10

type Command struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A command is used to handle momentary requests by the user such that, when the command is issued, the service does something useful. It is often rendered as a button with clear boundaries that suggest it can be clicked.

func NewCommand added in v0.0.40

func NewCommand(label string) *Command

Creates a new command and assigns a label.

func (*Command) Embodiment added in v0.0.27

func (cmd *Command) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Command) Enabled added in v0.0.40

func (cmd *Command) Enabled() bool

Returns the enabled status of the command. This is derived from the Status field.

func (*Command) Issued added in v0.0.10

func (cmd *Command) Issued() bool

Returns true if the command was issued during the current Wait cycle.

func (*Command) Label added in v0.0.10

func (cmd *Command) Label() string

Returns the label to display in the command.

func (*Command) PrepareForUpdates added in v0.0.10

func (cmd *Command) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Command) SetEmbodiment added in v0.0.27

func (cmd *Command) SetEmbodiment(s string) *Command

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Command) SetEnabled added in v0.0.40

func (cmd *Command) SetEnabled(enabled bool) *Command

Sets the enabled status of the command. Setting this to true will set Status to 0 (visible & enabled) and setting this to false will set Status to 1 (disabled).

func (*Command) SetLabel added in v0.0.11

func (cmd *Command) SetLabel(s string) *Command

Sets the label to display in the command.

func (*Command) SetStatus added in v0.0.11

func (cmd *Command) SetStatus(i int) *Command

Sets the status of the command: 0 = Command Normal, 1 = Command Disabled, 2 = Command Hidden.

func (*Command) SetTag added in v0.0.40

func (cmd *Command) SetTag(s string) *Command

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Commands as Table cells.

func (*Command) SetVisible added in v0.0.40

func (cmd *Command) SetVisible(visible bool) *Command

Sets the visibility of the command. Setting this to true will set Status to 0 (visible & enabled) and setting this to false will set Status to 2 (hidden).

func (*Command) Status added in v0.0.10

func (cmd *Command) Status() int

Returns the status of the command: 0 = Command Normal, 1 = Command Disabled, 2 = Command Hidden.

func (*Command) String added in v0.0.40

func (cmd *Command) String() string

Returns a string representation of this primitive: the label. Implements of fmt:Stringer interface.

func (*Command) Tag added in v0.0.40

func (cmd *Command) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Commands as Table cells.

func (*Command) Visible added in v0.0.40

func (cmd *Command) Visible() bool

Returns the visibility of the command. This is derived from the Status field.

type CommandWith added in v0.0.17

type CommandWith struct {
	Embodiment string
	Label      string
	Status     int
	Tag        string
}

A command is used to handle momentary requests by the user such that, when the command is issued, the service does something useful. It is often rendered as a button with clear boundaries that suggest it can be clicked.

func (CommandWith) Make added in v0.0.17

func (w CommandWith) Make() *Command

Makes a new Command with specified field values.

type EventField added in v0.0.42

type EventField struct {
	FieldBase

	// A function that returns a timestamp uniquely tied to the current Wait cycle.
	TimestampProvider func() time.Time
	// contains filtered or unexported fields
}

The EventField is used to capture an event condition happening on the App side. For example, when the user clicks on a Command, we need to know on the server side the moment this happens during a Wait cycle.

Unlike other field types, this field doesn't store a value per se, but tracks if a value has been injested during the current Wait cycle. This information is only valid if the Issued() method is called during the current Wait cycle. If another Wait cycle is entered and no value is injested by this field, then it will no longer report Issued() = true.

The field type solved a nagging problem when dealing with handling events on the service side, especially when Command primitivess are clicked/issued. The Command doesn't have any state that changes like a Check or TextField might have, and the information it produces is momentary in nature.

This field requires initialization after creation by setting its TimestampProvider member. The timestamp provider supplies a time value that originates from the time package and uniquely represents the current Wait cycle. A good implementation will keep a central timestamp generated from time.Now(), called at the beginning of each Wait cycle, and a central function for returning the timestamp. The central function is assigned to every EventField during construction.

We avoided creating a global timestamp in this module because in the future there could be multiple, concurrent Wait cycles going on. It is also fragile to write unit tests this way.

func (*EventField) EgestValue added in v0.0.42

func (f *EventField) EgestValue() any

func (*EventField) IngestValue added in v0.0.42

func (f *EventField) IngestValue(value any) error

func (*EventField) Issued added in v0.0.42

func (f *EventField) Issued() bool

Returns true if the event was assigned during the current Wait cycle, as determined from the timestamp provider.

func (*EventField) PrepareForUpdates added in v0.0.42

func (f *EventField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

type ExportFile added in v0.0.34

type ExportFile struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A file represents a blob of data that can be exported from the server side and stored to a file on the app side. The perspective of "export" is centered around the server software. This seems to be a little clearer than using Download/Upload terminology.

func NewExportFile added in v0.0.40

func NewExportFile() *ExportFile

Creates a new ExportFile.

func (*ExportFile) Data added in v0.0.34

func (ef *ExportFile) Data() []byte

Returns the blob of data representing the binary contents of the file. Note: this data could be empty and yet represent a valid, albeit empty, file for export.

func (*ExportFile) Embodiment added in v0.0.34

func (ef *ExportFile) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*ExportFile) Exported added in v0.0.34

func (ef *ExportFile) Exported() bool

Returns true when the file has been exported (stored to a file) by the app. This field is normally only updated by the app.

func (*ExportFile) Name added in v0.0.34

func (ef *ExportFile) Name() string

Returns the suggested file name (including its extension separated by a period) to save the file as.

func (*ExportFile) PrepareForUpdates added in v0.0.34

func (ef *ExportFile) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*ExportFile) Reset added in v0.0.49

func (ef *ExportFile) Reset()

Clears the exported data and the exported flag.

func (*ExportFile) SetData added in v0.0.34

func (ef *ExportFile) SetData(d []byte) *ExportFile

Sets the blob of data representing the binary contents of the file to export.

func (*ExportFile) SetEmbodiment added in v0.0.34

func (ef *ExportFile) SetEmbodiment(s string) *ExportFile

Sets a JSON string specifying the embodiment to use for this primitive.

func (*ExportFile) SetExported added in v0.0.34

func (ef *ExportFile) SetExported(b bool) *ExportFile

Sets whether or not the file has been exported (stored to a file) by the app. This field is normally only updated by the app.

func (*ExportFile) SetName added in v0.0.34

func (ef *ExportFile) SetName(s string) *ExportFile

Sets the suggested file name (including its extension separated by a period) to save the file as.

func (*ExportFile) SetTag added in v0.0.41

func (ef *ExportFile) SetTag(s string) *ExportFile

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using ExportFiles as Table cells.

func (*ExportFile) Tag added in v0.0.41

func (ef *ExportFile) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using ExportFiles as Table cells.

type ExportFileWith added in v0.0.34

type ExportFileWith struct {
	Data       []byte
	Embodiment string
	Name       string
	Tag        string
}

A file represents a blob of data that can be exported from the server side and stored to a file on the app side. The perspective of "export" is centered around the server software. This seems to be a little clearer than using Download/Upload terminology.

func (ExportFileWith) Make added in v0.0.34

func (w ExportFileWith) Make() *ExportFile

Makes a new Command with specified field values.

type Field added in v0.0.38

type Field interface {
	PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)
	EgestValue() any
	IngestValue(value any) error
}

type FieldBase added in v0.0.38

type FieldBase struct {
	// contains filtered or unexported fields
}

func (*FieldBase) OnSet added in v0.0.38

func (f *FieldBase) OnSet(structural bool)

func (*FieldBase) StashUpdateInfo added in v0.0.38

func (f *FieldBase) StashUpdateInfo(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction)

type FieldRef added in v0.0.11

type FieldRef struct {
	// contains filtered or unexported fields
}

type Frame added in v0.0.29

type Frame struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A frame represents a complete user interface to show on the screen. It could be the main user interface or a sub-screen in the app. It includes the ability to layout controls in a specific manner.

func NewFrame added in v0.0.40

func NewFrame(items ...Primitive) *Frame

Creates a new Frame and assigns a set of items.

func (*Frame) Embodiment added in v0.0.40

func (frame *Frame) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Frame) FrameItems added in v0.0.29

func (frame *Frame) FrameItems() []Primitive

Returns the collection of primitives that comprise the GUI frame.

func (*Frame) LocateNextDescendant added in v0.0.30

func (frame *Frame) LocateNextDescendant(locator *key.PKeyLocator) Primitive

A non-recursive method to locate descendants by PKey. This is used internally by this library and normally should not be called by users of the library.

func (*Frame) PrepareForUpdates added in v0.0.29

func (frame *Frame) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Frame) SetEmbodiment added in v0.0.40

func (frame *Frame) SetEmbodiment(s string) *Frame

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Frame) SetFrameItems added in v0.0.29

func (frame *Frame) SetFrameItems(items []Primitive) *Frame

Sets the collection of primitives that comprise the GUI frame.

func (*Frame) SetFrameItemsVA added in v0.0.29

func (frame *Frame) SetFrameItemsVA(items ...Primitive) *Frame

Sets the collection of primitives (variadic argument list) that comprise the GUI frame.

func (*Frame) SetShowing added in v0.0.33

func (frame *Frame) SetShowing(showing bool) *Frame

Sets whether the Frame is being shown on the screen.

func (*Frame) SetTag added in v0.0.41

func (frame *Frame) SetTag(s string) *Frame

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, uch as using Frames inside other containers.

func (*Frame) Showing added in v0.0.33

func (frame *Frame) Showing() bool

Returns whether the Frame is being shown on the screen.

func (*Frame) Tag added in v0.0.41

func (frame *Frame) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Frames inside other containers.

type FrameWith added in v0.0.29

type FrameWith struct {
	Embodiment string
	FrameItems []Primitive
	Showing    bool
	Tag        string
}

A frame represents a complete user interface to show on the screen. It could be the main user interface or a sub-screen in the app. It includes the ability to layout controls in a specific manner.

func (FrameWith) Make added in v0.0.29

func (w FrameWith) Make() *Frame

Creates a new Frame using the supplied field assignments.

type Group added in v0.0.16

type Group struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A group is a related set of primitives, such as a group of commands, that is static in type and quantity. If a dynamic number of primitives is desired then consider using a List primitive instead.

func NewGroup added in v0.0.40

func NewGroup(items ...Primitive) *Group

Creates a new Group and assigns items.

func (*Group) Embodiment added in v0.0.27

func (grp *Group) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Group) GroupItems added in v0.0.16

func (grp *Group) GroupItems() []Primitive

Returns the collection of primitives that make up the group.

func (*Group) LocateNextDescendant added in v0.0.27

func (grp *Group) LocateNextDescendant(locator *key.PKeyLocator) Primitive

A non-recursive method to locate descendants by PKey. This is used internally by this library and normally should not be called by users of the library.

func (*Group) PrepareForUpdates added in v0.0.16

func (grp *Group) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Group) SetEmbodiment added in v0.0.27

func (grp *Group) SetEmbodiment(s string) *Group

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Group) SetGroupItems added in v0.0.16

func (grp *Group) SetGroupItems(items []Primitive) *Group

Sets the collection of primitives that make up the group.

func (*Group) SetGroupItemsVA added in v0.0.16

func (grp *Group) SetGroupItemsVA(items ...Primitive) *Group

Sets the collection of primitives (a variadic argument list) that make up the group.

func (*Group) SetTag added in v0.0.41

func (grp *Group) SetTag(s string) *Group

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Groups inside other containers.

func (*Group) Tag added in v0.0.41

func (grp *Group) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Groups inside other containers.

type GroupWith added in v0.0.17

type GroupWith struct {
	Embodiment string
	GroupItems []Primitive
	Tag        string
}

A group is a related set of primitives, such as a group of commands, that is static in type and quantity. If a dynamic number of primitives is desired then consider using a List primitive instead.

func (GroupWith) Make added in v0.0.17

func (w GroupWith) Make() *Group

Creates a new Group using the supplied field assignments.

type Image added in v0.0.38

type Image struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

An image for displaying a graphic to display on the screen. (EXPERIMENTAL)

func NewImage added in v0.0.40

func NewImage(fromFile string) *Image

Creates a new Image from a file. (EXPERIMENTAL)

func (*Image) Embodiment added in v0.0.38

func (image *Image) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Image) Image added in v0.0.38

func (image *Image) Image() []byte

Returns the binary data for the image

func (*Image) PrepareForUpdates added in v0.0.38

func (image *Image) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Image) SetEmbodiment added in v0.0.38

func (image *Image) SetEmbodiment(s string) *Image

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Image) SetImage added in v0.0.38

func (image *Image) SetImage(data []byte) *Image

Sets the binary data for the image

func (*Image) SetTag added in v0.0.41

func (image *Image) SetTag(s string) *Image

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Commands as Table cells.

func (*Image) Tag added in v0.0.41

func (image *Image) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Commands as Table cells.

type ImageWith added in v0.0.38

type ImageWith struct {
	Embodiment string
	Image      []byte
	FromFile   string
	Tag        string
}

An image for displaying a graphic to display on the screen. (EXPERIMENTAL)

func (ImageWith) Make added in v0.0.38

func (w ImageWith) Make() *Image

Makes a new Image with specified field values.

type ImportFile added in v0.0.34

type ImportFile struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A file that represents a blob of data that can be imported from the app side and consumed on the server side.

func NewImportFile added in v0.0.40

func NewImportFile() *ImportFile

Creates a new ImportFile.

func (*ImportFile) Data added in v0.0.34

func (ifile *ImportFile) Data() []byte

Returns the blob of data for the file. Note: this data could be empty and yet represent a valid imported, albeit empty, file. Therefore, it is important to look at Imported() field to know whether data has been imported. Conversely, if the Imported() function returns false then this will return an empty array.

func (*ImportFile) Embodiment added in v0.0.34

func (ifile *ImportFile) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*ImportFile) ImportData added in v0.0.49

func (ifile *ImportFile) ImportData(d []byte) *ImportFile

Sets the blob of data for the file and sets imported flag to true.

func (*ImportFile) Imported added in v0.0.34

func (ifile *ImportFile) Imported() bool

Returns true when the file has been imported by the app side and signals to the server side that file is ready to processs. This field is normally only updated by the app.

func (*ImportFile) Name added in v0.0.34

func (ifile *ImportFile) Name() string

Returns the imported file name including its extension separated by a period.

func (*ImportFile) PrepareForUpdates added in v0.0.34

func (ifile *ImportFile) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*ImportFile) Reset added in v0.0.49

func (ifile *ImportFile) Reset()

Clears the imported data and the imported flag.

func (*ImportFile) SetEmbodiment added in v0.0.34

func (ifile *ImportFile) SetEmbodiment(s string) *ImportFile

Sets a JSON string specifying the embodiment to use for this primitive.

func (*ImportFile) SetImported added in v0.0.34

func (ifile *ImportFile) SetImported(b bool) *ImportFile

Sets whether the file has been imported by the app side and signals to the server side that file is ready to processs. This field is normally only updated by the app.

func (*ImportFile) SetName added in v0.0.34

func (ifile *ImportFile) SetName(s string) *ImportFile

Sets the imported file name including its extension separated by a period.

func (*ImportFile) SetTag added in v0.0.41

func (ifile *ImportFile) SetTag(s string) *ImportFile

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Commands as Table cells.

func (*ImportFile) SetValidExtensions added in v0.0.34

func (ifile *ImportFile) SetValidExtensions(sa []string) *ImportFile

Sets the valid extensions for importing (non-case sensitive and period separator is omitted).

func (*ImportFile) Tag added in v0.0.41

func (ifile *ImportFile) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Commands as Table cells.

func (*ImportFile) ValidExtensions added in v0.0.34

func (ifile *ImportFile) ValidExtensions() []string

Returns the valid extensions for importing (non-case sensitive and period separator is omitted).

type ImportFileWith added in v0.0.34

type ImportFileWith struct {
	Data            []byte
	Embodiment      string
	Name            string
	Tag             string
	ValidExtensions []string
}

A file that represents a blob of data that can be imported from the app side and consumed on the server side.

func (ImportFileWith) Make added in v0.0.34

func (w ImportFileWith) Make() *ImportFile

Makes a new ImportFile with specified field values.

type IntegerField added in v0.0.38

type IntegerField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*IntegerField) EgestValue added in v0.0.38

func (f *IntegerField) EgestValue() any

func (*IntegerField) Get added in v0.0.38

func (f *IntegerField) Get() int

func (*IntegerField) IngestValue added in v0.0.38

func (f *IntegerField) IngestValue(value any) error

func (*IntegerField) PrepareForUpdates added in v0.0.38

func (f *IntegerField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*IntegerField) Set added in v0.0.38

func (f *IntegerField) Set(i int)

type List added in v0.0.25

type List struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A list is a collection of primitives that have a sequential-like relationship and might be dynamic in quantity or kind.

func NewList added in v0.0.40

func NewList(items ...Primitive) *List

Creates a new List and assigns items.

func (*List) Embodiment added in v0.0.27

func (list *List) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*List) ListItems added in v0.0.25

func (list *List) ListItems() []Primitive

Returns the ttems to show in the list.

func (*List) LocateNextDescendant added in v0.0.27

func (list *List) LocateNextDescendant(locator *key.PKeyLocator) Primitive

A non-recursive method to locate descendants by PKey. This is used internally by this library and normally should not be called by users of the library.

func (*List) PrepareForUpdates added in v0.0.25

func (list *List) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*List) Selected added in v0.0.25

func (list *List) Selected() int

Returns the currently selected item or -1 for none selected.

func (*List) SelectedItem added in v0.0.51

func (list *List) SelectedItem() Primitive

SelectedItem returns the currently selected item from the list. If the selected index is within the valid range of list items, it returns the item at the selected index. If the selected index is out of range, it returns nil.

func (*List) SetEmbodiment added in v0.0.27

func (list *List) SetEmbodiment(s string) *List

Sets a JSON string specifying the embodiment to use for this primitive.

func (*List) SetListItems added in v0.0.25

func (list *List) SetListItems(items []Primitive) *List

Sets the ttems to show in the list.

func (*List) SetListItemsVA added in v0.0.25

func (list *List) SetListItemsVA(items ...Primitive) *List

Returns the ttems to show in the list (as a variadic argument list).

func (*List) SetSelected added in v0.0.25

func (list *List) SetSelected(selected int) *List

Sets the currently selected item or -1 for none selected.

func (*List) SetTag added in v0.0.41

func (list *List) SetTag(s string) *List

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Lists inside other containers.

func (*List) Tag added in v0.0.41

func (list *List) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Lists inside other containers.

type ListWith added in v0.0.25

type ListWith struct {
	Embodiment string
	ListItems  []Primitive
	Selected   int
	Tag        string
}

A list is a collection of primitives that have a sequential-like relationship and might be dynamic in quantity or kind.

func (ListWith) Make added in v0.0.25

func (w ListWith) Make() *List

Creates a new List using the supplied field assignments.

type Primitive added in v0.0.38

type Primitive interface {
	fmt.Stringer
	PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)
	LocateNextDescendant(locator *key.PKeyLocator) Primitive
	EgestUpdate(fullupdate bool, fkeys []key.FKey) map[any]any
	IngestUpdate(update map[any]any) error
}

type PrimitiveBase added in v0.0.38

type PrimitiveBase struct {
	// contains filtered or unexported fields
}

PrimitiveBase fields for primitive updates.

func (*PrimitiveBase) EgestUpdate added in v0.0.38

func (r *PrimitiveBase) EgestUpdate(fullupdate bool, fkeys []key.FKey) map[any]any

func (*PrimitiveBase) IndexOf added in v0.0.40

func (r *PrimitiveBase) IndexOf(parentLevel int) int

Returns the index of this primitive in a parent container specified by parentLevel as follows: parentLevel = 0, immediate parent container parentLevel = 1, grandparent parentLevel = 2, great grandparent And so on.

It returns -1 if parentLevel is a negative number or is invalid given the depth where the primitive belongs.

func (*PrimitiveBase) IngestUpdate added in v0.0.38

func (r *PrimitiveBase) IngestUpdate(update map[any]any) error

func (*PrimitiveBase) InternalPrepareForUpdates added in v0.0.38

func (r *PrimitiveBase) InternalPrepareForUpdates(pkey key.PKey, onset key.OnSetFunction, getFields func() []FieldRef)

func (*PrimitiveBase) LocateNextDescendant added in v0.0.38

func (r *PrimitiveBase) LocateNextDescendant(locator *key.PKeyLocator) Primitive

func (*PrimitiveBase) String added in v0.0.40

func (r *PrimitiveBase) String() string

Default implementation of fmt:Stringer interface.

type ProntoGUI added in v0.0.11

type ProntoGUI interface {
	StartServing(addr string, port int) error
	StopServing()
	SetGUI(primitives ...Primitive)
	Update() (Primitive, error)
	Wait() (Primitive, error)
}

The API for working with app-to-server communication.

func NewProntoGUI added in v0.0.11

func NewProntoGUI() ProntoGUI

Creates a new ProntoGUI instance.

type StringField added in v0.0.38

type StringField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*StringField) EgestValue added in v0.0.38

func (f *StringField) EgestValue() any

func (*StringField) Get added in v0.0.38

func (f *StringField) Get() string

func (*StringField) IngestValue added in v0.0.38

func (f *StringField) IngestValue(value any) error

func (*StringField) PrepareForUpdates added in v0.0.38

func (f *StringField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*StringField) Set added in v0.0.38

func (f *StringField) Set(s string)

type Strings1DField added in v0.0.38

type Strings1DField struct {
	FieldBase
	// contains filtered or unexported fields
}

func (*Strings1DField) EgestValue added in v0.0.38

func (f *Strings1DField) EgestValue() any

func (*Strings1DField) Get added in v0.0.38

func (f *Strings1DField) Get() []string

func (*Strings1DField) IngestValue added in v0.0.38

func (f *Strings1DField) IngestValue(value any) error

func (*Strings1DField) PrepareForUpdates added in v0.0.38

func (f *Strings1DField) PrepareForUpdates(fkey key.FKey, pkey key.PKey, fieldPKeyIndex int, onset key.OnSetFunction) (isContainer bool)

func (*Strings1DField) Set added in v0.0.38

func (f *Strings1DField) Set(sa []string)

type Synchro added in v0.0.11

type Synchro struct {
	// contains filtered or unexported fields
}

func NewSynchro added in v0.0.11

func NewSynchro() *Synchro

func (*Synchro) GetFullUpdate added in v0.0.11

func (s *Synchro) GetFullUpdate() ([]byte, error)

func (*Synchro) GetPartialUpdate added in v0.0.11

func (s *Synchro) GetPartialUpdate() ([]byte, error)

func (*Synchro) GetTopPrimitives added in v0.0.11

func (s *Synchro) GetTopPrimitives() []Primitive

func (*Synchro) IngestUpdate added in v0.0.11

func (s *Synchro) IngestUpdate(updatesCbor []byte) (updatedPrimitive Primitive, updateError error)

func (*Synchro) OnSet added in v0.0.11

func (s *Synchro) OnSet(pkey key.PKey, fkey key.FKey, structural bool)

func (*Synchro) SetTopPrimitives added in v0.0.11

func (s *Synchro) SetTopPrimitives(primitives ...Primitive)

type Table added in v0.0.35

type Table struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A table displays an array of primitives in a grid of rows and columns.

func NewTable added in v0.0.40

func NewTable(headings ...string) *Table

Creates a new Table with headings.

func (*Table) DeleteAllRows added in v0.0.50

func (table *Table) DeleteAllRows()

func (*Table) DeleteRow added in v0.0.40

func (table *Table) DeleteRow(index int) error

Deletes a row in this table at the given index. An error is returned if the index is out of range.

func (*Table) Embodiment added in v0.0.35

func (table *Table) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Table) Headings added in v0.0.35

func (table *Table) Headings() []string

Returns the headings to use for each column in the table.

func (*Table) InsertRow added in v0.0.40

func (table *Table) InsertRow(index int, row []Primitive)

Inserts a new row in this table before the index specified. If index is -1 or extends beyond the number of rows in the table then row is appended at the end of the table. The row must match the dimension and cell types of the template row

func (*Table) LocateNextDescendant added in v0.0.35

func (table *Table) LocateNextDescendant(locator *key.PKeyLocator) Primitive

A non-recursive method to locate descendants by PKey. This is used internally by this library and normally should not be called by users of the library.

func (*Table) PrepareForUpdates added in v0.0.35

func (table *Table) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Table) RowCount added in v0.0.47

func (table *Table) RowCount() int

Convenience function that returns the number of rows.

func (*Table) Rows added in v0.0.35

func (table *Table) Rows() [][]Primitive

Returns the dynamically populated 2D (rows, cols) collection of primitives that appear in the table.

func (*Table) SetEmbodiment added in v0.0.35

func (table *Table) SetEmbodiment(s string) *Table

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Table) SetHeadings added in v0.0.35

func (table *Table) SetHeadings(s []string) *Table

Sets the headings to use for each column in the table.

func (*Table) SetHeadingsVA added in v0.0.35

func (table *Table) SetHeadingsVA(items ...string) *Table

Sets the headings (as variadic arguments) to use for each column in the table.

func (*Table) SetRows added in v0.0.35

func (table *Table) SetRows(items [][]Primitive) *Table

Sets the dynamically populated 2D (rows, cols) collection of primitives that appear in the table.

func (*Table) SetStatus added in v0.0.40

func (table *Table) SetStatus(status int) *Table

Sets the status of the table: 0 = Table Normal, 1 = Table Disabled, 2 = Table Hidden.

func (*Table) SetTag added in v0.0.41

func (table *Table) SetTag(s string) *Table

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Tables inside other containers.

func (*Table) Status added in v0.0.40

func (table *Table) Status() int

Returns the status of the table: 0 = Table Normal, 1 = Table Disabled, 2 = Table Hidden.

func (*Table) Tag added in v0.0.41

func (table *Table) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Tables inside other containers.

type TableWith added in v0.0.35

type TableWith struct {
	Embodiment string
	Headings   []string
	Rows       [][]Primitive
	Status     int
	Tag        string
}

A table displays an array of primitives in a grid of rows and columns.

func (TableWith) Make added in v0.0.35

func (w TableWith) Make() *Table

Creates a new Table using the supplied field assignments.

type TestPrimitive added in v0.0.38

type TestPrimitive struct {
	// contains filtered or unexported fields
}

func (*TestPrimitive) EgestUpdate added in v0.0.38

func (tp *TestPrimitive) EgestUpdate(fullupdate bool, fkeys []key.FKey) map[any]any

func (*TestPrimitive) IngestUpdate added in v0.0.38

func (tp *TestPrimitive) IngestUpdate(update map[any]any) error

func (*TestPrimitive) IsPrepped added in v0.0.38

func (tp *TestPrimitive) IsPrepped() bool

func (*TestPrimitive) LocateNextDescendant added in v0.0.38

func (tp *TestPrimitive) LocateNextDescendant(locator *key.PKeyLocator) Primitive

func (*TestPrimitive) PrepareForUpdates added in v0.0.38

func (tp *TestPrimitive) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

func (*TestPrimitive) String added in v0.0.40

func (tp *TestPrimitive) String() string

type Text added in v0.0.15

type Text struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A text primitive displays text on the screen.

func NewText added in v0.0.40

func NewText(content string) *Text

Create a new Text and assign its content.

func (*Text) Content added in v0.0.15

func (txt *Text) Content() string

Returns the text content to display.

func (*Text) Embodiment added in v0.0.27

func (txt *Text) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Text) PrepareForUpdates added in v0.0.15

func (txt *Text) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Text) SetContent added in v0.0.15

func (txt *Text) SetContent(s string) *Text

Sets the text content to display.

func (*Text) SetEmbodiment added in v0.0.27

func (txt *Text) SetEmbodiment(s string) *Text

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Text) SetTag added in v0.0.41

func (txt *Text) SetTag(s string) *Text

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Texts as Table cells.

func (*Text) String added in v0.0.40

func (txt *Text) String() string

Returns a string representation of this primitive: the content. Implements of fmt:Stringer interface.

func (*Text) Tag added in v0.0.41

func (txt *Text) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Texts as Table cells.

type TextField added in v0.0.28

type TextField struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

An entry field that allows the user to enter text.

func NewTextField added in v0.0.40

func NewTextField(textEntry string) *TextField

Create a new TextField with initial text.

func (*TextField) Embodiment added in v0.0.28

func (txt *TextField) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*TextField) PrepareForUpdates added in v0.0.28

func (txt *TextField) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*TextField) SetEmbodiment added in v0.0.28

func (txt *TextField) SetEmbodiment(s string) *TextField

Sets a JSON string specifying the embodiment to use for this primitive.

func (*TextField) SetTag added in v0.0.41

func (txt *TextField) SetTag(s string) *TextField

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using TextFields as Table cells.

func (*TextField) SetTextEntry added in v0.0.28

func (txt *TextField) SetTextEntry(s string) *TextField

Sets the text entered by the user.

func (*TextField) String added in v0.0.40

func (txt *TextField) String() string

Returns a string representation of this primitive: the text entry. Implements of fmt:Stringer interface.

func (*TextField) Tag added in v0.0.41

func (txt *TextField) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using TextFields as Table cells.

func (*TextField) TextEntry added in v0.0.28

func (txt *TextField) TextEntry() string

Returns the text entered by the user.

type TextFieldWith added in v0.0.28

type TextFieldWith struct {
	Embodiment string
	Tag        string
	TextEntry  string
}

An entry field that allows the user to enter text.

func (TextFieldWith) Make added in v0.0.28

func (w TextFieldWith) Make() *TextField

Creates a new TextField using the supplied field assignments.

type TextWith added in v0.0.18

type TextWith struct {
	Content    string
	Embodiment string
	Tag        string
}

A text primitive displays text on the screen.

func (TextWith) Make added in v0.0.18

func (w TextWith) Make() *Text

Creates a new Text primitive using the supplief field assignments.

type Timer added in v0.0.37

type Timer struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A timer is an invisible primitive that fires an event, triggering an update to the server. This is useful for low-precision GUI updates that originate on the server side. An example is updating "live" readings from a running process on the server.

func NewTimer added in v0.0.40

func NewTimer(periodMs int) *Timer

Create a new Timer with period in milliseconds.

func (*Timer) Embodiment added in v0.0.37

func (tmr *Timer) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Timer) PeriodMs added in v0.0.37

func (tmr *Timer) PeriodMs() int

Returns the time period in milliseconds after which the timer fires an event. If the period is -1 (or any negative number) then the timer is disabled. A period of 0 will cause the timer to fire immediately after the primitive is updated.

func (*Timer) PrepareForUpdates added in v0.0.37

func (tmr *Timer) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Timer) SetEmbodiment added in v0.0.37

func (tmr *Timer) SetEmbodiment(s string) *Timer

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Timer) SetPeriodMs added in v0.0.37

func (tmr *Timer) SetPeriodMs(i int) *Timer

Sets the time period in milliseconds after which the timer fires an event. If the period is -1 (or any negative number) then the timer is disabled. A period of 0 will cause the timer to fire immediately after the primitive is updated.

func (*Timer) SetTag added in v0.0.41

func (tmr *Timer) SetTag(s string) *Timer

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Timers inside containers.

func (*Timer) Tag added in v0.0.41

func (tmr *Timer) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Timers inside containers.

type TimerWith added in v0.0.37

type TimerWith struct {
	Embodiment string
	PeriodMs   int
	Tag        string
}

A timer is an invisible primitive that fires an event, triggering an update to the server. This is useful for low-precision GUI updates that originate on the server side. An example is updating "live" readings from a running process on the server.

func (TimerWith) Make added in v0.0.37

func (w TimerWith) Make() *Timer

Makes a new Timer with specified field values.

type Tristate added in v0.0.16

type Tristate struct {
	// Mix-in the common guts for primitives
	PrimitiveBase
	// contains filtered or unexported fields
}

A choice presented to the user that give three possible states: Affirmative (Yes, On, 1, etc.), Negative (No, Off, 0, etc.), and Indeterminate.

func NewTristate added in v0.0.40

func NewTristate(label string) *Tristate

Create a new TriState and assign a label.

func (*Tristate) Embodiment added in v0.0.27

func (tri *Tristate) Embodiment() string

Returns a JSON string specifying the embodiment to use for this primitive.

func (*Tristate) Label added in v0.0.16

func (tri *Tristate) Label() string

Returns the label to display along with the tristate option.

func (*Tristate) PrepareForUpdates added in v0.0.16

func (tri *Tristate) PrepareForUpdates(pkey key.PKey, onset key.OnSetFunction)

Prepares the primitive for tracking pending updates to send to the app and for injesting updates from the app. This is used internally by this library and normally should not be called by users of the library.

func (*Tristate) SetEmbodiment added in v0.0.27

func (tri *Tristate) SetEmbodiment(s string) *Tristate

Sets a JSON string specifying the embodiment to use for this primitive.

func (*Tristate) SetLabel added in v0.0.16

func (tri *Tristate) SetLabel(s string) *Tristate

Sets the label to display along with the tristate option.

func (*Tristate) SetState added in v0.0.16

func (tri *Tristate) SetState(i int) *Tristate

Sets the state of the option (0 = Negative, 1 = Affirmative, and -1 = Indeterminate).

func (*Tristate) SetTag added in v0.0.41

func (tri *Tristate) SetTag(s string) *Tristate

Sets an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Tristates as Table cells.

func (*Tristate) State added in v0.0.16

func (tri *Tristate) State() int

Returns the state of the option (0 = Negative, 1 = Affirmative, and -1 = Indeterminate).

func (*Tristate) String added in v0.0.40

func (tri *Tristate) String() string

Returns a string representation of this primitive: the label. Implements of fmt:Stringer interface.

func (*Tristate) Tag added in v0.0.41

func (tri *Tristate) Tag() string

Returns an optional and arbitrary string to keep with this primitive. This is useful for identification later on, such as using Tristates as Table cells.

type TristateWith added in v0.0.17

type TristateWith struct {
	Embodiment string
	Label      string
	State      int
	Tag        string
}

A choice presented to the user that give three possible states: Affirmative (Yes, On, 1, etc.), Negative (No, Off, 0, etc.), and Indeterminate.

func (TristateWith) Make added in v0.0.17

func (w TristateWith) Make() *Tristate

Creates a new TriState using the supplied field assignments.

type Update added in v0.0.11

type Update struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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