aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-10-07 11:00:31 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-12 22:16:40 +0200
commitba24e92062f1a9b38065d503fd1dde749c27a56c (patch)
treed1a2981f8f9bda50a070b50c688388fe2130f770 /widgets
parent34014d3ceeebe8a9c131213fa56d1977fbc26b4a (diff)
downloadaerc-ba24e92062f1a9b38065d503fd1dde749c27a56c.tar.gz
invalidatable: cleanup dead code
Remove invalidatable type and all associated calls. All items can directly invalidate the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account-wizard.go15
-rw-r--r--widgets/account.go8
-rw-r--r--widgets/aerc.go15
-rw-r--r--widgets/authinfo.go3
-rw-r--r--widgets/compose.go35
-rw-r--r--widgets/dirlist.go3
-rw-r--r--widgets/exline.go9
-rw-r--r--widgets/getpasswd.go6
-rw-r--r--widgets/listbox.go3
-rw-r--r--widgets/msglist.go6
-rw-r--r--widgets/msgviewer.go31
-rw-r--r--widgets/pgpinfo.go3
-rw-r--r--widgets/selector.go9
-rw-r--r--widgets/spinner.go3
-rw-r--r--widgets/status.go3
-rw-r--r--widgets/terminal.go3
16 files changed, 27 insertions, 128 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go
index 4856c608..b6e0a5e4 100644
--- a/widgets/account-wizard.go
+++ b/widgets/account-wizard.go
@@ -40,7 +40,6 @@ const (
)
type AccountWizard struct {
- ui.Invalidatable
aerc *Aerc
conf *config.AercConfig
step int
@@ -224,9 +223,6 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
wizard.basics = []ui.Interactive{
wizard.accountName, wizard.fullName, wizard.email, selector,
}
- basics.OnInvalidate(func(_ ui.Drawable) {
- wizard.Invalidate()
- })
incoming := ui.NewGrid().Rows([]ui.GridSpec{
{Strategy: ui.SIZE_EXACT, Size: ui.Const(3)}, // Introduction
@@ -303,9 +299,6 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
wizard.imapUsername, wizard.imapPassword, wizard.imapServer,
imapMode, selector,
}
- incoming.OnInvalidate(func(_ ui.Drawable) {
- wizard.Invalidate()
- })
outgoing := ui.NewGrid().Rows([]ui.GridSpec{
{Strategy: ui.SIZE_EXACT, Size: ui.Const(3)}, // Introduction
@@ -399,9 +392,6 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
wizard.smtpUsername, wizard.smtpPassword, wizard.smtpServer,
smtpMode, copySent, selector,
}
- outgoing.OnInvalidate(func(_ ui.Drawable) {
- wizard.Invalidate()
- })
complete := ui.NewGrid().Rows([]ui.GridSpec{
{Strategy: ui.SIZE_EXACT, Size: ui.Const(7)}, // Introduction
@@ -431,9 +421,6 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
})
complete.AddChild(selector).At(1, 0)
wizard.complete = []ui.Interactive{selector}
- complete.OnInvalidate(func(_ ui.Drawable) {
- wizard.Invalidate()
- })
wizard.steps = []*ui.Grid{basics, incoming, outgoing, complete}
return wizard
@@ -665,7 +652,7 @@ func (wizard *AccountWizard) smtpUri() url.URL {
}
func (wizard *AccountWizard) Invalidate() {
- wizard.DoInvalidate(wizard)
+ ui.Invalidate()
}
func (wizard *AccountWizard) Draw(ctx *ui.Context) {
diff --git a/widgets/account.go b/widgets/account.go
index 93a75973..cafc29de 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -143,14 +143,8 @@ func (acct *AccountView) Name() string {
return acct.acct.Name
}
-func (acct *AccountView) OnInvalidate(onInvalidate func(d ui.Drawable)) {
- acct.grid.OnInvalidate(func(_ ui.Drawable) {
- onInvalidate(acct)
- })
-}
-
func (acct *AccountView) Invalidate() {
- acct.grid.Invalidate()
+ ui.Invalidate()
}
func (acct *AccountView) Draw(ctx *ui.Context) {
diff --git a/widgets/aerc.go b/widgets/aerc.go
index b396cf5e..56972771 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -152,14 +152,8 @@ func (aerc *Aerc) HandleMessage(msg types.WorkerMessage) {
}
}
-func (aerc *Aerc) OnInvalidate(onInvalidate func(d ui.Drawable)) {
- aerc.grid.OnInvalidate(func(_ ui.Drawable) {
- onInvalidate(aerc)
- })
-}
-
func (aerc *Aerc) Invalidate() {
- aerc.grid.Invalidate()
+ ui.Invalidate()
}
func (aerc *Aerc) Focus(focus bool) {
@@ -304,7 +298,7 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
Key: event.Key(),
Rune: event.Rune(),
})
- aerc.statusline.Invalidate()
+ ui.Invalidate()
bindings := aerc.getBindings()
incomplete := false
result, strokes := bindings.GetBinding(aerc.pendingKeys)
@@ -724,7 +718,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
} else {
tab.Name = subject
}
- tab.Content.Invalidate()
+ ui.Invalidate()
})
return nil
}
@@ -775,9 +769,6 @@ func (aerc *Aerc) CloseBackends() error {
func (aerc *Aerc) AddDialog(d ui.DrawableInteractive) {
aerc.dialog = d
- aerc.dialog.OnInvalidate(func(_ ui.Drawable) {
- aerc.Invalidate()
- })
aerc.Invalidate()
}
diff --git a/widgets/authinfo.go b/widgets/authinfo.go
index a57d8a13..2b406a7a 100644
--- a/widgets/authinfo.go
+++ b/widgets/authinfo.go
@@ -11,7 +11,6 @@ import (
)
type AuthInfo struct {
- ui.Invalidatable
authdetails *auth.Details
showInfo bool
uiConfig *config.UIConfig
@@ -85,5 +84,5 @@ func (a *AuthInfo) Draw(ctx *ui.Context) {
}
func (a *AuthInfo) Invalidate() {
- a.DoInvalidate(a)
+ ui.Invalidate()
}
diff --git a/widgets/compose.go b/widgets/compose.go
index 9b8b30cb..06452230 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -127,7 +127,6 @@ func (c *Composer) SwitchAccount(newAcct *AccountView) error {
editor.loadValue()
}
c.Invalidate()
- c.aerc.Invalidate()
logging.Infof("account sucessfully switched")
return nil
}
@@ -567,13 +566,7 @@ func (c *Composer) Draw(ctx *ui.Context) {
}
func (c *Composer) Invalidate() {
- c.grid.Invalidate()
-}
-
-func (c *Composer) OnInvalidate(fn func(d ui.Drawable)) {
- c.grid.OnInvalidate(func(_ ui.Drawable) {
- fn(c)
- })
+ ui.Invalidate()
}
func (c *Composer) Close() {
@@ -1107,7 +1100,7 @@ func extractHumanHeaderValue(key string, h *mail.Header) string {
// decoding issues are ignored and return their raw values
func (he *headerEditor) loadValue() {
he.input.Set(extractHumanHeaderValue(he.name, he.header))
- he.input.Invalidate()
+ ui.Invalidate()
}
// storeValue writes the current state back to the underlying header.
@@ -1159,13 +1152,7 @@ func (he *headerEditor) MouseEvent(localX int, localY int, event tcell.Event) {
}
func (he *headerEditor) Invalidate() {
- he.input.Invalidate()
-}
-
-func (he *headerEditor) OnInvalidate(fn func(ui.Drawable)) {
- he.input.OnInvalidate(func(_ ui.Drawable) {
- fn(he)
- })
+ ui.Invalidate()
}
func (he *headerEditor) Focus(focused bool) {
@@ -1301,13 +1288,7 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
}
func (rm *reviewMessage) Invalidate() {
- rm.grid.Invalidate()
-}
-
-func (rm *reviewMessage) OnInvalidate(fn func(ui.Drawable)) {
- rm.grid.OnInvalidate(func(_ ui.Drawable) {
- fn(rm)
- })
+ ui.Invalidate()
}
func (rm *reviewMessage) Draw(ctx *ui.Context) {
@@ -1344,13 +1325,7 @@ func (cs *cryptoStatus) Draw(ctx *ui.Context) {
}
func (cs *cryptoStatus) Invalidate() {
- cs.status.Invalidate()
-}
-
-func (cs *cryptoStatus) OnInvalidate(fn func(ui.Drawable)) {
- cs.status.OnInvalidate(func(_ ui.Drawable) {
- fn(cs)
- })
+ ui.Invalidate()
}
func (c *Composer) checkEncryptionKeys(_ string) bool {
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 0f86a081..70550394 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -48,7 +48,6 @@ type DirectoryLister interface {
}
type DirectoryList struct {
- ui.Invalidatable
sync.Mutex
Scrollable
aercConf *config.AercConfig
@@ -199,7 +198,7 @@ func (dirlist *DirectoryList) Selected() string {
}
func (dirlist *DirectoryList) Invalidate() {
- dirlist.DoInvalidate(dirlist)
+ ui.Invalidate()
}
func (dirlist *DirectoryList) getDirString(name string, width int, recentUnseen func() string) string {
diff --git a/widgets/exline.go b/widgets/exline.go
index 8d3c7ca6..789ccde8 100644
--- a/widgets/exline.go
+++ b/widgets/exline.go
@@ -9,7 +9,6 @@ import (
)
type ExLine struct {
- ui.Invalidatable
commit func(cmd string)
finish func()
tabcomplete func(cmd string) ([]string, string)
@@ -34,9 +33,6 @@ func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), fin
input: input,
conf: conf,
}
- input.OnInvalidate(func(d ui.Drawable) {
- exline.Invalidate()
- })
return exline
}
@@ -57,14 +53,11 @@ func NewPrompt(conf *config.AercConfig, prompt string, commit func(text string),
cmdHistory: &nullHistory{input: input},
input: input,
}
- input.OnInvalidate(func(d ui.Drawable) {
- exline.Invalidate()
- })
return exline
}
func (ex *ExLine) Invalidate() {
- ex.DoInvalidate(ex)
+ ui.Invalidate()
}
func (ex *ExLine) Draw(ctx *ui.Context) {
diff --git a/widgets/getpasswd.go b/widgets/getpasswd.go
index e6de75e1..70a2648d 100644
--- a/widgets/getpasswd.go
+++ b/widgets/getpasswd.go
@@ -10,7 +10,6 @@ import (
)
type GetPasswd struct {
- ui.Invalidatable
callback func(string, error)
title string
prompt string
@@ -28,9 +27,6 @@ func NewGetPasswd(title string, prompt string, conf *config.AercConfig,
conf: conf,
input: ui.NewTextInput("", &conf.Ui).Password(true).Prompt("Password: "),
}
- getpasswd.input.OnInvalidate(func(_ ui.Drawable) {
- getpasswd.Invalidate()
- })
getpasswd.input.Focus(true)
return getpasswd
}
@@ -47,7 +43,7 @@ func (gp *GetPasswd) Draw(ctx *ui.Context) {
}
func (gp *GetPasswd) Invalidate() {
- gp.DoInvalidate(gp)
+ ui.Invalidate()
}
func (gp *GetPasswd) Event(event tcell.Event) bool {
diff --git a/widgets/listbox.go b/widgets/listbox.go
index 2723ae37..d1f1b252 100644
--- a/widgets/listbox.go
+++ b/widgets/listbox.go
@@ -13,7 +13,6 @@ import (
type ListBox struct {
Scrollable
- ui.Invalidatable
title string
lines []string
selected string
@@ -186,7 +185,7 @@ func (lb *ListBox) drawScrollbar(ctx *ui.Context) {
}
func (lb *ListBox) Invalidate() {
- lb.DoInvalidate(lb)
+ ui.Invalidate()
}
func (lb *ListBox) Event(event tcell.Event) bool {
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 74308ccb..7857a3d7 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -19,7 +19,6 @@ import (
)
type MessageList struct {
- ui.Invalidatable
Scrollable
conf *config.AercConfig
height int
@@ -37,16 +36,13 @@ func NewMessageList(conf *config.AercConfig, aerc *Aerc) *MessageList {
isInitalizing: true,
aerc: aerc,
}
- ml.spinner.OnInvalidate(func(_ ui.Drawable) {
- ml.Invalidate()
- })
// TODO: stop spinner, probably
ml.spinner.Start()
return ml
}
func (ml *MessageList) Invalidate() {
- ml.DoInvalidate(ml)
+ ui.Invalidate()
}
func (ml *MessageList) Draw(ctx *ui.Context) {
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 126bf85b..8904758d 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -30,7 +30,6 @@ var ansi = regexp.MustCompile("\x1B\\[[0-?]*[ -/]*[@-~]")
var _ ProvidesMessages = (*MessageViewer)(nil)
type MessageViewer struct {
- ui.Invalidatable
acct *AccountView
conf *config.AercConfig
err error
@@ -41,7 +40,6 @@ type MessageViewer struct {
}
type PartSwitcher struct {
- ui.Invalidatable
parts []*PartViewer
selected int
showHeaders bool
@@ -219,9 +217,6 @@ func createSwitcher(acct *AccountView, switcher *PartSwitcher,
return err
}
switcher.parts = []*PartViewer{pv}
- pv.OnInvalidate(func(_ ui.Drawable) {
- switcher.Invalidate()
- })
} else {
switcher.parts, err = enumerateParts(acct, conf, msg,
msg.BodyStructure(), []int{})
@@ -231,9 +226,6 @@ func createSwitcher(acct *AccountView, switcher *PartSwitcher,
selectedPriority := -1
logging.Infof("Selecting best message from %v", conf.Viewer.Alternatives)
for i, pv := range switcher.parts {
- pv.OnInvalidate(func(_ ui.Drawable) {
- switcher.Invalidate()
- })
// Switch to user's preferred mimetype
if switcher.selected == -1 && pv.part.MIMEType != "multipart" {
switcher.selected = i
@@ -273,13 +265,7 @@ func (mv *MessageViewer) MouseEvent(localX int, localY int, event tcell.Event) {
}
func (mv *MessageViewer) Invalidate() {
- mv.grid.Invalidate()
-}
-
-func (mv *MessageViewer) OnInvalidate(fn func(d ui.Drawable)) {
- mv.grid.OnInvalidate(func(_ ui.Drawable) {
- fn(mv)
- })
+ ui.Invalidate()
}
func (mv *MessageViewer) Store() *lib.MessageStore {
@@ -408,7 +394,7 @@ func (mv *MessageViewer) UpdateScreen() {
}
func (ps *PartSwitcher) Invalidate() {
- ps.DoInvalidate(ps)
+ ui.Invalidate()
}
func (ps *PartSwitcher) Focus(focus bool) {
@@ -521,7 +507,6 @@ func (mv *MessageViewer) Focus(focus bool) {
}
type PartViewer struct {
- ui.Invalidatable
conf *config.AercConfig
acctConfig *config.AccountConfig
err error
@@ -630,9 +615,6 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig,
term.OnStart = func() {
pv.attemptCopy()
}
- term.OnInvalidate(func(_ ui.Drawable) {
- pv.Invalidate()
- })
}
return pv, nil
@@ -644,9 +626,7 @@ func (pv *PartViewer) SetSource(reader io.Reader) {
}
func (pv *PartViewer) UpdateScreen() {
- if pv.term != nil {
- pv.term.Invalidate()
- }
+ pv.Invalidate()
}
func (pv *PartViewer) attemptCopy() {
@@ -840,7 +820,7 @@ What would you like to do?`, pv.part.MIMEType, pv.part.MIMESubType)
}
func (pv *PartViewer) Invalidate() {
- pv.DoInvalidate(pv)
+ ui.Invalidate()
}
func (pv *PartViewer) Draw(ctx *ui.Context) {
@@ -878,7 +858,6 @@ func (pv *PartViewer) Event(event tcell.Event) bool {
}
type HeaderView struct {
- ui.Invalidatable
conf *config.AercConfig
Name string
Value string
@@ -913,5 +892,5 @@ func (hv *HeaderView) Draw(ctx *ui.Context) {
}
func (hv *HeaderView) Invalidate() {
- hv.DoInvalidate(hv)
+ ui.Invalidate()
}
diff --git a/widgets/pgpinfo.go b/widgets/pgpinfo.go
index ee2a0266..c64bcfdf 100644
--- a/widgets/pgpinfo.go
+++ b/widgets/pgpinfo.go
@@ -12,7 +12,6 @@ import (
)
type PGPInfo struct {
- ui.Invalidatable
details *models.MessageDetails
uiConfig *config.UIConfig
}
@@ -95,5 +94,5 @@ func (p *PGPInfo) Draw(ctx *ui.Context) {
}
func (p *PGPInfo) Invalidate() {
- p.DoInvalidate(p)
+ ui.Invalidate()
}
diff --git a/widgets/selector.go b/widgets/selector.go
index 8a1a1623..66dfb8b5 100644
--- a/widgets/selector.go
+++ b/widgets/selector.go
@@ -11,7 +11,6 @@ import (
)
type Selector struct {
- ui.Invalidatable
chooser bool
focused bool
focus int
@@ -36,7 +35,7 @@ func (sel *Selector) Chooser(chooser bool) *Selector {
}
func (sel *Selector) Invalidate() {
- sel.DoInvalidate(sel)
+ ui.Invalidate()
}
func (sel *Selector) Draw(ctx *ui.Context) {
@@ -166,7 +165,6 @@ func (sel *Selector) Event(event tcell.Event) bool {
var ErrNoOptionSelected = fmt.Errorf("no option selected")
type SelectorDialog struct {
- ui.Invalidatable
callback func(string, error)
title string
prompt string
@@ -184,9 +182,6 @@ func NewSelectorDialog(title string, prompt string, options []string, focus int,
uiConfig: uiConfig,
selector: NewSelector(options, focus, uiConfig).Chooser(true),
}
- sd.selector.OnInvalidate(func(_ ui.Drawable) {
- sd.Invalidate()
- })
sd.selector.Focus(true)
return sd
}
@@ -203,7 +198,7 @@ func (gp *SelectorDialog) Draw(ctx *ui.Context) {
}
func (gp *SelectorDialog) Invalidate() {
- gp.DoInvalidate(gp)
+ ui.Invalidate()
}
func (gp *SelectorDialog) Event(event tcell.Event) bool {
diff --git a/widgets/spinner.go b/widgets/spinner.go
index 0e7c9005..34c3d82e 100644
--- a/widgets/spinner.go
+++ b/widgets/spinner.go
@@ -13,7 +13,6 @@ import (
)
type Spinner struct {
- ui.Invalidatable
frame int64 // access via atomic
frames []string
stop chan struct{}
@@ -82,5 +81,5 @@ func (s *Spinner) Draw(ctx *ui.Context) {
}
func (s *Spinner) Invalidate() {
- s.DoInvalidate(s)
+ ui.Invalidate()
}
diff --git a/widgets/status.go b/widgets/status.go
index c5559d38..d8d0328a 100644
--- a/widgets/status.go
+++ b/widgets/status.go
@@ -12,7 +12,6 @@ import (
)
type StatusLine struct {
- ui.Invalidatable
stack []*StatusMessage
fallback StatusMessage
aerc *Aerc
@@ -33,7 +32,7 @@ func NewStatusLine(uiConfig config.UIConfig) *StatusLine {
}
func (status *StatusLine) Invalidate() {
- status.DoInvalidate(status)
+ ui.Invalidate()
}
func (status *StatusLine) Draw(ctx *ui.Context) {
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 39cd9f24..e0a76ca8 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -13,7 +13,6 @@ import (
)
type Terminal struct {
- ui.Invalidatable
closed bool
cmd *exec.Cmd
ctx *ui.Context
@@ -71,7 +70,7 @@ func (term *Terminal) Destroy() {
}
func (term *Terminal) Invalidate() {
- term.DoInvalidate(term)
+ ui.Invalidate()
}
func (term *Terminal) Draw(ctx *ui.Context) {