summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-07-03 10:11:12 -0500
committerRobin Jarry <robin@jarry.cc>2022-07-03 21:32:18 +0200
commitd45c07eb6a0955a24efec7bd915ba19746042778 (patch)
treedc8fdd2ad6e7a99a9af458235bffc3071254fdfa
parent12e8217d1fa0f4c4c83eebcc7473ecb8f0c072ba (diff)
downloadaerc-d45c07eb6a0955a24efec7bd915ba19746042778.zip
uiconfig: use pointer references to uiConfig
This patch changes references to uiConfig in function signatures and structs to be pointers. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--config/config.go4
-rw-r--r--lib/ui/borders.go4
-rw-r--r--lib/ui/textinput.go6
-rw-r--r--widgets/account-wizard.go32
-rw-r--r--widgets/account.go2
-rw-r--r--widgets/aerc.go8
-rw-r--r--widgets/authinfo.go4
-rw-r--r--widgets/compose.go6
-rw-r--r--widgets/dirlist.go4
-rw-r--r--widgets/exline.go4
-rw-r--r--widgets/getpasswd.go2
-rw-r--r--widgets/msgviewer.go6
-rw-r--r--widgets/pgpinfo.go4
-rw-r--r--widgets/selector.go8
-rw-r--r--widgets/status.go2
15 files changed, 48 insertions, 48 deletions
diff --git a/config/config.go b/config/config.go
index a6ee578..ee8dc6a 100644
--- a/config/config.go
+++ b/config/config.go
@@ -1017,14 +1017,14 @@ func (config AercConfig) mergeContextualUi(baseUi UIConfig,
return baseUi
}
-func (config AercConfig) GetUiConfig(params map[ContextType]string) UIConfig {
+func (config AercConfig) GetUiConfig(params map[ContextType]string) *UIConfig {
baseUi := config.Ui
for k, v := range params {
baseUi = config.mergeContextualUi(baseUi, k, v)
}
- return baseUi
+ return &baseUi
}
func (uiConfig UIConfig) GetStyle(so StyleObject) tcell.Style {
diff --git a/lib/ui/borders.go b/lib/ui/borders.go
index 886a171..6a5e9dc 100644
--- a/lib/ui/borders.go
+++ b/lib/ui/borders.go
@@ -18,11 +18,11 @@ type Bordered struct {
borders uint
content Drawable
onInvalidate func(d Drawable)
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
func NewBordered(
- content Drawable, borders uint, uiConfig config.UIConfig) *Bordered {
+ content Drawable, borders uint, uiConfig *config.UIConfig) *Bordered {
b := &Bordered{
borders: borders,
content: content,
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index 0a331dc..8bc32b0 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -33,13 +33,13 @@ type TextInput struct {
completeIndex int
completeDelay time.Duration
completeDebouncer *time.Timer
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
// Creates a new TextInput. TextInputs will render a "textbox" in the entire
// context they're given, and process keypresses to build a string from user
// input.
-func NewTextInput(text string, ui config.UIConfig) *TextInput {
+func NewTextInput(text string, ui *config.UIConfig) *TextInput {
return &TextInput{
cells: -1,
text: []rune(text),
@@ -383,7 +383,7 @@ type completions struct {
onSelect func(int)
onExec func()
onStem func(string)
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
func maxLen(ss []string) int {
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go
index 42d14d1..b352af6 100644
--- a/widgets/account-wizard.go
+++ b/widgets/account-wizard.go
@@ -75,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("", &conf.Ui).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("> "),
+ 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("> "),
+ 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("> "),
+ smtpUsername: ui.NewTextInput("", &conf.Ui).Prompt("> "),
}
// Autofill some stuff for the user
@@ -179,7 +179,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
At(7, 0)
basics.AddChild(wizard.email).
At(8, 0)
- selector := NewSelector([]string{"Next"}, 0, conf.Ui).
+ selector := NewSelector([]string{"Next"}, 0, &conf.Ui).
OnChoose(func(option string) {
email := wizard.email.String()
if strings.ContainsRune(email, '@') {
@@ -265,7 +265,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
"IMAP over SSL/TLS",
"IMAP with STARTTLS",
"Insecure IMAP",
- }, 0, conf.Ui).Chooser(true).OnSelect(func(option string) {
+ }, 0, &conf.Ui).Chooser(true).OnSelect(func(option string) {
switch option {
case "IMAP over SSL/TLS":
wizard.imapMode = IMAP_OVER_TLS
@@ -277,7 +277,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
wizard.imapUri()
})
incoming.AddChild(imapMode).At(11, 0)
- selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui).
+ selector = NewSelector([]string{"Previous", "Next"}, 1, &conf.Ui).
OnChoose(wizard.advance)
incoming.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(12, 0)
incoming.AddChild(wizard.imapStr).At(13, 0)
@@ -347,7 +347,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
"SMTP over SSL/TLS",
"SMTP with STARTTLS",
"Insecure SMTP",
- }, 0, conf.Ui).Chooser(true).OnSelect(func(option string) {
+ }, 0, &conf.Ui).Chooser(true).OnSelect(func(option string) {
switch option {
case "SMTP over SSL/TLS":
wizard.smtpMode = SMTP_OVER_TLS
@@ -359,7 +359,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
wizard.smtpUri()
})
outgoing.AddChild(smtpMode).At(11, 0)
- selector = NewSelector([]string{"Previous", "Next"}, 1, conf.Ui).
+ selector = NewSelector([]string{"Previous", "Next"}, 1, &conf.Ui).
OnChoose(wizard.advance)
outgoing.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(12, 0)
outgoing.AddChild(wizard.smtpStr).At(13, 0)
@@ -367,7 +367,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
outgoing.AddChild(
ui.NewText("Copy sent messages to 'Sent' folder?",
conf.Ui.GetStyle(config.STYLE_HEADER))).At(15, 0)
- copySent := NewSelector([]string{"Yes", "No"}, 0, conf.Ui).
+ copySent := NewSelector([]string{"Yes", "No"}, 0, &conf.Ui).
Chooser(true).OnChoose(func(option string) {
switch option {
case "Yes":
@@ -402,7 +402,7 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
"Previous",
"Finish & open tutorial",
"Finish",
- }, 1, conf.Ui).OnChoose(func(option string) {
+ }, 1, &conf.Ui).OnChoose(func(option string) {
switch option {
case "Previous":
wizard.advance("Previous")
diff --git a/widgets/account.go b/widgets/account.go
index 7c18004..725090e 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -36,7 +36,7 @@ type AccountView struct {
newConn bool // True if this is a first run after a new connection/reconnection
}
-func (acct *AccountView) UiConfig() config.UIConfig {
+func (acct *AccountView) UiConfig() *config.UIConfig {
var folder string
if dirlist := acct.Directories(); dirlist != nil {
folder = dirlist.Selected()
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 53d5944..3621201 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -95,7 +95,7 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger,
} else {
aerc.accounts[acct.Name] = view
conf := view.UiConfig()
- tabs.Add(view, acct.Name, &conf)
+ tabs.Add(view, acct.Name, conf)
}
}
@@ -325,10 +325,10 @@ func (aerc *Aerc) account(d ui.Drawable) *AccountView {
return nil
}
-func (aerc *Aerc) SelectedAccountUiConfig() config.UIConfig {
+func (aerc *Aerc) SelectedAccountUiConfig() *config.UIConfig {
acct := aerc.SelectedAccount()
if acct == nil {
- return aerc.conf.Ui
+ return &aerc.conf.Ui
}
return acct.UiConfig()
}
@@ -349,7 +349,7 @@ func (aerc *Aerc) NewTab(clickable ui.Drawable, name string) *ui.Tab {
var uiConf *config.UIConfig = nil
if acct := aerc.account(clickable); acct != nil {
conf := acct.UiConfig()
- uiConf = &conf
+ uiConf = conf
}
tab := aerc.tabs.Add(clickable, name, uiConf)
aerc.tabs.Select(len(aerc.tabs.Tabs) - 1)
diff --git a/widgets/authinfo.go b/widgets/authinfo.go
index 0879554..878a0c3 100644
--- a/widgets/authinfo.go
+++ b/widgets/authinfo.go
@@ -14,10 +14,10 @@ type AuthInfo struct {
ui.Invalidatable
authdetails *auth.Details
showInfo bool
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
-func NewAuthInfo(auth *auth.Details, showInfo bool, uiConfig config.UIConfig) *AuthInfo {
+func NewAuthInfo(auth *auth.Details, showInfo bool, uiConfig *config.UIConfig) *AuthInfo {
return &AuthInfo{authdetails: auth, showInfo: showInfo, uiConfig: uiConfig}
}
diff --git a/widgets/compose.go b/widgets/compose.go
index cbd4266..da2bde3 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -284,7 +284,7 @@ func (c *Composer) Encrypt() bool {
func (c *Composer) updateCrypto() error {
if c.crypto == nil {
uiConfig := c.acct.UiConfig()
- c.crypto = newCryptoStatus(&uiConfig)
+ c.crypto = newCryptoStatus(uiConfig)
}
var err error
// Check if signKey is empty so we only run this once
@@ -924,11 +924,11 @@ type headerEditor struct {
header *mail.Header
focused bool
input *ui.TextInput
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
func newHeaderEditor(name string, h *mail.Header,
- uiConfig config.UIConfig) *headerEditor {
+ uiConfig *config.UIConfig) *headerEditor {
he := &headerEditor{
input: ui.NewTextInput("", uiConfig),
name: name,
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 176be3b..006771a 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -78,7 +78,7 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig,
skipSelectCancel: cancel,
}
uiConf := dirlist.UiConfig()
- dirlist.spinner = NewSpinner(&uiConf)
+ dirlist.spinner = NewSpinner(uiConf)
dirlist.spinner.OnInvalidate(func(_ ui.Drawable) {
dirlist.Invalidate()
})
@@ -91,7 +91,7 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig,
return dirlist
}
-func (dirlist *DirectoryList) UiConfig() config.UIConfig {
+func (dirlist *DirectoryList) UiConfig() *config.UIConfig {
return dirlist.aercConf.GetUiConfig(map[config.ContextType]string{
config.UI_CONTEXT_ACCOUNT: dirlist.acctConf.Name,
config.UI_CONTEXT_FOLDER: dirlist.Selected(),
diff --git a/widgets/exline.go b/widgets/exline.go
index 0d245fb..4a4b655 100644
--- a/widgets/exline.go
+++ b/widgets/exline.go
@@ -22,7 +22,7 @@ func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), fin
tabcomplete func(cmd string) ([]string, string),
cmdHistory lib.History) *ExLine {
- input := ui.NewTextInput("", conf.Ui).Prompt(":").Set(cmd)
+ input := ui.NewTextInput("", &conf.Ui).Prompt(":").Set(cmd)
if conf.Ui.CompletionPopovers {
input.TabComplete(tabcomplete, conf.Ui.CompletionDelay)
}
@@ -43,7 +43,7 @@ func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), fin
func NewPrompt(conf *config.AercConfig, prompt string, commit func(text string),
tabcomplete func(cmd string) ([]string, string)) *ExLine {
- input := ui.NewTextInput("", conf.Ui).Prompt(prompt)
+ input := ui.NewTextInput("", &conf.Ui).Prompt(prompt)
if conf.Ui.CompletionPopovers {
input.TabComplete(tabcomplete, conf.Ui.CompletionDelay)
}
diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go
index 0a03f7d..e4cf07b 100644
--- a/widgets/getpasswd.go
+++ b/widgets/getpasswd.go
@@ -25,7 +25,7 @@ func NewGetPasswd(title string, prompt string, conf *config.AercConfig,
title: title,
prompt: prompt,
conf: conf,
- input: ui.NewTextInput("", conf.Ui).Password(true).Prompt("Password: "),
+ input: ui.NewTextInput("", &conf.Ui).Password(true).Prompt("Password: "),
}
getpasswd.input.OnInvalidate(func(_ ui.Drawable) {
getpasswd.Invalidate()
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index d88785c..24ea2fe 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -37,7 +37,7 @@ type MessageViewer struct {
grid *ui.Grid
switcher *PartSwitcher
msg lib.MessageView
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
type PartSwitcher struct {
@@ -523,7 +523,7 @@ type PartViewer struct {
source io.Reader
term *Terminal
grid *ui.Grid
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
links []string
}
@@ -837,7 +837,7 @@ type HeaderView struct {
Name string
Value string
ValueField ui.Drawable
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
func (hv *HeaderView) Draw(ctx *ui.Context) {
diff --git a/widgets/pgpinfo.go b/widgets/pgpinfo.go
index 078991c..3dd3fbb 100644
--- a/widgets/pgpinfo.go
+++ b/widgets/pgpinfo.go
@@ -14,10 +14,10 @@ import (
type PGPInfo struct {
ui.Invalidatable
details *models.MessageDetails
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
-func NewPGPInfo(details *models.MessageDetails, uiConfig config.UIConfig) *PGPInfo {
+func NewPGPInfo(details *models.MessageDetails, uiConfig *config.UIConfig) *PGPInfo {
return &PGPInfo{details: details, uiConfig: uiConfig}
}
diff --git a/widgets/selector.go b/widgets/selector.go
index 3eda06e..ea1dd97 100644
--- a/widgets/selector.go
+++ b/widgets/selector.go
@@ -16,13 +16,13 @@ type Selector struct {
focused bool
focus int
options []string
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
onChoose func(option string)
onSelect func(option string)
}
-func NewSelector(options []string, focus int, uiConfig config.UIConfig) *Selector {
+func NewSelector(options []string, focus int, uiConfig *config.UIConfig) *Selector {
return &Selector{
focus: focus,
options: options,
@@ -171,12 +171,12 @@ type SelectorDialog struct {
callback func(string, error)
title string
prompt string
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
selector *Selector
}
func NewSelectorDialog(title string, prompt string, options []string, focus int,
- uiConfig config.UIConfig, cb func(string, error)) *SelectorDialog {
+ uiConfig *config.UIConfig, cb func(string, error)) *SelectorDialog {
sd := &SelectorDialog{
callback: cb,
title: title,
diff --git a/widgets/status.go b/widgets/status.go
index 9944e0d..c5559d3 100644
--- a/widgets/status.go
+++ b/widgets/status.go
@@ -108,7 +108,7 @@ func (status *StatusLine) Expire() {
status.stack = nil
}
-func (status *StatusLine) uiConfig() config.UIConfig {
+func (status *StatusLine) uiConfig() *config.UIConfig {
return status.aerc.SelectedAccountUiConfig()
}