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>
This commit is contained in:
parent
12e8217d1f
commit
d45c07eb6a
15 changed files with 48 additions and 48 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue