From fff69046b02f3d9ea0218ff071ba5e4d5b3a3c12 Mon Sep 17 00:00:00 2001 From: Aron Lebani Date: Fri, 2 Aug 2024 09:59:33 +1000 Subject: view-message: add option to view message in background tab Add a -b flag to the :view command to open messages in a background tab instead of automatically switching to the new tab after opening. This is similar to opening browser tabs in the background. More generally, adds a new function app.NewBackgroundTab so that it is possible to enable other tabs to be opened in the background in the future. Implements: https://todo.sr.ht/~rjarry/aerc/266 Changelog-added: Add `-b` flag to the `:view` command to open messages in a background tab. Signed-off-by: Aron Lebani Acked-by: Robin Jarry --- commands/account/view.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'commands/account') diff --git a/commands/account/view.go b/commands/account/view.go index 9fa531b7..58450044 100644 --- a/commands/account/view.go +++ b/commands/account/view.go @@ -13,7 +13,8 @@ import ( ) type ViewMessage struct { - Peek bool `opt:"-p"` + Peek bool `opt:"-p"` + Background bool `opt:"-b"` } func init() { @@ -49,8 +50,12 @@ func (v ViewMessage) Execute(args []string) error { app.PushError(msg.Error.Error()) return nil } - lib.NewMessageStoreView(msg, !v.Peek && acct.UiConfig().AutoMarkRead, - store, app.CryptoProvider(), app.DecryptKeys, + lib.NewMessageStoreView( + msg, + !v.Peek && acct.UiConfig().AutoMarkRead, + store, + app.CryptoProvider(), + app.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { app.PushError(err.Error()) @@ -68,7 +73,11 @@ func (v ViewMessage) Execute(args []string) error { acct.PushError(err) return } - app.NewTab(viewer, buf.String()) + if v.Background { + app.NewBackgroundTab(viewer, buf.String()) + } else { + app.NewTab(viewer, buf.String()) + } }) return nil } -- cgit