diff options
author | Reto Brunner <reto@labrat.space> | 2020-05-27 07:37:02 +0200 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-05-27 07:57:10 +0200 |
commit | 0f78f06610c0e8887aba2ae50e99b86477a384b3 (patch) | |
tree | ff4cd6581d3af0911954a37550602366d2bb0e2f /lib/ui/text.go | |
parent | 6c4ed3cfe2fe66a1e5f26c404ea90e048142db72 (diff) | |
download | aerc-0f78f06610c0e8887aba2ae50e99b86477a384b3.tar.gz |
Add Style configuration
The following functionalities are added to configure aerc ui styles. - Read stylesets from file with very basic fnmatch wildcard matching - Add default styleset - Support different stylesets as part of UiConfig allowing contextual styles. - Move widgets/ui elements to use the stylesets. - Add configuration manual for the styleset
Diffstat (limited to 'lib/ui/text.go')
-rw-r--r-- | lib/ui/text.go | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/lib/ui/text.go b/lib/ui/text.go index 2b82598..455c2eb 100644 --- a/lib/ui/text.go +++ b/lib/ui/text.go @@ -15,17 +15,13 @@ type Text struct { Invalidatable text string strategy uint - fg tcell.Color - bg tcell.Color - bold bool - reverse bool + style tcell.Style } -func NewText(text string) *Text { +func NewText(text string, style tcell.Style) *Text { return &Text{ - bg: tcell.ColorDefault, - fg: tcell.ColorDefault, - text: text, + text: text, + style: style, } } @@ -41,25 +37,6 @@ func (t *Text) Strategy(strategy uint) *Text { return t } -func (t *Text) Bold(bold bool) *Text { - t.bold = bold - t.Invalidate() - return t -} - -func (t *Text) Color(fg tcell.Color, bg tcell.Color) *Text { - t.fg = fg - t.bg = bg - t.Invalidate() - return t -} - -func (t *Text) Reverse(reverse bool) *Text { - t.reverse = reverse - t.Invalidate() - return t -} - func (t *Text) Draw(ctx *Context) { size := runewidth.StringWidth(t.text) x := 0 @@ -69,15 +46,8 @@ func (t *Text) Draw(ctx *Context) { if t.strategy == TEXT_RIGHT { x = ctx.Width() - size } - style := tcell.StyleDefault.Background(t.bg).Foreground(t.fg) - if t.bold { - style = style.Bold(true) - } - if t.reverse { - style = style.Reverse(true) - } - ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', style) - ctx.Printf(x, 0, style, "%s", t.text) + ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', t.style) + ctx.Printf(x, 0, t.style, "%s", t.text) } func (t *Text) Invalidate() { |