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:
Tim Culverhouse 2022-10-07 11:00:31 -05:00 committed by Robin Jarry
parent 34014d3cee
commit ba24e92062
41 changed files with 76 additions and 303 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/emersion/go-message/mail"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -64,7 +65,7 @@ func (Compose) Execute(aerc *widgets.Aerc, args []string) error {
} else {
tab.Name = subject
}
tab.Content.Invalidate()
ui.Invalidate()
})
go func() {
defer logging.PanicHandler()

View File

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/widgets"
)
@ -34,13 +35,13 @@ func (NextPrevResult) Execute(aerc *widgets.Aerc, args []string) error {
if store != nil {
store.PrevResult()
}
acct.Messages().Invalidate()
ui.Invalidate()
} else {
store := acct.Store()
if store != nil {
store.NextResult()
}
acct.Messages().Invalidate()
ui.Invalidate()
}
return nil
}

View File

@ -6,6 +6,7 @@ import (
"strconv"
"strings"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/widgets"
)
@ -65,13 +66,13 @@ func ExecuteNextPrevMessage(args []string, acct *widgets.AccountView, pct bool,
store := acct.Store()
if store != nil {
store.NextPrev(-n)
acct.Messages().Invalidate()
ui.Invalidate()
}
} else {
store := acct.Store()
if store != nil {
store.NextPrev(n)
acct.Messages().Invalidate()
ui.Invalidate()
}
}
return nil

View File

@ -8,6 +8,7 @@ import (
"path/filepath"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -110,7 +111,7 @@ func (Recover) Execute(aerc *widgets.Aerc, args []string) error {
tab := aerc.NewTab(composer, "Recovered")
composer.OnHeaderChange("Subject", func(subject string) {
tab.Name = subject
tab.Content.Invalidate()
ui.Invalidate()
})
go func() {
defer logging.PanicHandler()

View File

@ -5,6 +5,7 @@ import (
"strings"
"git.sr.ht/~rjarry/aerc/lib/statusline"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@ -54,7 +55,7 @@ func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
logging.Infof("Search results: %v", uids)
store.ApplySearch(uids)
// TODO: Remove when stores have multiple OnUpdate handlers
acct.Messages().Invalidate()
ui.Invalidate()
}
store.Search(args, cb)
}

View File

@ -9,6 +9,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -117,7 +118,7 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
if next == nil {
aerc.RemoveTab(h.msgProvider)
acct.Messages().Select(-1)
acct.Messages().Invalidate()
ui.Invalidate()
return
}
lib.NewMessageStoreView(next, mv.MessageView().SeenFlagSet(),

View File

@ -5,6 +5,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
@ -60,7 +61,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
if next == nil {
aerc.RemoveTab(h.msgProvider)
acct.Messages().Select(-1)
acct.Messages().Invalidate()
ui.Invalidate()
return
}
lib.NewMessageStoreView(next, mv.MessageView().SeenFlagSet(),

View File

@ -14,6 +14,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/format"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -117,7 +118,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
} else {
tab.Name = subject
}
tab.Content.Invalidate()
ui.Invalidate()
})
return composer, nil
}

View File

@ -8,6 +8,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/calendar"
"git.sr.ht/~rjarry/aerc/lib/format"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -167,7 +168,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
} else {
tab.Name = subject
}
tab.Content.Invalidate()
ui.Invalidate()
})
composer.OnClose(func(c *widgets.Composer) {

View File

@ -13,6 +13,7 @@ import (
"github.com/pkg/errors"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -93,7 +94,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
} else {
tab.Name = subject
}
tab.Content.Invalidate()
ui.Invalidate()
})
composer.OnClose(func(composer *widgets.Composer) {
worker := composer.Worker()

View File

@ -13,6 +13,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/crypto"
"git.sr.ht/~rjarry/aerc/lib/format"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -194,7 +195,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
} else {
tab.Name = subject
}
tab.Content.Invalidate()
ui.Invalidate()
})
composer.OnClose(func(c *widgets.Composer) {

View File

@ -4,6 +4,7 @@ import (
"errors"
"git.sr.ht/~rjarry/aerc/lib/statusline"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/widgets"
)
@ -36,6 +37,6 @@ func (ToggleThreads) Execute(aerc *widgets.Aerc, args []string) error {
}
store.SetThreadedView(!store.ThreadedView())
acct.SetStatus(statusline.Threading(store.ThreadedView()))
acct.Messages().Invalidate()
ui.Invalidate()
return nil
}

View File

@ -9,6 +9,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/widgets"
@ -168,7 +169,7 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error {
} else {
tab.Name = subject
}
tab.Content.Invalidate()
ui.Invalidate()
})
composer.FocusTerminal()
return nil

