Documentation ¶
Overview ¶
Package list provides a widget displaying a vertical list of widgets with one in focus and support for previous and next.
Index ¶
- Variables
- func CalculateOnScreen(w IListFns, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) (int, int, int, error)
- func Render(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas
- func SubWidgetSize(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize
- type IBoundedWalker
- type IBoundedWalkerPosition
- type IListFns
- type IWalker
- type IWalkerEnd
- type IWalkerHome
- type IWalkerPosition
- type IWidget
- type IndexedWidget
- type ListPos
- type Options
- type SimpleListWalker
- func (w *SimpleListWalker) At(pos IWalkerPosition) gowid.IWidget
- func (w *SimpleListWalker) First() IWalkerPosition
- func (w *SimpleListWalker) Focus() IWalkerPosition
- func (w *SimpleListWalker) Last() IWalkerPosition
- func (w *SimpleListWalker) Length() int
- func (w *SimpleListWalker) Next(ipos IWalkerPosition) IWalkerPosition
- func (w *SimpleListWalker) Previous(ipos IWalkerPosition) IWalkerPosition
- func (w *SimpleListWalker) SetFocus(focus IWalkerPosition, app gowid.IApp)
- type SubRenders
- type WalkerIndex
- type Widget
- func (w *Widget) AtBottom() bool
- func (w *Widget) AtTop() bool
- func (w *Widget) CalculateOnScreen(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) (int, int, int, error)
- func (w *Widget) GoToBottom(app gowid.IApp)
- func (w *Widget) GoToMiddle(app gowid.IApp)
- func (w *Widget) GoToTop(app gowid.IApp)
- func (w *Widget) InMiddle() bool
- func (w *Widget) MoveToNextFocus(subRenderSize gowid.IRenderSize, focus gowid.Selector, screenLines int, ...) (bool, IWalkerPosition)
- func (w *Widget) MoveToPreviousFocus(subRenderSize gowid.IRenderSize, focus gowid.Selector, screenLines int, ...) (bool, IWalkerPosition)
- func (w *Widget) Render(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.ICanvas
- func (w *Widget) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox
- func (w *Widget) RenderSubwidgets(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) (top []SubRenders, middle SubRenders, bottom []SubRenders)
- func (w *Widget) SelectChild(f gowid.Selector) bool
- func (w *Widget) SetState(st interface{}, app gowid.IApp)
- func (w *Widget) SetWalker(l IWalker, app gowid.IApp)
- func (w *Widget) State() interface{}
- func (w *Widget) String() string
- func (w *Widget) SubWidgetSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize
- func (w *Widget) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool
- func (w *Widget) Walker() IWalker
- type WidgetIsUnboundedError
Constants ¶
This section is empty.
Variables ¶
var BadState = fmt.Errorf("Broken state in list widget")
Functions ¶
func CalculateOnScreen ¶
func SubWidgetSize ¶
func SubWidgetSize(w IWidget, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize
Types ¶
type IBoundedWalker ¶
IBoundedWalker is implemented by an IWalker type that knows the maximum length of its underlying data set. It must return IBoundedWalkerPosition rather than only IWalkerPosition.
type IBoundedWalkerPosition ¶
type IBoundedWalkerPosition interface { IWalkerPosition ToInt() int }
For most simple uses
type IListFns ¶ added in v1.1.0
type IListFns interface { RenderSubwidgets(gowid.IRenderSize, gowid.Selector, gowid.IApp) ([]SubRenders, SubRenders, []SubRenders) Walker() IWalker SetWalker(IWalker, gowid.IApp) }
type IWalker ¶
type IWalker interface { At(pos IWalkerPosition) gowid.IWidget Focus() IWalkerPosition SetFocus(pos IWalkerPosition, app gowid.IApp) Next(pos IWalkerPosition) IWalkerPosition Previous(pos IWalkerPosition) IWalkerPosition }
Remove HaveFocus because the Next and Previous APIs have to return an gowid.IWidget anyway - so just standardize on assuming a nil interface means invalid
type IWalkerEnd ¶
type IWalkerEnd interface {
Last() IWalkerPosition // nil possible if empty
}
IWalkerEnd is any type that supports being able to provide a last position. This is used to support the End key on the keyboard.
type IWalkerHome ¶
type IWalkerHome interface {
First() IWalkerPosition // nil possible if empty
}
IWalkerHome is any type that supports being able to provide a first position.
type IWalkerPosition ¶
type IWalkerPosition interface { Equal(IWalkerPosition) bool GreaterThan(IWalkerPosition) bool }
IWalkerPosition is satisfied by any struct with an Equal() method that can determine whether it's at the "same" position as another or is more advanced than another.
type IndexedWidget ¶
type IndexedWidget struct { *Widget // contains filtered or unexported fields }
func NewBounded ¶
func NewBounded(walker IBoundedWalker, opts ...Options) *IndexedWidget
func (*IndexedWidget) Walker ¶
func (w *IndexedWidget) Walker() IWalker
type ListPos ¶
type ListPos int
func (ListPos) Equal ¶
func (l ListPos) Equal(other IWalkerPosition) bool
func (ListPos) GreaterThan ¶
func (l ListPos) GreaterThan(other IWalkerPosition) bool
type SimpleListWalker ¶
func NewSimpleListWalker ¶
func NewSimpleListWalker(widgets []gowid.IWidget) *SimpleListWalker
func (*SimpleListWalker) At ¶
func (w *SimpleListWalker) At(pos IWalkerPosition) gowid.IWidget
func (*SimpleListWalker) First ¶
func (w *SimpleListWalker) First() IWalkerPosition
func (*SimpleListWalker) Focus ¶
func (w *SimpleListWalker) Focus() IWalkerPosition
func (*SimpleListWalker) Last ¶
func (w *SimpleListWalker) Last() IWalkerPosition
func (*SimpleListWalker) Length ¶
func (w *SimpleListWalker) Length() int
func (*SimpleListWalker) Next ¶
func (w *SimpleListWalker) Next(ipos IWalkerPosition) IWalkerPosition
func (*SimpleListWalker) Previous ¶
func (w *SimpleListWalker) Previous(ipos IWalkerPosition) IWalkerPosition
func (*SimpleListWalker) SetFocus ¶
func (w *SimpleListWalker) SetFocus(focus IWalkerPosition, app gowid.IApp)
type SubRenders ¶
type SubRenders struct { Widget gowid.IWidget Position IWalkerPosition Canvas gowid.ICanvas FullCanvasLines int }
func (*SubRenders) IsChopped ¶
func (r *SubRenders) IsChopped() bool
IsChopped is a utility function for a SubRender struct that returns true if the canvas returned for this widget is smaller than the full size rendered (i.e. that it has been adjusted vertically)
type WalkerIndex ¶
type WalkerIndex struct { Widget gowid.IWidget Pos IWalkerPosition }
WalkerMoved is a simple struct used to hold the result of a Next() or Previous() call on an IWalker. I find its use more convenient than returning multiple values because you can use it inline with other expressions.
type Widget ¶
type Widget struct { gowid.AddressProvidesID *gowid.Callbacks gowid.FocusCallbacks gowid.IsSelectable // contains filtered or unexported fields }
func (*Widget) CalculateOnScreen ¶
func (*Widget) GoToBottom ¶
func (*Widget) GoToMiddle ¶
func (*Widget) MoveToNextFocus ¶
func (w *Widget) MoveToNextFocus(subRenderSize gowid.IRenderSize, focus gowid.Selector, screenLines int, app gowid.IApp) (bool, IWalkerPosition)
func (*Widget) MoveToPreviousFocus ¶
func (w *Widget) MoveToPreviousFocus(subRenderSize gowid.IRenderSize, focus gowid.Selector, screenLines int, app gowid.IApp) (bool, IWalkerPosition)
func (*Widget) RenderSize ¶
func (w *Widget) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderBox
func (*Widget) RenderSubwidgets ¶
func (w *Widget) RenderSubwidgets(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) (top []SubRenders, middle SubRenders, bottom []SubRenders)
RenderSubWidgets starts at the focus widget, rendering it, and returning the result as middle, a SubRenders struct. This tells the caller information about the widget rendered, including the full number of lines that would've been used if the provided render size had been large enough (this information tells the caller that the whole widget isn't displayed). After rendering the middle widget, the function renders Previous and Next widgets until the space above the middle widget and the space below the middle widget is filled.
func (*Widget) SubWidgetSize ¶
func (w *Widget) SubWidgetSize(size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) gowid.IRenderSize
type WidgetIsUnboundedError ¶
type WidgetIsUnboundedError struct {
Type interface{}
}
func (WidgetIsUnboundedError) Error ¶
func (e WidgetIsUnboundedError) Error() string