about summary refs log tree commit diff stats
path: root/widgets/account-wizard.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/account-wizard.go')
-rw-r--r--widgets/account-wizard.go109
1 files changed, 47 insertions, 62 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go
index e247dd2..6f93367 100644
--- a/widgets/account-wizard.go
+++ b/widgets/account-wizard.go
@@ -10,7 +10,6 @@ import (
 	"path"
 	"strconv"
 	"strings"
-	"time"
 
 	"github.com/gdamore/tcell"
 	"github.com/go-ini/ini"
@@ -76,21 +75,21 @@ type AccountWizard struct {
 
 func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 	wizard := &AccountWizard{
-		accountName:  ui.NewTextInput("", conf.Ui).Prompt("> "),
+		accountName:  ui.NewTextInput("").Prompt("> "),
 		aerc:         aerc,
 		conf:         conf,
 		temporary:    false,
 		copySent:     true,
-		email:        ui.NewTextInput("", conf.Ui).Prompt("> "),
-		fullName:     ui.NewTextInput("", conf.Ui).Prompt("> "),
-		imapPassword: ui.NewTextInput("", conf.Ui).Prompt("] ").Password(true),
-		imapServer:   ui.NewTextInput("", conf.Ui).Prompt("> "),
-		imapStr:      ui.NewText("imaps://", conf.Ui.GetStyle(config.STYLE_DEFAULT)),
-		imapUsername: ui.NewTextInput("", conf.Ui).Prompt("> "),
-		smtpPassword: ui.NewTextInput("", conf.Ui).Prompt("] ").Password(true),
-		smtpServer:   ui.NewTextInput("", conf.Ui).Prompt("> "),
-		smtpStr:      ui.NewText("smtps://", conf.Ui.GetStyle(config.STYLE_DEFAULT)),
-		smtpUsername: ui.NewTextInput("", conf.Ui).Prompt("> "),
+		email:        ui.NewTextInput("").Prompt("> "),
+		fullName:     ui.NewTextInput("").Prompt("> "),
+		imapPassword: ui.NewTextInput("").Prompt("] ").Password(true),
+		imapServer:   ui.NewTextInput("").Prompt("> "),
+		imapStr:      ui.NewText("imaps://"),
+		imapUsername: ui.NewTextInput("").Prompt("> "),
+		smtpPassword: ui.NewTextInput("").Prompt("] ").Password(true),
+		smtpServer:   ui.NewTextInput("").Prompt("> "),
+		smtpStr:      ui.NewText("smtps://"),
+		smtpUsername: ui.NewTextInput("").Prompt("> "),
 	}
 
 	// Autofill some stuff for the user
@@ -151,36 +150,33 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 		{ui.SIZE_WEIGHT, 1},
 	})
 	basics.AddChild(
-		ui.NewText("\nWelcome to aerc! Let's configure your account.\n\n"+
-			"This wizard supports basic IMAP & SMTP configuration.\n"+
-			"For other configurations, use <Ctrl+q> to exit and read the "+
-			"aerc-config(5) man page.\n"+
-			"Press <Tab> and <Shift+Tab> to cycle between each field in this form, "+
-			"or <Ctrl+j> and <Ctrl+k>.",
-			conf.Ui.GetStyle(config.STYLE_DEFAULT)))
+		ui.NewText("\nWelcome to aerc! Let's configure your account.\n\n" +
+			"This wizard supports basic IMAP & SMTP configuration.\n" +
+			"For other configurations, use <Ctrl+q> to exit and read the " +
+			"aerc-config(5) man page.\n" +
+			"Press <Tab> and <Shift+Tab> to cycle between each field in this form, or <Ctrl+j> and <Ctrl+k>."))
 	basics.AddChild(
-		ui.NewText("Name for this account? (e.g. 'Personal' or 'Work')",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Name for this account? (e.g. 'Personal' or 'Work')").
+			Bold(true)).
 		At(1, 0)
 	basics.AddChild(wizard.accountName).
 		At(2, 0)
 	basics.AddChild(ui.NewFill(' ')).
 		At(3, 0)
 	basics.AddChild(
-		ui.NewText("Full name for outgoing emails? (e.g. 'John Doe')",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Full name for outgoing emails? (e.g. 'John Doe')").
+			Bold(true)).
 		At(4, 0)
 	basics.AddChild(wizard.fullName).
 		At(5, 0)
 	basics.AddChild(ui.NewFill(' ')).
 		At(6, 0)
 	basics.AddChild(
-		ui.NewText("Your email address? (e.g. 'john@example.org')",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Your email address? (e.g. 'john@example.org')").Bold(true)).
 		At(7, 0)
 	basics.AddChild(wizard.email).
 		At(8, 0)
-	selecter := NewSelecter([]string{"Next"}, 0, conf.Ui).
+	selecter := NewSelecter([]string{"Next"}, 0).
 		OnChoose(func(option string) {
 			email := wizard.email.String()
 			if strings.ContainsRune(email, '@') {
@@ -231,19 +227,16 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 	}).Columns([]ui.GridSpec{
 		{ui.SIZE_WEIGHT, 1},
 	})
-	incoming.AddChild(ui.NewText("\nConfigure incoming mail (IMAP)",
-		conf.Ui.GetStyle(config.STYLE_DEFAULT)))
+	incoming.AddChild(ui.NewText("\nConfigure incoming mail (IMAP)"))
 	incoming.AddChild(
-		ui.NewText("Username",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Username").Bold(true)).
 		At(1, 0)
 	incoming.AddChild(wizard.imapUsername).
 		At(2, 0)
 	incoming.AddChild(ui.NewFill(' ')).
 		At(3, 0)
 	incoming.AddChild(
-		ui.NewText("Password",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Password").Bold(true)).
 		At(4, 0)
 	incoming.AddChild(wizard.imapPassword).
 		At(5, 0)
@@ -251,22 +244,20 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 		At(6, 0)
 	incoming.AddChild(
 		ui.NewText("Server address "+
-			"(e.g. 'mail.example.org' or 'mail.example.org:1313')",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+			"(e.g. 'mail.example.org' or 'mail.example.org:1313')").Bold(true)).
 		At(7, 0)
 	incoming.AddChild(wizard.imapServer).
 		At(8, 0)
 	incoming.AddChild(ui.NewFill(' ')).
 		At(9, 0)
 	incoming.AddChild(
-		ui.NewText("Connection mode",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Connection mode").Bold(true)).
 		At(10, 0)
 	imapMode := NewSelecter([]string{
 		"IMAP over SSL/TLS",
 		"IMAP with STARTTLS",
 		"Insecure IMAP",
-	}, 0, conf.Ui).Chooser(true).OnSelect(func(option string) {
+	}, 0).Chooser(true).OnSelect(func(option string) {
 		switch option {
 		case "IMAP over SSL/TLS":
 			wizard.imapMode = IMAP_OVER_TLS
@@ -278,7 +269,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 		wizard.imapUri()
 	})
 	incoming.AddChild(imapMode).At(11, 0)
-	selecter = NewSelecter([]string{"Previous", "Next"}, 1, conf.Ui).
+	selecter = NewSelecter([]string{"Previous", "Next"}, 1).
 		OnChoose(wizard.advance)
 	incoming.AddChild(ui.NewFill(' ')).At(12, 0)
 	incoming.AddChild(wizard.imapStr).At(13, 0)
@@ -313,19 +304,16 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 	}).Columns([]ui.GridSpec{
 		{ui.SIZE_WEIGHT, 1},
 	})
-	outgoing.AddChild(ui.NewText("\nConfigure outgoing mail (SMTP)",
-		conf.Ui.GetStyle(config.STYLE_DEFAULT)))
+	outgoing.AddChild(ui.NewText("\nConfigure outgoing mail (SMTP)"))
 	outgoing.AddChild(
-		ui.NewText("Username",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Username").Bold(true)).
 		At(1, 0)
 	outgoing.AddChild(wizard.smtpUsername).
 		At(2, 0)
 	outgoing.AddChild(ui.NewFill(' ')).
 		At(3, 0)
 	outgoing.AddChild(
-		ui.NewText("Password",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Password").Bold(true)).
 		At(4, 0)
 	outgoing.AddChild(wizard.smtpPassword).
 		At(5, 0)
@@ -333,22 +321,20 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 		At(6, 0)
 	outgoing.AddChild(
 		ui.NewText("Server address "+
-			"(e.g. 'mail.example.org' or 'mail.example.org:1313')",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+			"(e.g. 'mail.example.org' or 'mail.example.org:1313')").Bold(true)).
 		At(7, 0)
 	outgoing.AddChild(wizard.smtpServer).
 		At(8, 0)
 	outgoing.AddChild(ui.NewFill(' ')).
 		At(9, 0)
 	outgoing.AddChild(
-		ui.NewText("Connection mode",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).
+		ui.NewText("Connection mode").Bold(true)).
 		At(10, 0)
 	smtpMode := NewSelecter([]string{
 		"SMTP over SSL/TLS",
 		"SMTP with STARTTLS",
 		"Insecure SMTP",
-	}, 0, conf.Ui).Chooser(true).OnSelect(func(option string) {
+	}, 0).Chooser(true).OnSelect(func(option string) {
 		switch option {
 		case "SMTP over SSL/TLS":
 			wizard.smtpMode = SMTP_OVER_TLS
@@ -360,15 +346,15 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 		wizard.smtpUri()
 	})
 	outgoing.AddChild(smtpMode).At(11, 0)
-	selecter = NewSelecter([]string{"Previous", "Next"}, 1, conf.Ui).
+	selecter = NewSelecter([]string{"Previous", "Next"}, 1).
 		OnChoose(wizard.advance)
 	outgoing.AddChild(ui.NewFill(' ')).At(12, 0)
 	outgoing.AddChild(wizard.smtpStr).At(13, 0)
 	outgoing.AddChild(ui.NewFill(' ')).At(14, 0)
 	outgoing.AddChild(
-		ui.NewText("Copy sent messages to 'Sent' folder?",
-			conf.Ui.GetStyle(config.STYLE_HEADER))).At(15, 0)
-	copySent := NewSelecter([]string{"Yes", "No"}, 0, conf.Ui).
+		ui.NewText("Copy sent messages to 'Sent' folder?").Bold(true)).
+		At(15, 0)
+	copySent := NewSelecter([]string{"Yes", "No"}, 0).
 		Chooser(true).OnChoose(func(option string) {
 		switch option {
 		case "Yes":
@@ -394,16 +380,15 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
 		{ui.SIZE_WEIGHT, 1},
 	})
 	complete.AddChild(ui.NewText(
-		"\nConfiguration complete!\n\n"+
-			"You can go back and double check your settings, or choose 'Finish' to\n"+
-			"save your settings to accounts.conf.\n\n"+
-			"To add another account in the future, run ':new-account'.",
-		conf.Ui.GetStyle(config.STYLE_DEFAULT)))
+		"\nConfiguration complete!\n\n" +
+			"You can go back and double check your settings, or choose 'Finish' to\n" +
+			"save your settings to accounts.conf.\n\n" +
+			"To add another account in the future, run ':new-account'."))
 	selecter = NewSelecter([]string{
 		"Previous",
 		"Finish & open tutorial",
 		"Finish",
-	}, 1, conf.Ui).OnChoose(func(option string) {
+	}, 1).OnChoose(func(option string) {
 		switch option {
 		case "Previous":
 			wizard.advance("Previous")
@@ -429,7 +414,7 @@ func (wizard *AccountWizard) ConfigureTemporaryAccount(temporary bool) {
 
 func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
 	if d == nil {
-		wizard.aerc.PushError(" "+err.Error(), 10*time.Second)
+		wizard.aerc.PushError(" " + err.Error())
 		wizard.Invalidate()
 		return
 	}
@@ -444,7 +429,7 @@ func (wizard *AccountWizard) errorFor(d ui.Interactive, err error) {
 				wizard.step = step
 				wizard.focus = focus
 				wizard.Focus(true)
-				wizard.aerc.PushError(" "+err.Error(), 10*time.Second)
+				wizard.aerc.PushError(" " + err.Error())
 				wizard.Invalidate()
 				return
 			}
@@ -555,7 +540,7 @@ func (wizard *AccountWizard) finish(tutorial bool) {
 		term.OnClose = func(err error) {
 			wizard.aerc.RemoveTab(term)
 			if err != nil {
-				wizard.aerc.PushError(" "+err.Error(), 10*time.Second)
+				wizard.aerc.PushError(" " + err.Error())
 			}
 		}
 	}