View File

@ -5,6 +5,7 @@ import (
"github.com/riywo/loginshell"
"git.sr.ht/~rjarry/aerc/lib/ui"
"git.sr.ht/~rjarry/aerc/widgets"
)
@ -41,7 +42,7 @@ func TermCore(aerc *widgets.Aerc, args []string) error {
title = args[1]
}
tab.Name = title
tab.Content.Invalidate()
ui.Invalidate()
}
term.OnClose = func(err error) {
aerc.RemoveTab(term)

View File

@ -14,7 +14,6 @@ const (
)
type Bordered struct {
Invalidatable
borders uint
content Drawable
uiConfig *config.UIConfig
@ -28,20 +27,15 @@ func NewBordered(
content: content,
uiConfig: uiConfig,
}
content.OnInvalidate(b.contentInvalidated)
return b
}
func (bordered *Bordered) contentInvalidated(d Drawable) {
bordered.Invalidate()
}
func (bordered *Bordered) Children() []Drawable {
return []Drawable{bordered.content}
}
func (bordered *Bordered) Invalidate() {
bordered.DoInvalidate(bordered)
Invalidate()
}
func (bordered *Bordered) Draw(ctx *Context) {

View File

@ -21,10 +21,6 @@ func (f Fill) Draw(ctx *Context) {
}
}
func (f Fill) OnInvalidate(callback func(d Drawable)) {
// no-op
}
func (f Fill) Invalidate() {
// no-op
}

View File

@ -1,21 +1,17 @@
package ui
import (
"fmt"
"math"
"sync"
"sync/atomic"
"github.com/gdamore/tcell/v2"
)
type Grid struct {
Invalidatable
rows []GridSpec
rowLayout []gridLayout
columns []GridSpec
columnLayout []gridLayout
invalid bool
// Protected by mutex
cells []*GridCell
@ -51,11 +47,10 @@ type GridCell struct {
RowSpan int
ColSpan int
Content Drawable
invalid atomic.Value // bool
}
func NewGrid() *Grid {
return &Grid{invalid: true}
return &Grid{}
}
// MakeGrid creates a grid with the specified number of columns and rows. Each
@ -95,19 +90,12 @@ func (grid *Grid) Columns(spec []GridSpec) *Grid {
}
func (grid *Grid) Draw(ctx *Context) {
invalid := grid.invalid
if invalid {
grid.reflow(ctx)
}
grid.reflow(ctx)
grid.mutex.RLock()
defer grid.mutex.RUnlock()
for _, cell := range grid.cells {
cellInvalid := cell.invalid.Load().(bool)
if !cellInvalid && !invalid {
continue
}
rows := grid.rowLayout[cell.Row : cell.Row+cell.RowSpan]
cols := grid.columnLayout[cell.Column : cell.Column+cell.ColSpan]
x := cols[0].Offset
@ -142,16 +130,11 @@ func (grid *Grid) Draw(ctx *Context) {
func (grid *Grid) MouseEvent(localX int, localY int, event tcell.Event) {
if event, ok := event.(*tcell.EventMouse); ok {
invalid := grid.invalid
grid.mutex.RLock()
defer grid.mutex.RUnlock()
for _, cell := range grid.cells {
cellInvalid := cell.invalid.Load().(bool)
if !cellInvalid && !invalid {
continue
}
rows := grid.rowLayout[cell.Row : cell.Row+cell.RowSpan]
cols := grid.columnLayout[cell.Column : cell.Column+cell.ColSpan]
x := cols[0].Offset
@ -220,23 +203,10 @@ func (grid *Grid) reflow(ctx *Context) {
}
flow(&grid.rows, &grid.rowLayout, ctx.Height())
flow(&grid.columns, &grid.columnLayout, ctx.Width())
grid.invalid = false
}
func (grid *Grid) invalidateLayout() {
grid.invalid = true
grid.DoInvalidate(grid)
}
func (grid *Grid) Invalidate() {
grid.invalidateLayout()
grid.mutex.RLock()
for _, cell := range grid.cells {
if cell.Content != nil {
cell.Content.Invalidate()
}
}
grid.mutex.RUnlock()
Invalidate()
}
func (grid *Grid) AddChild(content Drawable) *GridCell {
@ -248,9 +218,7 @@ func (grid *Grid) AddChild(content Drawable) *GridCell {
grid.mutex.Lock()
grid.cells = append(grid.cells, cell)
grid.mutex.Unlock()
cell.Content.OnInvalidate(grid.cellInvalidated)
cell.invalid.Store(true)
grid.invalidateLayout()
grid.Invalidate()
return cell
}
@ -263,24 +231,7 @@ func (grid *Grid) RemoveChild(content Drawable) {
}
}
grid.mutex.Unlock()
grid.invalidateLayout()
}
func (grid *Grid) cellInvalidated(drawable Drawable) {
var cell *GridCell
grid.mutex.RLock()
for _, cell = range grid.cells {
if cell.Content == drawable {
break
}
cell = nil
}
grid.mutex.RUnlock()
if cell == nil {
panic(fmt.Errorf("Attempted to invalidate unknown cell"))
}
cell.invalid.Store(true)
grid.DoInvalidate(grid)
grid.Invalidate()
}
func Const(i int) func() int {

View File

@ -12,10 +12,7 @@ type AercMsg interface{}
type Drawable interface {
// Called when this renderable should draw itself.
Draw(ctx *Context)
// Specifies a function to call when this cell needs to be redrawn. The
// callback may be called in any goroutine.
OnInvalidate(callback func(d Drawable))
// Invalidates the drawable. This can be called from any goroutine.
// Invalidates the UI. This can be called from any goroutine.
Invalidate()
}

View File

@ -1,17 +0,0 @@
package ui
import (
"sync/atomic"
)
type Invalidatable struct {
onInvalidate atomic.Value
}
func (i *Invalidatable) OnInvalidate(f func(d Drawable)) {
i.onInvalidate.Store(f)
}
func (i *Invalidatable) DoInvalidate(d Drawable) {
atomic.StoreInt32(&dirty, DIRTY)
}

View File

@ -53,11 +53,5 @@ func (p *Popover) Focus(f bool) {
}
func (p *Popover) Invalidate() {
p.content.Invalidate()
}
func (p *Popover) OnInvalidate(f func(Drawable)) {
p.content.OnInvalidate(func(_ Drawable) {
f(p)
})
Invalidate()
}

View File

@ -9,9 +9,8 @@ import (
)
type Stack struct {
children []Drawable
onInvalidate []func(d Drawable)
uiConfig config.UIConfig
children []Drawable
uiConfig config.UIConfig
}
func NewStack(uiConfig config.UIConfig) *Stack {
@ -22,14 +21,8 @@ func (stack *Stack) Children() []Drawable {
return stack.children
}
func (stack *Stack) OnInvalidate(onInvalidate func(d Drawable)) {
stack.onInvalidate = append(stack.onInvalidate, onInvalidate)
}
func (stack *Stack) Invalidate() {
for _, fn := range stack.onInvalidate {
fn(stack)
}
Invalidate()
}
func (stack *Stack) Draw(ctx *Context) {
@ -50,11 +43,7 @@ func (stack *Stack) MouseEvent(localX int, localY int, event tcell.Event) {
}
func (stack *Stack) Push(d Drawable) {
if len(stack.children) != 0 {
stack.Peek().OnInvalidate(nil)
}
stack.children = append(stack.children, d)
d.OnInvalidate(stack.invalidateFromChild)
stack.Invalidate()
}
@ -65,10 +54,6 @@ func (stack *Stack) Pop() Drawable {
d := stack.children[len(stack.children)-1]
stack.children = stack.children[:len(stack.children)-1]
stack.Invalidate()
d.OnInvalidate(nil)
if len(stack.children) != 0 {
stack.Peek().OnInvalidate(stack.invalidateFromChild)
}
return d
}
@ -78,7 +63,3 @@ func (stack *Stack) Peek() Drawable {
}
return stack.children[len(stack.children)-1]
}
func (stack *Stack) invalidateFromChild(d Drawable) {
stack.Invalidate()
}

View File

@ -20,9 +20,6 @@ type Tabs struct {
uiConfig *config.UIConfig
onInvalidateStrip func(d Drawable) //nolint:structcheck // used within this file
onInvalidateContent func(d Drawable)
parent *Tabs //nolint:structcheck // used within this file
CloseTab func(index int)
}
@ -59,7 +56,6 @@ func (tabs *Tabs) Add(content Drawable, name string, uiConf *config.UIConfig) *T
}
tabs.tabs = append(tabs.tabs, tab)
tabs.selectPriv(len(tabs.tabs) - 1)
content.OnInvalidate(tabs.invalidateChild)
return tab
}
@ -73,18 +69,6 @@ func (tabs *Tabs) Names() []string {
return names
}
func (tabs *Tabs) invalidateChild(d Drawable) {
if tabs.curIndex >= len(tabs.tabs) {
return
}
if tabs.tabs[tabs.curIndex].Content == d {
if tabs.onInvalidateContent != nil {
tabs.onInvalidateContent(tabs.TabContent)
}
}
}
func (tabs *Tabs) Remove(content Drawable) {
tabs.m.Lock()
defer tabs.m.Unlock()
@ -133,8 +117,7 @@ func (tabs *Tabs) Replace(contentSrc Drawable, contentTarget Drawable, name stri
break
}
}
tabs.TabStrip.Invalidate()
contentTarget.OnInvalidate(tabs.invalidateChild)
Invalidate()
}
func (tabs *Tabs) Get(index int) *Tab {
@ -172,8 +155,7 @@ func (tabs *Tabs) selectPriv(index int) bool {
tabs.pushHistory(tabs.curIndex)
}
tabs.curIndex = index
tabs.TabStrip.Invalidate()
tabs.TabContent.Invalidate()
Invalidate()
}
return true
}
@ -246,7 +228,7 @@ func (tabs *Tabs) moveTabPriv(to int, relative bool) {
tabs.tabs[to] = tab
tabs.curIndex = to
tabs.TabStrip.Invalidate()
Invalidate()
}
func (tabs *Tabs) PinTab() {
@ -384,9 +366,7 @@ func (strip *TabStrip) Draw(ctx *Context) {
}
func (strip *TabStrip) Invalidate() {
if strip.onInvalidateStrip != nil {
strip.onInvalidateStrip(strip)
}
Invalidate()
}
func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
@ -440,10 +420,6 @@ func (strip *TabStrip) MouseEvent(localX int, localY int, event tcell.Event) {
}
}
func (strip *TabStrip) OnInvalidate(onInvalidate func(d Drawable)) {
strip.onInvalidateStrip = onInvalidate
}
func (strip *TabStrip) clicked(mouseX int, mouseY int) (int, bool) {
x := 0
for i, tab := range strip.tabs {
@ -490,13 +466,5 @@ func (content *TabContent) MouseEvent(localX int, localY int, event tcell.Event)
}
func (content *TabContent) Invalidate() {
if content.onInvalidateContent != nil {
content.onInvalidateContent(content)
}
tab := content.tabs[content.curIndex]
tab.Content.Invalidate()
}
func (content *TabContent) OnInvalidate(onInvalidate func(d Drawable)) {
content.onInvalidateContent = onInvalidate
Invalidate()
}

View File

@ -12,7 +12,6 @@ const (
)
type Text struct {
Invalidatable
text string
strategy uint
style tcell.Style
@ -51,5 +50,5 @@ func (t *Text) Draw(ctx *Context) {
}
func (t *Text) Invalidate() {
t.DoInvalidate(t)
Invalidate()
}

View File

@ -17,7 +17,6 @@ import (
// TODO: scrolling
type TextInput struct {
Invalidatable
sync.Mutex
cells int
ctx *Context
@ -90,7 +89,7 @@ func (ti *TextInput) Set(value string) *TextInput {
}
func (ti *TextInput) Invalidate() {
ti.DoInvalidate(ti)
Invalidate()
}
func (ti *TextInput) Draw(ctx *Context) {
@ -530,5 +529,3 @@ func findStem(words []string) string {
func (c *completions) Focus(_ bool) {}
func (c *completions) Invalidate() {}
func (c *completions) OnInvalidate(_ func(Drawable)) {}

View File

@ -122,7 +122,7 @@ func (state *UI) HandleEvent(event tcell.Event) {
state.screen.Clear()
width, height := event.Size()
state.ctx = NewContext(width, height, state.screen, state.onPopover)
state.Content.Invalidate()
Invalidate()
}
// if we have a popover, and it can handle the event, it does so
if state.popover == nil || !state.popover.Event(event) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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) {

View File

@ -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 {

View File

@ -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 {

View File

@ -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) {

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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 {

View File

@ -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()
}

View File

@ -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) {

View File

@ -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) {