aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 5d0402aeea1dcc69adb46227ab1cd73b5e768880
parent 04d9ab3ce6b8161ef7bc0ec4e5011f6ceadb73b6
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 30 Mar 2019 21:45:41 -0400

Add message view commands, :close

Diffstat:
Maerc.go | 6++++++
Acommands/msgview/close.go | 21+++++++++++++++++++++
Acommands/msgview/msgview.go | 16++++++++++++++++
Mcommands/terminal/close.go | 5+----
Mconfig/binds.conf | 2+-
Mwidgets/aerc.go | 2++
6 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/aerc.go b/aerc.go @@ -12,6 +12,7 @@ import ( "git.sr.ht/~sircmpwn/aerc2/config" "git.sr.ht/~sircmpwn/aerc2/commands" "git.sr.ht/~sircmpwn/aerc2/commands/account" + "git.sr.ht/~sircmpwn/aerc2/commands/msgview" "git.sr.ht/~sircmpwn/aerc2/commands/terminal" libui "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/widgets" @@ -24,6 +25,11 @@ func getCommands(selected libui.Drawable) []*commands.Commands { account.AccountCommands, commands.GlobalCommands, } + case *widgets.MessageViewer: + return []*commands.Commands{ + msgview.MessageViewCommands, + commands.GlobalCommands, + } case *widgets.Terminal: return []*commands.Commands{ terminal.TerminalCommands, diff --git a/commands/msgview/close.go b/commands/msgview/close.go @@ -0,0 +1,21 @@ +package msgview + +import ( + "errors" + + "git.sr.ht/~sircmpwn/aerc2/widgets" +) + +func init() { + register("close", CommandClose) +} + +func CommandClose(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: close") + } + mv, _ := aerc.SelectedTab().(*widgets.MessageViewer) + aerc.RemoveTab(mv) + return nil +} + diff --git a/commands/msgview/msgview.go b/commands/msgview/msgview.go @@ -0,0 +1,16 @@ +package msgview + +import ( + "git.sr.ht/~sircmpwn/aerc2/commands" +) + +var ( + MessageViewCommands *commands.Commands +) + +func register(name string, cmd commands.AercCommand) { + if MessageViewCommands == nil { + MessageViewCommands = commands.NewCommands() + } + MessageViewCommands.Register(name, cmd) +} diff --git a/commands/terminal/close.go b/commands/terminal/close.go @@ -14,10 +14,7 @@ func CommandClose(aerc *widgets.Aerc, args []string) error { if len(args) != 1 { return errors.New("Usage: close") } - term, ok := aerc.SelectedTab().(*widgets.Terminal) - if !ok { - return errors.New("Error: not a terminal") - } + term, _ := aerc.SelectedTab().(*widgets.Terminal) term.Close(nil) aerc.RemoveTab(term) return nil diff --git a/config/binds.conf b/config/binds.conf @@ -32,7 +32,7 @@ c = :cf<space> $ = :term<space> | = :pipe<space> -[msgview] +[view] q = :close<Enter> | = :pipe<space> r = :reply<Enter> diff --git a/widgets/aerc.go b/widgets/aerc.go @@ -93,6 +93,8 @@ func (aerc *Aerc) getBindings() *config.KeyBindings { switch aerc.SelectedTab().(type) { case *AccountView: return aerc.conf.Bindings.MessageList + case *MessageViewer: + return aerc.conf.Bindings.MessageView case *Terminal: return aerc.conf.Bindings.Terminal default: