block

package
v0.0.0-...-56ca850 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatementInput = "input_statement"
	ValueInput     = "input_value"
	DummyInput     = "input_dummy"

	AngleField    = "field_angle"
	CheckboxField = "field_checkbox"
	ColourField   = "field_colour"
	DateField     = "field_date"
	DropdownField = "field_dropdown"
	ImageField    = "field_image"
	LabelField    = "field_label"
	NumberField   = "field_number" //options['value'], options['min'], options['max'], options['precision']
	TextField     = "field_input"  // text input options['spellcheck”],
	VariableField = "field_variable"

	NextStatement     = "NextStatement"
	PreviousStatement = "PreviousStatement"
)

Variables

This section is empty.

Functions

func Merge

func Merge(dst, src Dict, key string, defaultValue interface{})

add key to this from dict or the defaultValue if it doesnt exist

func Scope

func Scope(str ...string) string

helper to separate pieces of ids see Blockly.utils.genUid.soup_ for characters blockly uses

func VisitStack

func VisitStack(in Input, cb func(b Shape) (keepGoing bool)) (exhausted bool)

iterate over all blocks stacked in this input returns true if the callback function doesnt exit early

Types

type Args

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

Args - accumulate the inputs and fields of blocks.

func NewArgs

func NewArgs(msg string, list ...Dict) Args

func (*Args) AddArg

func (args *Args) AddArg(desc Dict)

func (*Args) List

func (args *Args) List() []Dict

func (*Args) Message

func (args *Args) Message() string

type Connection

type Connection interface {
	SourceBlock() Shape
	TargetBlock() Shape
	TargetConnection() Connection
	IsConnected() bool
	Connect(Connection)
	Disconnect()
}

type Dict

type Dict map[string]interface{}

func (Dict) Lookup

func (d Dict) Lookup(key string) (ret string, okay bool)

type Flag

type Flag int
const (
	Deletable Flag = iota
	Movable
	Shadow
	InsertionMaker
	Editable
	Collapsed
	Enabled      // blockly uses isEnabled, setDisabled
	InputsInline // getInputsInline, setInputsInline
)

func (Flag) String

func (i Flag) String() string

type Flags

type Flags interface {
	GetFlag(Flag) bool
	SetFlag(Flag, bool)
}

type Input

type Input interface {
	InputName() string
	InputType() string
	SetInvisible()
	Connection() Connection
}

type Inputs

type Inputs interface {
	NumInputs() int
	Input(int) Input
	InputByName(string) (Input, int)
	RemoveInput(string)
	SetInput(int, Input)
	Interpolate(msg string, args []Dict)
}

input access

type Limits

type Limits struct {
	Types    []string
	Connects bool
}

lists types permitted to linking statements or terms becomes the "check" field in blockly block and item descriptions.

func MakeLimits

func MakeLimits(types []string) Limits

list of type names allowed for a connection

func MakeOffLimits

func MakeOffLimits() Limits

returns emtpy array

func MakeUnlimited

func MakeUnlimited() Limits

func (*Limits) Check

func (l *Limits) Check() (ret interface{})

return the types in a blockly friendly format: a nil pointer, a string, or an array of strings.

func (*Limits) IsUnlimited

func (l *Limits) IsUnlimited() bool

type Mutator

type Mutator interface {
	// list of block names to appear in the mui palette
	Quarks() []string
	// callback after a block instance containing a mutator has been created
	PostMixin(main Shape) error
	//
	MutationToDom(main Shape) (dom string, err error)
	DomToMutation(main Shape, dom string) error
	Decompose(main Shape, popup Workspace) (mui Shape, err error)
	Compose(main, mui Shape) error
	SaveConnections(main, mui Shape) error
}

type OnDelete

type OnDelete interface {
	OnDelete(workspaceId, blockId string)
}

type Option

type Option struct{}

for use with golang descriptions; to provide block options ex. Msg block.Option `msg:"The description of %1 is"` ex. Colour block.Option `colour:"160"`

type Project

type Project interface {
	IsBlockRegistered(blockType string) bool
	RegisterBlock(blockType string, desc Dict) error
	RegisterMutator(name string, mutator Mutator) error
	GenerateUniqueName() string
}

type Shape

type Shape interface {
	// unique only within the workspace
	BlockId() string
	BlockType() string

	// indicates if the block has been disposed ( deleted by the user. )
	HasWorkspace() bool
	BlockWorkspace() Workspace
	InitSvg() // wish this happened on demand
	Dispose()

	// note: blockly puts all "fields" ( editable and non-editable items ) inside of inputs.
	Inputs
	Flags

	// for statement blocks, the following block in a stack of blocks
	PreviousConnection() Connection
	NextConnection() Connection
}

an instance of a block

type Workspace

type Workspace interface {
	WorkspaceId() string
	NewBlock(blockType string) (Shape, error)
	NewBlockWithId(blockId, blockType string) (Shape, error)
	OnDelete(OnDelete)
}

Jump to

Keyboard shortcuts

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