panel

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseItem

type BaseItem struct {
	// base item should be a frame with settings for
	//  - the header dropdown
	//  - parent/widget
	//  - save/load
	*tview.Frame
	// contains filtered or unexported fields
}

BaseItem can be used as a starting point for your custom PanelItems. It wraps a Widget in some metadata and a tview.Frame

func NewBaseItem

func NewBaseItem(parent *Panel) *BaseItem

func (*BaseItem) Decode

func (I *BaseItem) Decode(map[string]any) (widget.Widget, error)

dummy

func (*BaseItem) Encode

func (I *BaseItem) Encode() (ItemContext, error)

func (*BaseItem) Handle

func (I *BaseItem) Handle(context map[string]any) (handled bool, err error)

this is how you can pass data built up in top-level pages, commands, and keybindings and then modify or rebuild the component locally, you decide how to refresh

func (*BaseItem) Id

func (I *BaseItem) Id() string

func (*BaseItem) Name

func (I *BaseItem) Name() string

func (*BaseItem) Parent

func (I *BaseItem) Parent() *Panel

func (*BaseItem) Rebuild

func (I *BaseItem) Rebuild() error

should rebuild the item from the current or latest context

func (*BaseItem) SetName

func (I *BaseItem) SetName(name string)

func (*BaseItem) SetParent

func (I *BaseItem) SetParent(parent *Panel)

func (*BaseItem) SetWidget

func (I *BaseItem) SetWidget(w widget.Widget)

func (*BaseItem) Widget

func (I *BaseItem) Widget() widget.Widget

type Factory

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

I hope this doesn't trigger you :] It is a default helper for creating interesting CUE widgets and quick actions for them note, you should always add a "default" key, as this is used in panel when CRUD'n items/nested panels

func NewFactory

func NewFactory() *Factory

func (*Factory) Creator

func (F *Factory) Creator(context ItemContext, parent *Panel) (PanelItem, error)

func (*Factory) Register

func (F *Factory) Register(itemKey string, creator ItemCreator)

type ItemContext

type ItemContext map[string]any

the context format is determined by the user of Panel you will need to construct this from user input and then process it in items Panel will handle moving it to the right Item, or use the ItemCreator to make a new one

type ItemCreator

type ItemCreator func(context ItemContext, parent *Panel) (PanelItem, error)

This is a function that builds a new PanelItem from an ItemContext

type Panel

type Panel struct {
	*tview.Flex
	// contains filtered or unexported fields
}

func New

func New(parent *Panel, creator ItemCreator) *Panel

func PanelDecodeMap

func PanelDecodeMap(input map[string]any, parent *Panel, creator ItemCreator) (*Panel, error)

func (*Panel) Decode

func (I *Panel) Decode(map[string]any) (widget.Widget, error)

dummy

func (*Panel) Encode

func (P *Panel) Encode() (map[string]any, error)

func (*Panel) FlipFlexDirection

func (P *Panel) FlipFlexDirection()

func (*Panel) Focus

func (P *Panel) Focus(delegate func(p tview.Primitive))

func (*Panel) GetItemById

func (P *Panel) GetItemById(id string) tview.Primitive

func (*Panel) GetItemByName

func (P *Panel) GetItemByName(name string) tview.Primitive

func (*Panel) GetMostFocusedPanel

func (P *Panel) GetMostFocusedPanel() *Panel

func (*Panel) GetMostFocusedParent

func (P *Panel) GetMostFocusedParent() *Panel

func (*Panel) GetParent

func (P *Panel) GetParent() *Panel

func (*Panel) Id

func (P *Panel) Id() string

func (*Panel) Mount

func (P *Panel) Mount(context map[string]any) error

func (*Panel) Name

func (P *Panel) Name() string

func (*Panel) RangeItems

func (P *Panel) RangeItems(fn func(PanelItem))

func (*Panel) Refresh

func (P *Panel) Refresh(context map[string]any) error

func (*Panel) SetDirection

func (P *Panel) SetDirection(d int)

func (*Panel) SetName

func (P *Panel) SetName(name string)

func (*Panel) SetParent

func (P *Panel) SetParent(parent *Panel)

func (*Panel) SetShowBordersR

func (P *Panel) SetShowBordersR(showPanel, showOther bool)

func (*Panel) TitleString

func (P *Panel) TitleString() string

func (*Panel) TypeName

func (P *Panel) TypeName() string

func (*Panel) Unmount

func (P *Panel) Unmount() error

type PanelItem

type PanelItem interface {
	tview.Primitive

	// some functions we need to add to primitive
	SetBorder(show bool) *tview.Box
	SetTitle(title string) *tview.Box

	// some metadata
	Name() string
	SetName(string)

	Parent() *Panel
	SetParent(*Panel)

	Widget() widget.Widget
	SetWidget(widget.Widget)

	// this is how you can pass data built up in top-level pages, commands, and keybindings
	// and then modify or rebuild the component locally, you decide how to refresh
	Handle(context map[string]any) (handled bool, err error)

	// should rebuild the item from the current or latest context
	Rebuild() error

	// Encode should turn the PanelItem into ItemContext.
	// It should contain enough detail to rebuild the item
	// after serialization to JSON and back.
	Encode() (ItemContext, error)
}

func ItemDecodeMap

func ItemDecodeMap(data map[string]any, parent *Panel, creator ItemCreator) (PanelItem, error)

Jump to

Keyboard shortcuts

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