summary refs log blame commit diff stats
path: root/widgets/account.go
blob: a83624fed7fedb489dd301050d53598c1204294f (plain) (tree)
="w"> tcell.StyleDefault, "%s", pv.err.Error()) return } pv.term.Draw(ctx) } func (pv *PartViewer) Cleanup() { if pv.pager != nil && pv.pager.Process != nil { pv.pager.Process.Kill() pv.pager = nil } } func (pv *PartViewer) Event(event tcell.Event) bool { if pv.term != nil { return pv.term.Event(event) } return pv.selecter.Event(event) } type HeaderView struct { ui.Invalidatable Name string Value string } func (hv *HeaderView) Draw(ctx *ui.Context) { name := hv.Name size := runewidth.StringWidth(name) lim := ctx.Width() - size - 1 value := runewidth.Truncate(" "+hv.Value, lim, "…") var ( hstyle tcell.Style vstyle tcell.Style ) // TODO: Make this more robust and less dumb if hv.Name == "PGP" { vstyle = tcell.StyleDefault.Foreground(tcell.ColorGreen) hstyle = tcell.StyleDefault.Bold(true) } else { vstyle = tcell.StyleDefault hstyle = tcell.StyleDefault.Bold(true) } ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', vstyle) ctx.Printf(0, 0, hstyle, name) ctx.Printf(size, 0, vstyle, value) } func (hv *HeaderView) Invalidate() { hv.DoInvalidate(hv) }