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>
This commit is contained in:
parent
34014d3cee
commit
ba24e92062
41 changed files with 76 additions and 303 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue