Created
November 5, 2017 07:02
-
-
Save cceckman/5fb78e1165c67b0137a6c0a36af4484d to your computer and use it in GitHub Desktop.
Show gist
This file contains hidden or 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