diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-04-16 09:53:46 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-22 22:40:12 +0200 |
commit | d8c2d63ee9b37e78d0e06ec71b2227b83ee52aa5 (patch) | |
tree | ea71295539f16c1f696dcb2edbca1475d93298a8 /widgets | |
parent | 669431702f46eb58f893cbe722040de3792f6b03 (diff) | |
download | aerc-d8c2d63ee9b37e78d0e06ec71b2227b83ee52aa5.tar.gz |
directory: add role to template fields
Add .Role as a template field for use in distinguishing between
mailboxes with a given IANA role, or custom role defined by aerc
("query" for notmuch queries, for example).
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry<robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account.go | 2 | ||||
-rw-r--r-- | widgets/compose.go | 4 | ||||
-rw-r--r-- | widgets/dirlist.go | 2 | ||||
-rw-r--r-- | widgets/dirtree.go | 10 | ||||
-rw-r--r-- | widgets/msglist.go | 2 | ||||
-rw-r--r-- | widgets/status.go | 2 |
6 files changed, 15 insertions, 7 deletions
diff --git a/widgets/account.go b/widgets/account.go index 983c2382..a99f7a48 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -606,7 +606,7 @@ func (acct *AccountView) setTitle() { return } data.SetAccount(acct.acct) - data.SetFolder(acct.SelectedDirectory()) + data.SetFolder(acct.Directories().SelectedDirectory()) data.SetRUE(acct.dirlist.List(), acct.dirlist.GetRUECount) var buf bytes.Buffer diff --git a/widgets/compose.go b/widgets/compose.go index 3693ad18..3a960325 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -98,7 +98,7 @@ func NewComposer( var data state.TemplateData data.SetAccount(acct.acct) - data.SetFolder(acct.Directories().Selected()) + data.SetFolder(acct.Directories().SelectedDirectory()) data.SetHeaders(h, orig) if err := c.AddTemplate(template, &data); err != nil { return nil, err @@ -1589,7 +1589,7 @@ func (c *Composer) setTitle() { header.SetSubject("New Email") } data.SetAccount(c.acctConfig) - data.SetFolder(c.acct.SelectedDirectory()) + data.SetFolder(c.acct.Directories().SelectedDirectory()) data.SetHeaders(&header, c.parent) var buf bytes.Buffer diff --git a/widgets/dirlist.go b/widgets/dirlist.go index ee2acb1b..da2fa69a 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -247,7 +247,7 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) { break } - data.SetFolder(name) + data.SetFolder(dirlist.Directory(name)) data.SetRUE([]string{name}, dirlist.GetRUECount) left, right, style := dirlist.renderDir( name, uiConfig, &data, diff --git a/widgets/dirtree.go b/widgets/dirtree.go index 88e930ec..b0943ae4 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -11,6 +11,7 @@ import ( "git.sr.ht/~rjarry/aerc/lib/state" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/log" + "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/types" "github.com/gdamore/tcell/v2" ) @@ -106,7 +107,14 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) { } path := dt.getDirectory(node) - data.SetFolder(dt.displayText(node)) + dir := dt.Directory(path) + treeDir := &models.Directory{ + Name: dt.displayText(node), + } + if dir != nil { + treeDir.Role = dir.Role + } + data.SetFolder(treeDir) data.SetRUE([]string{path}, dt.GetRUECount) left, right, style := dt.renderDir( diff --git a/widgets/msglist.go b/widgets/msglist.go index 161dcadc..45d2555c 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -94,7 +94,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) { var data state.TemplateData data.SetAccount(acct.acct) - data.SetFolder(acct.Directories().Selected()) + data.SetFolder(acct.Directories().SelectedDirectory()) customDraw := func(t *ui.Table, r int, c *ui.Context) bool { row := &t.Rows[r] diff --git a/widgets/status.go b/widgets/status.go index 209348c5..9f2544c7 100644 --- a/widgets/status.go +++ b/widgets/status.go @@ -53,7 +53,7 @@ func (status *StatusLine) Draw(ctx *ui.Context) { data.SetPendingKeys(status.aerc.pendingKeys) data.SetState(&status.acct.state) data.SetAccount(status.acct.acct) - data.SetFolder(status.acct.Directories().Selected()) + data.SetFolder(status.acct.Directories().SelectedDirectory()) msg, _ := status.acct.SelectedMessage() data.SetInfo(msg, 0, false) table := ui.NewTable( |