Minor refactoring to header view

This commit is contained in:
Drew DeVault 2019-03-30 16:50:14 -04:00
parent fd27a2baf6
commit 4bdc0f3715

View file

@ -206,16 +206,21 @@ type HeaderView struct {
func (hv *HeaderView) Draw(ctx *ui.Context) { func (hv *HeaderView) Draw(ctx *ui.Context) {
size := runewidth.StringWidth(hv.Name) size := runewidth.StringWidth(hv.Name)
var style tcell.Style var (
hstyle tcell.Style
vstyle tcell.Style
)
// TODO: Make this more robust and less dumb
if hv.Name == "PGP" { if hv.Name == "PGP" {
style = tcell.StyleDefault.Foreground(tcell.ColorGreen) vstyle = tcell.StyleDefault.Foreground(tcell.ColorGreen)
hstyle = tcell.StyleDefault.Bold(true)
} else { } else {
style = tcell.StyleDefault vstyle = tcell.StyleDefault
hstyle = tcell.StyleDefault.Bold(true)
} }
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style) ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', vstyle)
ctx.Printf(0, 0, ctx.Printf(0, 0, hstyle, hv.Name)
tcell.StyleDefault.Bold(true), hv.Name) ctx.Printf(size, 0, vstyle, " "+hv.Value)
ctx.Printf(size, 0, style, " "+hv.Value)
} }
func (hv *HeaderView) Invalidate() { func (hv *HeaderView) Invalidate() {