aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/getpasswd.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/getpasswd.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/getpasswd.go')
-rw-r--r--widgets/getpasswd.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go
index 34f8b1f5..b3ea9e07 100644
--- a/widgets/getpasswd.go
+++ b/widgets/getpasswd.go
@@ -5,6 +5,7 @@ import (
"github.com/gdamore/tcell"
+ "git.sr.ht/~sircmpwn/aerc/config"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
)
@@ -14,14 +15,16 @@ type GetPasswd struct {
title string
prompt string
input *ui.TextInput
+ conf *config.AercConfig
}
-func NewGetPasswd(title string, prompt string, cb func(string, error)) *GetPasswd {
+func NewGetPasswd(title string, prompt string, conf *config.AercConfig, cb func(string, error)) *GetPasswd {
getpasswd := &GetPasswd{
callback: cb,
title: title,
prompt: prompt,
- input: ui.NewTextInput("").Password(true).Prompt("Password: "),
+ conf: conf,
+ input: ui.NewTextInput("", conf.Ui).Password(true).Prompt("Password: "),
}
getpasswd.input.OnInvalidate(func(_ ui.Drawable) {
getpasswd.Invalidate()
@@ -31,10 +34,13 @@ func NewGetPasswd(title string, prompt string, cb func(string, error)) *GetPassw
}
func (gp *GetPasswd) Draw(ctx *ui.Context) {
- ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
- ctx.Fill(0, 0, ctx.Width(), 1, ' ', tcell.StyleDefault.Reverse(true))
- ctx.Printf(1, 0, tcell.StyleDefault.Reverse(true), "%s", gp.title)
- ctx.Printf(1, 1, tcell.StyleDefault, gp.prompt)
+ defaultStyle := gp.conf.Ui.GetStyle(config.STYLE_DEFAULT)
+ titleStyle := gp.conf.Ui.GetStyle(config.STYLE_TITLE)
+
+ ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', defaultStyle)
+ ctx.Fill(0, 0, ctx.Width(), 1, ' ', titleStyle)
+ ctx.Printf(1, 0, titleStyle, "%s", gp.title)
+ ctx.Printf(1, 1, defaultStyle, gp.prompt)
gp.input.Draw(ctx.Subcontext(1, 3, ctx.Width()-2, 1))
}