aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/getpasswd.go
diff options
context:
space:
mode:
authorRay Ganardi <ray@ganardi.xyz>2020-05-19 13:06:47 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-25 09:30:20 -0400
commitc32ab765a7cfecab7a30b2c6a50d43ba69036850 (patch)
treee827cf0e08282957d508ee55946cd53c1e9cb1cd /widgets/getpasswd.go
parent58db517c8d79c7fd8897d8ab5d5cf9c2de67a071 (diff)
downloadaerc-c32ab765a7cfecab7a30b2c6a50d43ba69036850.tar.gz
feat(pgp): Add <ESC> to cancel password prompt
Previously there was no way to cancel the password prompt.
Diffstat (limited to 'widgets/getpasswd.go')
-rw-r--r--widgets/getpasswd.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go
index 08702c58..34f8b1f5 100644
--- a/widgets/getpasswd.go
+++ b/widgets/getpasswd.go
@@ -1,6 +1,8 @@
package widgets
import (
+ "fmt"
+
"github.com/gdamore/tcell"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
@@ -8,13 +10,13 @@ import (
type GetPasswd struct {
ui.Invalidatable
- callback func(string)
+ callback func(string, error)
title string
prompt string
input *ui.TextInput
}
-func NewGetPasswd(title string, prompt string, cb func(string)) *GetPasswd {
+func NewGetPasswd(title string, prompt string, cb func(string, error)) *GetPasswd {
getpasswd := &GetPasswd{
callback: cb,
title: title,
@@ -46,7 +48,10 @@ func (gp *GetPasswd) Event(event tcell.Event) bool {
switch event.Key() {
case tcell.KeyEnter:
gp.input.Focus(false)
- gp.callback(gp.input.String())
+ 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)
}