panel

package
v0.6.9-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: Apache-2.0 Imports: 5 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(context map[string]any, parent *Panel) *BaseItem

func (*BaseItem) Decode

func (I *BaseItem) Decode(context ItemContext, creator ItemCreator, parent *Panel) (PanelItem, error)

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 (*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) 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) Refresh

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

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) 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)

	// Decode should create a PanelItem from an ItemContext
	Decode(context ItemContext, creator ItemCreator, parent *Panel) (PanelItem, error)
}

Jump to

Keyboard shortcuts

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