Documentation
¶
Overview ¶
Package widgets gives you widgets that allow you to quickly start writing TUI apps with gocui. Creating a widget is easy:
package main
import (
"github.com/awesome-gocui/gocui"
"github.com/panproteus/gocui-widgets"
)
func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
panic(err)
}
defer g.Close()
w, h := g.Size()
textWi := widgets.NewText("example-widget", "hello world", true, true, w/2, h/2)
g.SetManager(text)
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
panic(err)
}
}
To see more please visit '_examples/'
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// View is a pointer to the gocui view of this widget
View *gocui.View
// Type is an enum WidgetType
Type WidgetType
// contains filtered or unexported fields
}
Collection is a widget that groups other widgets
func NewCollection ¶
NewCollection initializes the Collection widget if center is true x and y becomes the center not start
func (*Collection) ChangeTitle ¶
func (w *Collection) ChangeTitle(t string) func(g *gocui.Gui) error
ChangeTitle changes the title of the widget
type Input ¶
type Input struct {
// View is a pointer to the gocui view of this widget
View *gocui.View
// Type is an enum WidgetType
Type WidgetType
// contains filtered or unexported fields
}
Input is a widget allows for user input
func NewInput ¶
func NewInput(name string, frame, center bool, x, y int, w, h int, overlaps byte, onChange func(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool) *Input
NewInput initializes the Input widget if frame is true a border is rendered if center is true x and y becomes the center not start
func (*Input) ChangeText ¶
ChangeText changes the inner text
type Menu ¶
type Menu struct {
// View is a pointer to the gocui view of this widget
View *gocui.View
// Type is an enum WidgetType
Type WidgetType
// contains filtered or unexported fields
}
Menu is a widget that creates a vertical clickable menu
func NewMenu ¶
func NewMenu(name string, items []string, center bool, x, y int, overlaps byte, onChange, onSubmit func(i int)) *Menu
NewMenu initializes the Menu widget
func (*Menu) ChangeSelected ¶
ChangeSelected changes the selected menu item
type Modal ¶
type Modal struct {
// View is a pointer to the gocui view of this widget
View *gocui.View
// Type is an enum WidgetType
Type WidgetType
// contains filtered or unexported fields
}
Modal is a widget creates a pop-up with buttons
type Text ¶
type Text struct {
// View is a pointer to the gocui view of this widget
View *gocui.View
// Type is an enum WidgetType
Type WidgetType
// contains filtered or unexported fields
}
Text is a widget that displays text
func NewText ¶
NewText initializes the Text widget if frame is true a border is rendered if center is true x and y becomes the center not start
func (*Text) ChangeText ¶
ChangeText changes the text within
type WidgetType ¶
type WidgetType int
WidgetType is a enum describing the widget
const ( // TypeText for Text widget TypeText WidgetType = iota // TypeMenu for Menu widget TypeMenu // TypeCollection for Collection widget TypeCollection // TypeInput for Input widget TypeInput // TypeModal for Modal widget TypeModal )