diff options
author | Jason Cox <me@jasoncarloscox.com> | 2024-02-29 22:21:30 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-03-04 22:33:15 +0100 |
commit | 6a84f1331f1c18dccfbe58601a4243995ac5c7d2 (patch) | |
tree | bd99fb962ad5824b14aa8db82aed3c0b909c67d7 | |
parent | 2453375721832304b512380e6610de2c3d765bd5 (diff) | |
download | aerc-6a84f1331f1c18dccfbe58601a4243995ac5c7d2.tar.gz |
templates: add visual mode indicator to TrayInfo
It's useful to have some indicator of whether or not aerc is in visual
mark mode. Add such an indicator to the TrayInfo available in the status
line.
Changelog-changed: The `TrayInfo` template variable now includes a
visual mark mode indicator.
Signed-off-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | app/status.go | 3 | ||||
-rw-r--r-- | doc/aerc-templates.7.scd | 4 | ||||
-rw-r--r-- | lib/marker/marker.go | 6 | ||||
-rw-r--r-- | lib/state/templates.go | 9 | ||||
-rw-r--r-- | lib/state/texter.go | 9 |
5 files changed, 29 insertions, 2 deletions
diff --git a/app/status.go b/app/status.go index a0cf5e6f..846e0e4e 100644 --- a/app/status.go +++ b/app/status.go @@ -56,6 +56,9 @@ func (status *StatusLine) Draw(ctx *ui.Context) { msg, _ := status.acct.SelectedMessage() data.SetInfo(msg, 0, false) data.SetRUE(status.acct.dirlist.List(), status.acct.dirlist.GetRUECount) + if store := status.acct.Store(); store != nil { + data.SetVisual(store.Marker().IsVisualMark()) + } table := ui.NewTable( ctx.Height(), config.Statusline.StatusColumns, diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd index d0cb0f6e..71acc6b1 100644 --- a/doc/aerc-templates.7.scd +++ b/doc/aerc-templates.7.scd @@ -261,8 +261,8 @@ available always. {{.StatusInfo}} ``` - General on/off information (e.g. passthrough, threading, sorting), - separated with *[statusline].separator*. + General on/off information (e.g. passthrough, threading, sorting, visual + mode), separated with *[statusline].separator*. ``` {{.TrayInfo}} diff --git a/lib/marker/marker.go b/lib/marker/marker.go index 21c151f3..a0860be9 100644 --- a/lib/marker/marker.go +++ b/lib/marker/marker.go @@ -8,6 +8,7 @@ type Marker interface { Remark() Marked() []uint32 IsMarked(uint32) bool + IsVisualMark() bool ToggleVisualMark(bool) UpdateVisualMark() ClearVisualMark() @@ -114,6 +115,11 @@ func (mc *controller) Marked() []uint32 { return marked } +// IsVisualMark indicates whether visual marking mode is enabled. +func (mc *controller) IsVisualMark() bool { + return mc.visualMarkMode +} + // ToggleVisualMark enters or leaves the visual marking mode func (mc *controller) ToggleVisualMark(clear bool) { mc.visualMarkMode = !mc.visualMarkMode diff --git a/lib/state/templates.go b/lib/state/templates.go index e1570cd3..37767660 100644 --- a/lib/state/templates.go +++ b/lib/state/templates.go @@ -27,6 +27,7 @@ type DataSetter interface { Data() models.TemplateData SetHeaders(*mail.Header, *models.OriginalMail) SetInfo(*models.MessageInfo, int, bool) + SetVisual(bool) SetThreading(string, bool, int, int, bool, bool) SetComposer(Composer) SetAccount(*config.AccountConfig) @@ -54,6 +55,7 @@ type templateData struct { info *models.MessageInfo marked bool msgNum int + visual bool // message list threading threadInfo ThreadInfo @@ -94,6 +96,10 @@ func (d *templateData) SetInfo(info *models.MessageInfo, num int, marked bool, d.marked = marked } +func (d *templateData) SetVisual(visual bool) { + d.visual = visual +} + func (d *templateData) SetThreading(prefix string, same bool, count int, unread int, folded bool, context bool, ) { @@ -624,6 +630,9 @@ func (d *templateData) TrayInfo() string { if d.state.passthrough { tray = append(tray, texter().Passthrough()) } + if d.visual { + tray = append(tray, texter().Visual()) + } return strings.Join(tray, config.Statusline.Separator) } diff --git a/lib/state/texter.go b/lib/state/texter.go index 9212108d..f51d4d33 100644 --- a/lib/state/texter.go +++ b/lib/state/texter.go @@ -12,6 +12,7 @@ type texterInterface interface { Passthrough() string Sorting() string Threading() string + Visual() string FormatFilter(string) string FormatSearch(string) string } @@ -40,6 +41,10 @@ func (t text) Threading() string { return "threading" } +func (t text) Visual() string { + return "visual" +} + func (t text) FormatFilter(s string) string { return s } @@ -72,6 +77,10 @@ func (i icon) Threading() string { return "๐งต" } +func (i icon) Visual() string { + return "๐ถ" +} + func (i icon) FormatFilter(s string) string { return strings.ReplaceAll(s, "filter", "๐ฆ") } |