Documentation ¶
Overview ¶
Package container defines a type that wraps other containers or widgets.
The container supports splitting container into sub containers, defining container styles and placing widgets. The container also creates and manages canvases assigned to the placed widgets.
Example ¶
Example demonstrates how to use the Container API.
New( /* terminal = */ nil, SplitVertical( Left( SplitHorizontal( Top( Border(draw.LineStyleLight), ), Bottom( SplitHorizontal( Top( Border(draw.LineStyleLight), ), Bottom( Border(draw.LineStyleLight), ), ), ), ), ), Right( Border(draw.LineStyleLight), PlaceWidget(fakewidget.New(widgetapi.Options{})), ), ), )
Output:
Index ¶
- type BottomOption
- type Container
- type LeftOption
- type Option
- func AlignHorizontal(h align.Horizontal) Option
- func AlignVertical(v align.Vertical) Option
- func Border(ls draw.LineStyle) Option
- func BorderColor(color cell.Color) Option
- func BorderTitle(title string) Option
- func BorderTitleAlignCenter() Option
- func BorderTitleAlignLeft() Option
- func BorderTitleAlignRight() Option
- func FocusedColor(color cell.Color) Option
- func PlaceWidget(w widgetapi.Widget) Option
- func SplitHorizontal(t TopOption, b BottomOption) Option
- func SplitVertical(l LeftOption, r RightOption) Option
- type RightOption
- type TopOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BottomOption ¶
type BottomOption interface {
// contains filtered or unexported methods
}
BottomOption is used to provide options to the bottom sub container after a horizontal split of the parent.
func Bottom ¶
func Bottom(opts ...Option) BottomOption
Bottom applies options to the bottom sub container after a horizontal split of the parent.
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container wraps either sub containers or widgets and positions them on the terminal. This is not thread-safe.
func New ¶
func New(t terminalapi.Terminal, opts ...Option) *Container
New returns a new root container that will use the provided terminal and applies the provided options.
func (*Container) Keyboard ¶
func (c *Container) Keyboard(k *terminalapi.Keyboard) error
Keyboard is used to forward a keyboard event to the container. Keyboard events are forwarded to the widget in the currently focused container, assuming that the widget registered for keyboard events.
func (*Container) Mouse ¶
func (c *Container) Mouse(m *terminalapi.Mouse) error
Mouse is used to forward a mouse event to the container. Container uses mouse events to track and change which is the active (focused) container.
If the container that receives the mouse click contains a widget that registered for mouse events, the mouse event is further forwarded to that widget. Only mouse events that fall within the widget's canvas are forwarded and the coordinates are adjusted relative to the widget's canvas.
type LeftOption ¶
type LeftOption interface {
// contains filtered or unexported methods
}
LeftOption is used to provide options to the left sub container after a vertical split of the parent.
func Left ¶
func Left(opts ...Option) LeftOption
Left applies options to the left sub container after a vertical split of the parent.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options to a container.
func AlignHorizontal ¶
func AlignHorizontal(h align.Horizontal) Option
AlignHorizontal sets the horizontal alignment for the widget placed in the container. Has no effect if the container contains no widget. Defaults alignment in the center.
func AlignVertical ¶
AlignVertical sets the vertical alignment for the widget placed in the container. Has no effect if the container contains no widget. Defaults to alignment in the middle.
func BorderColor ¶
BorderColor sets the color of the border around the container. This option is inherited to sub containers created by container splits.
func BorderTitle ¶
BorderTitle sets a text title within the border.
func BorderTitleAlignCenter ¶
func BorderTitleAlignCenter() Option
BorderTitleAlignCenter aligns the border title in the center.
func BorderTitleAlignLeft ¶
func BorderTitleAlignLeft() Option
BorderTitleAlignLeft aligns the border title on the left.
func BorderTitleAlignRight ¶
func BorderTitleAlignRight() Option
BorderTitleAlignRight aligns the border title on the right.
func FocusedColor ¶
FocusedColor sets the color of the border around the container when it has keyboard focus. This option is inherited to sub containers created by container splits.
func PlaceWidget ¶
PlaceWidget places the provided widget into the container. The use of this option removes any sub containers. Containers with sub containers cannot have widgets.
func SplitHorizontal ¶
func SplitHorizontal(t TopOption, b BottomOption) Option
SplitHorizontal splits the container along the horizontal axis into two sub containers. The use of this option removes any widget placed at this container, containers with sub containers cannot contain widgets.
func SplitVertical ¶
func SplitVertical(l LeftOption, r RightOption) Option
SplitVertical splits the container along the vertical axis into two sub containers. The use of this option removes any widget placed at this container, containers with sub containers cannot contain widgets.
type RightOption ¶
type RightOption interface {
// contains filtered or unexported methods
}
RightOption is used to provide options to the right sub container after a vertical split of the parent.
func Right ¶
func Right(opts ...Option) RightOption
Right applies options to the right sub container after a vertical split of the parent.