Skip to content

Instantly share code, notes, and snippets.

@cceckman
Created Nov 5, 2017
Embed
What would you like to do?
Show gist
// Demonstrate bug: spacer doesn't render its background color.
package main
import (
"log"
"github.com/marcusolsson/tui-go"
)
func Theme() *tui.Theme {
r := tui.NewTheme()
r.SetStyle("reverse", tui.Style{
Fg: tui.ColorWhite,
Bg: tui.ColorBlack,
Reverse: true,
})
return r
}
type customWidget struct {
*tui.Box
}
func (c *customWidget) Draw(p *tui.Painter) {
p.WithStyle("reverse", c.Box.Draw)
}
func NewCustom() *customWidget {
return &customWidget{
Box: tui.NewHBox(
tui.NewSpacer(),
tui.NewLabel("text here"),
tui.NewSpacer(),
),
}
}
func main() {
ui := tui.New(tui.NewVBox(
tui.NewSpacer(),
NewCustom(),
tui.NewSpacer(),
))
ui.SetTheme(Theme())
ui.SetKeybinding("Esc", func() { ui.Quit() })
if err := ui.Run(); err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment