aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/getpasswd.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-09 13:52:20 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-10 11:37:56 +0200
commit598e4a5803578ab3e291f232d6aad31b4efd8ea4 (patch)
treec55e16d60e2c3eea2d6de27d1bac18db5670ec77 /widgets/getpasswd.go
parent61bca76423ee87bd59084a146eca71c6bae085e1 (diff)
downloadaerc-598e4a5803578ab3e291f232d6aad31b4efd8ea4.tar.gz
widgets: rename package to app
This is the central point of all aerc. Having it named widgets is confusing. Rename it to app. It will make a cleaner transition when making the app.Aerc object available globally in the next commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'widgets/getpasswd.go')
-rw-r--r--widgets/getpasswd.go68
1 files changed, 0 insertions, 68 deletions
diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go
deleted file mode 100644
index 17274626..00000000
--- a/widgets/getpasswd.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package widgets
-
-import (
- "fmt"
-
- "github.com/gdamore/tcell/v2"
-
- "git.sr.ht/~rjarry/aerc/config"
- "git.sr.ht/~rjarry/aerc/lib/ui"
-)
-
-type GetPasswd struct {
- callback func(string, error)
- title string
- prompt string
- input *ui.TextInput
-}
-
-func NewGetPasswd(
- title string, prompt string, cb func(string, error),
-) *GetPasswd {
- getpasswd := &GetPasswd{
- callback: cb,
- title: title,
- prompt: prompt,
- input: ui.NewTextInput("", config.Ui).Password(true).Prompt("Password: "),
- }
- getpasswd.input.Focus(true)
- return getpasswd
-}
-
-func (gp *GetPasswd) Draw(ctx *ui.Context) {
- defaultStyle := config.Ui.GetStyle(config.STYLE_DEFAULT)
- titleStyle := config.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))
-}
-
-func (gp *GetPasswd) Invalidate() {
- ui.Invalidate()
-}
-
-func (gp *GetPasswd) Event(event tcell.Event) bool {
- switch event := event.(type) {
- case *tcell.EventKey:
- switch event.Key() {
- case tcell.KeyEnter:
- gp.input.Focus(false)
- gp.callback(gp.input.String(), nil)
- case tcell.KeyEsc:
- gp.input.Focus(false)
- gp.callback("", fmt.Errorf("no password provided"))
- default:
- gp.input.Event(event)
- }
- default:
- gp.input.Event(event)
- }
- return true
-}
-
-func (gp *GetPasswd) Focus(f bool) {
- // Who cares
-}