named

package
v0.303.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteHTMLSelect

func WriteHTMLSelect(w io.Writer, jid jid.Jid, nba *BoolArray, attrs []template.HTMLAttr) (err error)

WriteHTMLSelect writes a select tag with options from a NamedBoolArray.

Types

type Bool

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

Bool stores a named boolen value with a HTML representation.

func NewBool

func NewBool(nba *BoolArray, name string, html template.HTML, checked bool) *Bool

func (*Bool) Array

func (nb *Bool) Array() *BoolArray

func (*Bool) Checked

func (nb *Bool) Checked() (checked bool)

func (*Bool) HTML

func (nb *Bool) HTML() (h template.HTML)

func (*Bool) JawsGet

func (nb *Bool) JawsGet(*jaws.Element) (v bool)

func (*Bool) JawsGetHTML

func (nb *Bool) JawsGetHTML(*jaws.Element) (h template.HTML)

func (*Bool) JawsSet

func (nb *Bool) JawsSet(e *jaws.Element, checked bool) (err error)

func (*Bool) Name

func (nb *Bool) Name() (s string)

func (*Bool) Set

func (nb *Bool) Set(checked bool) (changed bool)

func (*Bool) String

func (nb *Bool) String() string

String returns a string representation of the NamedBool suitable for debugging.

type BoolArray

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

BoolArray stores the data required to support HTML 'select' elements and sets of HTML radio buttons. It it safe to use from multiple goroutines concurrently.

func NewBoolArray

func NewBoolArray(multi bool) *BoolArray

func (*BoolArray) Add

func (nba *BoolArray) Add(name string, text template.HTML) *BoolArray

Add adds a NamedBool with the given name and the given text. Returns itself.

Note that while it's legal to have multiple NamedBool with the same name since it's allowed in HTML, it's probably not a good idea.

func (*BoolArray) Count

func (nba *BoolArray) Count(name string) (n int)

Count returns the number of NamedBool in the set that have the given name.

func (*BoolArray) Get

func (nba *BoolArray) Get() (name string)

Get returns the name of first NamedBool in the group that has it's Checked value set to true. Returns an empty string if none are true.

In case you can have more than one selected or you need to distinguish between a blank name and the fact that none are set to true, use ReadLocked() to inspect the data directly.

func (*BoolArray) IsChecked

func (nba *BoolArray) IsChecked(name string) (state bool)

IsChecked returns true if any of the NamedBool in the set that have the given name are Checked. Returns false if the name is not found.

func (*BoolArray) JawsContains

func (nba *BoolArray) JawsContains(e *jaws.Element) (contents []jaws.UI)

func (*BoolArray) JawsGet

func (nba *BoolArray) JawsGet(e *jaws.Element) string

func (*BoolArray) JawsSet

func (nba *BoolArray) JawsSet(e *jaws.Element, name string) (err error)

func (*BoolArray) ReadLocked

func (nba *BoolArray) ReadLocked(fn func(nbl []*Bool))

ReadLocked calls the given function with the NamedBoolArray locked for reading.

func (*BoolArray) Set

func (nba *BoolArray) Set(name string, state bool) (changed bool)

Set sets the Checked state for the NamedBool(s) with the given name.

If the given name doesn't match any NamedBool(s) in single-select mode, everything will be deselected.

func (*BoolArray) String

func (nba *BoolArray) String() string

String returns a string representation of the NamedBoolArray suitable for debugging.

func (*BoolArray) WriteLocked

func (nba *BoolArray) WriteLocked(fn func(nbl []*Bool) []*Bool)

WriteLocked calls the given function with the NamedBoolArray locked for writing and replaces the internal []*NamedBool slice with the return value.

type SelectHandler

type SelectHandler interface {
	jaws.Container
	bind.Setter[string]
}

Jump to

Keyboard shortcuts

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