Show gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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