diff options
author | Kalyan Sriram <coder.kalyan@gmail.com> | 2020-07-27 01:03:55 -0700 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-07-30 19:35:59 +0200 |
commit | 1ff687ca2b0821c2cacc1fa725abb3302d2af9da (patch) | |
tree | b84df04a645c1fd2ee94d7a08f2f9c717930e9ab /widgets/getpasswd.go | |
parent | 1bab1754f095a5c0537fc639d0214f6efbb340a2 (diff) | |
download | aerc-1ff687ca2b0821c2cacc1fa725abb3302d2af9da.tar.gz |
Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of aerc's look (color scheme, font weight, etc). Default styleset is installed to /path/to/aerc/stylesets/default.
Diffstat (limited to 'widgets/getpasswd.go')
-rw-r--r-- | widgets/getpasswd.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go index 34f8b1f..3cdc5cf 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,17 @@ 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 +35,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)) } |