aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/selecter.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-05-27 07:37:02 +0200
committerReto Brunner <reto@labrat.space>2020-05-27 07:57:10 +0200
commit0f78f06610c0e8887aba2ae50e99b86477a384b3 (patch)
treeff4cd6581d3af0911954a37550602366d2bb0e2f /widgets/selecter.go
parent6c4ed3cfe2fe66a1e5f26c404ea90e048142db72 (diff)
downloadaerc-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 'widgets/selecter.go')
-rw-r--r--widgets/selecter.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/widgets/selecter.go b/widgets/selecter.go
index 7fae9cda..0faf37ea 100644
--- a/widgets/selecter.go
+++ b/widgets/selecter.go
@@ -3,24 +3,27 @@ package widgets
import (
"github.com/gdamore/tcell"
+ "git.sr.ht/~sircmpwn/aerc/config"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
)
type Selecter struct {
ui.Invalidatable
- chooser bool
- focused bool
- focus int
- options []string
+ chooser bool
+ focused bool
+ focus int
+ options []string
+ uiConfig config.UIConfig
onChoose func(option string)
onSelect func(option string)
}
-func NewSelecter(options []string, focus int) *Selecter {
+func NewSelecter(options []string, focus int, uiConfig config.UIConfig) *Selecter {
return &Selecter{
- focus: focus,
- options: options,
+ focus: focus,
+ options: options,
+ uiConfig: uiConfig,
}
}
@@ -34,15 +37,16 @@ func (sel *Selecter) Invalidate() {
}
func (sel *Selecter) Draw(ctx *ui.Context) {
- ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
+ ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ',
+ sel.uiConfig.GetStyle(config.STYLE_SELECTER_DEFAULT))
x := 2
for i, option := range sel.options {
- style := tcell.StyleDefault
+ style := sel.uiConfig.GetStyle(config.STYLE_SELECTER_DEFAULT)
if sel.focus == i {
if sel.focused {
- style = style.Reverse(true)
+ style = sel.uiConfig.GetStyle(config.STYLE_SELECTER_FOCUSED)
} else if sel.chooser {
- style = style.Bold(true)
+ style = sel.uiConfig.GetStyle(config.STYLE_SELECTER_CHOOSER)
}
}
x += ctx.Printf(x, 1, style, "[%s]", option)